blob: 165c3b708b262df6b6d97b2ec666b60d0b408b25 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/*=========================================================================
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@_std_sstream
#define @KWSYS_NAMESPACE@_std_sstream
#include <@KWSYS_NAMESPACE@/Configure.hxx>
/* Define this macro temporarily to keep the code readable. */
#if !defined (KWSYS_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_NAME_IS_KWSYS)
# define kwsys_std @KWSYS_NAMESPACE@_std
#endif
#if !defined(@KWSYS_NAMESPACE@_NO_ANSI_STRING_STREAM)
# 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 !defined(@KWSYS_NAMESPACE@_NO_ANSI_STREAM_HEADERS)
# include <strstream>
# else
# include <strstream.h>
# if !defined(@KWSYS_NAMESPACE@_NO_STD_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_FAKE_STD_NAMESPACE)
namespace std
{
using ::ostream;
using ::istream;
using ::istrstream;
using ::ostrstream;
using ::ios;
using ::endl;
using ::ends;
using ::flush;
}
# endif
# 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@/std/string>
# if !defined(@KWSYS_NAMESPACE@_NO_STD_NAMESPACE)
namespace std
{
# endif
class ostringstream_cleanup
{
public:
ostringstream_cleanup(kwsys_std::ostrstream& ostr): m_OStrStream(ostr) {}
~ostringstream_cleanup() { m_OStrStream.rdbuf()->freeze(0); }
static void IgnoreUnusedVariable(const ostringstream_cleanup&) {}
protected:
kwsys_std::ostrstream& m_OStrStream;
};
class ostringstream: public kwsys_std::ostrstream
{
public:
typedef kwsys_std::ostrstream Superclass;
ostringstream() {}
kwsys_std::string str()
{
ostringstream_cleanup cleanup(*this);
ostringstream_cleanup::IgnoreUnusedVariable(cleanup);
int pcount = this->pcount();
const char* ptr = this->Superclass::str();
return kwsys_std::string(ptr?ptr:"", pcount);
}
private:
ostringstream(const ostringstream&);
void operator=(const ostringstream&);
};
class istringstream: private kwsys_std::string, public kwsys_std::istrstream
{
public:
typedef kwsys_std::string StdString;
typedef kwsys_std::istrstream IStrStream;
istringstream(): StdString(), IStrStream(StdString::c_str()) {}
istringstream(const kwsys_std::string& s):
StdString(s), IStrStream(StdString::c_str()) {}
kwsys_std::string str() const { return *this; }
void str(const kwsys_std::string& s)
{
// Very dangerous. If this throws, the object is hosed. When the
// destructor is later called, the program is hosed too.
this->~istringstream();
new (this) istringstream(s);
}
private:
istringstream(const istringstream&);
void operator=(const istringstream&);
};
# if !defined(@KWSYS_NAMESPACE@_NO_STD_NAMESPACE)
}
# endif
#endif
/* Undefine temporary macro. */
#if !defined (KWSYS_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_NAME_IS_KWSYS)
# undef kwsys_std
#endif
#endif
|