Public Member Functions | Private Attributes

formatter Class Reference

std::ostringstream wrapper. More...

#include <formatter.hpp>

Collaboration diagram for formatter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 formatter ()
template<typename T >
formatteroperator<< (const T &o)
std::string str ()

Private Attributes

std::ostringstream stream_

Detailed Description

std::ostringstream wrapper.

ostringstream's operator<< doesn't return a ostringstream&. It returns an ostream& instead. This is unfortunate, because it means that you can't do something like this: (ostringstream() << n).str() to convert an integer to a string, all in one line instead you have to use this far more tedious approach: ostringstream s; s << n; s.str(); This class corrects this shortcoming, allowing something like this: string result = (formatter() << "blah " << n << x << " blah").str();

Definition at line 33 of file formatter.hpp.


Constructor & Destructor Documentation

formatter::formatter (  )  [inline]

Definition at line 36 of file formatter.hpp.


Member Function Documentation

template<typename T >
formatter& formatter::operator<< ( const T &  o  )  [inline]

Definition at line 42 of file formatter.hpp.

References stream_.

std::string formatter::str (  )  [inline]

Definition at line 47 of file formatter.hpp.

References stream_.


Member Data Documentation

std::ostringstream formatter::stream_ [private]

Definition at line 52 of file formatter.hpp.

Referenced by operator<<(), and str().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:13:48 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs