![]() |
xyginext
0.2.0
Second generation of xygine game creation framework
|
A configuration object can hold one or more nested objects or configuration properties. All objects require a name, and may have an optional id as a string value. More...
#include <ConfigFile.hpp>
Public Types | |
using | NameValue = std::pair< std::string, std::string > |
Public Member Functions | |
ConfigObject (const std::string &name="", const std::string &id="") | |
const std::string & | getId () const |
Get the id of the object. | |
ConfigProperty * | findProperty (const std::string &name) const |
Returns a pointer to the property if found, else nullptr Pointers returned from this function should only be used within a small scope as adding or removing any properties from the parent object is likely to invalidate them. | |
ConfigObject * | findObjectWithId (const std::string &id) const |
Searches for a child object with given id and returns a pointer to it if found, else returns nullptr. Pointers returned from this function should only be used within a small scope as adding or removing any objects from the is likely to invalidate them. | |
ConfigObject * | findObjectWithName (const std::string &name) const |
Searches for a child object with the given name and returns a pointer to it if found, else returns nullptr. Pointers returned from this function should only be used within a small scope as adding or removing any objects from the is likely to invalidate them. | |
const std::vector< ConfigProperty > & | getProperties () const |
Returns a reference to the vector of properties owned by this object. | |
std::vector< ConfigProperty > & | getProperties () |
const std::vector< ConfigObject > & | getObjects () const |
Returns a reference to the vector objects owned by this object. | |
std::vector< ConfigObject > & | getObjects () |
ConfigProperty & | addProperty (const std::string &name, const std::string &value="") |
Adds a name / value property pair to this object WARNING this will most likely invalidate any pointers retreived with findProperty() | |
void | addProperty (const ConfigProperty &prop) |
Adds a copy of the given ConfigProperty to this objects list of properties. WARNING this will most likely invalidate any pointers retreived with findProperty() | |
ConfigObject * | addObject (const std::string &name, const std::string &id="") |
Adds an object with the given name and optional id to this object and returns a pointer to it. WARNING this will likely invalidate any existing pointers to objects retreived with findObject() | |
void | addObject (const ConfigObject &obj) |
Adds a copy of an existing object to this object. WARNING this will likely invalidate any existing pointers to objects retreived with findObject() | |
void | removeProperty (const std::string &name) |
Removes a property with the given name from this object if it exists. | |
ConfigObject | removeObject (const std::string &name, const std::string &="") |
Removes an object (and all of its children) with the given name from this object if it exists. | |
bool | save (const std::string &path) const |
Writes this object and all its children to given path. | |
bool | loadFromFile (const std::string &path) |
Attempts to load a config file into the object. More... | |
![]() | |
ConfigItem (const std::string &name) | |
ConfigItem (const ConfigItem &)=default | |
ConfigItem & | operator= (const ConfigItem &)=default |
ConfigItem (ConfigItem &&)=default | |
ConfigItem & | operator= (ConfigItem &&)=default |
const std::string & | getName () const |
Returns the name of this item. | |
Additional Inherited Members | |
![]() | |
void | setParent (ConfigItem *parent) |
ConfigItem * | getParent () const |
void | setName (const std::string &name) |
A configuration object can hold one or more nested objects or configuration properties. All objects require a name, and may have an optional id as a string value.
bool xy::ConfigObject::loadFromFile | ( | const std::string & | path | ) |
Attempts to load a config file into the object.