Ocean
Ocean::Config::Value Class Reference

This class implements a configuration value. More...

Inheritance diagram for Ocean::Config::Value:

Public Member Functions

virtual ValueType type () const
 Returns the type of this value. More...
 
virtual bool isMultiType () const
 Returns whether this value holds a multi type. More...
 
virtual unsigned int values () const
 Returns the number of sub values. More...
 
virtual unsigned int values (const std::string &name) const
 Returns the number of sub values with a given name. More...
 
virtual bool exist (const std::string &name) const
 Returns whether this value holds at least one specified sub value. More...
 
virtual Valuevalue (const std::string &name, const unsigned int index=0u)
 Returns a sub value specified by it's name and it's index if more than one value exists with the same name. More...
 
virtual bool value (const std::string &name, const unsigned int index, Value **value)
 Returns a sub value specified by it's name and it's index if more than one value exists with the same name. More...
 
virtual Valuevalue (const unsigned int index, std::string &name)
 Returns a sub value specified by it's index. More...
 
virtual bool value (const unsigned int index, std::string &name, Value **value)
 Returns a sub value specified by it's index. More...
 
virtual Valueadd (const std::string &name)
 Adds a new sub value specified by it's name. More...
 
virtual bool operator() (const bool value) const
 Returns this value as boolean. More...
 
virtual int operator() (const int value) const
 Returns this value as integer. More...
 
virtual double operator() (const double value) const
 Returns this value as number. More...
 
std::string operator() (const char *value) const
 Returns this value as string. More...
 
virtual std::string operator() (const std::string &value) const
 Returns this value as string. More...
 
virtual std::vector< bool > operator() (const std::vector< bool > &value) const
 Returns this value as multi boolean. More...
 
virtual std::vector< int > operator() (const std::vector< int > &value) const
 Returns this value as multi integer. More...
 
virtual std::vector< double > operator() (const std::vector< double > &value) const
 Returns this value as multi number. More...
 
virtual std::vector< std::string > operator() (const std::vector< std::string > &value) const
 Returns this value as multi string. More...
 
virtual bool operator= (const bool value)
 Sets this value as boolean. More...
 
virtual bool operator= (const int value)
 Sets this value as integer. More...
 
virtual bool operator= (const double value)
 Sets this value as number. More...
 
bool operator= (const char *value)
 Sets this value as string. More...
 
virtual bool operator= (const std::string &value)
 Sets this value as string. More...
 
virtual bool operator= (const std::vector< bool > &values)
 Sets this value as multi boolean. More...
 
virtual bool operator= (const std::vector< int > &values)
 Sets this value as multi integer. More...
 
virtual bool operator= (const std::vector< double > &values)
 Sets this value as multi number. More...
 
virtual bool operator= (const std::vector< std::string > &values)
 Sets this value as multi string. More...
 
virtual Valueoperator[] (const std::string &name)
 Returns the first sub value specified by it's name or creates a new value if no existing. More...
 

Protected Member Functions

 Value ()=default
 Creates a new value object. More...
 
 Value (const Value &value)=default
 Default copy constructor. More...
 
virtual ~Value ()=default
 Destructs a value object. More...
 

Protected Attributes

ValueType valueType_ = TYPE_INVALID
 Value type. More...
 

Friends

class Config
 

Detailed Description

This class implements a configuration value.

Each value can represent a single parameter or a grouping object.

Constructor & Destructor Documentation

◆ Value() [1/2]

Ocean::Config::Value::Value ( )
protecteddefault

Creates a new value object.

◆ Value() [2/2]

Ocean::Config::Value::Value ( const Value value)
protecteddefault

Default copy constructor.

Parameters
valueThe value to copied

◆ ~Value()

virtual Ocean::Config::Value::~Value ( )
protectedvirtualdefault

Destructs a value object.

Member Function Documentation

◆ add()

virtual Value& Ocean::Config::Value::add ( const std::string &  name)
virtual

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

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

Reimplemented in Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ exist()

virtual bool Ocean::Config::Value::exist ( const std::string &  name) const
virtual

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

Parameters
nameThe name of the sub value to check
Returns
True, if so

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ isMultiType()

virtual bool Ocean::Config::Value::isMultiType ( ) const
virtual

Returns whether this value holds a multi type.

Returns
True, if so

◆ operator()() [1/9]

virtual bool Ocean::Config::Value::operator() ( const bool  value) const
virtual

Returns this value as boolean.

Parameters
valueDefault value which will be returned if this value holds no boolean
Returns
Internal value

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator()() [2/9]

std::string Ocean::Config::Value::operator() ( const char *  value) const
inline

Returns this value as string.

Parameters
valueDefault value which will be returned if this value holds no string
Returns
Internal value

◆ operator()() [3/9]

virtual double Ocean::Config::Value::operator() ( const double  value) const
virtual

Returns this value as number.

Parameters
valueDefault value which will be returned if this value holds no number
Returns
Internal value

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator()() [4/9]

virtual int Ocean::Config::Value::operator() ( const int  value) const
virtual

Returns this value as integer.

Parameters
valueDefault value which will be returned if this value holds no integer
Returns
Internal value

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator()() [5/9]

virtual std::string Ocean::Config::Value::operator() ( const std::string &  value) const
virtual

Returns this value as string.

Parameters
valueDefault value which will be returned if this value holds no string
Returns
Internal value

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator()() [6/9]

virtual std::vector<bool> Ocean::Config::Value::operator() ( const std::vector< bool > &  value) const
virtual

Returns this value as multi boolean.

Parameters
valueDefault value which will be returned if this value holds no boolean
Returns
Internal value

Reimplemented in Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator()() [7/9]

virtual std::vector<double> Ocean::Config::Value::operator() ( const std::vector< double > &  value) const
virtual

Returns this value as multi number.

Parameters
valueDefault value which will be returned if this value holds no number
Returns
Internal value

Reimplemented in Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator()() [8/9]

virtual std::vector<int> Ocean::Config::Value::operator() ( const std::vector< int > &  value) const
virtual

Returns this value as multi integer.

Parameters
valueDefault value which will be returned if this value holds no integer
Returns
Internal value

Reimplemented in Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator()() [9/9]

virtual std::vector<std::string> Ocean::Config::Value::operator() ( const std::vector< std::string > &  value) const
virtual

Returns this value as multi string.

Parameters
valueDefault value which will be returned if this value holds no string
Returns
Internal value

Reimplemented in Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator=() [1/9]

virtual bool Ocean::Config::Value::operator= ( const bool  value)
virtual

Sets this value as boolean.

Parameters
valueThe value to set
Returns
True, if succeeded

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator=() [2/9]

bool Ocean::Config::Value::operator= ( const char *  value)
inline

Sets this value as string.

Parameters
valueThe value to set
Returns
True, if succeeded

◆ operator=() [3/9]

virtual bool Ocean::Config::Value::operator= ( const double  value)
virtual

Sets this value as number.

Parameters
valueThe value to set
Returns
True, if succeeded

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator=() [4/9]

virtual bool Ocean::Config::Value::operator= ( const int  value)
virtual

Sets this value as integer.

Parameters
valueThe value to set
Returns
True, if succeeded

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator=() [5/9]

virtual bool Ocean::Config::Value::operator= ( const std::string &  value)
virtual

Sets this value as string.

Parameters
valueThe value to set
Returns
True, if succeeded

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator=() [6/9]

virtual bool Ocean::Config::Value::operator= ( const std::vector< bool > &  values)
virtual

Sets this value as multi boolean.

Parameters
valuesThe values to set
Returns
True, if succeeded

Reimplemented in Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator=() [7/9]

virtual bool Ocean::Config::Value::operator= ( const std::vector< double > &  values)
virtual

Sets this value as multi number.

Parameters
valuesThe values to set
Returns
True, if succeeded

Reimplemented in Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator=() [8/9]

virtual bool Ocean::Config::Value::operator= ( const std::vector< int > &  values)
virtual

Sets this value as multi integer.

Parameters
valuesThe values to set
Returns
True, if succeeded

Reimplemented in Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator=() [9/9]

virtual bool Ocean::Config::Value::operator= ( const std::vector< std::string > &  values)
virtual

Sets this value as multi string.

Parameters
valuesThe values to set
Returns
True, if succeeded

Reimplemented in Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ operator[]()

virtual Value& Ocean::Config::Value::operator[] ( const std::string &  name)
virtual

Returns the first sub value specified by it's name or creates a new value if no existing.

Parameters
nameThe name of the sub-value to return
Returns
Specified sub value

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ type()

virtual ValueType Ocean::Config::Value::type ( ) const
virtual

Returns the type of this value.

Returns
Value type

◆ value() [1/4]

virtual bool Ocean::Config::Value::value ( const std::string &  name,
const unsigned int  index,
Value **  value 
)
virtual

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

Parameters
nameThe name of the value to return
indexThe index within those sub values with the specified name
valueResulting sub value
Returns
True, if the value exists

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ value() [2/4]

virtual Value& Ocean::Config::Value::value ( const std::string &  name,
const unsigned int  index = 0u 
)
virtual

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

Parameters
nameThe name of the value to return
indexThe index within those sub values with the specified name
Returns
Sub value

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ value() [3/4]

virtual Value& Ocean::Config::Value::value ( const unsigned int  index,
std::string &  name 
)
virtual

Returns a sub value specified by it's index.

Parameters
indexThe index of the sub value to return
nameResulting name of the returning value
Returns
Sub value

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ value() [4/4]

virtual bool Ocean::Config::Value::value ( const unsigned int  index,
std::string &  name,
Value **  value 
)
virtual

Returns a sub value specified by it's index.

Parameters
indexThe index of the sub value to return
nameResulting name of the returning value
valueResulting sub value
Returns
True, if the value exists

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

◆ values() [1/2]

virtual unsigned int Ocean::Config::Value::values ( ) const
virtual

◆ values() [2/2]

virtual unsigned int Ocean::Config::Value::values ( const std::string &  name) const
virtual

Returns the number of sub values with a given name.

Parameters
nameThe name of the sub values to return
Returns
Sub value number

Reimplemented in Ocean::Platform::Win::RegistryConfig::RegistryValue, Ocean::IO::XMLConfig::XMLValue, Ocean::IO::JSONConfig::JSONValue, and Ocean::IO::FileConfig::FileValue.

Friends And Related Function Documentation

◆ Config

friend class Config
friend

Field Documentation

◆ valueType_

ValueType Ocean::Config::Value::valueType_ = TYPE_INVALID
protected

Value type.


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