Functions for string convertions. More...
#include <utilities/string_utilities.h>
Static Public Member Functions | |
| static int | atoi (const std::string &StringValue, const std::size_t &Mode=nitro::DECIMAL) |
| template<class str_type > | |
| static double | atof (str_type StringValue) |
| static double | atof (const char *StringValue) |
| template<class str_type > | |
| static str_type | itoa (int Value, str_type &RetValue, const std::size_t &Mode=nitro::DECIMAL) |
| static void | itoa (int Value, char *OutputBuffer, const std::size_t &Mode=nitro::DECIMAL) |
| template<class str_type > | |
| static str_type | ftoa (double Value, str_type &RetValue) |
| static void | ftoa (double Value, char *OutputBuffer) |
Functions for string convertions.
Definition at line 1881 of file string_utilities.h.
| double nitro::Converters::atof | ( | str_type | StringValue | ) | [static] |
Function for convertation of string to float value.
| StringValue | - String representation of numeric value. |
| nitro::exception | Throws exception with error description. |
Definition at line 2074 of file string_utilities.h.
References nitro::exception::code(), and nitro::exception::what().
Referenced by atof(), and nitro::StringCollection::GetValueAsFloat().
{
try
{
return( ::atof( StringValue.c_str() ) );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "Converters::atof( str_type StringValue )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "Converters::atof( str_type StringValue )::An error occured" ) , 0 ) );
}
}

| double nitro::Converters::atof | ( | const char * | StringValue | ) | [static] |
Function for convertation of string to float value.
| StringValue | - String representation of numeric value. |
| nitro::exception | Throws exception with error description. |
Definition at line 1049 of file string_utilities.cpp.
References atof(), nitro::exception::code(), and nitro::exception::what().
{
try
{
return( ::atof( StringValue ) );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "Converters::atof( const char * StringValue )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "Converters::atof( const char * StringValue )::An error occured " ) , 1 ) );
}
}

| int nitro::Converters::atoi | ( | const std::string & | StringValue, | |
| const std::size_t & | Mode = nitro::DECIMAL | |||
| ) | [static] |
Function for convertation of string to integer value.
| StringValue | - String representation of numeric value. | |
| Mode | - Convertion mode. |
| nitro::exception | Throws exception with error description. |
Definition at line 1016 of file string_utilities.cpp.
References nitro::exception::code(), nitro::DECIMAL, nitro::HEXADECIMAL, nitro::OCTAL, and nitro::exception::what().
Referenced by nitro::MySQLDatabase::Connect(), nitro::UnTARAbstraction::ExtractFile(), nitro::UnTARAbstraction::GetCountOfFiles(), nitro::StringCollection::GetValueAsInteger(), and nitro::UnTARAbstraction::SetReadCursor().
{
try
{
int Result( 0 );
switch( Mode )
{
case( nitro::OCTAL ):
sscanf( StringValue.c_str() , "%o" , & Result );
break;
case( nitro::DECIMAL ):
sscanf( StringValue.c_str() , "%d" , & Result );
break;
case( nitro::HEXADECIMAL ):
sscanf( StringValue.c_str() , "%x" , & Result );
break;
}
return( Result );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "Converters::atoi( const std::string & StringValue , const std::size_t & Mode /* = nitro::Converters::DECIMAL */ )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "Converters::atoi( const std::string & StringValue , const std::size_t & Mode )::An error occured" ) , 0 ) );
}
}

| str_type nitro::Converters::ftoa | ( | double | Value, | |
| str_type & | RetValue | |||
| ) | [static] |
Function converts float value into string.
| Value | - Value to be converted. | |
| RetValue | - Buffer to output string. |
| nitro::exception | Throws exception with error description. |
Definition at line 2114 of file string_utilities.h.
References nitro::exception::code(), and nitro::exception::what().
{
try
{
char Buffer[ 128 ];
memset( Buffer , 0 , 128 );
ftoa( Value , Buffer );
RetValue = Buffer;
return( RetValue );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "Converters::ftoa( double Value , str_type & RetValue )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "Converters::ftoa( double Value , str_type & RetValue )::An error occured" ) , 0 ) );
}
}
}

| void nitro::Converters::ftoa | ( | double | Value, | |
| char * | OutputBuffer | |||
| ) | [static] |
Function converts float value into string.
| Value | - Value to be converted. | |
| OutputBuffer | - Buffer to output string. |
| nitro::exception | Throws exception with error description. |
Definition at line 1096 of file string_utilities.cpp.
References nitro::exception::code(), and nitro::exception::what().
{
try
{
OutputBuffer[ 0 ] = '\0';
sprintf( OutputBuffer , "%f" , Value );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "Converters::ftoa( double Value , char * OutputBuffer )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "Converters::ftoa( double Value , char * OutputBuffer )::An error occured " ) , 1 ) );
}
}

| str_type nitro::Converters::itoa | ( | int | Value, | |
| str_type & | RetValue, | |||
| const std::size_t & | Mode = nitro::DECIMAL | |||
| ) | [static] |
Function converts numeric value into string.
| Value | - Value to be converted. | |
| RetValue | - Buffer to output string. | |
| Mode | - Convertion mode. |
| nitro::exception | Throws exception with error description. |
Definition at line 2090 of file string_utilities.h.
References nitro::exception::code(), and nitro::exception::what().
Referenced by nitro::XMLTag::operator[]().
{
try
{
char Buffer[ 128 ];
memset( Buffer , 0 , 128 );
itoa( Value , Buffer , Mode );
RetValue = Buffer;
return( RetValue );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "Converters::itoa( int Value , str_type & RetValue , const std::size_t & Mode /* = nitro::DECIMAL */ )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "Converters::itoa( int Value , str_type & RetValue , const std::size_t & Mode /* = nitro::DECIMAL */ )::An error occured" ) , 0 ) );
}
}

| void nitro::Converters::itoa | ( | int | Value, | |
| char * | OutputBuffer, | |||
| const std::size_t & | Mode = nitro::DECIMAL | |||
| ) | [static] |
Function converts numeric value into string.
| Value | - Value to be converted. | |
| OutputBuffer | - Buffer to output string. | |
| Mode | - Convertion mode. |
| nitro::exception | Throws exception with error description. |
Definition at line 1065 of file string_utilities.cpp.
References nitro::exception::code(), nitro::DECIMAL, nitro::HEXADECIMAL, nitro::OCTAL, and nitro::exception::what().
{
try
{
OutputBuffer[ 0 ] = '\0';
switch( Mode )
{
case( nitro::OCTAL ):
sprintf( OutputBuffer , "%o" , Value );
break;
case( nitro::DECIMAL ):
sprintf( OutputBuffer , "%d" , Value );
break;
case( nitro::HEXADECIMAL ):
sprintf( OutputBuffer , "%x" , Value );
break;
}
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "Converters::itoa( int Value , char * OutputBuffer , const std::size_t & Mode /* = nitro::DECIMAL */ )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "Converters::itoa( int Value , char * OutputBuffer , const std::size_t & Mode /* = nitro::DECIMAL */ )::An error occured " ) , 1 ) );
}
}

1.6.1