Go to the documentation of this file.00001 #ifndef __TEMPLATE_ENGINE_H__
00002 #define __TEMPLATE_ENGINE_H__
00003
00004 #if !defined( WIN32_PLATFORM ) && !defined( NIX_PLATFORM ) && !defined( MINGW_PLATFORM ) && !defined( CYGWIN_PLATFORM )
00005 #define WIN32_PLATFORM
00006 #endif
00007
00008 #ifdef TEMPLATE_ENGINE
00009 #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM ) || defined( CYGWIN_PLATFORM )
00010 #define TEMPLATE_ENGINE_DLL_ENTITY __declspec( dllexport )
00011 #endif
00012
00013 #if defined( NIX_PLATFORM )
00014 #define TEMPLATE_ENGINE_DLL_ENTITY
00015 #endif
00016 #else
00017 #ifdef WIN32_PLATFORM
00018 #define TEMPLATE_ENGINE_DLL_ENTITY __declspec( dllimport )
00019 #pragma comment( lib , "template_engine.lib" )
00020 #endif
00021
00022 #if defined( CYGWIN_PLATFORM ) || defined( MINGW_PLATFORM )
00023 #define TEMPLATE_ENGINE_DLL_ENTITY __declspec( dllimport )
00024 #endif
00025
00026 #if defined( NIX_PLATFORM )
00027 #define TEMPLATE_ENGINE_DLL_ENTITY
00028 #endif
00029 #endif
00030
00031 namespace nitro
00032 {
00033 class BinaryData;
00034
00047 class TEMPLATE_ENGINE_DLL_ENTITY TemplateEngine
00048 {
00049 public:
00050
00069 void LoadTemplateFromFile( const char * FilePath );
00070
00071 ALIAS_FUNCTION_1( LoadTemplateFromFile , aliasLoadTemplateFromFile , const char * );
00072
00091 void LoadTemplateFromFile( const std::string & FilePath );
00092
00115 void SetVariable( const char * VariableName , const char * VariableValue );
00116
00117 ALIAS_FUNCTION_2( SetVariable , aliasSetVariable , const char * , const char * );
00118
00141 void SetVariable( const std::string & VariableName , const std::string & VariableValue );
00142
00165 template< class Iter >void SetVariables( const Iter & IterBegin , const Iter & IterEnd );
00166
00185 const nitro::BinaryData & GetTemplate( void ) const;
00186
00197 virtual ~TemplateEngine( void );
00198
00199 private:
00200
00211 BinaryData TemplateData;
00212 };
00213
00214 template< class Iter >void TemplateEngine::SetVariables( const Iter & IterBegin , const Iter & IterEnd )
00215 {
00216 try
00217 {
00218 for( Iter i( IterBegin ) ; i != IterEnd ; i++ )
00219 {
00220 SetVariable( i->first , i->second );
00221 }
00222 }
00223 catch( nitro::exception e )
00224 {
00225 throw( nitro::exception( std::string( "TemplateEngine::SetVariables( const Iter & IterBegin , const Iter & IterEnd )::" ) + e.what() , e.code() ) );
00226 }
00227 catch( ... )
00228 {
00229 throw( nitro::exception( std::string( "TemplateEngine::SetVariables( const Iter & IterBegin , const Iter & IterEnd )::An error occured" ) , 1 ) );
00230 }
00231 }
00232
00233 }
00234
00235 #endif