#include <pantheios/inserters/integer.hpp>
This class converts an integer into a string, thereby enabling it to be inserted into a logging statement. Consider the following statement
int i = 123; char s[] = "abc"; std::string str("def"); pantheios::log(pantheios::notice, "s=", s, ", i=", pantheios::integer(i), ", str=", str);
This will produce the output:
s=abc, i=123, str=def
The constructor takes a second, defaulted (to 0), parameter, which allows a width (up to a maximum of 255) and a format to be specified. The low 8 bits of this parameter are interpreted as an unsigned integer specifying the width. The remaining bits are treated as bit flags that control the
cpp/example_cpp_custom_type_1/example_cpp_custom_type_1.cpp, and cpp/example_cpp_integer/example_cpp_integer.cpp.
Member Types | |
typedef integer | class_type |
Public Member Functions | |
Construction | |
integer (int i, int widthAndFormat=0) | |
Construct from an int. | |
integer (unsigned int i, int widthAndFormat=0) | |
Construct from an unsigned int. | |
integer (long i, int widthAndFormat=0) | |
Construct from a long. | |
integer (unsigned long i, int widthAndFormat=0) | |
Construct from an unsigned long. | |
Accessors | |
char const * | data () const |
A possibly non-nul-terminated non-null pointer to the c-style string representation of the integer. | |
char const * | c_str () const |
A nul-terminated non-null pointer to the c-style string representation of the integer. | |
size_t | length () const |
The length of the c-style string representation of the integer. | |
Classes | |
union | u |
|
|
|
Construct from an int.
|
|
Construct from an unsigned int.
|
|
Construct from a long.
|
|
Construct from an unsigned long.
|
|
A nul-terminated non-null pointer to the c-style string representation of the integer.
|
|
A possibly non-nul-terminated non-null pointer to the c-style string representation of the integer.
|
|
The length of the c-style string representation of the integer.
|
|
|
pantheios Library documentation © Matthew Wilson, 2006 |
|