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

Inserters
[Pantheios Application Layer API]


Detailed Description

String inserters for fundamental types.

By using string access shims, strings, or those things that are expressible ( as String types, or

These classes are used to wrap instances of fundamental types in order to pass them into the Pantheios diagnostic logging functions, as in:

  short         s     = 123;
  int           i     = 456;
  long          l     = 789;
  float         f     = static_cast<float>(0.123);
  double        d     = 0.456;
  long double   ld    = 0.789;
  void*         p    = reinterpret_cast<void*>(0x01230123);
  unsigned char ar[]  = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };

  pantheios::log_INFORMATIONAL( "This string contains: "
                              , "some integers (", pantheios::integer(s), ", ", pantheios::integer(i, 4 | pantheios::fmt::zeroPadded), ", ", pantheios::integer(l), "); "
                              , "some real numbers (", pantheios::real(f), ", ", pantheios::real(d), ", ", pantheios::real(ld), "); "
                              , "a pointer (", pantheios::pointer(p, pantheios::fmt::fullHex), "); "
                              , "and a blob (", pantheios::blob(&ar[0], sizeof(ar), ")"
                              );

which will produce the following output:

    This string contains: some integers (123, 0456, 789); some real numbers (0.123, 0.456, 0.789); a pointer (0x1230123); and a blob (0011223344)

Within the scope of a given function, it can be appropriate to use a using directive to reduce the clutter, as in:

  using namespace pantheios;

  short         s     = 123;
  int           i     = 456;
  long          l     = 789;
  float         f     = static_cast<float>(0.123);
  double        d     = 0.456;
  long double   ld    = 0.789;
  void*         p    = reinterpret_cast<void*>(0x01230123);
  unsigned char ar[]  = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };

  log_INFORMATIONAL( "This string contains: "
                   , "some integers (", integer(s), ", ", integer(i, 4 | fmt::zeroPadded), ", ", integer(l), "); "
                   , "some real numbers (", real(f), ", ", real(d), ", ", real(ld), "); "
                   , "and a pointer (", pointer(p, fmt::fullHex), "); "
                   , "and a blob (", blob(&ar[0], sizeof(ar), ")"
                   );

or using declarations, as in:

  using pantheios::log_INFORMATIONAL;
  using pantheios::blob;
  using pantheios::integer;
  using pantheios::real;
  using pantheios::pointer;
  using pantheios::fmt;

  short         s     = 123;
  int           i     = 456;
  long          l     = 789;
  float         f     = static_cast<float>(0.123);
  double        d     = 0.456;
  long double   ld    = 0.789;
  void*         p     = reinterpret_cast<void*>(0x01230123);
  unsigned char ar[]  = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };

  log_INFORMATIONAL( "This string contains: "
                   , "some integers (", integer(s), ", ", integer(i, 4 | fmt::zeroPadded), ", ", integer(l), "); "
                   , "some real numbers (", real(f), ", ", real(d), ", ", real(ld), "); "
                   , "and a pointer (", pointer(p, fmt::fullHex), "); "
                   , "and a blob (", blob(&ar[0], sizeof(ar), ")"
                   );


Classes

class  args
 Class for inserting argc+argv arguments into Pantheios diagnostic logging statements. More...
class  b64
 Class for inserting binary regions types into Pantheios diagnostic logging statements. More...
class  blob
 Class for inserting binary regions types into Pantheios diagnostic logging statements. More...
class  boolean
 Class for inserting Boolean types into Pantheios diagnostic logging statements. More...
class  character
 Class for inserting characters into Pantheios diagnostic logging statements. More...
struct  fmt
 Format constants used by Pantheios inserter classes. More...
class  hex_ptr
 [DEPRECATED] Class for inserting pointers into Pantheios diagnostic logging statements. More...
class  integer
 Class for inserting integral types into Pantheios diagnostic logging statements. More...
class  pointer
 Class for inserting pointers into Pantheios diagnostic logging statements. More...
class  real
 Class for inserting floating-point types into Pantheios diagnostic logging statements. More...
class  w2m
 Class for inserting wide strings into Pantheios diagnostic logging statements. More...

Defines

#define PANTHEIOS_LPAD(var, minWidth)   ( ::pantheios::pad(var, minWidth)), (var)
 Inserts a variable with a minimum width, padding to the left with spaces.
#define PANTHEIOS_RPAD(var, minWidth)   (var), ( ::pantheios::pad(var, minWidth))
 Inserts a variable with a minimum width, padding to the right with spaces.

Typedefs

typedef character ch
 Class for inserting characters into Pantheios diagnostic logging statements.
typedef stlsoft::string_view m2w
 Class for inserting wide strings into Pantheios diagnostic logging statements.

Variables

struct hostId_t const * hostId
 Global instance that may be used to insert a host identity into a log statement.
struct processId_t const * processId
 Global instance that may be used to insert a process identity into a log statement.
struct threadId_t const * threadId
 Global instance that may be used to insert a thread identity into a log statement.


Define Documentation

#define PANTHEIOS_LPAD ( var,
minWidth   )     ( ::pantheios::pad(var, minWidth)), (var)

Inserts a variable with a minimum width, padding to the left with spaces.

Parameters:
var The variable to be inserted
minWidth The minimum width of the inserted variable
Examples:
cpp/format/example.cpp.format.pad/example.cpp.format.pad.cpp.

#define PANTHEIOS_RPAD ( var,
minWidth   )     (var), ( ::pantheios::pad(var, minWidth))

Inserts a variable with a minimum width, padding to the right with spaces.

Parameters:
var The variable to be inserted
minWidth The minimum width of the inserted variable
Examples:
cpp/format/example.cpp.format.pad/example.cpp.format.pad.cpp.


Typedef Documentation

typedef character ch

Class for inserting characters into Pantheios diagnostic logging statements.

This class converts a character variable into a string, thereby enabling it to be inserted into a logging statement. Consider the following statement:

  char        c   = '#';
  char        s[] = "abc";
  std::string str("def");

  pantheios::log(pantheios::notice, "s=", s, ", c=", pantheios::character(c), ", str=", str);

This will produce the output:

    s=abc, c=#, str=def

Note:
Currently, Pantheios does not support the insertion of character types in diagnostic logging statements, due to the various ambiguities inherent in the C++ language. (See chapters 14, 15, 19, 24 of Imperfect C++ for discussions of these issues.) It is possible that a future version of the library will be able to incorporate them directly, so long as that does not sacrifice Pantheios's central claim of not paying for what you don't use.

typedef stlsoft:: string_view m2w

Class for inserting wide strings into Pantheios diagnostic logging statements.

This class converts a m2w variable into a string, thereby enabling it to be inserted into a logging statement. Consider the following statement:

  char          s[] = "abc";
  wchar_t       ws  = L"def";
  std::wstring  wstr(L"ghi");

  pantheios::log(pantheios::notice, L"s=", pantheios::m2w(s), L", ws=", ws, L", wstr=", wstr);

This will produce the output:

    s=abc, ws=def, str=ghi

Examples:
cpp/inserters/example.cpp.inserter.m2w/example.cpp.inserter.m2w.cpp.


Variable Documentation

struct hostId_t const* hostId

Global instance that may be used to insert a host identity into a log statement.

This will produce output such as the following:

   host id=my-system
Examples:
cpp/inserters/example.cpp.inserter.hostid/example.cpp.inserter.hostid.cpp.

struct processId_t const* processId

Global instance that may be used to insert a process identity into a log statement.

This will produce output such as the following:

   process id=2436
Examples:
cpp/inserters/example.cpp.inserter.processid/example.cpp.inserter.processid.cpp, and cpp/misc/example.cpp.misc.extended_severity_information/example.cpp.misc.extended_severity_information.cpp.

struct threadId_t const* threadId

Global instance that may be used to insert a thread identity into a log statement.

This will produce output such as the following:

   thread id=1310
Examples:
cpp/inserters/example.cpp.inserter.threadid/example.cpp.inserter.threadid.cpp.


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