diff --git a/include/osg/io_utils b/include/osg/io_utils index 6f6d9aaf0..95768c90c 100644 --- a/include/osg/io_utils +++ b/include/osg/io_utils @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -35,6 +36,43 @@ namespace osg { +/** Convinience class for building std::string using stringstream. + * Usage: + * MakeString str; + * std::string s = str<<"Mix strings with numbers "<<0" ; + * std::string s2 = str.clear()<<"and other classes such as ("< + MakeString& operator << (const T& t) + { + sstream << t; + return *this; + } + + MakeString& operator << (std::ostream& (*fun)(std::ostream&)) + { + sstream << fun; + return *this; + } + + inline MakeString& clear() { sstream.str("") ; return *this; } + + inline operator std::string () const { return sstream.str(); } + + inline std::string str() const { return sstream.str(); } + inline const char* c_str() const { return sstream.str().c_str(); } +}; + + + +inline std::ostream& operator << (std::ostream& output, const MakeString& str) { output << str.str(); return output; } + ////////////////////////////////////////////////////////////////////////// // Vec2f streaming operators inline std::ostream& operator << (std::ostream& output, const Vec2f& vec)