MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / process_lrl

Function process_lrl

tools/comdb2ar/deserialise.cpp:168–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166
167
168static void process_lrl(
169 std::ostream& of,
170 const std::string& filename,
171 const std::string& lrltext,
172 bool strip_cluster_info,
173 bool strip_consumer_info,
174 std::string& datadestdir,
175 const std::string& lrldestdir,
176 std::string& dbname,
177 std::set<std::string>& table_set
178 )
179// Parse the lrl file that has been read from the stream, set database
180// parameters as they are discovered, and write out a rewritten lrl file
181// to the output stream of. dir, table and resource lines will be rewritten
182// with the new data directory.
183// dbname and datadestdir, if empty, will be populated with the values read
184// from the lrltext.
185// table_set will be updated with the names of any tables found
186{
187 std::istringstream lrlss(lrltext);
188 int lineno = 0;
189 while(!lrlss.eof()) {
190 std::string line;
191 std::getline(lrlss, line);
192 lineno++;
193
194 std::string bareline(line);
195 size_t pos = bareline.find_first_of('#');
196 if(pos != std::string::npos) {
197 bareline.resize(pos);
198 }
199 std::istringstream liness(bareline);
200
201 std::string tok;
202 if(liness >> tok) {
203
204 if(tok == "name" && dbname.empty()) {
205 // Get the db name from the first lrl file found,
206 // which should be the primary.
207 if(!(liness >> dbname)) {
208 throw LRLError(filename, lineno, "missing database name directive");
209 }
210 } else if(tok == "dir") {
211 if(!(liness >> tok)) {
212 throw LRLError(filename, lineno, "missing database directory");
213 }
214 // If we don't have a directory yet then use this one
215 if(datadestdir.empty()) {
216 datadestdir = tok;
217 }
218 line = "dir " + datadestdir;
219
220 } else if(tok == "table") {
221 std::string name;
222 std::string schema_path, new_path;
223 std::string dbnum;
224 if(!(liness >> name)) {
225 throw LRLError(filename, lineno, "missing table name");

Callers 1

deserialise_databaseFunction · 0.85

Calls 4

LRLErrorClass · 0.85
makebasenameFunction · 0.85
ErrorClass · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected