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

#include <Template.h>

+ Inheritance diagram for CTemplate:
+ Collaboration diagram for CTemplate:

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

 CTemplate ()
 
 CTemplate (const CString &sFileName)
 
 CTemplate (const std::shared_ptr< CTemplateOptions > &Options, CTemplate *pParent=nullptr)
 
virtual ~CTemplate ()
 
 CTemplate (const CTemplate &other)=default
 
CTemplateoperator= (const CTemplate &other)=default
 
void AddTagHandler (std::shared_ptr< CTemplateTagHandler > spTagHandler)
 Class for implementing custom tags in subclasses. More...
 
std::vector< std::shared_ptr< CTemplateTagHandler > > & GetTagHandlers ()
 
CString ResolveLiteral (const CString &sString)
 
void Init ()
 
CTemplateGetParent (bool bRoot)
 
CString ExpandFile (const CString &sFilename, bool bFromInc=false)
 
bool SetFile (const CString &sFileName)
 
void SetPath (const CString &sPath)
 
CString MakePath (const CString &sPath) const
 
void PrependPath (const CString &sPath, bool bIncludesOnly=false)
 
void AppendPath (const CString &sPath, bool bIncludesOnly=false)
 
void RemovePath (const CString &sPath)
 
void ClearPaths ()
 
bool PrintString (CString &sRet)
 
bool Print (std::ostream &oOut)
 
bool Print (const CString &sFileName, std::ostream &oOut)
 
bool ValidIf (const CString &sArgs)
 
bool ValidExpr (const CString &sExpr)
 
bool IsTrue (const CString &sName)
 
bool HasLoop (const CString &sName)
 
CString GetValue (const CString &sName, bool bFromIf=false)
 
CTemplateAddRow (const CString &sName)
 
CTemplateGetRow (const CString &sName, unsigned int uIndex)
 
std::vector< CTemplate * > * GetLoop (const CString &sName)
 
void DelCurLoopContext ()
 
CTemplateLoopContextGetCurLoopContext ()
 
CTemplateGetCurTemplate ()
 
const CStringGetFileName () const
 
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...
 

Member Enumeration Documentation

◆ status_t

enum MCString::status_t
inherited

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

◆ CTemplate() [1/4]

CTemplate::CTemplate ( )
inline

◆ CTemplate() [2/4]

CTemplate::CTemplate ( const CString sFileName)
inline

◆ CTemplate() [3/4]

CTemplate::CTemplate ( const std::shared_ptr< CTemplateOptions > &  Options,
CTemplate pParent = nullptr 
)
inline

◆ ~CTemplate()

virtual CTemplate::~CTemplate ( )
virtual

◆ CTemplate() [4/4]

CTemplate::CTemplate ( const CTemplate other)
default

Member Function Documentation

◆ AddRow()

CTemplate& CTemplate::AddRow ( const CString sName)

◆ AddTagHandler()

void CTemplate::AddTagHandler ( std::shared_ptr< CTemplateTagHandler spTagHandler)
inline

Class for implementing custom tags in subclasses.

◆ AppendPath()

void CTemplate::AppendPath ( const CString sPath,
bool  bIncludesOnly = false 
)

◆ ClearPaths()

void CTemplate::ClearPaths ( )

◆ Decode()

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

Undo the effects of Encode().

This is an internal function.

◆ DelCurLoopContext()

void CTemplate::DelCurLoopContext ( )

◆ Encode()

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

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

This is an internal function.

◆ ExpandFile()

CString CTemplate::ExpandFile ( const CString sFilename,
bool  bFromInc = false 
)

◆ GetCurLoopContext()

CTemplateLoopContext* CTemplate::GetCurLoopContext ( )

◆ GetCurTemplate()

CTemplate* CTemplate::GetCurTemplate ( )

◆ GetFileName()

const CString& CTemplate::GetFileName ( ) const
inline

◆ GetLoop()

std::vector<CTemplate*>* CTemplate::GetLoop ( const CString sName)

◆ GetParent()

CTemplate* CTemplate::GetParent ( bool  bRoot)

◆ GetRow()

CTemplate* CTemplate::GetRow ( const CString sName,
unsigned int  uIndex 
)

◆ GetTagHandlers()

std::vector<std::shared_ptr<CTemplateTagHandler> >& CTemplate::GetTagHandlers ( )
inline

References GetTagHandlers().

Referenced by GetTagHandlers().

◆ GetValue()

CString CTemplate::GetValue ( const CString sName,
bool  bFromIf = false 
)

◆ HasLoop()

bool CTemplate::HasLoop ( const CString sName)

◆ Init()

void CTemplate::Init ( )

◆ IsTrue()

bool CTemplate::IsTrue ( const CString sName)

◆ MakePath()

CString CTemplate::MakePath ( const CString sPath) const

◆ operator=()

CTemplate& CTemplate::operator= ( const CTemplate other)
default

◆ PrependPath()

void CTemplate::PrependPath ( const CString sPath,
bool  bIncludesOnly = false 
)

◆ Print() [1/2]

bool CTemplate::Print ( const CString sFileName,
std::ostream &  oOut 
)

◆ Print() [2/2]

bool CTemplate::Print ( std::ostream &  oOut)

◆ PrintString()

bool CTemplate::PrintString ( CString sRet)

◆ ReadFilter()

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

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)
inherited

Read a map from a file.

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

◆ RemovePath()

void CTemplate::RemovePath ( const CString sPath)

◆ ResolveLiteral()

CString CTemplate::ResolveLiteral ( const CString sString)

◆ SetFile()

bool CTemplate::SetFile ( const CString sFileName)

◆ SetPath()

void CTemplate::SetPath ( const CString sPath)

◆ ValidExpr()

bool CTemplate::ValidExpr ( const CString sExpr)

◆ ValidIf()

bool CTemplate::ValidIf ( const CString sArgs)

◆ WriteFilter()

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

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
inherited

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
staticinherited

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: