Ocean
Ocean::IO::XMLConfig Class Referencefinal

This class implements a configuration toolkit using XML encoding to store the parameters. More...

Inheritance diagram for Ocean::IO::XMLConfig:

Data Structures

class  XMLValue
 Definition of a file value object. More...
 

Public Types

typedef std::vector< XMLValue * > XMLValues
 Definition of a vector holding values. More...
 
- Public Types inherited from Ocean::Config
enum  ValueType {
  TYPE_INVALID , TYPE_UNDEFINED , TYPE_BOOL , TYPE_INT ,
  TYPE_NUMBER , TYPE_STRING , TYPE_MULTI_BOOL , TYPE_MULTI_INT ,
  TYPE_MULTI_NUMBER , TYPE_MULTI_STRING , TYPE_GROUP
}
 Definition of different value types. More...
 

Public Member Functions

 XMLConfig ()
 Creates a new config object. More...
 
 ~XMLConfig () override
 Destructs a xml config object. More...
 
 XMLConfig (const std::string &filename, const bool read=true)
 Creates a new config object by a given configuration file. More...
 
 XMLConfig (std::istream &inputStream, const bool read=true)
 Creates a new config object by a given configuration input stream. More...
 
const std::string & filename () const
 Returns the config file. More...
 
bool setFilename (const std::string &filename, const bool read=true)
 Sets the filename of the new config objects. More...
 
bool read () override
 Reads / loads all values of this configuration. More...
 
bool write () override
 Writes / saves all values of this configuration. More...
 
unsigned int values () const override
 Returns the number of sub values. More...
 
unsigned int values (const std::string &name) const override
 Returns the number of sub values with a given name. More...
 
bool exist (const std::string &name) const override
 Returns whether this value holds at least one specified sub value. More...
 
XMLValuevalue (const unsigned int index, std::string &name) override
 Returns a sub value specified by it's index. More...
 
bool value (const unsigned int index, std::string &name, Value **value) override
 Returns a sub value specified by it's index. More...
 
XMLValuevalue (const std::string &name, const unsigned int index) override
 Returns a sub value specified by it's name and it's index if more than one value exists with the same name. More...
 
bool value (const std::string &name, const unsigned int index, Value **value) override
 Returns a sub value specified by it's name and it's index if more than one value exists with the same name. More...
 
XMLValueadd (const std::string &name) override
 Adds a new sub value specified by it's name. More...
 
XMLValueoperator[] (const std::string &name) override
 Returns a sub value specified by it's name. More...
 
bool isEmpty () const
 Returns whether this file configuration container does not hold any values. More...
 
- Public Member Functions inherited from Ocean::Config
virtual ~Config ()
 Destructs a configuration toolkit. More...
 
Timestamp writeTimestamp () const
 Returns the timestamp of the last write execution. More...
 

Static Protected Member Functions

static const tinyxml2::XMLText * firstText (const tinyxml2::XMLNode *xmlNode)
 Returns the first text node connected with a given node. More...
 
static tinyxml2::XMLText * firstText (tinyxml2::XMLNode *xmlNode)
 Returns the first text node connected with a given node. More...
 
static XMLValuenullValue ()
 Returns the default value holding no data. More...
 
- Static Protected Member Functions inherited from Ocean::Config
static ValuenullValue ()
 Returns the default value holding no data. More...
 

Protected Attributes

tinyxml2::XMLDocument * xmlDocument_ = nullptr
 XML parser. More...
 
XMLValues xmlIntermediateValues_
 XML values. More...
 
std::string filename_
 Filename of this config object. More...
 
std::istream & inputStream_
 The input stream. More...
 
std::ifstream inputFileStream_
 The input file stream which is used if a filename is specified. More...
 
- Protected Attributes inherited from Ocean::Config
Timestamp writeTimestamp_
 Holds the timestamp of the most recent write execution. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Ocean::Config
 Config ()
 Creates a new configuration toolkit. More...
 
 Config (const Config &config)=delete
 Disabled copy constructor. More...
 
Configoperator= (const Config &config)=delete
 Disabled copy operator. More...
 

Detailed Description

This class implements a configuration toolkit using XML encoding to store the parameters.

Member Typedef Documentation

◆ XMLValues

Definition of a vector holding values.

Constructor & Destructor Documentation

◆ XMLConfig() [1/3]

Ocean::IO::XMLConfig::XMLConfig ( )

Creates a new config object.

◆ ~XMLConfig()

Ocean::IO::XMLConfig::~XMLConfig ( )
override

Destructs a xml config object.

◆ XMLConfig() [2/3]

Ocean::IO::XMLConfig::XMLConfig ( const std::string &  filename,
const bool  read = true 
)
explicit

Creates a new config object by a given configuration file.

Parameters
filenameConfiguration file
readTrue, to load the file directly

◆ XMLConfig() [3/3]

Ocean::IO::XMLConfig::XMLConfig ( std::istream &  inputStream,
const bool  read = true 
)
explicit

Creates a new config object by a given configuration input stream.

Parameters
inputStreamThe input stream providing the configuration information
readTrue, to load the file directly

Member Function Documentation

◆ add()

XMLValue& Ocean::IO::XMLConfig::add ( const std::string &  name)
overridevirtual

Adds a new sub value specified by it's name.

Parameters
nameThe name of the sub value to create
Returns
New sub value

Reimplemented from Ocean::Config.

◆ exist()

bool Ocean::IO::XMLConfig::exist ( const std::string &  name) const
overridevirtual

Returns whether this value holds at least one specified sub value.

See also
Config::exist().

Reimplemented from Ocean::Config.

◆ filename()

const std::string & Ocean::IO::XMLConfig::filename ( ) const
inline

Returns the config file.

Returns
Config file

◆ firstText() [1/2]

static const tinyxml2::XMLText* Ocean::IO::XMLConfig::firstText ( const tinyxml2::XMLNode *  xmlNode)
staticprotected

Returns the first text node connected with a given node.

Parameters
xmlNodeNode for that the connected text node is requested
Returns
First text node

◆ firstText() [2/2]

static tinyxml2::XMLText* Ocean::IO::XMLConfig::firstText ( tinyxml2::XMLNode *  xmlNode)
staticprotected

Returns the first text node connected with a given node.

Parameters
xmlNodeNode for that the connected text node is requested
Returns
First text node

◆ isEmpty()

bool Ocean::IO::XMLConfig::isEmpty ( ) const

Returns whether this file configuration container does not hold any values.

Returns
True, if so

◆ nullValue()

static XMLValue& Ocean::IO::XMLConfig::nullValue ( )
staticprotected

Returns the default value holding no data.

Returns
The default value holding no data.

◆ operator[]()

XMLValue& Ocean::IO::XMLConfig::operator[] ( const std::string &  name)
overridevirtual

Returns a sub value specified by it's name.

See also
Config::operator[]().

Reimplemented from Ocean::Config.

◆ read()

bool Ocean::IO::XMLConfig::read ( )
overridevirtual

Reads / loads all values of this configuration.

See also
Config::read().

Reimplemented from Ocean::Config.

◆ setFilename()

bool Ocean::IO::XMLConfig::setFilename ( const std::string &  filename,
const bool  read = true 
)

Sets the filename of the new config objects.

All old config objects will be released before.

Parameters
filenameto set
readTrue, to load the file directly
Returns
True, if the file could be loaded

◆ value() [1/4]

XMLValue& Ocean::IO::XMLConfig::value ( const std::string &  name,
const unsigned int  index 
)
overridevirtual

Returns a sub value specified by it's name and it's index if more than one value exists with the same name.

See also
Config::value().

Reimplemented from Ocean::Config.

◆ value() [2/4]

bool Ocean::IO::XMLConfig::value ( const std::string &  name,
const unsigned int  index,
Value **  value 
)
overridevirtual

Returns a sub value specified by it's name and it's index if more than one value exists with the same name.

See also
Config::value().

Reimplemented from Ocean::Config.

◆ value() [3/4]

XMLValue& Ocean::IO::XMLConfig::value ( const unsigned int  index,
std::string &  name 
)
overridevirtual

Returns a sub value specified by it's index.

See also
Config::value().

Reimplemented from Ocean::Config.

◆ value() [4/4]

bool Ocean::IO::XMLConfig::value ( const unsigned int  index,
std::string &  name,
Value **  value 
)
overridevirtual

Returns a sub value specified by it's index.

See also
Config::value().

Reimplemented from Ocean::Config.

◆ values() [1/2]

unsigned int Ocean::IO::XMLConfig::values ( ) const
overridevirtual

Returns the number of sub values.

See also
Config::values().

Reimplemented from Ocean::Config.

◆ values() [2/2]

unsigned int Ocean::IO::XMLConfig::values ( const std::string &  name) const
overridevirtual

Returns the number of sub values with a given name.

See also
Config::values().

Reimplemented from Ocean::Config.

◆ write()

bool Ocean::IO::XMLConfig::write ( )
overridevirtual

Writes / saves all values of this configuration.

See also
Config::write().

Reimplemented from Ocean::Config.

Field Documentation

◆ filename_

std::string Ocean::IO::XMLConfig::filename_
protected

Filename of this config object.

◆ inputFileStream_

std::ifstream Ocean::IO::XMLConfig::inputFileStream_
protected

The input file stream which is used if a filename is specified.

◆ inputStream_

std::istream& Ocean::IO::XMLConfig::inputStream_
protected

The input stream.

◆ xmlDocument_

tinyxml2::XMLDocument* Ocean::IO::XMLConfig::xmlDocument_ = nullptr
protected

XML parser.

◆ xmlIntermediateValues_

XMLValues Ocean::IO::XMLConfig::xmlIntermediateValues_
protected

XML values.


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