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

integer Class Reference
[Inserters]

#include <pantheios/inserters/integer.hpp>

List of all members.


Detailed Description

Class for inserting integral types into Pantheios 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, cpp/example.cpp.highres/example.cpp.highres.cpp, cpp/example.cpp.integer/example.cpp.integer.cpp, and cpp/example.cpp.lowres/example.cpp.lowres.cpp.


Public Types

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

Constructor & Destructor Documentation

integer ( int  i,
int  widthAndFormat = 0 
) [explicit]

Construct from an int.

integer ( unsigned int  i,
int  widthAndFormat = 0 
) [explicit]

Construct from an unsigned int.

integer ( long  i,
int  widthAndFormat = 0 
) [explicit]

Construct from a long.

integer ( unsigned long  i,
int  widthAndFormat = 0 
) [explicit]

Construct from an unsigned long.


Member Function Documentation

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.


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

pantheios Library documentation © Matthew Wilson, 2006-2008 SourceForge.net Logo