68{
71
72 typedef JToken<
';'> token_type;
73
74 string inputFile;
79 bool squash;
81
82 try {
83
85
94
95 JParser<> zap(
"General purpose program to edit or create properties file.");
96
102 zap[
'q'] =
make_field(squash,
"squash meta data");
104
105 zap(argc, argv);
106 }
107 catch(const exception &error) {
108 FATAL(error.what() << endl);
109 }
110
111
112
113
114 map_type zip;
115
116 if (!modifier.empty()) {
117
119
120 istringstream is;
121
122 is.imbue(locale(is.getloc(), facet.clone()));
123
124 for (const token_type& token : modifier) {
125
126 is.clear();
127 is.str(token);
128
130
131 if (is >> equation && facet.isSeparator(equation.
getSeparator()))
133 else
134 ERROR(
"Invalid modifier: " << token << endl);
135 }
136 }
137
138
139
140
142
143 ostringstream os;
144
145 os.imbue(locale(cout.getloc(), facet.clone()));
146
147
148
149
150 ifstream in(inputFile.c_str());
151
153
154 in >> comment;
155
156 if (squash) {
157 comment.clear();
158 }
159
161
162 os << comment;
163
164 istringstream is;
165
166 is.imbue(locale(is.getloc(), facet.clone()));
167
168 for (
string buffer;
getline(in, buffer, facet.getDefaultEndOfLine()); ) {
169
170 is.clear();
171 is.str(buffer);
172
174
175 if (is >> equation && facet.isSeparator(equation.
getSeparator())) {
176
177 if (rm.count(equation.
getKey()) == 0) {
178 os << zip(equation);
179 }
180
181 } else {
182
183 os << buffer << endl;
184 }
185 }
186
187 in.close();
188
189
190
191
192 for (const auto& i : zip) {
193 if (i.second.count == 0) {
194 os <<
JEquation(i.first, i.second.value);
195 }
196 }
197
198
199
200
201 filebuf buffer;
202
205 }
206
207 ostream out(buffer.is_open() ? &buffer : cout.rdbuf());
208
209 out << os.str();
210
211 buffer.close();
212}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse parameter values.
Facet class to specify parsing of equations in currect locale (see class JLANG::JEquation).
Simple data structure to support I/O of equations (see class JLANG::JEquation).
const std::string & getSkipLine() const
Get skip line characters.
const std::string & getComment() const
Get comment string.
const std::string & getSeparator() const
Get separator characters.
char getLeftBracket() const
Get left bracket.
const string_type & getEndOfLine() const
Get end of line characters.
char getRightBracket() const
Get right bracket.
const std::string & getDivision() const
Get division characters.
const string_type & getWhiteSpace() const
Get white space characters.
General purpose equation class.
const std::string & getKey() const
Get key.
const std::string & getValue() const
Get value.
const char getSeparator() const
Get separator.
Wrapper class around string.
Utility class to parse command line options.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Empty structure for specification of parser element that is initialised (i.e. does not require input)...