1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
19 int main(int argc
, char** argv
)
21 const std::string
optsintro("--");
22 std::map
<std::string
, std::string
> vartofile
;
23 for(int i
=1; i
< argc
; ++i
)
25 const std::string
arg(argv
[i
]);
26 if(arg
.substr(0,2) != optsintro
)
28 std::cerr
<< "Only option args starting with -- allowed." << std::endl
;
31 const size_t eqpos
= arg
.find("=", 2);
32 if(eqpos
== std::string::npos
)
34 std::cerr
<< "Only option args assigning with = allowed." << std::endl
;
37 const std::string
argname(arg
.substr(2, eqpos
-2));
38 vartofile
[argname
] = arg
.substr(eqpos
+1, std::string::npos
);
42 for(const auto& varandfile
: vartofile
)
47 std::cout
<< "," << std::endl
;
48 std::string
varupper(varandfile
.first
);
49 for(auto& c
: varupper
)
52 std::ifstream
filestream(varandfile
.second
.c_str());
53 std::stringstream contents
;
54 contents
<< filestream
.rdbuf();
56 (void)remove(varandfile
.second
.c_str());
57 std::string escapedcontents
;
58 for(const auto& c
: contents
.str())
61 escapedcontents
+= "\\\\";
63 escapedcontents
+= "\\\"";
69 std::cout
<< "\"" << varupper
<< "\": \"" << escapedcontents
<< "\"";
71 std::cout
<< "}" << std::endl
;
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */