ZNC  trunk
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
MCString Class Reference

A dictionary for strings. More...

#include <ZNCString.h>

+ Inheritance diagram for MCString:
+ Collaboration diagram for MCString:

Public Types

enum  status_t {
  MCS_SUCCESS = 0 , MCS_EOPEN = 1 , MCS_EWRITE = 2 , MCS_EWRITEFIL = 3 ,
  MCS_EREADFIL = 4
}
 Status codes that can be returned by WriteToDisk() and ReadFromDisk(). More...
 

Public Member Functions

 MCString ()
 Construct an empty MCString. More...
 
 MCString (std::initializer_list< std::pair< const CString, CString >> list)
 Construct a MCString using an initializer list eg. More...
 
virtual ~MCString ()
 Destruct this MCString. More...
 
enum status_t WriteToDisk (const CString &sPath, mode_t iMode=0644) const
 Write this map to a file. More...
 
enum status_t ReadFromDisk (const CString &sPath)
 Read a map from a file. More...
 
virtual bool WriteFilter (CString &sKey, CString &sValue) const
 Filter used while writing this map. More...
 
virtual bool ReadFilter (CString &sKey, CString &sValue) const
 Filter used while reading this map. More...
 
virtual CStringEncode (CString &sValue) const
 Encode a value so that it can safely be parsed by ReadFromDisk(). More...
 
virtual CStringDecode (CString &sValue) const
 Undo the effects of Encode(). More...
 

Public Attributes

keys
 STL member. More...
 
elements
 STL member. More...
 

Static Public Attributes

static const MCString EmptyMap
 A static instance of an empty map. More...
 

Detailed Description

A dictionary for strings.

Todo:
Replace with "using MCString = std::map<CString, CString>;" in ZNC 2.0

This class maps strings to other strings.

Member Enumeration Documentation

◆ status_t

Status codes that can be returned by WriteToDisk() and ReadFromDisk().

Enumerator
MCS_SUCCESS 

No errors.

MCS_EOPEN 

Opening the file failed.

MCS_EWRITE 

Writing to the file failed.

MCS_EWRITEFIL 

WriteFilter() failed.

MCS_EREADFIL 

ReadFilter() failed.

Constructor & Destructor Documentation

◆ MCString() [1/2]

MCString::MCString ( )
inline

Construct an empty MCString.

◆ MCString() [2/2]

MCString::MCString ( std::initializer_list< std::pair< const CString, CString >>  list)
inline

Construct a MCString using an initializer list eg.

MCString m = { {"key1", "val1"}, {"key2", "val2"} };

◆ ~MCString()

virtual MCString::~MCString ( )
inlinevirtual

Destruct this MCString.

Member Function Documentation

◆ Decode()

virtual CString& MCString::Decode ( CString sValue) const
virtual

Undo the effects of Encode().

This is an internal function.

◆ Encode()

virtual CString& MCString::Encode ( CString sValue) const
virtual

Encode a value so that it can safely be parsed by ReadFromDisk().

This is an internal function.

◆ ReadFilter()

virtual bool MCString::ReadFilter ( CString sKey,
CString sValue 
) const
inlinevirtual

Filter used while reading this map.

This function is called by ReadFromDisk() for each pair that is beging read. This function has the chance to modify the data that is being read.

Parameters
sKeyThe key that was read. Can be modified.
sValueThe value that was read. Can be modified.
Returns
true unless ReadFromDisk() should fail with MCS_EWRITEFIL.

◆ ReadFromDisk()

enum status_t MCString::ReadFromDisk ( const CString sPath)

Read a map from a file.

Parameters
sPathThe file name to read from.
Returns
The result of the operation.
See also
ReadFilter.

◆ WriteFilter()

virtual bool MCString::WriteFilter ( CString sKey,
CString sValue 
) const
inlinevirtual

Filter used while writing this map.

This function is called by WriteToDisk() for each pair that is going to be written. This function has the chance to modify the data that will be written.

Parameters
sKeyThe key that will be written. Can be modified.
sValueThe value that will be written. Can be modified.
Returns
true unless WriteToDisk() should fail with MCS_EWRITEFIL.

◆ WriteToDisk()

enum status_t MCString::WriteToDisk ( const CString sPath,
mode_t  iMode = 0644 
) const

Write this map to a file.

Parameters
sPathThe file name to write to.
iModeThe mode for the file.
Returns
The result of the operation.
See also
WriteFilter.

Member Data Documentation

◆ elements

T std::map< K, T >::elements
inherited

STL member.

◆ EmptyMap

const MCString MCString::EmptyMap
static

A static instance of an empty map.

◆ keys

K std::map< K, T >::keys
inherited

STL member.


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