diff options
author | Brad King <brad.king@kitware.com> | 2006-12-14 18:18:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-12-14 18:18:27 (GMT) |
commit | 1fe21ae35ec49db320955a6d9c1cbf4807e2f9f3 (patch) | |
tree | 39da228d20dd8f958a52c7ec576c2109017b236c /Source | |
parent | 55af790ebfc4d95c57be817eb1b02fa254220602 (diff) | |
download | CMake-1fe21ae35ec49db320955a6d9c1cbf4807e2f9f3.zip CMake-1fe21ae35ec49db320955a6d9c1cbf4807e2f9f3.tar.gz CMake-1fe21ae35ec49db320955a6d9c1cbf4807e2f9f3.tar.bz2 |
ENH: Adding stringstream compatibility implementation. It is currently identical to ostringstream. Fixed local variable pcount hiding method warning.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/kwsys/kwsys_ios_sstream.h.in | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/Source/kwsys/kwsys_ios_sstream.h.in b/Source/kwsys/kwsys_ios_sstream.h.in index ccf9113..61e3691 100644 --- a/Source/kwsys/kwsys_ios_sstream.h.in +++ b/Source/kwsys/kwsys_ios_sstream.h.in @@ -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) { |