The internal representation for a Defaults_Text object. More...
Public Member Functions | |
Defaults_Textrep (string file) | |
Constructor, construct a Defaults_Textrep instance from an ASCII text-file and command line arguments. | |
Defaults_Textrep (string file, int argc, char **argv) | |
Constructor, construct a Defaults_Textrep instance from an ASCII text-file. | |
string | get_val (string name) const |
Public Attributes | |
std::map< std::string, std::string > | _map |
Private Member Functions | |
void | doline (string l) |
void | process_args (int argc, char **argv) |
void | read_file (string file) |
The internal representation for a Defaults_Text object.
Definition at line 107 of file Defaults_Text.cc.
hitfit::Defaults_Textrep::Defaults_Textrep | ( | string | file | ) |
Constructor, construct a Defaults_Textrep instance from an ASCII text-file and command line arguments.
file | The name of the input ASCII file to read. See the header file for a description of the format for this and the argument list. Pass an empty string to skip reading a file. |
Definition at line 180 of file Defaults_Text.cc.
References read_file().
hitfit::Defaults_Textrep::Defaults_Textrep | ( | string | file, |
int | argc, | ||
char ** | argv | ||
) |
Constructor, construct a Defaults_Textrep instance from an ASCII text-file.
file | The name of the input ASCII file to read. See the header file for a description of the format for this and the argument list. Pass an empty string to skip reading a file. |
argc | The length of the argument list. |
argv | The argument list. |
Definition at line 195 of file Defaults_Text.cc.
References process_args(), and read_file().
{ read_file (file); process_args (argc, argv); }
void hitfit::Defaults_Textrep::doline | ( | string | l | ) | [private] |
Helper function to process a line defining a single parameter.
l | The line to process. |
Definition at line 305 of file Defaults_Text.cc.
References _map, dtNoiseDBValidation_cfg::cerr, mergeVDriftHistosByStation::name, pos, and strip().
Referenced by process_args(), and read_file().
{ // Strip spaces from the line and ignore it if it's blank. l = strip (l); if (l.size() == 0) return; // It must contain a `=' character. string::size_type pos = l.find ('='); if (pos == string::npos) { cerr << "bad defaults line " << l << "\n"; abort (); } // Split off name and value parts. std::string name = strip (l.substr (0, pos)); std::string val = strip (l.substr (pos+1)); // Add it to the map. _map[name] = val; }
string hitfit::Defaults_Textrep::get_val | ( | string | name | ) | const |
Look up parameter name and return its value.
name | The name of the parameter. |
Definition at line 278 of file Defaults_Text.cc.
References dtNoiseDBValidation_cfg::cerr, and mergeVDriftHistosByStation::name.
void hitfit::Defaults_Textrep::process_args | ( | int | argc, |
char ** | argv | ||
) | [private] |
Look for additional parameter settings in the argument list argc and argv and add the content to data.
argc | The length of the argument list. |
argv | The argument list. |
Definition at line 240 of file Defaults_Text.cc.
References dir2webdir::argc, doline(), i, and prof2calltree::l.
Referenced by Defaults_Textrep().
{ // Look for arguments starting with `--'. for (int i=1; i < argc; i++) { if (argv[i][0] == '-' && argv[i][1] == '-') { // Found one. string l; if (strchr (argv[i], '=') != 0) // It was of the form `--NAME=VALUE'. Change to `NAME=VALUE'. l = argv[i] + 2; else if (argv[i][2] == 'n' && argv[i][3] == 'o') { // It was of the form `--noNAME'. Change to `NAME=0'. l = argv[i] + 4; l += "=0"; } else { // It was of the form `--NAME'. Change to `NAME=1'. l = argv[i] + 2; l += "=1"; } // Process it like a line we read from a file. doline (l); } } }
void hitfit::Defaults_Textrep::read_file | ( | string | file | ) | [private] |
Read parameters from ASCII text file file and add the content to data.
file | The ASCII text file to read. |
Definition at line 213 of file Defaults_Text.cc.
References dtNoiseDBValidation_cfg::cerr, doline(), f, and prof2calltree::l.
Referenced by Defaults_Textrep().
std::map<std::string,std::string> hitfit::Defaults_Textrep::_map |
The data, maps from parameter names to values (which are stored as strings)
Definition at line 140 of file Defaults_Text.cc.
Referenced by doline(), and hitfit::operator<<().