StringStream.h
1 /*
2  * Copyright (C) 2007 Marc Boris Duerner
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * As a special exception, you may use this file as part of a free
10  * software library without restriction. Specifically, if other files
11  * instantiate templates or use macros or inline functions from this
12  * file, or you compile this file and link it with other files to
13  * produce an executable, this file does not by itself cause the
14  * resulting executable to be covered by the GNU General Public
15  * License. This exception does not however invalidate any other
16  * reasons why the executable file might be covered by the GNU Library
17  * General Public License.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27  */
28 
29 #ifndef PT_STRINGSTREAM_H
30 #define PT_STRINGSTREAM_H
31 
32 #include <Pt/Api.h>
33 #include <Pt/String.h>
34 #include <Pt/StreamBuffer.h>
35 #include <Pt/IOStream.h>
36 #include <Pt/String.h>
37 #include <sstream>
38 
39 //namespace Pt {
40 
41 //* @brief Unicode string stream buffer.
42 //
43 // @ingroup Unicode
44 //*/
45 //class PT_API StringBuffer : public std::basic_stringbuf<Pt::Char>
46 //{
47 // public:
48 // explicit StringBuffer(std::ios::openmode mode = std::ios::in | std::ios::out);
49 //
50 // explicit StringBuffer(const Pt::String& str,
51 // std::ios::openmode mode = std::ios::in | std::ios::out);
52 //};
53 //
54 //} // namespace Pt
55 //
56 //namespace std {
57 //
58 //template<>
59 //class PT_API basic_istringstream<Pt::Char> : public basic_istream<Pt::Char>
60 //{
61 // public:
62 // typedef Pt::Char char_type;
63 // typedef std::char_traits<Pt::Char> traits_type;
64 // typedef std::allocator<Pt::Char> allocator_type;
65 // typedef traits_type::int_type int_type;
66 // typedef traits_type::pos_type pos_type;
67 // typedef traits_type::off_type off_type;
68 //
69 // public:
70 // explicit basic_istringstream(ios_base::openmode mode = ios_base::in);
71 //
72 // explicit basic_istringstream(const Pt::String& str,
73 // std::ios_base::openmode mode = std::ios_base::in);
74 //
75 // basic_stringbuf<Pt::Char>* rdbuf() const
76 // { return const_cast<Pt::StringBuffer*>(&_buffer); }
77 //
78 // Pt::String str() const
79 // { return _buffer.str(); }
80 //
81 // void str(const Pt::String& str)
82 // { _buffer.str(str); }
83 //
84 // private:
85 // Pt::StringBuffer _buffer;
86 //};
87 //
88 //template<>
89 //class PT_API basic_ostringstream<Pt::Char> : public basic_ostream<Pt::Char>
90 //{
91 // public:
92 // typedef Pt::Char char_type;
93 // typedef std::char_traits<Pt::Char> traits_type;
94 // typedef std::allocator<Pt::Char> allocator_type;
95 // typedef traits_type::int_type int_type;
96 // typedef traits_type::pos_type pos_type;
97 // typedef traits_type::off_type off_type;
98 //
99 // public:
100 // explicit basic_ostringstream(ios_base::openmode mode = ios_base::out);
101 //
102 // explicit basic_ostringstream(const Pt::String& str,
103 // std::ios_base::openmode mode = std::ios_base::out);
104 //
105 // basic_stringbuf<Pt::Char>* rdbuf() const
106 // { return const_cast<Pt::StringBuffer*>(&_buffer); }
107 //
108 // Pt::String str() const
109 // { return _buffer.str(); }
110 //
111 // void str(const Pt::String& str)
112 // { _buffer.str(str); }
113 //
114 // private:
115 // Pt::StringBuffer _buffer;
116 //};
117 //
118 //template<>
119 //class PT_API basic_stringstream<Pt::Char> : public basic_iostream<Pt::Char>
120 //{
121 // public:
122 // typedef Pt::Char char_type;
123 // typedef std::char_traits<Pt::Char> traits_type;
124 // typedef std::allocator<Pt::Char> allocator_type;
125 // typedef traits_type::int_type int_type;
126 // typedef traits_type::pos_type pos_type;
127 // typedef traits_type::off_type off_type;
128 //
129 // public:
130 // explicit basic_stringstream(ios_base::openmode mode = ios_base::in | ios_base::out);
131 //
132 // explicit basic_stringstream(const Pt::String& str,
133 // std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out);
134 //
135 // basic_stringbuf<Pt::Char>* rdbuf() const
136 // { return const_cast<Pt::StringBuffer*>(&_buffer); }
137 //
138 // Pt::String str() const
139 // { return _buffer.str(); }
140 //
141 // void str(const Pt::String& str)
142 // { _buffer.str(str); }
143 //
144 // private:
145 // Pt::StringBuffer _buffer;
146 //};
147 //
148 //} // namespace std
149 
150 
151 namespace Pt {
152 
165 typedef std::basic_stringstream<Pt::Char> StringStream;
166 
179 typedef std::basic_istringstream<Pt::Char> IStringStream;
180 
193 typedef std::basic_ostringstream<Pt::Char> OStringStream;
194 
195 } // namespace Pt
196 
197 #endif