#include <config.hpp>
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.
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_record & | operator= (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::string & | get_attribute (const gsgl::string &) |
const gsgl::string & | get_attribute (const gsgl::string &) const |
dictionary< gsgl::string, gsgl::string > & | get_attributes () |
const dictionary< gsgl::string, gsgl::string > & | get_attributes () const |
config_record & | get_child (const gsgl::string &path) |
const config_record & | get_child (const gsgl::string &path) const |
list< config_record > & | get_children () |
const list< config_record > & | get_children () const |
const io::directory & | get_directory () const |
const io::file & | get_file () const |
gsgl::string & | get_name () |
const gsgl::string & | get_name () const |
gsgl::string & | get_text () |
const gsgl::string & | get_text () const |
string & | operator[] (const gsgl::string &name) |
const string & | operator[] (const gsgl::string &name) const |
Private Member Functions | |
config_record & | find_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_config * | associated_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_record > | children |
data::shared_pointer< io::file > | f |
Shared between all the children. | |
gsgl::string | name |
config_record * | parent |
gsgl::string | text |
config_record | ( | ) |
Definition at line 46 of file config.cpp.
Referenced by config_record::find_child(), config_record::from_stream(), and config_record::override_with().
config_record | ( | const config_record & | conf | ) |
Definition at line 52 of file config.cpp.
References config_record::attributes, config_record::children, config_record::name, and config_record::text.
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.
config_record & find_child | ( | gsgl::data::list< gsgl::string >::iterator & | pos_in_path, | |
bool | create | |||
) | [private] |
Definition at line 173 of file config.cpp.
References assert, config_record::children, config_record::config_record(), and string::trim().
Referenced by config_record::get_child().
void from_stream | ( | io::text_stream & | s, | |
int & | line | |||
) | [private] |
Definition at line 434 of file config.cpp.
References string::append(), simple_array::append(), config_record::attributes, CHECK_EOF, config_record::children, simple_array::clear(), config_record::config_record(), config_record::f, config_record::from_stream(), countable::is_empty(), config_record::name, config_record::parent, text_stream::peek(), simple_array::ptr(), string::size(), SYNTAX_ERROR, config_record::text, string::trim(), and text_stream::unget().
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 | ) |
const string & get_attribute | ( | const gsgl::string & | a | ) | const |
Definition at line 147 of file config.cpp.
References config_record::attributes.
dictionary< gsgl::string, gsgl::string > & get_attributes | ( | ) |
const dictionary< gsgl::string, gsgl::string > & get_attributes | ( | ) | const |
Definition at line 159 of file config.cpp.
References config_record::attributes.
config_record & get_child | ( | const gsgl::string & | path | ) |
Definition at line 233 of file config.cpp.
References config_record::find_child(), iterable::iter(), string::split(), and string::w_string().
const config_record & get_child | ( | const gsgl::string & | path | ) | const |
Definition at line 217 of file config.cpp.
References config_record::find_child(), iterable::iter(), string::split(), and string::w_string().
Referenced by application::get_cmdline_dir(), application::get_config_overrides(), package::package(), pkg_scenery::pkg_scenery(), and pkg_vehicle::pkg_vehicle().
list< config_record > & get_children | ( | ) |
const list< config_record > & get_children | ( | ) | const |
Definition at line 249 of file config.cpp.
References config_record::children.
Referenced by application::application(), event_map::load_events(), event_map::load_keyboard_events(), application::load_objects(), application::load_scenery(), model::model(), package::package(), simulation::simulation(), vehicle::vehicle(), and vehicle_module::vehicle_module().
const io::directory & get_directory | ( | ) | const |
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 |
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 | ( | ) |
const string & get_name | ( | ) | const |
Definition at line 121 of file config.cpp.
References config_record::name.
Referenced by application::get_config_overrides(), event_map::load_events(), application::load_objects(), application::load_scenery(), package::package(), pkg_scenery::pkg_scenery(), pkg_vehicle::pkg_vehicle(), and simulation::simulation().
string & get_text | ( | ) |
const string & get_text | ( | ) | const |
Definition at line 133 of file config.cpp.
References config_record::text.
Referenced by config_variable< gsgl::platform::color >::config_variable(), application::get_cmdline_dir(), application::get_config_overrides(), package::package(), pkg_scenery::pkg_scenery(), and pkg_vehicle::pkg_vehicle().
config_record & operator= | ( | const config_record & | conf | ) |
Definition at line 77 of file config.cpp.
References config_record::associated_var, config_record::attributes, config_record::children, config_record::f, config_record::name, config_record::parent, and config_record::text.
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] |
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] |
Definition at line 357 of file config.cpp.
References config_record::attributes, config_record::children, iterable::iter(), config_record::name, string::size(), and config_record::text.
void to_stream | ( | io::text_stream & | s | ) | const [private] |
global_config* associated_var [private] |
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().
dictionary<gsgl::string, gsgl::string> attributes [private] |
Definition at line 68 of file config.hpp.
Referenced by config_record::config_record(), config_record::from_stream(), config_record::get_attribute(), config_record::get_attributes(), config_record::operator=(), config_record::operator==(), config_record::override_with(), and config_record::to_stream().
gsgl::data::list<config_record> children [private] |
Definition at line 64 of file config.hpp.
Referenced by config_record::config_record(), config_record::find_child(), config_record::from_stream(), config_record::get_children(), config_record::operator=(), config_record::operator==(), config_record::override_with(), and config_record::to_stream().
data::shared_pointer<io::file> f [private] |
Shared between all the children.
Definition at line 73 of file config.hpp.
Referenced by config_record::config_record(), config_record::from_stream(), config_record::get_directory(), config_record::get_file(), config_record::operator=(), config_record::operator==(), and config_record::save().
gsgl::string name [private] |
Definition at line 66 of file config.hpp.
Referenced by config_record::config_record(), config_record::from_stream(), config_record::get_name(), config_record::operator=(), config_record::operator==(), config_record::override_with(), and config_record::to_stream().
config_record* parent [private] |
Definition at line 63 of file config.hpp.
Referenced by config_record::from_stream(), config_record::operator=(), config_record::operator==(), and config_record::save().
gsgl::string text [private] |
Definition at line 67 of file config.hpp.
Referenced by config_record::config_record(), config_record::from_stream(), config_record::get_text(), config_record::operator=(), config_record::operator==(), config_record::override_with(), and config_record::to_stream().