Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
SoftwareAndServices::Library::Common::config Class Reference

This class is used to read and write standard configuration files. More...

#include "<SaS/Common/config.hpp>"

+ Inheritance diagram for SoftwareAndServices::Library::Common::config:
+ Collaboration diagram for SoftwareAndServices::Library::Common::config:

Public Member Functions

 config ()
 config - Constructor. More...
 
virtual ~config ()
 config - Destructor. More...
 
bool Add (const char *tag, const char *value, bool override=false)
 Add a TAG/VALUE, the default is to fail if TAG already exists in the configuration data. More...
 
bool Add (const char *tag, const char *value, int Code1, int Code2, bool override=false)
 Add a TAG/VALUE, the default is to fail if TAG already exists in the configuration data. More...
 
virtual InstanceCount_t decInstance () const
 Decrement the instance. More...
 
const char * Get (const char *tag) const
 Get the value associated with tag (key). More...
 
const char * Get (const char *tag, int &Code1, int &Code2) const
 Get the value associated with tag (key). More...
 
virtual InstanceCount_t getInstance () const
 
int Has (const char *tag) const
 See if the tag (key) is in this configuration file. More...
 
virtual InstanceCount_t incInstance () const
 Increment the instance. More...
 
void operator delete (void *ToFree)
 
bool Read (const char *configFileName)
 Read in the named configuration file. More...
 
bool Remove (const char *tag, const char *value=nullptr, bool all=false)
 Delete TAG from the configuration. More...
 
bool Write (const char *ConfigFileName) const
 Write the configuration data to the named file. More...
 

Detailed Description

This class is used to read and write standard configuration files.

Blank lines and lines starting with '#' are ignored. Everything after a '#' in a line is ignored.

Deprecated:
This object is being deprecated as back end code.
See also
Preference Preference uses config for file I/O. The Preference object has more options for varying data types.

Definition at line 112 of file config.hpp.

Constructor & Destructor Documentation

◆ config()

SoftwareAndServices::Library::Common::config::config ( )

config - Constructor.

◆ ~config()

virtual SoftwareAndServices::Library::Common::config::~config ( )
virtual

config - Destructor.

Member Function Documentation

◆ Add() [1/2]

bool SoftwareAndServices::Library::Common::config::Add ( const char *  tag,
const char *  value,
bool  override = false 
)

Add a TAG/VALUE, the default is to fail if TAG already exists in the configuration data.

Parameters
tagThe name of the tag to write.
valueThe value to associate with this tag.
overrideOnly override an existing entry, if override is TRUE.
Returns
TRUE if added.

◆ Add() [2/2]

bool SoftwareAndServices::Library::Common::config::Add ( const char *  tag,
const char *  value,
int  Code1,
int  Code2,
bool  override = false 
)

Add a TAG/VALUE, the default is to fail if TAG already exists in the configuration data.

Parameters
tagThe name of the tag to write.
valueThe value to associate with this tag.
Code1A code value used by Preferences.
Code2A code value used by Preferences.
overrideOnly override an existing entry, if override is TRUE.
Returns
TRUE if added.

◆ decInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< config >::decInstance ( ) const
inlinevirtualinherited

Decrement the instance.

Returns
The instance count, after decrementing it.

Definition at line 129 of file instance.hpp.

◆ Get() [1/2]

const char* SoftwareAndServices::Library::Common::config::Get ( const char *  tag) const

Get the value associated with tag (key).

The results are stored in StringCache, caller must StringCache::remove them when done.

Parameters
tagA key to look for.
Returns
The value, or nullptr if no such tag exists.

◆ Get() [2/2]

const char* SoftwareAndServices::Library::Common::config::Get ( const char *  tag,
int &  Code1,
int &  Code2 
) const

Get the value associated with tag (key).

The results are stored in StringCache, caller must StringCache::remove them when done.

Parameters
tagA key to look for.
[out]Code1The code type used by Preference.
[out]Code2The code type used by Preference.
Returns
The value, or nullptr if no such tag exists.

◆ getInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< config >::getInstance ( ) const
inlinevirtualinherited
Returns
The current instance count.

Definition at line 118 of file instance.hpp.

◆ Has()

int SoftwareAndServices::Library::Common::config::Has ( const char *  tag) const

See if the tag (key) is in this configuration file.

Parameters
tagA key to look for.
Returns
The Code type stored, or zero if not found.

◆ incInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< config >::incInstance ( ) const
inlinevirtualinherited

Increment the instance.

Returns
The instance value, after incrementing it.

Definition at line 109 of file instance.hpp.

◆ Read()

bool SoftwareAndServices::Library::Common::config::Read ( const char *  configFileName)

Read in the named configuration file.

Parameters
configFileNameThe name of the file to read.
Returns
TRUE if parsed successfully.

◆ Remove()

bool SoftwareAndServices::Library::Common::config::Remove ( const char *  tag,
const char *  value = nullptr,
bool  all = false 
)

Delete TAG from the configuration.

If VALUE is NOT null, then delete all that match TAG/VALUE. If 'all' is true and VALUE is nullptr then delete all TAG that match 'tag'

Parameters
tagThe tag to look up.
valueIf not nullptr, only delete if it has this value.
allIf TRUE delete all tags with a matching name.
Returns
TRUE if it worked.

◆ Write()

bool SoftwareAndServices::Library::Common::config::Write ( const char *  ConfigFileName) const

Write the configuration data to the named file.

Parameters
ConfigFileNameThe name of the file to write.
Returns
TRUE if written.

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