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

w2m Class Reference
[Inserters]

#include <pantheios/inserters/w2m.hpp>

List of all members.


Detailed Description

Class for inserting wide strings into Pantheios diagnostic logging statements.

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

  wchar_t     ws  = L"abc";
  char        s[] = "abc";
  std::string str("def");

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

This will produce the output:

    s=abc, c=abc, str=def

Examples:

cpp/inserters/example.cpp.inserter.w2m/example.cpp.inserter.w2m.cpp, and cpp/misc/example.cpp.misc.custom_type_1/example.cpp.misc.custom_type_1.cpp.


Public Types

typedef w2m class_type
 This type.

Public Member Functions

 w2m (wchar_t const *s)
 Construct from a c-style string.
 w2m (wchar_t const *s, size_t len)
 Construct from a pointer to a string and a given length.
template<typename WS>
 w2m (WS const &ws)
 Construct from a widestring of unknown type.
 ~w2m () throw ()
 Releases any resources allocated for the conversion.
char const * data () const
 A possibly non-nul-terminated non-null pointer to the c-style string representation of the w2m.
char const * c_str () const
 A nul-terminated non-null pointer to the c-style string representation of the w2m.
size_t length () const
 The length of the c-style string representation of the w2m.

Member Typedef Documentation

typedef w2m class_type

This type.


Constructor & Destructor Documentation

w2m ( wchar_t const *  s  )  [explicit]

Construct from a c-style string.

w2m ( wchar_t const *  s,
size_t  len 
)

Construct from a pointer to a string and a given length.

w2m ( WS const &  ws  )  [inline, explicit]

Construct from a widestring of unknown type.

Warning:
This method must only be used "inline", i.e. in a log statement. If you create a separate instance of w2m using this constructor and attempt to access its converted value - either directly, via c_str()/data(), or indirectly via inserting into a log statement - the program will have undefined behaviour.

~w2m (  )  throw ()

Releases any resources allocated for the conversion.


Member Function Documentation

char const* data (  )  const

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

char const* c_str (  )  const

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

size_t length (  )  const

The length of the c-style string representation of the w2m.


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

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