Открытые члены | Открытые статические члены

Класс nitro::Parsers

Класс для разбора строк. Подробнее...

#include <utilities/string_utilities.h>

Полный список членов класса

Открытые члены

template<class Iter1 , class Iter2 >
int FindSubSequence (const Iter1 &Begin, const Iter1 &End, const Iter2 &SequenceBegin, const Iter2 &SequenceEnd)

Открытые статические члены

template<class cont >
static void ExplodeString (const std::string &Str, cont &StringSegments, char ch)
template<class cont >
static void ExplodeString (const std::string &Str, cont &StringSegments, std::set< char > &Chars)
template<class cont >
static void StringToSet (std::string &Str, cont &c)
static void GetCommandLineParameter (const char *CommandLine, const char *ParameterName, const char *DefaultValue, char *ParameterValue)
template<class str_type >
static str_type GetCommandLineParameter (const str_type &CommandLine, const str_type &ParameterName, const str_type &DefaultValue)
template<class str_type >
static str_type GetCommandLineParameter (int argc, const char **argv, const str_type &ParameterName, const str_type &DefaultValue)
static void GetCommandLineParameter (int argc, const char **argv, const char *ParameterName, const char *DefaultValue, char *ParameterValue)
static bool CommandLineParameterExists (const char *CommandLine, const char *ParameterName)
template<class str_type >
static bool CommandLineParameterExists (const str_type &CommandLine, const str_type &ParameterName)
static bool CommandLineParameterExists (int argc, const char **argv, const char *ParameterName)
template<class str_type >
static bool CommandLineParameterExists (int argc, const char **argv, const str_type &ParameterName)
template<class str_type >
static bool BeginsWith (const str_type &String, const str_type &Prefix)
static bool BeginsWith (const char *String, const char *Prefix)
template<class str_type >
static bool EndsWith (const str_type &String, const str_type &Suffix)
static bool EndsWith (const char *String, const char *Suffix)
template<class Iter >
static std::string GetCommonPrefix (const Iter &IterBegin, const Iter &IterEnd)

Подробное описание

Класс для разбора строк.

Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1047


Методы

template<class str_type >
bool nitro::Parsers::BeginsWith ( const str_type &  String,
const str_type &  Prefix 
) [static]

Функция проверяет начинается ли строка String с подстроки Prefix.

Аргументы:
String - Проверяемая строка.
Prefix - Проверяемый префикс.
Возвращает:
true если строка String начинается с подстроки Prefix.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1742

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

Используется в CommandLineParameterExists() и GetCommandLineParameter().

        {
                try
                {
                        return( BeginsWith( String.c_str() , Prefix.c_str() ) );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::BeginsWith( const str_type & String , const str_type & Prefix )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::BeginsWith( const str_type & String , const str_type & Prefix )::An error occured while validating prefix " ) + Prefix + " for string " + String , 0 ) );
                }
        }

Граф вызовов:

bool nitro::Parsers::BeginsWith ( const char *  String,
const char *  Prefix 
) [static]

Функция проверяет начинается ли строка String с подстроки Prefix.

Аргументы:
String - Проверяемая строка.
Prefix - Проверяемый префикс.
Возвращает:
true если строка String начинается с подстроки Prefix.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.cpp строка 953

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                        if( strlen( String ) < strlen( Prefix ) )
                        {
                                return( false );
                        }

                        std::size_t                     i( 0 );

                        for( ; i < strlen( Prefix ) && Prefix[ i ] == String[ i ] ; i++ );

                        if( i == strlen( Prefix ) )
                        {
                                return( true );
                        }

                        return( false );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::BeginsWith( const char * String , const char * Prefix )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::BeginsWith( const char * String , const char * Prefix )::An error occured" ) , 1 ) );
                }
        }

Граф вызовов:

template<class str_type >
bool nitro::Parsers::CommandLineParameterExists ( const str_type &  CommandLine,
const str_type &  ParameterName 
) [static]

Функция для проверки налиция параметра в командной сттроке.

Аргументы:
CommandLine - Командная строка.
ParameterName - Название параметра командной строки.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1710

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                        GetCommandLineParameterExists( CommandLine.c_str() , ParameterName.c_str() );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::CommandLineParameterExists( const str_type & CommandLine , const str_type & ParameterName )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::CommandLineParameterExists( const str_type & CommandLine , const str_type & ParameterName )::An error occured" ) , 0 ) );
                }
        }
        

Граф вызовов:

bool nitro::Parsers::CommandLineParameterExists ( int  argc,
const char **  argv,
const char *  ParameterName 
) [static]

Функция получения значения парметра командной строки.

Аргументы:
argc - Количество токенов в командной строке.
argv - Токены командной строки.
ParameterName - Имя параметра.
Возвращает:
- Значение параметра.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.cpp строка 798

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                        std::string             tmpParamName( ParameterName );
                        for( std::size_t i( 0 ) ; i < ( std::size_t )argc ; i++ )
                        {
                                if( tmpParamName == argv[ i ] )
                                {
                                        return( true );
                                }
                        }

                        return( false );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::CommandLineParameterExists( int argc , const char * * argv , const str_type & ParameterName )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::CommandLineParameterExists( int argc , const char * * argv , const str_type & ParameterName )::An error occured" ) , 1 ) );
                }
        }

Граф вызовов:

template<class str_type >
bool nitro::Parsers::CommandLineParameterExists ( int  argc,
const char **  argv,
const str_type &  ParameterName 
) [static]

Функция получения значения парметра командной строки.

Аргументы:
argc - Количество токенов в командной строке.
argv - Токены командной строки.
ParameterName - Имя параметра.
Возвращает:
- Значение параметра.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1726

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                        GetCommandLineParameterExists( ParameterName.c_str() );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::CommandLineParameterExists( int argc , const char * * argv , const str_type & ParameterName )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::CommandLineParameterExists( int argc , const char * * argv , const str_type & ParameterName )::An error occured" ) , 0 ) );
                }
        }
        

Граф вызовов:

bool nitro::Parsers::CommandLineParameterExists ( const char *  CommandLine,
const char *  ParameterName 
) [static]

Функция для проверки налиция параметра в командной сттроке.

Аргументы:
CommandLine - Командная строка.
ParameterName - Название параметра командной строки.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.cpp строка 757

Перекрестные ссылки BeginsWith(), nitro::exception::code() и nitro::exception::what().

Используется в GetCommandLineParameter().

        {
                try
                {
                        for( std::size_t i( 0 ) ; i < strlen( CommandLine ) ; i++ )
                        {
                                // ищем параметр
                                if( Parsers::BeginsWith( CommandLine + i , ParameterName ) && 
                                        ( CommandLine[ i + strlen( ParameterName ) ] == ' ' || CommandLine[ i + strlen( ParameterName ) ] == '=' ||
                                        CommandLine[ i + strlen( ParameterName ) ] == '\0' ) )
                                {
                                        if( i == 0 )
                                        {
                                                // типа это самый первый параметр
                                                // нашли нужный нам параметр
                                                return( true );
                                        }
                                        else
                                        {
                                                // это не самый первый параметр
                                                // следовательно надо проверить есть ли перед ним пробел
                                                if( CommandLine[ i - 1 ] == ' ' )
                                                {
                                                        return( true );
                                                }
                                        }
                                }
                        }

                        return( false );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::CommandLineParameterExists( const char * CommandLine , const char * ParameterName )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::CommandLineParameterExists( const char * CommandLine , const char * ParameterName )::An error occured" ) , 1 ) );
                }
        }

Граф вызовов:

bool nitro::Parsers::EndsWith ( const char *  String,
const char *  Suffix 
) [static]

Функция проверяет кончается ли строка String на подстроку Prefix.

Аргументы:
String - Проверяемая строка.
Suffix -Проверяемый суффикс.
Возвращает:
true если строка String кончается на подстроку Prefix.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.cpp строка 983

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                        std::size_t             a( strlen( String ) );
                        std::size_t             b( strlen( Suffix ) );

                        if( a < b )
                        {
                                return( false );
                        }

                        size_t i( 0 );

                        for( ; i < b && Suffix[ i ] == String[ a - b + i ] ; i++ );

                        if( i == strlen( Suffix ) )
                        {
                                return( true );
                        }

                        return( false );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::EndsWith( const char * String , const char * Suffix )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::EndsWith( const char * String , const char * Suffix )::An error occured" ) , 1 ) );
                }
        }

Граф вызовов:

template<class str_type >
bool nitro::Parsers::EndsWith ( const str_type &  String,
const str_type &  Suffix 
) [static]

Функция проверяет кончается ли строка String на подстроку Prefix.

Аргументы:
String - Проверяемая строка.
Suffix - Проверяемый суффикс.
Возвращает:
true если строка String кончается на подстроку Prefix.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1758

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

Используется в nitro::MVC::LoadModules().

        {
                try
                {
                        return( EndsWith( String.c_str() , Suffix.c_str() ) );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::EndsWith( const str_type & String , const str_type & Suffix )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::EndsWith( const str_type & String , const str_type & Suffix )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

template<class cont >
void nitro::Parsers::ExplodeString ( const std::string &  Str,
cont &  StringSegments,
char  ch 
) [static]

Функция для разбивки строки на состовляющие по какому-либо разделителю.

Аргументы:
Str - Разбиваемая строка.
StringSegments - Сегменты строки после разбивки.
ch - Символ, по которому разбиваем строку.
Заметки:
Контейнер типа cont должен поддерживать операцию вставки в конец и иметь двунаправленные итераторы.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1573

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

Используется в nitro::INIFile::GetString(), nitro::INIFile::LoadINIFile() и nitro::INIFile::SetString().

        {
                try
                {
                        std::set< char >                Chars;
                        Chars.insert( ch );
                        ExplodeString( Str , StrSegments , Chars );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::ExplodeString( const std::string & Str , cont & StrSegments , char ch )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::ExplodeString( const std::string & Str , cont & StrSegments , char ch )::An error occured" ) , 0 ) );
                }
        }
        

Граф вызовов:

template<class cont >
void nitro::Parsers::ExplodeString ( const std::string &  Str,
cont &  StringSegments,
std::set< char > &  Chars 
) [static]

Функция для разбивки строки на состовляющие по какому-либо разделителю.

Аргументы:
Str - Разбиваемая строка.
StringSegments - Сегменты строки после разбивки.
Chars - Символы, по которым разбиваем строку.
Заметки:
Контейнер типа cont должен поддерживать операцию вставки в конец и иметь двунаправленные итераторы.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1591

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                        std::string                                     TmpStr( Str );

                        std::string::const_iterator     IterOld( Str.begin() );
                        std::string::const_iterator     IterNew;
                        for( std::set< char >::iterator i( Chars.begin() ) ; i != Chars.end() && IterNew != Str.end() ; i++ )
                        {
                                IterNew = std::find( IterOld , Str.end() , *i );
                        }

                        std::string                                     Segment;

                        while( IterNew != Str.end() )
                        {
                                Segment.resize( 0 );
                                std::copy( IterOld , IterNew , std::back_inserter< std::string >( Segment ) );
                                StringSegments.push_back( Segment );

                                IterOld = IterNew;
                                IterOld++;
                                for( std::set< char >::iterator i( Chars.begin() ) ; i != Chars.end() && IterNew != Str.end() ; i++ )
                                {
                                        IterNew = std::find( IterOld , Str.end() , *i );
                                }
                        }

                        Segment = "";
                        std::copy( IterOld , Str.end() , std::back_inserter< std::string >( Segment ) );
                        StringSegments.push_back( Segment );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::ExplodeString( const std::string & Str , cont & StrSegments , std::set< char > & Chars )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::ExplodeString( const std::string & Str , cont & StrSegments , std::set< char > & Chars )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

template<class Iter1 , class Iter2 >
int nitro::Parsers::FindSubSequence ( const Iter1 &  Begin,
const Iter1 &  End,
const Iter2 &  SequenceBegin,
const Iter2 &  SequenceEnd 
)

Функция поиска подпоследовательности в последовательности.

Аргументы:
Begin - Начало последовательности строк.
End - Конец последовательности строк.
SequenceBegin - Начало последовательности строк.
SequenceEnd -Конец последовательности строк.
Возвращает:
Курсор начала подпоследовательности, -1 если ничего не найдено.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1803

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                        for( Iter1 i( Begin ) ; i != End ; i++ )
                        {
                                if( * i == * SequenceBegin )
                                {
                                        Iter2 j( SequenceBegin );
                                        for( ; i != End && j != SequenceEnd && * i == * j ; j++ , i++ );

                                        if( j == SequenceEnd )
                                        {
                                                return( ( int )( i - Begin ) );
                                        }
                                }
                        }

                        return( -1 );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::FindSubSequence( const Iter1 & Begin , const Iter1 & End , const Iter2 & SequenceBegin , const Iter2 & SequenceEnd )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::FindSubSequence( const Iter1 & Begin , const Iter1 & End , const Iter2 & SequenceBegin , const Iter2 & SequenceEnd )::An error occured" ) , 1 ) );
                }
        }

Граф вызовов:

template<class str_type >
str_type nitro::Parsers::GetCommandLineParameter ( int  argc,
const char **  argv,
const str_type &  ParameterName,
const str_type &  DefaultValue 
) [static]

Функция получения значения парметра командной строки.

Аргументы:
argc - Количество токенов в командной строке.
argv - Токены командной строки.
ParameterName - Имя параметра.
DefaultValue - Значение по умолчанию.
Возвращает:
- Значение параметра.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1679

Перекрестные ссылки nitro::exception::code(), GetCommandLineParameter() и nitro::exception::what().

        {
                try
                {
                        std::size_t             a( 0 );
                        for( int i( 0 ) ; i < argc ; i++ )
                        {
                                a += strlen( argv[ i ] );
                        }
                        std::size_t             b( DefaultValue.size() );

                        char *                  ParameterValue( new char [ ( a > b ? a : b ) + 1 ] );

                        GetCommandLineParameter( argc , argv , ParameterName.c_str() , DefaultValue.c_str() , ParameterValue );
                        
                        std::string             Ret( ParameterValue );

                        delete [] ParameterValue;

                        return( Ret );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::GetCommandLineParameter( const str_type & CommandLine , const str_type & ParameterName )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::GetCommandLineParameter( const str_type & CommandLine , const str_type & ParameterName )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

template<class str_type >
str_type nitro::Parsers::GetCommandLineParameter ( const str_type &  CommandLine,
const str_type &  ParameterName,
const str_type &  DefaultValue 
) [static]

Функция получения значения парметра командной строки.

Аргументы:
CommandLine - Командная строка.
ParameterName - Название параметра командной строки.
DefaultValue - Значение по умолчанию.
Возвращает:
- Значение параметра.
Заметки:
Вид командной строки должен быть примерно следующим
param value - если в значении нет пробелов
param "value_part1 value_part2" - если в значении есть пробелы.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1653

Перекрестные ссылки nitro::exception::code(), GetCommandLineParameter() и nitro::exception::what().

        {
                try
                {
                        std::size_t             a( CommandLine.size() );
                        std::size_t             b( DefaultValue.size() );
                        char *                  ParameterValue( new char [ ( a > b ? a : b ) + 1 ] );

                        GetCommandLineParameter( CommandLine.c_str() , ParameterName.c_str() , DefaultValue.c_str() , ParameterValue );

                        std::string             Ret( ParameterValue );

                        delete [] ParameterValue;

                        return( Ret );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::GetCommandLineParameter( const str_type & CommandLine , const str_type & ParameterName , const str_type & DefaultValue )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::GetCommandLineParameter( const str_type & CommandLine , const str_type & ParameterName , const str_type & DefaultValue )::An error occured" ) , 0 ) );
                }
        }
        

Граф вызовов:

void nitro::Parsers::GetCommandLineParameter ( int  argc,
const char **  argv,
const char *  ParameterName,
const char *  DefaultValue,
char *  ParameterValue 
) [static]

Функция получения значения парметра командной строки.

Аргументы:
argc - Количество токенов в командной строке.
argv - Токены командной строки.
ParameterName - Имя параметра.
DefaultValue - Значение по умолчанию.
ParameterValue - Значение параметра.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.cpp строка 921

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                        std::string             tmpParamName( ParameterName );
                        for( std::size_t i( 0 ) ; i < ( std::size_t )( argc - 1 ) ; i++ )
                        {
                                if( tmpParamName == argv[ i ] )
                                {
                                        ParameterValue[ 0 ] = '\0';
                                        strcpy( ParameterValue , argv[ i + 1 ] );

                                        return;
                                }
                        }

                        ParameterValue[ 0 ] = '\0';
                        if( DefaultValue )
                        {
                                strcpy( ParameterValue , DefaultValue );
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::GetCommandLineParameter( int argc , const char * * argv , const char * ParameterName , const char * DefaultValue , const char * ParameterValue )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::GetCommandLineParameter( int argc , const char * * argv , const char * ParameterName , const char * DefaultValue , const char * ParameterValue )::An error occured" ) , 1 ) );
                }
        }

Граф вызовов:

void nitro::Parsers::GetCommandLineParameter ( const char *  CommandLine,
const char *  ParameterName,
const char *  DefaultValue,
char *  ParameterValue 
) [static]

Функция получения значения парметра командной строки.

Аргументы:
CommandLine - Командная строка.
ParameterName - Название параметра командной строки.
DefaultValue - Значение по умолчанию.
ParameterValue - Значение параметра.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.cpp строка 823

Перекрестные ссылки BeginsWith(), nitro::exception::code(), CommandLineParameterExists() и nitro::exception::what().

Используется в nitro::PGDatabase::Connect(), nitro::MySQLDatabase::Connect() и GetCommandLineParameter().

        {
                try
                {
                        ParameterValue[ 0 ] = '\0';

                        if( CommandLineParameterExists( CommandLine , ParameterName ) == false )
                        {
                                strcpy( ParameterValue , DefaultValue );
                                return;
                        }

                        bool                    SearchParameter( true );
                        bool                    SpaceSeparatedValue( false );
                        std::size_t             StartValueCursor( 0 );

                        for( std::size_t i( 0 ) ; i < strlen( CommandLine ) ; i++ )
                        {
                                if( SearchParameter )
                                {
                                        // ищем параметр
                                        if( Parsers::BeginsWith( CommandLine + i , ParameterName ) && ( CommandLine[ i + strlen( ParameterName ) ] == ' ' || CommandLine[ i + strlen( ParameterName ) ] == '=' ) )
                                        {
                                                // нашли нужный нам параметр
                                                // соотв. теперь можно искать где начинаются данные
                                                SearchParameter = false;
                                                i += strlen( ParameterName );
                                        }
                                }
                                else
                                {
                                        // ищем значение параметра
                                        if( ( CommandLine[ i - 1 ] == ' ' || CommandLine[ i - 1 ] == '=' ) && CommandLine[ i ] != ' ' && CommandLine[ i ] != '=' && StartValueCursor == 0 )
                                        {
                                                StartValueCursor = i;

                                                if( CommandLine[ i ] == '"' && SpaceSeparatedValue == false )
                                                {
                                                        // наткнулись на начало параметра
                                                        SpaceSeparatedValue = true;
                                                        StartValueCursor = i + 1;
                                                }

                                                continue;
                                        }
                                        if( StartValueCursor != 0 )
                                        {
                                                if( ( CommandLine[ i ] == '"' && SpaceSeparatedValue == true ) || 
                                                        ( CommandLine[ i ] == ' ' && SpaceSeparatedValue == false ) || 
                                                        ( strlen( CommandLine ) == i + 1 && SpaceSeparatedValue == false ) )
                                                {
                                                        // наткнулись на конец параметра
                                                        // т.е. конец определяем либо по " если была открывающая кавычка
                                                        // либо по пробелу, если открывающей кавычки не было
                                                        /*if( SpaceSeparatedValue )
                                                        {
                                                                strncpy( ParameterValue , CommandLine + StartValueCursor , i - StartValueCursor );
                                                                ParameterValue[ i - StartValueCursor ] = '\0';
                                                        }
                                                        else
                                                        {*/
                                                        if( strlen( CommandLine ) == i + 1 && SpaceSeparatedValue == false )
                                                        {
                                                                strncpy( ParameterValue , CommandLine + StartValueCursor , i - StartValueCursor + 1 );
                                                                ParameterValue[ i - StartValueCursor + 1 ] = '\0';
                                                        }
                                                        else
                                                        {
                                                                strncpy( ParameterValue , CommandLine + StartValueCursor , i - StartValueCursor );
                                                                ParameterValue[ i - StartValueCursor ] = '\0';
                                                        }

                                                        return;
                                                }
                                        }
                                }
                        }
                        if( SpaceSeparatedValue )
                        {
                                throw( nitro::exception( "Illegal sintax" , 0 ) );
                        }
                        else
                        {
                                std::size_t             StrLen( strlen( CommandLine ) );
                                strncpy( ParameterValue , CommandLine + StartValueCursor , StrLen - StartValueCursor + 1 );
                                ParameterValue[ StrLen - StartValueCursor + 1 ] = '\0';
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::GetCommandLineParameter( const char * CommandLine , const char * ParameterName , const char * DefaultValue , char * ParameterValue )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::GetCommandLineParameter( const char * CommandLine , const char * ParameterName , const char * DefaultValue , char * ParameterValue )::An error occured" ) , 1 ) );
                }
        }

Граф вызовов:

template<class Iter >
std::string nitro::Parsers::GetCommonPrefix ( const Iter &  IterBegin,
const Iter &  IterEnd 
) [static]

Функция получения общего префикса набора строк.

Аргументы:
IterBegin - Начало последовательности строк.
IterEnd -Конец последовательности строк.
Возвращает:
Общий префикс.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1774

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                        std::string                                     Prefix( * IterBegin );

                        for( Iter i( IterBegin ) ; i != IterEnd ; i++ )
                        {
                                for( std::size_t j( 0 ) ; j < i->size() && j < Prefix.size() ; j++ )
                                {
                                        if( Prefix[ j ] != ( * i )[ j ] )
                                        {
                                                Prefix.resize( j );
                                        }
                                }
                        }

                        return( Prefix );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::GetCommonPrefix( const Iter & IterBegin , const Iter & IterEnd )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::GetCommonPrefix( const Iter & IterBegin , const Iter & IterEnd )::An error occured" ) , 1 ) );
                }
        }

Граф вызовов:

template<class cont >
void nitro::Parsers::StringToSet ( std::string &  Str,
cont &  c 
) [static]

Функция преобразовывает строку в набор символов.

Аргументы:
Str - Преобразовываемая строка.
c - Множество символов.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле string_utilities.h строка 1634

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                        for( std::size_t i( 0 ) ; i < Str.size() ; i++ )
                        {
                                c.insert( Str[ i ] );
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "Parsers::StringToSet( std::string & Str , cont & c )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "Parsers::StringToSet( std::string & Str , cont & c )::An error occured" ) , 0 ) );
                }
        }
        

Граф вызовов:


Объявления и описания членов классов находятся в файлах:

Generated by  doxygen 1.6.1