config_record Class Reference

#include <config.hpp>

Inheritance diagram for config_record:

Inheritance graph
[legend]
Collaboration diagram for config_record:

Collaboration graph
[legend]

List of all members.


Detailed Description

Stores seralizable configuration information.

This class represents a node in a simple XML data file format. It contains a list of its children and a string of data. It also stores the file and directory that the data was stored in, purely for error reporting purposes.

Todo:
Replace this with a real XML library.

Definition at line 60 of file config.hpp.


Public Member Functions

 config_record (const gsgl::string &fname)
 Creates a config_record object tree from a file.
 config_record (const config_record &)
 config_record ()
config_recordoperator= (const config_record &)
bool operator== (const config_record &) const
 Comparison function for collections of config records.
void override_with (const config_record &cr)
 Overrides the contents of this config record (and any associated config variables) with the values in the given config record.
void save ()
 Saves the config record back to its original file.
virtual ~config_record ()
Accessors
gsgl::stringget_attribute (const gsgl::string &)
const gsgl::stringget_attribute (const gsgl::string &) const
dictionary< gsgl::string,
gsgl::string > & 
get_attributes ()
const dictionary< gsgl::string,
gsgl::string > & 
get_attributes () const
config_recordget_child (const gsgl::string &path)
const config_recordget_child (const gsgl::string &path) const
list< config_record > & get_children ()
const list< config_record > & get_children () const
const io::directoryget_directory () const
const io::fileget_file () const
gsgl::stringget_name ()
const gsgl::stringget_name () const
gsgl::stringget_text ()
const gsgl::stringget_text () const
stringoperator[] (const gsgl::string &name)
const stringoperator[] (const gsgl::string &name) const

Private Member Functions

config_recordfind_child (gsgl::data::list< gsgl::string >::iterator &pos_in_path, bool create)
void from_stream (io::text_stream &, int &line)
void from_stream (io::text_stream &)
void to_stream (io::text_stream &, int indent) const
void to_stream (io::text_stream &) const

Private Attributes

global_configassociated_var
 Many records may point to the same variable, but the variable only knows about one (the global config).
dictionary< gsgl::string,
gsgl::string
attributes
gsgl::data::list< config_recordchildren
data::shared_pointer< io::filef
 Shared between all the children.
gsgl::string name
config_recordparent
gsgl::string text

Constructor & Destructor Documentation

config_record (  ) 

config_record ( const config_record conf  ) 

config_record ( const gsgl::string fname  )  [explicit]

Creates a config_record object tree from a file.

Definition at line 62 of file config.cpp.

References file::exists(), config_record::f, config_record::from_stream(), and string::w_string().

~config_record (  )  [virtual]

Definition at line 91 of file config.cpp.


Member Function Documentation

config_record & find_child ( gsgl::data::list< gsgl::string >::iterator &  pos_in_path,
bool  create 
) [private]

void from_stream ( io::text_stream s,
int &  line 
) [private]

void from_stream ( io::text_stream s  )  [private]

Definition at line 424 of file config.cpp.

Referenced by config_record::config_record(), and config_record::from_stream().

string & get_attribute ( const gsgl::string a  ) 

Definition at line 153 of file config.cpp.

References config_record::attributes.

const string & get_attribute ( const gsgl::string a  )  const

Returns:
The value of the first attribute with the given name.

Definition at line 147 of file config.cpp.

References config_record::attributes.

dictionary< gsgl::string, gsgl::string > & get_attributes (  ) 

Definition at line 165 of file config.cpp.

References config_record::attributes.

const dictionary< gsgl::string, gsgl::string > & get_attributes (  )  const

Returns:
The collection of the node's attributes.

Definition at line 159 of file config.cpp.

References config_record::attributes.

config_record & get_child ( const gsgl::string path  ) 

const config_record & get_child ( const gsgl::string path  )  const

list< config_record > & get_children (  ) 

Definition at line 255 of file config.cpp.

References config_record::children.

const list< config_record > & get_children (  )  const

const io::directory & get_directory (  )  const

Returns:
The directory that the config_record object resides in.

Definition at line 115 of file config.cpp.

References config_record::f.

Referenced by celestial_body::celestial_body(), model_part::model_part(), package::package(), star::star(), stellar_db::stellar_db(), and vehicle::vehicle().

const io::file & get_file (  )  const

Returns:
The file that the config_record object resides in.

Definition at line 109 of file config.cpp.

References config_record::f.

Referenced by application::load_objects(), model_part::model_part(), simulation::simulation(), and solar_system::solar_system().

string & get_name (  ) 

Definition at line 127 of file config.cpp.

References config_record::name.

const string & get_name (  )  const

string & get_text (  ) 

Definition at line 139 of file config.cpp.

References config_record::text.

const string & get_text (  )  const

config_record & operator= ( const config_record conf  ) 

bool operator== ( const config_record conf  )  const

Comparison function for collections of config records.

Definition at line 96 of file config.cpp.

References config_record::attributes, config_record::children, config_record::f, config_record::name, config_record::parent, and config_record::text.

string& operator[] ( const gsgl::string name  )  [inline]

Definition at line 118 of file config.hpp.

const string& operator[] ( const gsgl::string name  )  const [inline]

Returns:
The value of the first attribute with the given name.

Definition at line 113 of file config.hpp.

void override_with ( const config_record cr  ) 

Overrides the contents of this config record (and any associated config variables) with the values in the given config record.

Definition at line 263 of file config.cpp.

References global_config::assign_from_string(), config_record::associated_var, config_record::attributes, config_record::children, config_record::config_record(), iterable::iter(), config_record::name, config_record::text, and string::w_string().

Referenced by global_config::override_with(), and global_config::save().

void save (  ) 

Saves the config record back to its original file.

Definition at line 319 of file config.cpp.

References config_record::f, gsgl::io::FILE_OPEN_WRITE, config_record::parent, config_record::save(), and config_record::to_stream().

Referenced by global_config::save(), and config_record::save().

void to_stream ( io::text_stream s,
int  indent 
) const [private]

void to_stream ( io::text_stream s  )  const [private]

Definition at line 351 of file config.cpp.

Referenced by config_record::save().


Member Data Documentation

Many records may point to the same variable, but the variable only knows about one (the global config).

Definition at line 71 of file config.hpp.

Referenced by global_config::global_config(), config_record::operator=(), and config_record::override_with().

gsgl::string name [private]

config_record* parent [private]

gsgl::string text [private]


The documentation for this class was generated from the following files:

Generated on Sat Mar 1 13:50:05 2008 for Periapsis Project by  doxygen 1.5.5