Public Member Functions | Private Attributes

nitro::CommandRedirections Class Reference

#include <utilities/mvc/mvc_interfaces.h>

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

List of all members.

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

Detailed Description

Command redirection table.

Author:
Dodonov A.A.

Definition at line 89 of file mvc_interfaces.h.


Constructor & Destructor Documentation

virtual nitro::CommandRedirections::~CommandRedirections (  )  [inline, virtual]

Destructor.

Note:
Virtual destructor.
Author:
Dodonov A.A.

Definition at line 154 of file mvc_interfaces.h.

{}


Member Function Documentation

void nitro::CommandRedirections::AddRedirectionRule ( const char *  CommandOriginal,
const char *  CommandRedirected 
) [virtual]

Function creates redirection rule.

Parameters:
CommandOriginal - Original command name.
CommandRedirected - Command name after redirection.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

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

Here is the call graph for this function:

const char * nitro::CommandRedirections::RedirectCommand ( const char *  CommandOriginal  )  [virtual]

Function applyes redirection rule.

Parameters:
CommandOriginal - Original rule.
Returns:
Rule after redirection.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

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

Here is the call graph for this function:


Member Data Documentation

std::map< std::string , std::string > nitro::CommandRedirections::Rules [private]

Redirection rules.

Author:
Dodonov A.A.

Definition at line 168 of file mvc_interfaces.h.

Referenced by AddRedirectionRule(), and RedirectCommand().


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

Generated by  doxygen 1.6.1