#include <pantheios/inserters/blob.hpp>
This class formats a binary region into a string, thereby enabling it to be inserted into a logging statement. Consider the following statement:
int ar[2] = { 0x00112233, 0x44556677 }; char s[] = "abc"; std::string str("def"); pantheios::log(pantheios::notice, "s=", s, ", blob=", pantheios::blob(ar, sizeof(ar)), ", str=", str);
This will produce the output:
s=abc, blob=0011223344556677, str=def
The bytes can be grouped and these groups separated. Consider the following statement:
int ar[2] = { 0x00112233, 0x44556677 }; char s[] = "abc"; std::string str("def"); pantheios::log(pantheios::notice, "s=", s, ", blob=", pantheios::blob(ar, sizeof(ar), 2, "-"), ", str=", str);
This will produce the output:
s=abc, blob=2233-0011-6677-4455, str=def
The output can be split into lines. Consider the following statement:
int ar[2] = { 0x00112233, 0x44556677 }; char s[] = "abc"; std::string str("def"); pantheios::log(pantheios::notice, "s=", s, ", blob=", pantheios::blob(ar, sizeof(ar), 2, "-", 3, "\n\t"), ", str=", str);
This will produce the output:
s=abc, blob=2233-0011-6677 4455, str=def
Public Types | |
Member Types | |
typedef blob | class_type |
Public Member Functions | |
Construction | |
blob (void const *pv, size_t cb) | |
Constructs a blob inserter that will display as an unbroken sequence of hexadecimal digits. | |
blob (void const *pv, size_t cb, unsigned bytesPerGroup, char const *groupSeparator) | |
Constructs a blob inserter that will break the sequence of hexadecimal digits into groups of the specified number of bytes, separating groups with the specified separator. | |
blob (void const *pv, size_t cb, unsigned bytesPerGroup, char const *groupSeparator, int groupsPerLine, char const *lineSeparator="\n") | |
Constructs a blob inserter that will break the sequence of hexadecimal digits into groups of the specified number of bytes, separating groups with the specified separator, and break into lines of the specified number of groups, using the given line separator. | |
~blob () stlsoft_throw_0() | |
Releases any storage associated with the instance. | |
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. |
|
|
|
Constructs a blob inserter that will display as an unbroken sequence of hexadecimal digits.
|
|
Constructs a blob inserter that will break the sequence of hexadecimal digits into groups of the specified number of bytes, separating groups with the specified separator.
|
|
Constructs a blob inserter that will break the sequence of hexadecimal digits into groups of the specified number of bytes, separating groups with the specified separator, and break into lines of the specified number of groups, using the given line separator.
|
|
Releases any storage associated with the instance.
|
|
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 |
|