00001 #ifndef EDG_WORKLOAD_COMMON_UTILITIES_EDGSTRSTREAM_H
00002 #define EDG_WORKLOAD_COMMON_UTILITIES_EDGSTRSTREAM_H
00003
00004 #ifdef HAVE_CONFIG_H
00005 #include <config.h>
00006 #endif
00007
00008 #ifdef HAVE_STRINGSTREAM
00009 #include <sstream>
00010 #else
00011 #include <strstream>
00012 #include <string>
00013 #endif
00014
00015 namespace edg { namespace workload { namespace common { namespace utilities {
00016
00017 #ifdef HAVE_STRINGSTREAM
00018 typedef std::stringstream edgstrstream;
00019 typedef std::istringstream iedgstrstream;
00020 typedef std::ostringstream oedgstrstream;
00021 #else
00022
00023 class edgstrstream : public std::strstream {
00024 public:
00025 edgstrstream( int which = std::ios::out ) : std::strstream() {}
00026 edgstrstream( const std::string &s, int which = std::ios::in | std::ios::out ) : std::strstream() {}
00027 ~edgstrstream( void ) {}
00028
00029 std::string str( void ) const
00030 {
00031 std::string output( ((std::strstream*)this)->std::strstream::str() );
00032 ((std::strstream*)this)->freeze( 0 );
00033 return output;
00034 }
00035 void str( std::string &s )
00036 {
00037 s.assign( this->std::strstream::str() );
00038 ((std::strstream*)this)->freeze( 0 );
00039 }
00040 };
00041
00042 class iedgstrstream : public std::istrstream {
00043 public:
00044 iedgstrstream( const char *s, int which = std::ios::in ) : std::istrstream( s, which )
00045 {}
00046 iedgstrstream( const std::string &s, int which = std::ios::in ) :
00047 std::istrstream( s.c_str(), which ) {}
00048 ~iedgstrstream( void ) {}
00049
00050 std::string str( void )
00051 {
00052 std::string output( this->rdbuf()->str() );
00053 this->rdbuf()->freeze( 0 );
00054 return output;
00055 }
00056 void str( std::string &s )
00057 {
00058 s.assign( this->rdbuf()->str() );
00059 this->rdbuf()->freeze( 0 );
00060 }
00061 };
00062
00063 class oedgstrstream : public std::ostrstream {
00064 public:
00065 oedgstrstream( int which = std::ios::out ) : std::ostrstream() {}
00066 oedgstrstream( const std::string &s, int which = std::ios::out ) : std::ostrstream() {}
00067 ~oedgstrstream( void ) {}
00068
00069 std::string str( void )
00070 {
00071 std::string output( this->std::ostrstream::str() );
00072 this->freeze( 0 );
00073 return output;
00074 }
00075 void str( std::string &s )
00076 {
00077 s.assign( this->std::ostrstream::str() );
00078 this->freeze( 0 );
00079 }
00080 };
00081
00082 #endif
00083
00084 }}}}
00085
00086 #endif
00087
00088
00089
00090