PIP 0.5.0_alpha Platform-Independent Primitives

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
PIConfig::Entry Class Reference

Entry of configuration file More...

## Public Member Functions
Entry * | parent () const
| Returns parent entry, or 0 if there is no parent (root of default value)
int | childCount () const
| Returns children count.
Branch & | children () const
| Returns children as PIConfig::Branch.
Entry * | child (const int index) const
| Returns child at index "index".
Entry * | findChild (const PIString &name)
| Returns first child with name "name".
const Entry * | findChild (const PIString &name) const
| Returns first child with name "name".
bool | isLeaf () const
| Returns true if there is no children.
const PIString & | name () const
| Returns name.
const PIString & | value () const
| Returns value.
const PIString & | type () const
| Returns type.
const PIString & | comment () const
| Returns comment.
const PIString & | fullName () const
| Returns full name, i.e. name as it looks in file. More...
Entry & | setName (const PIString &value)
| Set name to "value" and returns this.
Entry & | setType (const PIString &value)
| Set type to "value" and returns this.
Entry & | setComment (const PIString &value)
| Set comment to "value" and returns this.
Entry & | setValue (const PIString &value)
| Set value to "value" and returns this.
Entry & | setValue (const PIStringList &value)
| Set value to "value" and returns this. Type is set to "l".
Entry & | setValue (const char *value)
| Set value to "value" and returns this. Type is set to "s".
Entry & | setValue (const bool value)
| Set value to "value" and returns this. Type is set to "b".
Entry & | setValue (const char value)
| Set value to "value" and returns this. Type is set to "s".
Entry & | setValue (const short value)
| Set value to "value" and returns this. Type is set to "n".
Entry & | setValue (const int value)
| Set value to "value" and returns this. Type is set to "n".
Entry & | setValue (const long value)
| Set value to "value" and returns this. Type is set to "n".
Entry & | setValue (const uchar value)
| Set value to "value" and returns this. Type is set to "n".
Entry & | setValue (const ushort value)
| Set value to "value" and returns this. Type is set to "n".
Entry & | setValue (const uint value)
| Set value to "value" and returns this. Type is set to "n".
Entry & | setValue (const ulong value)
| Set value to "value" and returns this. Type is set to "n".
Entry & | setValue (const float value)
| Set value to "value" and returns this. Type is set to "f".
Entry & | setValue (const double value)
| Set value to "value" and returns this. Type is set to "f".
Entry & | getValue (const PIString &vname, const PIString &def=PIString(), bool *exists=0)
| Returns entry with name "vname" and default value "def". More...
Entry & | getValue (const PIString &vname, const char *def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Entry & | getValue (const PIString &vname, const PIStringList &def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Entry & | getValue (const PIString &vname, const bool def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Entry & | getValue (const PIString &vname, const short def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Entry & | getValue (const PIString &vname, const int def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Entry & | getValue (const PIString &vname, const long def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Entry & | getValue (const PIString &vname, const uchar def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Entry & | getValue (const PIString &vname, const ushort def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Entry & | getValue (const PIString &vname, const uint def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Entry & | getValue (const PIString &vname, const ulong def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Entry & | getValue (const PIString &vname, const float def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Entry & | getValue (const PIString &vname, const double def, bool *exists=0)
| Returns entry with name "vname" and default value "def".
Branch | getValues (const PIString &vname)
| Find all entries with names with substrings "vname" and returns them as PIConfig::Branch.
bool | isEntryExists (const PIString &name) const
| If there is no children returns if name == "name". Else returns if any child has name == "name".
| operator bool ()
| Convertion to boolean.
| operator char ()
| Convertion to char.
| operator short ()
| Convertion to short.
| operator int ()
| Convertion to int.
| operator long ()
| Convertion to long.
| operator uchar ()
| Convertion to uchar.
| operator ushort ()
| Convertion to ushort.
| operator uint ()
| Convertion to uint.
| operator ulong ()
| Convertion to ulong.
| operator float ()
| Convertion to float.
| operator double ()
| Convertion to double.
| operator PIString ()
| Convertion to PIString.
| operator PIStringList ()
| Convertion to PIStringList.

## Detailed Description

Entry of configuration file

This class is node of internal PIConfig tree. Entry provide access to elements of PIConfig. Each entry has children or next properties:

- name
- value
- type
- comment

Each property is a PIString. These properties forms from text line with format:

<name> = <value> #<type> <comment>

Type and comment are optional fields. Type is a single letter immediately after comment symbol "#".
Entry has many implicit convertions to common types: boolean, integers, float, double, PIString, PIStringList.
Generally there is no need to create instance of PIConfig::Entry manually, it returns by functions getValue() of PIConfig, PIConfig::Entry or PIConfig::Branch. If there is no suitable entry to return, reference to internal instance of PIConfig::Entry with "default" value will be returned.

/* "example.conf"
a = 1
s0.a = A
s0.b = B
*/
PIConfig conf("example.conf", PIIODevice::ReadOnly);
PIConfig::Entry ce = conf.getValue("a");
int a = ce; // a = 1
PIString A = ce; // A = "1"
ce = conf.getValue("s0");
piCout << ce.childCount(); // 2
A = ce.getValue("b"); // A = "B"
A = conf.getValue("s0.a"); // A = "A"

## Member Function Documentation

const PIString& PIConfig::Entry::fullName | ( |  | ) | const
| inline

Returns full name, i.e. name as it looks in file.

In case of default entry full name always is empty

PIConfig conf("example.conf", PIIODevice::ReadOnly);
piCout << conf.getValue("a.b.c").name(); // "c"
piCout << conf.getValue("a.b.c").fullName(); // "a.b.c"

PIConfig::Entry & PIConfig::Entry::getValue | ( | const PIString & | vname,
|  | const PIString & | def = `PIString()`,
|  | bool * | exists = `0`
| ) |  |

Returns entry with name "vname" and default value "def".

If there is no suitable entry found, reference to default internal entry with value = "def" will be returned, and if "exists" not null it will be set to false