Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

sword::LexicalFormatter Class Reference

Lexical Formatter. More...


Public Methods

 LexicalFormatter (const char *format)
 LexicalFormatter (const std::string &format)
const char * parseFormat (const char *format)
word width_int (int value) const
word width_word (word value) const
word width_int64 (int64 value) const
word width_word64 (word64 value) const
char * format_int (int value, char *buffer, word bufferLen) const
char * format_word (word value, char *buffer, word bufferLen) const
char * format_int64 (int64 value, char *buffer, word bufferLen) const
char * format_word64 (word64 value, char *buffer, word bufferLen) const


Detailed Description

Lexical Formatter.

Contains a ready-to-use formatter. The LexicalFormatter parses and store formatter information. The LexicalFormatterActor applies the formatting on a data of any primitive type.

Example: LexicalFormatter f("+10.5d"); int value = -52; char buffer[10]; char *p = LexicalFormatterActor<int>::format(f, value, buffer, 10); // now p points to a part of buffer which contains " -00052"

The actual format is described using a printf-like formatter string. Beware that there may be differences between the standard printf format string and this formatter specification (mostly because this one allows slightly more combinaisons).

The general format syntax is: [flags][width][.precision][type]

If the type is omitted, then the formatter will apply to all data types, using the flags, witdh and precision as much as possible each time.

Integer Formatters:

flags + For signed integers, print a plus sign if positive ( For signed integers, display negative values in parenthesis # Prefix the octal and hexadecimal reprenstation with '0' (octal) or '0x' (lower case hexadecimal) or '0X' (upper case hexadecimal) ' Separate digits in groups < Left align within field = Center within field > Right align within field width The minimum width of the field precision The minimum number of significant digits type d Signed integer, decimal representation u Unsigned integer, decimal representation x Lower-case hexadecimal representation X Upper-case hexadecimal representation o octal representation


Generated on Tue Dec 23 20:08:57 2003 for SWORD by doxygen1.3-rc2