Skip to content
Snippets Groups Projects
Commit dc6b8493 authored by Brad King's avatar Brad King
Browse files

ENH: Adding stringstream compatibility implementation. It is currently...

ENH: Adding stringstream compatibility implementation.  It is currently identical to ostringstream.  Fixed local variable pcount hiding method warning.
parent 0b48bc1d
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,7 @@ namespace @KWSYS_NAMESPACE@_ios
using @KWSYS_NAMESPACE@_ios_namespace::streambuf;
using @KWSYS_NAMESPACE@_ios_namespace::ostream;
using @KWSYS_NAMESPACE@_ios_namespace::istream;
using @KWSYS_NAMESPACE@_ios_namespace::strstream;
using @KWSYS_NAMESPACE@_ios_namespace::istrstream;
using @KWSYS_NAMESPACE@_ios_namespace::ostrstream;
using @KWSYS_NAMESPACE@_ios_namespace::ios;
......@@ -69,6 +70,42 @@ using @KWSYS_NAMESPACE@_ios_namespace::endl;
using @KWSYS_NAMESPACE@_ios_namespace::ends;
using @KWSYS_NAMESPACE@_ios_namespace::flush;
class stringstream_cleanup
{
public:
stringstream_cleanup(strstream& str): m_StrStream(str) {}
~stringstream_cleanup() { m_StrStream.rdbuf()->freeze(0); }
static void IgnoreUnusedVariable(const stringstream_cleanup&) {}
protected:
strstream& m_StrStream;
private:
void operator=(stringstream_cleanup const&);
};
class stringstream: public strstream
{
public:
typedef strstream Superclass;
stringstream() {}
stringstream(const kwsys_stl::string& s) { *this << s.c_str(); }
kwsys_stl::string str()
{
stringstream_cleanup cleanup(*this);
stringstream_cleanup::IgnoreUnusedVariable(cleanup);
int count = this->pcount();
const char* ptr = this->Superclass::str();
return kwsys_stl::string(ptr?ptr:"", count);
}
void str(const kwsys_stl::string& s)
{
this->~stringstream();
new (this) stringstream(s);
}
private:
stringstream(const stringstream&);
void operator=(const stringstream&);
};
class ostringstream_cleanup
{
public:
......@@ -91,9 +128,9 @@ public:
{
ostringstream_cleanup cleanup(*this);
ostringstream_cleanup::IgnoreUnusedVariable(cleanup);
int pcount = this->pcount();
int count = this->pcount();
const char* ptr = this->Superclass::str();
return kwsys_stl::string(ptr?ptr:"", pcount);
return kwsys_stl::string(ptr?ptr:"", count);
}
void str(const kwsys_stl::string& s)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment