This library is written for converting numeric formats into string and for doing the opposite. The library is of a static type, everything is included in a single header file and is very easy to include in any project - the only requirements are the inclusion of the stl libraries. Every function is templated to work with every kind of numeric formats.
Some examples:
string a=CStringConverter::NumToString( num, std::fixed, 10 );
Converts a number expressed in fixed form with a precision of 10 digits.
float a=CStringConverter::NumToString( numstring, std::fixed, 10 );
Similar to the above with different type.
Quick conversion functions:
double a=CStringConveter::StringToDouble( numstring );
float a=CStringConveter::StringToDouble( numstring );
string a =CStringConverter::DecToBinStr( n );
Converts a decimal number into a binary string.
string a =CStringConverter::DecToHexStr( n );
Converts a decimal number into an hexadecimal string.
int a =CStringConverter::HexToDecStr( numstr );
Reverse of the above.
string a = CStringConverter::DateToStr();
Converts the current date into a string.
RGB rgb=CStringConverter::HexStrToRGB( numstring );
Converts an hexadecimal color value into an RGB triple, the RGB data structure is included in the library.
string a=CStringConverter::RgbToHex( r,g,b );
Reverse of the above function.
int a=CStringConverter::OctToDec( num );
Converts an octal number into decimal.
int a=CStringConverter::DecToOct( num );
Reverse of the above function.
The library has been updated to include different classes most of them are documented well enough to put inside any existing code without much problems the classes are : string validator class , which tests if s given string is a numeric format , included there is also a function for computing the similarity of two strings. string formatter class which eliminates whites, trailing spaces and other string normalizing functions split path class, given a full path , separates directories, filenames and extensions I have also include the message error handling class which was missing in the previous version
Well commented and readable
The only good point I could find was the documentation... (Though this could have been even better with doxygen :-) )
The code is far from being usable with an undefined CMessage class which is used for error handling in the library but has neither a declaration nor a definition...
Also it uses the MultiByteToWideChar function which would require windows.h to be included... which is not included...
There are some modern C++ style issues as well... (<time.h> instead of the correct <ctime>, typedefs for structs which are unneccessary in C++, a class which is against all principles of OOP... CStringConverter should rather have been a namespace)
Questions & Comments