A container for name-value pairs. More...
|typedef std::map< const char *, resource *, ibis::lessi >||gList|
|The name-value pairs are categorized into two types, names that map to simple values (vList) and names that map to groups of name-value pairs (gList). More...|
|typedef std::map< const char *, char *, ibis::lessi >||vList|
|void||add (const char *name, const char *value)|
|Add a name-value pair to the resource list. More...|
|bool||empty () const|
|Returns true if there is no name-value pair on record. |
|gList::const_iterator||gBegin () const|
|gList::const_iterator||gEnd () const|
|const resource *||getGroup (const char *name) const|
|Find a group with the given name. More...|
|double||getNumber (const char *name) const|
|Locate the named parameter and return its value as a number. More...|
|std::string||getPrefix () const|
|Return the name of the full prefix of the resource. |
|const char *||getValue (const char *name) const|
|Find a named parameter. More...|
|bool||isTrue (const char *name) const|
|Locate the named parameter and return its value as true or false. More...|
|resource &||operator= (const resource &rhs)|
|The assignment operator. |
|const char *||operator (const char *name) const|
|Locate the named parameter and return its value in raw string form. More...|
|int||read (const char *fn=0)|
|Read a configuration file. More...|
|Default constructor. Creates an empty object. |
|resource (const char *fn)|
|Read the content of a parameter file. |
|resource (const resource *ctx, const char *pfx)|
|Create an empty object with the specified prefix and context. |
|resource (const resource &rhs)|
|Copy constructor. Deep copy. |
|vList::const_iterator||vBegin () const|
|vList::const_iterator||vEnd () const|
|void||write (const char *fn=0) const|
|Write the content to a file. More...|
|static void||clear (vList &vl)|
|Clear a vList. More...|
|static bool||isStringTrue (const char *val)|
|static void||parseNameValuePairs (const char *in, vList &lst)|
|Parse a string into a name-value list. More...|
A container for name-value pairs.
It is mostly used for storing the configuration parameters. The parameters are in a format as follows:
where the delimiter can be either '*', ':' or '.' and anything following the first '=' sign is assumed to be part of the value string until the end of line. The leading and trailing spaces are removed from both the name and the value. The specification that appears later in the same configuration file or read later (through a call to read()) will overwrite the parameter with the same name. This include the groups and individual parameters. For example if a parameter named 'abcd' is specified first, but later, the same name is used as a group name, then the previously specified parameter will be removed from the list and the new group will be inserted. If the parameter with name 'abcd' appeared again, then the group 'abcd' will be removed and the named parameter will be inserted.
The line length must of no more than MAX_LINE defined in const.h.
The top level group name can be any one of the following: all, common, and '*'. When writing out the parameters, the top level name is not written.
The name-value pairs are categorized into two types, names that map to simple values (vList) and names that map to groups of name-value pairs (gList).
|void ibis::resource::add||(||const char *||name,|
|const char *||value|
Find a group with the given name.
The name is expected to be a simple name without any separators. Any separator in the name will cause it to return a nil pointer.
|double ibis::resource::getNumber||(||const char *||name||)||const|
Locate the named parameter and return its value as a number.
Parse the string value as a number.
If the first non-numeric character is a 'k' or 'm' or 'g', the proceeding number is mutiplied by 1024, 1048576, or 1073742824. If the first non-numeric character is 'h', the value before it is multiplied by 3600 (h for hour), converting it from hours to seconds.
Referenced by ibis::fileManager::fileManager().
Find a named parameter.
The name is expected to be a simple name without any separators. Any separator in it will cause a nil pointer to be returned.
Referenced by ibis::util::gatherParts().
|bool ibis::resource::isTrue||(||const char *||name||)||const|
Locate the named parameter and return its value as true or false.
If the named parameter exists and its value is one of "true", "yes", "on" or "1", this function will return true, otherwise false.
|const char * ibis::resource::operator||(||const char *||name||)||const|
Locate the named parameter and return its value in raw string form.
The incoming name can contain multiple separators.
Each component of the name is separated by one separator. From the left to right, the left-most component defines the highest level of the hierarchy. A high-level name forms the context for the next level of the name hierarchy. The final component of the name is directly associated with a string value. The search algorithm first descend to the lowest level with the matching names and starts to look for a name that matches the last component of the specified name. If a match is not found, it will go back one level and perform the same search. This continues until a match is found or it has searched all the levels.
Parse a string into a name-value list.
Parse a string of the form "name=vale, name=value, ..." into a simple list of name-value pairs.
Add the new ones to the incoming list, lst.
The list is sparated by comas or blank spaces. Every character before the equal sign is treated as part of the name except the blank space surrounding the string. Therefore, embedded blanks are allowed here, but this usage is not consistent of the SQL naming convention and is therefore discoveraged. Each value can be a single non-empty string or collection of string values surrended by parentheses or quotes. The parentheses and quotes may be nested, but has to match properly. For example, the following strings are valid input strings: "pressure = 1.025E10, template = (10, 10, 5)" and "meshShape = (ny=100, nx=100), creator = 'octave version 1.2'". Here is the list of special characters can contain compound values:
When the openning character of a pair is encountered, this function will not recognize the normal terminators untill the corresponding matching closing character is found or the end of the string is found.
|int ibis::resource::read||(||const char *||fn = ||)|
Read a configuration file.
It will open the first file in the following list and add the content to the existing list of parameter,
It attempts to parse the content of the first file it finds. The content of the file is added to the current content of the resouce object. The parameters with the same names will overwrite the existing values.
If it can not find any one of these files, it will return without modifying the current content of the resource object.
Return values: 0 – normal return, -1 – the incoming argument appears to point to a valid file, but the file can not be opened, +1 – can not open any of the default files specified in the above list.
|void ibis::resource::write||(||const char *||fn = ||)||const|