boost::locale::basic_format< CharType > Class Template Reference
[Format]

a printf like class that allows type-safe and locale aware message formatting More...

#include <boost/locale/format.hpp>

List of all members.

Public Types

typedef CharType char_type
typedef std::basic_string
< CharType > 
string_type
typedef std::basic_ostream
< CharType > 
stream_type
 output stream type for this type of character

Public Member Functions

 basic_format (string_type format_string)
 basic_format (message const &trans)
template<typename Formattible>
basic_formatoperator% (Formattible const &object)
string_type str (std::locale const &loc=std::locale()) const
void write (stream_type &out) const


Detailed Description

template<typename CharType>
class boost::locale::basic_format< CharType >

a printf like class that allows type-safe and locale aware message formatting

This class creates formatted message similarly to printf or boost::format and receives formatted entries via operator %.

For example

  cout << format("Hello {1}, you are {2} years old") % name % age << endl;

Formatting is enclosed between curl brackets { } and defined by comma separated list of flags in format key[=value] value may also be text included between single quotes ' that is used for special purposes where inclusion of non-ASCII text is allowed

For example:

   cout << format("The hight of water at {1,time} is {2,num=fixed,precision=3}") % time % height;

The special key -- number without value defines a position of input parameter. List of keys:


Member Typedef Documentation

template<typename CharType>
typedef CharType boost::locale::basic_format< CharType >::char_type

Underlying character type

template<typename CharType>
typedef std::basic_string<CharType> boost::locale::basic_format< CharType >::string_type

string type for this type of character


Constructor & Destructor Documentation

template<typename CharType>
boost::locale::basic_format< CharType >::basic_format ( string_type  format_string  )  [inline]

Create a format class for format_string

template<typename CharType>
boost::locale::basic_format< CharType >::basic_format ( message const &  trans  )  [inline]

Create a format class using message trans. The message if translated first according to the rules of target locale and then interpreted as format string


Member Function Documentation

template<typename CharType>
template<typename Formattible>
basic_format& boost::locale::basic_format< CharType >::operator% ( Formattible const &  object  )  [inline]

Add new parameter to format list

template<typename CharType>
string_type boost::locale::basic_format< CharType >::str ( std::locale const &  loc = std::locale()  )  const [inline]

Format a string using a locale loc

template<typename CharType>
void boost::locale::basic_format< CharType >::write ( stream_type out  )  const [inline]

write a formatted string to output stream out using out's locale


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

Generated on Thu Mar 18 23:02:03 2010 for Boost.Locale by doxygen 1.5.6