pantheios::integer Class Reference
[Inserters]

#include <pantheios/inserters/integer.hpp>

List of all members.


Detailed Description

Class for inserting integral types into Panthieos logging statements.

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

Note:
Currently, Pantheios does not support the insertion of integral types in 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.
Examples:

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


Member Typedef Documentation

typedef integer pantheios::integer::class_type
 


Constructor & Destructor Documentation

pantheios::integer::integer int  i,
int  widthAndFormat = 0
[explicit]
 

Construct from an int.

pantheios::integer::integer unsigned int  i,
int  widthAndFormat = 0
[explicit]
 

Construct from an unsigned int.

pantheios::integer::integer long  i,
int  widthAndFormat = 0
[explicit]
 

Construct from a long.

pantheios::integer::integer unsigned long  i,
int  widthAndFormat = 0
[explicit]
 

Construct from an unsigned long.


Member Function Documentation

char const* pantheios::integer::c_str  )  const
 

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

char const* pantheios::integer::data  )  const
 

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

size_t pantheios::integer::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, 2006 SourceForge.net Logo