Template engine. More...
#include <utilities/template_engine.h>

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::BinaryData & | GetTemplate (void) const |
| virtual | ~TemplateEngine (void) |
Private Attributes | |
| BinaryData | TemplateData |
Template engine.
Definition at line 47 of file template_engine.h.
| nitro::TemplateEngine::~TemplateEngine | ( | void | ) | [virtual] |
Destructor (virtual).
Definition at line 93 of file template_engine.cpp.
{
try
{
}
catch( ... )
{
}
}
| 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.
| nitro::exception | Throws exception with the description of error. |
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 ) );
}
}

| void nitro::TemplateEngine::LoadTemplateFromFile | ( | const char * | FilePath | ) |
Function loads template from file.
| FilePath | - Path to the template. |
| nitro::exception | Throws exception with the description of error. |
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 ) );
}
}

| 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 ) );
}
}

| void nitro::TemplateEngine::SetVariable | ( | const char * | VariableName, | |
| const char * | VariableValue | |||
| ) |
Function sets vriable value.
| VariableName | - Name of the variable. | |
| VariableValue | - Value of the variable. |
| nitro::exception | Throws exception with the description of error. |
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 ) );
}
}

| void nitro::TemplateEngine::SetVariable | ( | const std::string & | VariableName, | |
| const std::string & | VariableValue | |||
| ) |
Function sets vriable value.
| VariableName | - Name of the variable. | |
| VariableValue | - Value of the variable. |
| nitro::exception | Throws exception with the description of error. |
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 ) );
}
}

| void nitro::TemplateEngine::SetVariables | ( | const Iter & | IterBegin, | |
| const Iter & | IterEnd | |||
| ) |
Function sets vriables values.
| IterBegin | - Beginning of the data sequence. | |
| IterEnd | - Ending of the data sequence. |
| nitro::exception | Throws exception with the description of error. |
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 ) );
}
}

Template.
Definition at line 211 of file template_engine.h.
Referenced by GetTemplate(), LoadTemplateFromFile(), and SetVariable().
1.6.1