Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

blob Class Reference
[Inserters]

#include <pantheios/inserters/blob.hpp>

List of all members.


Detailed Description

Class for inserting binary regions types into Pantheios diagnostic logging statements.

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
Examples:

cpp/inserters/example.cpp.inserter.blob/example.cpp.inserter.blob.cpp.


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, pan_char_t 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, pan_char_t const *groupSeparator, int groupsPerLine, pan_char_t const *lineSeparator=PANTHEIOS_LITERAL_STRING("\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 () throw ()
 Releases any storage associated with the instance.
Accessors
pan_char_t const * data () const
 A possibly non-nul-terminated non-null pointer to the c-style string representation of the integer.
pan_char_t 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.

Constructor & Destructor Documentation

blob ( void const *  pv,
size_t  cb 
)

Constructs a blob inserter that will display as an unbroken sequence of hexadecimal digits.

Parameters:
pv Pointer to the first byte in the sequence to be displayed.
cb Number of bytes in the sequence.

blob ( void const *  pv,
size_t  cb,
unsigned  bytesPerGroup,
pan_char_t 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.

Parameters:
pv Pointer to the first byte in the sequence to be displayed.
cb Number of bytes in the sequence.
bytesPerGroup Number of bytes per group. Must be a power of 2.
groupSeparator The string used to separate the byte groups.

blob ( void const *  pv,
size_t  cb,
unsigned  bytesPerGroup,
pan_char_t const *  groupSeparator,
int  groupsPerLine,
pan_char_t const *  lineSeparator = PANTHEIOS_LITERAL_STRING("\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.

Parameters:
pv Pointer to the first byte in the sequence to be displayed.
cb Number of bytes in the sequence.
bytesPerGroup Number of bytes per group. Must be a power of 2.
groupSeparator The string used to separate the byte groups.
groupsPerLine Number of groups per line.
lineSeparator The string used to separate the lines.

~blob (  )  throw ()

Releases any storage associated with the instance.


Member Function Documentation

pan_char_t const* data (  )  const

A possibly non-nul-terminated non-null pointer to the c-style string representation of the integer.

pan_char_t 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.


The documentation for this class was generated from the following file:

pantheios Library documentation Matthew Wilson & Synesis Software, 2006-2011 SourceForge.net Logo