summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/kwsys_ios_sstream.h.in
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2003-12-23 16:03:33 (GMT)
committerBrad King <brad.king@kitware.com>2003-12-23 16:03:33 (GMT)
commit032d1d86524fe1748cc7070786655c0ba563ae99 (patch)
tree04a415af48884aab3e549b7bdecd7d5470d54831 /Source/kwsys/kwsys_ios_sstream.h.in
parent0bdb092a019c87825a88208d4fdaef77379e3004 (diff)
downloadCMake-032d1d86524fe1748cc7070786655c0ba563ae99.zip
CMake-032d1d86524fe1748cc7070786655c0ba563ae99.tar.gz
CMake-032d1d86524fe1748cc7070786655c0ba563ae99.tar.bz2
ENH: Merging changes from KWSys-IOS-bp to KWSys-IOS-b2t-1-mp to main tree. This introduces separate kwsys_ios and kwsys_stl macros needed to support all platforms.
Diffstat (limited to 'Source/kwsys/kwsys_ios_sstream.h.in')
-rw-r--r--Source/kwsys/kwsys_ios_sstream.h.in122
1 files changed, 122 insertions, 0 deletions
diff --git a/Source/kwsys/kwsys_ios_sstream.h.in b/Source/kwsys/kwsys_ios_sstream.h.in
new file mode 100644
index 0000000..876259d
--- /dev/null
+++ b/Source/kwsys/kwsys_ios_sstream.h.in
@@ -0,0 +1,122 @@
+/*=========================================================================
+
+ Program: KWSys - Kitware System Library
+ Module: $RCSfile$
+
+ Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef @KWSYS_NAMESPACE@_ios_sstream
+#define @KWSYS_NAMESPACE@_ios_sstream
+
+#include <@KWSYS_NAMESPACE@/Configure.hxx>
+
+/* Define this macro temporarily to keep the code readable. */
+#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# define kwsys_stl @KWSYS_NAMESPACE@_stl
+#endif
+
+#if @KWSYS_NAMESPACE@_IOS_HAVE_SSTREAM
+# ifdef _MSC_VER
+# pragma warning (push, 1)
+# pragma warning (disable: 4702)
+# endif
+# include <sstream>
+# ifdef _MSC_VER
+# pragma warning(pop)
+# endif
+#else
+# ifdef _MSC_VER
+# pragma warning (push, 1)
+# pragma warning (disable: 4702)
+# endif
+# if @KWSYS_NAMESPACE@_IOS_HAVE_ANSI
+# include <strstream>
+# elif @KWSYS_NAMESPACE@_IOS_HAVE_STRSTREAM_H
+# include <strstream.h>
+# elif @KWSYS_NAMESPACE@_IOS_HAVE_STRSTREA_H
+# include <strstrea.h>
+# endif
+# ifdef _MSC_VER
+# pragma warning(pop)
+# endif
+
+// Only have old std::strstream classes. Wrap them to look like new
+// ostringstream and istringstream classes.
+
+# include <@KWSYS_NAMESPACE@/stl/string>
+
+namespace @KWSYS_NAMESPACE@_ios
+{
+using @KWSYS_NAMESPACE@_ios_namespace::ostream;
+using @KWSYS_NAMESPACE@_ios_namespace::istream;
+using @KWSYS_NAMESPACE@_ios_namespace::istrstream;
+using @KWSYS_NAMESPACE@_ios_namespace::ostrstream;
+using @KWSYS_NAMESPACE@_ios_namespace::ios;
+using @KWSYS_NAMESPACE@_ios_namespace::endl;
+using @KWSYS_NAMESPACE@_ios_namespace::ends;
+using @KWSYS_NAMESPACE@_ios_namespace::flush;
+
+class ostringstream_cleanup
+{
+public:
+ ostringstream_cleanup(ostrstream& ostr): m_OStrStream(ostr) {}
+ ~ostringstream_cleanup() { m_OStrStream.rdbuf()->freeze(0); }
+ static void IgnoreUnusedVariable(const ostringstream_cleanup&) {}
+protected:
+ ostrstream& m_OStrStream;
+};
+
+class ostringstream: public ostrstream
+{
+public:
+ typedef ostrstream Superclass;
+ ostringstream() {}
+ kwsys_stl::string str()
+ {
+ ostringstream_cleanup cleanup(*this);
+ ostringstream_cleanup::IgnoreUnusedVariable(cleanup);
+ int pcount = this->pcount();
+ const char* ptr = this->Superclass::str();
+ return kwsys_stl::string(ptr?ptr:"", pcount);
+ }
+private:
+ ostringstream(const ostringstream&);
+ void operator=(const ostringstream&);
+};
+
+class istringstream: private kwsys_stl::string, public istrstream
+{
+public:
+ typedef kwsys_stl::string StdString;
+ typedef istrstream IStrStream;
+ istringstream(): StdString(),
+ IStrStream(const_cast<char*>(StdString::c_str())) {}
+ istringstream(const kwsys_stl::string& s):
+ StdString(s), IStrStream(const_cast<char*>(StdString::c_str())) {}
+ kwsys_stl::string str() const { return *this; }
+ void str(const kwsys_stl::string& s)
+ {
+ this->~istringstream();
+ new (this) istringstream(s);
+ }
+private:
+ istringstream(const istringstream&);
+ void operator=(const istringstream&);
+};
+
+} // namespace @KWSYS_NAMESPACE@_ios
+
+#endif
+
+/* Undefine temporary macro. */
+#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# undef kwsys_stl
+#endif
+
+#endif