89 std::ostringstream outdata;
90 outdata.precision(15);
92 while(infile.good()) {
94 std::getline(infile, line,
'\n');
97 std::map<std::string, std::string>::iterator itr =
dictionary_.begin();
99 size_t pos = line.find(
"_" + itr->first +
"_");
100 while(pos != std::string::npos) {
101 line.replace(pos, itr->first.length() + 2, itr->second);
102 pos = line.find(
"_" + itr->first +
"_");
106 outdata << line << std::endl;
111 std::ofstream outfile(outputFile.c_str());
112 outfile.precision(15);
113 outfile << outdata.str();
115 outfile.rdbuf()->pubsync();
147 namespace fs = std::filesystem;
149 fs::path pwd = fs::current_path();
153 std::ifstream infile;
157 unsigned int line_nr = 0;
158 while(infile.good()) {
159 std::fill_n(tmp, 1024,
'\0');
160 infile.getline(tmp, 1024);
163 std::string stmp(tmp);
168 std::vector<std::string> all_strings;
169 boost::split(all_strings, stmp,
170 boost::is_any_of(
"\r\n\v\f\t "),
171 boost::token_compress_on);
173 if(all_strings.size() < 2) {
174 std::cout <<
"PROBLEM with the following line "
175 <<
"(at least name and value required)!"
177 std::cout << stmp << std::endl;
178 std::ostringstream ex;
179 ex <<
"Invalid data file on line " << line_nr;
181 "GenerateOpalSimulation::fillDictionary()",
185 std::string varname = all_strings[0];
186 std::string value = all_strings[1];
187 scale(varname, &value);
188 dictionary_.insert(std::pair<std::string, std::string>(