#include <FileConfigNode.h>
Public Member Functions | |
FileConfigNode (const string &path, const string &fileName) | |
virtual string | getName () const |
virtual void | flush () |
virtual string | readProperty (const string &property) const |
virtual void | setProperty (const string &property, const string &value, const string &comment="", const string *defValue=NULL) |
virtual void | readProperties (map< string, string > &props) const |
virtual void | removeProperty (const string &property) |
virtual bool | exists () const |
Each node is mapped to one file whose location is determined by the ConfigTree when the node gets created. Each node represents one .ini file with entries of the type <property>*=*
*
Comments look like: *# <comment>
Definition at line 44 of file FileConfigNode.h.
FileConfigNode::FileConfigNode | ( | const string & | path, | |
const string & | fileName | |||
) |
Open or create a new file. The file will be physically created right away whereas changes to its content will not be written immediately.
path | node name, maps to directory | |
fileName | name of file inside that directory |
Definition at line 33 of file FileConfigNode.cpp.
virtual bool FileConfigNode::exists | ( | ) | const [inline, virtual] |
Node exists in backend storage.
Implements ConfigNode.
Definition at line 75 of file FileConfigNode.h.
void FileConfigNode::flush | ( | ) | [virtual] |
save all changes persistently
Implements ConfigNode.
Definition at line 64 of file FileConfigNode.cpp.
References mkdir_p(), and EvolutionSyncClient::throwError().
virtual string FileConfigNode::getName | ( | ) | const [inline, virtual] |
a name for the node that the user can understand
Implements ConfigNode.
Definition at line 65 of file FileConfigNode.h.
void FileConfigNode::readProperties | ( | map< string, string > & | props | ) | const [virtual] |
Extract all list of all currently defined properties and their values. Does not include values which were initialized with their defaults, if the implementation remembers that.
props | to be filled with key/value pairs; guaranteed to be empty before the call |
Implements ConfigNode.
Definition at line 207 of file FileConfigNode.cpp.
string FileConfigNode::readProperty | ( | const string & | property | ) | const [virtual] |
Returns the value of the given property
property | - the property name |
Implements ConfigNode.
Definition at line 192 of file FileConfigNode.cpp.
void FileConfigNode::removeProperty | ( | const string & | property | ) | [virtual] |
Remove a certain property.
property | the name of the property which is to be removed |
Implements ConfigNode.
Definition at line 222 of file FileConfigNode.cpp.
void FileConfigNode::setProperty | ( | const string & | property, | |
const string & | value, | |||
const string & | comment = "" , |
|||
const string * | defValue = NULL | |||
) | [virtual] |
Sets a property value.
property | the property name | |
value | the property value (zero terminated string) | |
comment | a comment explaining what the property is about, with separating lines; might be used by the backend when adding a new property | |
defValue | If a defValue is provided and the value matches the default, then the node is asked to remember that the value hasn't really been changed. An implementation can decide to not support this. |
Implements ConfigNode.
Definition at line 239 of file FileConfigNode.cpp.
References ConfigProperty::splitComment().