moved handling of defaults row to MessageMap, added documentation
This commit is contained in:
@@ -28,7 +28,15 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
/** \file filereader.h */
|
||||
/** @file filereader.h
|
||||
* Helper class and constants for reading configuration files.
|
||||
*
|
||||
* The @a FileReader template class allows to read CSV compliant text files
|
||||
* while splitting each read line into fields.
|
||||
* It also supports special treatment of comment lines starting with a "#", as
|
||||
* well as so called "default values" indicated by the first field starting
|
||||
* with a "*" symbol.
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -174,14 +182,6 @@ public:
|
||||
virtual result_t addDefaultFromFile(vector< vector<string> >& defaults, vector<string>& row,
|
||||
vector<string>::iterator& begin, string defaultDest, string defaultCircuit,
|
||||
const string& filename, unsigned int lineNo) {
|
||||
if (row.size()>1 && defaultCircuit.length()>0) {
|
||||
if (row[1].length()==0)
|
||||
row[1] = defaultCircuit; // set default circuit
|
||||
else if (row[1][0]=='#')
|
||||
row[1] = defaultCircuit+row[1]; // append security suffix to circuit prefix
|
||||
}
|
||||
if (row.size()>5 && defaultDest.length()>0 && row[5].length()==0)
|
||||
row[5] = defaultDest; // set default destination
|
||||
defaults.push_back(row);
|
||||
begin = row.end();
|
||||
return RESULT_OK;
|
||||
|
||||
@@ -886,7 +886,7 @@ result_t MessageMap::addDefaultFromFile(vector< vector<string> >& defaults, vect
|
||||
vector<string>::iterator& begin, string defaultDest, string defaultCircuit,
|
||||
const string& filename, unsigned int lineNo)
|
||||
{
|
||||
// convert conditions in defaults
|
||||
// check for condition in defaults
|
||||
string type = row[0];
|
||||
if (type.length()>0 && type[0]=='[' && type[type.length()-1]==']') {
|
||||
// condition
|
||||
@@ -906,6 +906,14 @@ result_t MessageMap::addDefaultFromFile(vector< vector<string> >& defaults, vect
|
||||
m_conditions[key] = condition;
|
||||
return RESULT_OK;
|
||||
}
|
||||
if (row.size()>1 && defaultCircuit.length()>0) {
|
||||
if (row[1].length()==0)
|
||||
row[1] = defaultCircuit; // set default circuit
|
||||
else if (row[1][0]=='#')
|
||||
row[1] = defaultCircuit+row[1]; // append security suffix to circuit prefix
|
||||
}
|
||||
if (row.size()>5 && defaultDest.length()>0 && row[5].length()==0)
|
||||
row[5] = defaultDest; // set default destination
|
||||
return FileReader<DataFieldTemplates*>::addDefaultFromFile(defaults, row, begin, defaultDest, defaultCircuit, filename, lineNo);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user