Public Member Functions | Private Attributes

nitro::TemplateEngine Class Reference

Template engine. More...

#include <utilities/template_engine.h>

Collaboration diagram for nitro::TemplateEngine:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void LoadTemplateFromFile (const char *FilePath)
 ALIAS_FUNCTION_1 (LoadTemplateFromFile, aliasLoadTemplateFromFile, const char *)
void LoadTemplateFromFile (const std::string &FilePath)
void SetVariable (const char *VariableName, const char *VariableValue)
 ALIAS_FUNCTION_2 (SetVariable, aliasSetVariable, const char *, const char *)
void SetVariable (const std::string &VariableName, const std::string &VariableValue)
template<class Iter >
void SetVariables (const Iter &IterBegin, const Iter &IterEnd)
const nitro::BinaryDataGetTemplate (void) const
virtual ~TemplateEngine (void)

Private Attributes

BinaryData TemplateData

Detailed Description

Template engine.

Author:
Dodonov A.A.

Definition at line 47 of file template_engine.h.


Constructor & Destructor Documentation

nitro::TemplateEngine::~TemplateEngine ( void   )  [virtual]

Destructor (virtual).

Author:
Dodonov A.A.

Definition at line 93 of file template_engine.cpp.

        {
                try
                {
                }
                catch( ... )
                {
                }
        }


Member Function Documentation

nitro::TemplateEngine::ALIAS_FUNCTION_1 ( LoadTemplateFromFile  ,
aliasLoadTemplateFromFile  ,
const char *   
)
nitro::TemplateEngine::ALIAS_FUNCTION_2 ( SetVariable  ,
aliasSetVariable  ,
const char *  ,
const char *   
)
const nitro::BinaryData & nitro::TemplateEngine::GetTemplate ( void   )  const

Function provides access to template.

Returns:
Pointer on the template buffer.
Exceptions:
nitro::exception Throws exception with the description of error.
Author:
Dodonov A.A.

Definition at line 45 of file template_engine.cpp.

References nitro::exception::code(), TemplateData, and nitro::exception::what().

        {
                try
                {
                        return( TemplateData );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::TemplateEngine::GetTemplate( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::TemplateEngine::GetTemplate( void )::An error occured" ) , 0 ) );
                }
        }

Here is the call graph for this function:

void nitro::TemplateEngine::LoadTemplateFromFile ( const char *  FilePath  ) 

Function loads template from file.

Parameters:
FilePath - Path to the template.
Exceptions:
nitro::exception Throws exception with the description of error.
Author:
Dodonov A.A.

Definition at line 10 of file template_engine.cpp.

References nitro::exception::code(), nitro::File::LoadBinDataFromFile(), TemplateData, and nitro::exception::what().

Referenced by LoadTemplateFromFile().

        {
                try
                {
                        nitro::File::LoadBinDataFromFile( TemplateData , FilePath );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::LoadTemplateFromFile( const char *  FilePath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::LoadTemplateFromFile( const char *  FilePath )::An error occured" ) , 0 ) );
                }
        }

Here is the call graph for this function:

void nitro::TemplateEngine::LoadTemplateFromFile ( const std::string &  FilePath  ) 

Definition at line 61 of file template_engine.cpp.

References nitro::exception::code(), LoadTemplateFromFile(), and nitro::exception::what().

        {
                try
                {
                        LoadTemplateFromFile( FilePath.c_str() );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::LoadTemplateFromFile( const std::string & FilePath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::LoadTemplateFromFile( const std::string & FilePath )::An error occured" ) , 0 ) );
                }
        }

Here is the call graph for this function:

void nitro::TemplateEngine::SetVariable ( const char *  VariableName,
const char *  VariableValue 
)

Function sets vriable value.

Parameters:
VariableName - Name of the variable.
VariableValue - Value of the variable.
Exceptions:
nitro::exception Throws exception with the description of error.
Author:
Dodonov A.A.

Definition at line 26 of file template_engine.cpp.

References nitro::exception::code(), nitro::BinaryData::GetFirstOccurance(), nitro::BinaryData::ReplaceBuffer(), TemplateData, and nitro::exception::what().

Referenced by SetVariable(), and SetVariables().

        {
                try
                {
                        for( int OccurancePos( 0 ) ; ( OccurancePos = nitro::BinaryData::GetFirstOccurance( TemplateData , ( std::string( "{" ) + VariableName + std::string( "}" ) ).c_str() , strlen( VariableName ) ) ) != -1 ; )
                        {
                                nitro::BinaryData::ReplaceBuffer( TemplateData , OccurancePos , strlen( VariableName ) + 2 , VariableValue , strlen( VariableValue ) );
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::SetVariable( const char * VariableName , const char * VariableValue )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::SetVariable( const char * VariableName , const char * VariableValue )::An error occured" ) , 0 ) );
                }
        }

Here is the call graph for this function:

void nitro::TemplateEngine::SetVariable ( const std::string &  VariableName,
const std::string &  VariableValue 
)

Function sets vriable value.

Parameters:
VariableName - Name of the variable.
VariableValue - Value of the variable.
Exceptions:
nitro::exception Throws exception with the description of error.
Author:
Dodonov A.A.

Definition at line 77 of file template_engine.cpp.

References nitro::exception::code(), SetVariable(), and nitro::exception::what().

        {
                try
                {
                        SetVariable( VariableName.c_str() , VariableValue.c_str() );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::SetVariable( const std::string & VariableName , const std::string & VariableValue )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::SetVariable( const std::string & VariableName , const std::string & VariableValue )::An error occured" ) , 0 ) );
                }
        }

Here is the call graph for this function:

template<class Iter >
void nitro::TemplateEngine::SetVariables ( const Iter &  IterBegin,
const Iter &  IterEnd 
)

Function sets vriables values.

Parameters:
IterBegin - Beginning of the data sequence.
IterEnd - Ending of the data sequence.
Exceptions:
nitro::exception Throws exception with the description of error.
Author:
Dodonov A.A.

Definition at line 214 of file template_engine.h.

References nitro::exception::code(), SetVariable(), and nitro::exception::what().

        {
                try
                {
                        for( Iter i( IterBegin ) ; i != IterEnd ; i++ )
                        {
                                SetVariable( i->first , i->second );
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::SetVariables( const Iter & IterBegin , const Iter & IterEnd )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "TemplateEngine::SetVariables( const Iter & IterBegin , const Iter & IterEnd )::An error occured" ) , 1 ) );
                }
        }

Here is the call graph for this function:


Member Data Documentation

Template.

Author:
Dodonov A.A.

Definition at line 211 of file template_engine.h.

Referenced by GetTemplate(), LoadTemplateFromFile(), and SetVariable().


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

Generated by  doxygen 1.6.1