nomlib
Loading...
Searching...
No Matches
nom::IConfigFile Class Referenceabstract

Abstract base class for configuration file types. More...

#include <IConfigFile.hpp>

Inheritance diagram for nom::IConfigFile:
[legend]

Public Types

typedef IConfigFile self_type
typedef self_type * raw_ptr
typedef std::unique_ptr< self_type > unique_ptr
typedef std::shared_ptr< self_type > shared_ptr
typedef std::pair< std::string, ValuePair
typedef std::map< std::string, Valuevalue_type

Public Member Functions

 IConfigFile (void)
 Default constructor.
virtual ~IConfigFile (void)
 Destructor.
virtual IValueDeserializerdeserializer (void) const =0
virtual IValueSerializerserializer (void) const =0
virtual bool flush (void)=0
 Force an output (save) of the current configuration.
virtual bool load (void)=0
 Deserialize the configuration from the set file path.
virtual bool save (void)=0
 Serialize the current configuration to the set file path.
const std::string & filename (void) const
 Obtain the set file path.
bool exists (const std::string &key) const
 Check to see if an existing configuration key exists.
int get_int (const std::string &key, int default_value) const
uint get_uint (const std::string &key, uint default_value) const
double get_double (const std::string &key, double default_value) const
const std::string get_string (const std::string &key, const std::string &default_value) const
bool get_bool (const std::string &key, bool default_value) const
void set_property (const std::string &key, const Value &value)
 Write a value to the configuration, mapped by key.
bool erase (const std::string &key)
 Destroy a configuration item.
void set_filename (const std::string &filename)
 Set the file I/O path.

Private Member Functions

const value_type & get (void) const
 Internal getter method for the storage container.

Private Attributes

std::string filename_
 File I/O path.
value_type config_
 The internal configuration storage map.

Friends

class JsonConfigFile
 Access to our (private) get method; returns value_type container.

Detailed Description

Member Typedef Documentation

◆ Pair

typedef std::pair<std::string, Value> nom::IConfigFile::Pair

Definition at line 61 of file IConfigFile.hpp.

◆ raw_ptr

typedef self_type* nom::IConfigFile::raw_ptr

Definition at line 57 of file IConfigFile.hpp.

◆ self_type

typedef IConfigFile nom::IConfigFile::self_type

Definition at line 55 of file IConfigFile.hpp.

◆ shared_ptr

typedef std::shared_ptr<self_type> nom::IConfigFile::shared_ptr

Definition at line 59 of file IConfigFile.hpp.

◆ unique_ptr

typedef std::unique_ptr<self_type> nom::IConfigFile::unique_ptr

Definition at line 58 of file IConfigFile.hpp.

◆ value_type

typedef std::map<std::string, Value> nom::IConfigFile::value_type

Definition at line 62 of file IConfigFile.hpp.

Member Function Documentation

◆ deserializer()

virtual IValueDeserializer * nom::IConfigFile::deserializer ( void ) const
pure virtual
Remarks
This function provides type-safe casting.

Implemented in nom::JsonConfigFile.

◆ erase()

bool nom::IConfigFile::erase ( const std::string & key)

Destroy a configuration item.

Parameters
keyThe configuration item, referenced by member key.

◆ filename()

const std::string & nom::IConfigFile::filename ( void ) const

Obtain the set file path.

Remarks
This is the file path used for I/O during a call to load or save.

◆ flush()

virtual bool nom::IConfigFile::flush ( void )
pure virtual

Force an output (save) of the current configuration.

Implemented in nom::JsonConfigFile.

◆ get_bool()

bool nom::IConfigFile::get_bool ( const std::string & key,
bool default_value ) const
Returns
The boolean value of the configuration key.

◆ get_double()

double nom::IConfigFile::get_double ( const std::string & key,
double default_value ) const
Returns
The double value of the configuration key.

◆ get_int()

int nom::IConfigFile::get_int ( const std::string & key,
int default_value ) const
Returns
The signed integer of the configuration key.

◆ get_string()

const std::string nom::IConfigFile::get_string ( const std::string & key,
const std::string & default_value ) const
Returns
The string of the configuration key.

◆ get_uint()

uint nom::IConfigFile::get_uint ( const std::string & key,
uint default_value ) const
Returns
The unsigned integer of the configuration key.

◆ load()

virtual bool nom::IConfigFile::load ( void )
pure virtual

Deserialize the configuration from the set file path.

Implemented in nom::JsonConfigFile.

◆ save()

virtual bool nom::IConfigFile::save ( void )
pure virtual

Serialize the current configuration to the set file path.

Implemented in nom::JsonConfigFile.

◆ serializer()

virtual IValueSerializer * nom::IConfigFile::serializer ( void ) const
pure virtual
Remarks
This function provides type-safe casting.

Implemented in nom::JsonConfigFile.

◆ set_filename()

void nom::IConfigFile::set_filename ( const std::string & filename)

Set the file I/O path.

Remarks
The command to load the file is given after the filename has been set.

◆ set_property()

void nom::IConfigFile::set_property ( const std::string & key,
const Value & value )

Write a value to the configuration, mapped by key.

Remarks
If the existing item's key exists, it will be overwritten by the new value.

◆ JsonConfigFile

friend class JsonConfigFile ( void )
friend

Access to our (private) get method; returns value_type container.

Definition at line 65 of file IConfigFile.hpp.

Member Data Documentation

◆ config_

value_type nom::IConfigFile::config_
private

The internal configuration storage map.

Definition at line 137 of file IConfigFile.hpp.

◆ filename_

std::string nom::IConfigFile::filename_
private

File I/O path.

Definition at line 134 of file IConfigFile.hpp.


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