#include <utilities/mvc/mvc_interfaces.h>
Public Member Functions | |
virtual void | AddRedirectionRule (const char *CommandOriginal, const char *CommandRedirected) |
virtual const char * | RedirectCommand (const char *CommandOriginal) |
virtual | ~CommandRedirections () |
Private Attributes | |
std::map< std::string, std::string > | Rules |
Command redirection table.
Definition at line 89 of file mvc_interfaces.h.
virtual nitro::CommandRedirections::~CommandRedirections | ( | ) | [inline, virtual] |
void nitro::CommandRedirections::AddRedirectionRule | ( | const char * | CommandOriginal, | |
const char * | CommandRedirected | |||
) | [virtual] |
Function creates redirection rule.
CommandOriginal | - Original command name. | |
CommandRedirected | - Command name after redirection. |
nitro::exception | - An exception of this type is thrown if the error occured. |
Definition at line 17 of file mvc_interfaces.cpp.
References nitro::exception::code(), Rules, and nitro::exception::what().
{ try { std::map< std::string , std::string >::iterator i( Rules.find( std::string( CommandOriginal ) ) ); if( i == Rules.end() ) { Rules.insert( std::pair< std::string , std::string >( std::string( CommandOriginal ) , std::string( CommandRedirected ) ) ); } else { throw( nitro::exception( std::string( "Redirection for rule \"" ) + CommandOriginal + "\" was already defined : " + i->first + " => " + i->second , 1 ) ); } } catch( nitro::exception e ) { throw( nitro::exception( std::string( "CommandRedirections::AddRedirectionRule( const char * CommandOriginal , const char * CommandRedirected )::" )+ e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( "CommandRedirections::AddRedirectionRule( const char * CommandOriginal , const char * CommandRedirected )::An error occured" , 1 ) ); } }
const char * nitro::CommandRedirections::RedirectCommand | ( | const char * | CommandOriginal | ) | [virtual] |
Function applyes redirection rule.
CommandOriginal | - Original rule. |
nitro::exception | - An exception of this type is thrown if the error occured. |
Definition at line 42 of file mvc_interfaces.cpp.
References nitro::exception::code(), Rules, and nitro::exception::what().
{ try { std::map< std::string , std::string >::iterator i( Rules.find( std::string( CommandOriginal ) ) ); if( i == Rules.end() ) { return( i->second.c_str() ); } else { return( CommandOriginal ); } } catch( nitro::exception e ) { throw( nitro::exception( std::string( "CommandRedirections::RedirectCommand( const char * CommandOriginal )::" )+ e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( "CommandRedirections::RedirectCommand( const char * CommandOriginal )::An error occured" , 1 ) ); } return( NULL ); }
std::map< std::string , std::string > nitro::CommandRedirections::Rules [private] |
Redirection rules.
Definition at line 168 of file mvc_interfaces.h.
Referenced by AddRedirectionRule(), and RedirectCommand().