Here are three new methods to test if a TString is in a binary, octal or decimal format.
All are based on the TString::IsHex() method.
Could you please add them to the trunk (diff files below are given against root 5.32.00)?
a set of itoa functions acting as enhanced sprintfs i.e. converting an integer to a string with respect to the base specified (2-36). This is an adaptation of versions 0.4 of jb.man.ac.uk/~slowe/cpp/itoa.html.
Usage
/// - Conversion to binary format (not possible with sprintf)
/// (the statements below produce the same output, namely "1111")
cout << TString::Itoa(15,2) << endl ;
cout << TString::Itoa(0xF,2) << endl ; /// 0x prefix to handle hex
cout << TString::Itoa(017,2) << endl ; /// 0 prefix to handle oct
/// - Conversion to any bases between 2 and 36 (not possible with sprintf)
cout << TString::Itoa(1000,36) << endl ;
a function to convert a string from one base to another (using the above itoa functions). Supported bases are 2-36. The input string must be unsigned. For the time being, only 32 bit data can be converted (the 64 bit upgrade is commented inside the code). The input string format is checked through the new function TString::IsInBaseN(Int_t base).
A small fix/enhancement for TString::BaseConvert(): hex prefix (0x), leading zeros and signs (+/-) are now taken into account.
The archive below replaces the previous one.