32         std::runtime_error(msg.c_str()) {
 
   36         std::invalid_argument(msg) {
 
   44     _noFoundWarnings(false), _convertSlashes(true), _delimiter(
';') {
 
   85     std::ofstream file(fileName.c_str(), std::ios::trunc);
 
   88                 "Parameter file \"" + fileName + 
"\" could not be saved. " 
  100                 "Parameter file \"" + fileName + 
"\": " 
  103     file.open(fileName.c_str());
 
  106                 "Parameter file \"" + fileName + 
"\" could not be opened. " 
  117     std::vector<std::string> result;
 
  121     std::vector<std::string>::const_iterator iter;
 
  122     std::string key, keyL;
 
  129         if (beginsWith.empty() ||
 
  130                 ((keyL.length() >= beginsWith.length()) &&
 
  131                     (keyL.substr(0,beginsWith.length()) == beginsWith))) {
 
  132             result.push_back(key);
 
  139         const std::string & param)
 const {
 
  140     std::vector<std::string> result;
 
  143     std::vector<std::string>::const_iterator it;
 
  146         std::string key = *it;
 
  147         size_t pos = key.find_first_of(
'.');
 
  148         if (key.length() >= pos + param.length() && (key.substr(pos + 1,
 
  149                 param.length()) == param))
 
  150             result.push_back(key);
 
  156     std::map<std::string, std::string>::const_iterator i = 
_setParams.begin();
 
  158     unsigned int maxSize = 0;
 
  160         std::string key = i->first;
 
  161         if (key.size() > maxSize)
 
  162             maxSize = (
unsigned int) key.size();
 
  168         std::string key = i->first;
 
  169         std::string value = i->second;
 
  171         if ((p++ % 2) != 0) {
 
  172             fillUp = std::string(maxSize - key.size(), 
' ');
 
  173             sout << key << 
" " << fillUp << 
"  " << value << std::endl;
 
  175             fillUp = std::string(maxSize - key.size(), 
'-');
 
  176             sout << key << 
" " << fillUp << 
"> " << value << std::endl;
 
  183     std::vector<std::string>::const_iterator i;
 
  185         std::string key = *i;
 
  187             std::string value = get<std::string> (key);
 
  188             strm << key << 
"\t\t" << value << std::endl;
 
  195     std::set<std::string> processedKeys;
 
  196     while (strm.good()) {
 
  197         std::string key, line, value;
 
  198         if (strm.peek() == 
'\n')
 
  203             if (key.substr(0, 1) != 
"#") {
 
  216                         size_t cPos = line.find(
"#");
 
  219                         const char& test = line.at(line.length()-1);
 
  220                         if ((cont = (test == 
'\\'))) {
 
  221                             line = line.substr(0, line.length()-1);
 
  226                 if (processedKeys.find(key) != processedKeys.end()) {
 
  227                     sout << 
"(WW) fromStream: " 
  228                         << 
"Duplicate Key in Parameter File: " 
  232                 processedKeys.insert(key);
 
  242     if (!
isSet(parameter))
 
  246     _setParams[
"[del] " + parameter] = get<std::string>(parameter);
 
  257         if (cur == parameter)
 
std::map< std::string, std::string > _params
maps parameters to their respective values 
 
void showSetParams() const 
Print a list of all set parameters to sout. 
 
SplitStream sout
Dummy instance for usage in other files (for interface too). 
 
void erase(std::string parameter)
Delete a parameter from the parameter list. 
 
void _toLower(std::string &input) const 
Get the lowercase version of a string. 
 
void setDelimiter(char delimiter)
Change property delimiter. 
 
Exception thrown when trying to access unset parameters. 
 
void clear()
Clear parameter list. 
 
std::map< std::string, std::string > _setParams
stores modified and new parameters in a seperate map (see showSetParams()) 
 
void resetSetParams()
Clear list of modifications. 
 
bool _convertSlashes
convert linux to windows slashes and vice versa (depends on define CHARON_LINUX/CHARON_WINDOWS in Str...
 
std::vector< std::string > getKeyList(std::string beginsWith="") const 
Look for parameters beginning with a given string. 
 
std::vector< std::string > _parameterLines
this vector keeps a copy of all parameters in order to preserve their ordering in the actual file it ...
 
char _delimiter
delimiter for lists of values (default is ';') 
 
Unset(const std::string &msg)
constuctor using given error message 
 
I/O error exception thrown by ParameterFile instances. 
 
bool isSet(std::string parameter) const 
Check if a givem parameter has already been set. 
 
void setConvertSlashes(bool convertSlashes)
Change property convertSlashes. 
 
Implementation of the template class ParameterFile. 
 
bool _noFoundWarnings
warn if parameter was not found 
 
void _set(std::string parameter, std::string value)
Store a string value to the parameter list. 
 
void fromStream(std::istream &strm)
Restore parameters reading from the given stream. 
 
bool save(std::string fileName) const 
Save parameters and values to a plain text file. 
 
ParameterFile()
Default constructor. 
 
void toStream(std::ostream &strm) const 
Save parameters in the same order as they where inserted. 
 
void setNotFoundWarningsOn(bool noFoundWarnings)
Set property noFoundWarnings. 
 
~ParameterFile()
Default destructor. 
 
charon_DEPRECATED std::vector< std::string > getEveryParameter(const std::string ¶m) const 
Look for parameters ignoring the instance name. 
 
IoError(const std::string &msg)
constuctor using given error message 
 
bool load(std::string fileName)
Load parameters from the given file.