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/.
21 int main(int argc
, char** argv
)
23 const string
optsintro("--");
24 map
<string
, string
> vartofile
;
25 for(int i
=1; i
< argc
; ++i
)
27 const string
arg(argv
[i
]);
28 if(arg
.substr(0,2) != optsintro
)
30 cerr
<< "Only option args starting with -- allowed." << endl
;
33 const size_t eqpos
= arg
.find("=", 2);
34 if(eqpos
== string::npos
)
36 cerr
<< "Only option args assigning with = allowed." << endl
;
39 const string
argname(arg
.substr(2, eqpos
-2));
40 vartofile
[argname
] = arg
.substr(eqpos
+1, string::npos
);
44 for(const auto& varandfile
: vartofile
)
50 string
varupper(varandfile
.first
);
51 for(auto& c
: varupper
)
54 ifstream
filestream(varandfile
.second
.c_str());
55 stringstream contents
;
56 contents
<< filestream
.rdbuf();
58 (void)remove(varandfile
.second
.c_str());
59 string escapedcontents
;
60 for(const auto& c
: contents
.str())
63 escapedcontents
+= "\\\\";
65 escapedcontents
+= "\\\"";
71 cout
<< "\"" << varupper
<< "\": \"" << escapedcontents
<< "\"";
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */