ug4
Stringify Class Reference

#include <stringify.h>

Public Member Functions

 operator std::string () const
 
template<typename T >
Stringifyoperator<< (T t)
 
std::string str () const
 
 Stringify ()
 

Public Attributes

std::stringstream ss
 

Detailed Description

use this class like this std::string myTmpString = Stringify() << "My_" << iInteger << "_SuperString" << ".txt"; also in functions CallStdStringFunction(Stringify() << "My_" << iInteger << "_SuperString" << ".txt"); Note that this can NOT work for const char * functions, since you need an temporary object which is valid for the whol call of the function. Then you'd do std::string myTmpString = Stringify() << "My_" << iInteger << "_SuperString" << ".txt"; CallConstCharFunction(myTmpString.c_str());

Note
be sure that the object c_str is referring to is valid. According to the C++ standard, "Temporary objects are destroyed as the last step in evaluating the full-expression (1.9) that (lexically) contains the point where they were created. [12.2/3]" so you can also do CallConstCharFunction((Stringify() << "bla").c_str()); however, const char *str = (Stringify() << "bla").c_str()); will NOT work.

You can use mkstr as a wrapper around Stringify like this:

std::string s = mkstr("Hello " << 5 << " is a number");
parameterString s
#define mkstr(s)
Comfortable (but not necessarily efficient) string building.
Definition: stringify.h:100
See also
mkstr

Constructor & Destructor Documentation

◆ Stringify()

Stringify::Stringify ( )
inline

Member Function Documentation

◆ operator std::string()

Stringify::operator std::string ( ) const
inline

References str().

◆ operator<<()

template<typename T >
Stringify& Stringify::operator<< ( t)
inline

References ss.

◆ str()

std::string Stringify::str ( ) const
inline

References ss.

Referenced by operator std::string().

Member Data Documentation

◆ ss

std::stringstream Stringify::ss

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


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