Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * Neither the name of Nokia Corporation nor the names of its contributors
13 * may be used to endorse or promote products derived from this software
14 * without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef _STLP_STRING_IO_C
32 #define _STLP_STRING_IO_C
34 #ifndef _STLP_STRING_IO_H
35 # include <stl/_string_io.h>
38 #ifndef _STLP_INTERNAL_CTYPE_H
39 # include <stl/_ctype.h>
43 # define basic_string _Nondebug_string
48 # if defined (_STLP_OWN_IOSTREAMS)
49 # define _STLP_USING_IO
51 # define _STLP_USING_IO _STLP_USING_VENDOR_STD
54 #if defined (_STLP_USE_NEW_IOSTREAMS)
56 template <class _CharT, class _Traits>
58 __stlp_string_fill(basic_ostream<_CharT, _Traits>& __os,
59 basic_streambuf<_CharT, _Traits>* __buf,
62 _CharT __f = __os.fill();
66 for (__i = 0; __i < __n; ++__i)
67 __ok = __ok && !_Traits::eq_int_type(__buf->sputc(__f), _Traits::eof());
71 template <class _CharT, class _Traits, class _Alloc>
72 basic_ostream<_CharT, _Traits>& _STLP_CALL
73 operator<<(basic_ostream<_CharT, _Traits>& __os,
74 const basic_string<_CharT,_Traits,_Alloc>& __s)
78 typedef basic_ostream<_CharT, _Traits> __ostream;
79 typename __ostream::sentry __sentry(__os);
84 size_t __n = __s.size();
86 const bool __left = (__os.flags() & __ostream::left) != 0;
87 const size_t __w = __os.width(0);
88 basic_streambuf<_CharT, _Traits>* __buf = __os.rdbuf();
91 __pad_len = __w - __n;
95 __ok = __stlp_string_fill(__os, __buf, __pad_len);
97 __ok = __ok && (__buf->sputn(__s.data(), streamsize(__n)) == streamsize(__n));
100 __ok = __ok && __stlp_string_fill(__os, __buf, __pad_len);
104 __os.setstate(__ostream::failbit);
109 template <class _CharT, class _Traits, class _Alloc>
110 basic_istream<_CharT, _Traits>& _STLP_CALL
111 operator>>(basic_istream<_CharT, _Traits>& __is,
112 basic_string<_CharT,_Traits, _Alloc>& __s)
115 typedef basic_istream<_CharT, _Traits> __istream;
116 typename __istream::sentry __sentry(__is);
119 basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
120 typedef ctype<_CharT> _C_type;
122 #ifdef _STLP_OWN_IOSTREAMS
123 // const _C_type& _Ctype = use_facet<_C_type>(__loc);
124 const _C_type& _Ctype = *(const _C_type*)__is._M_ctype_facet();
126 # if defined (_STLP_MSVC) && (_STLP_MSVC <= 1200 ) || defined (__ICL)
127 const locale& __loc = __is.getloc();
128 const _C_type& _Ctype = use_facet(__loc , ( _C_type * ) 0, true);
129 # elif defined (__SUNPRO_CC)
130 const locale& __loc = __is.getloc();
131 const _C_type& _Ctype = use_facet(__loc , ( _C_type * ) 0);
133 const locale& __loc = __is.getloc();
134 const _C_type& _Ctype = use_facet<_C_type>(__loc);
138 size_t __n = __is.width(0);
140 __n = __STATIC_CAST(size_t,-1);
146 typename _Traits::int_type __c1 = __buf->sbumpc();
147 if (_Traits::eq_int_type(__c1, _Traits::eof())) {
148 __is.setstate(__istream::eofbit);
152 _CharT __c = _Traits::to_char_type(__c1);
154 if (_Ctype.is(_C_type::space, __c)) {
155 if (_Traits::eq_int_type(__buf->sputbackc(__c), _Traits::eof()))
156 __is.setstate(__istream::failbit);
160 else if (__c == '\b') {
169 // If we have read no characters, then set failbit.
171 __is.setstate(__istream::failbit);
174 __is.setstate(__istream::failbit);
179 template <class _CharT, class _Traits, class _Alloc>
180 basic_istream<_CharT, _Traits>& _STLP_CALL
181 getline(basic_istream<_CharT, _Traits>& __is,
182 basic_string<_CharT,_Traits,_Alloc>& __s,
186 typedef basic_istream<_CharT, _Traits> __istream;
188 typename basic_istream<_CharT, _Traits>::sentry __sentry(__is, true);
190 basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
193 while (__nread < __s.max_size()) {
194 int __c1 = __buf->sbumpc();
195 if (_Traits::eq_int_type(__c1, _Traits::eof())) {
196 __is.setstate(__istream::eofbit);
201 _CharT __c = _Traits::to_char_type(__c1);
202 if (!_Traits::eq(__c, __delim))
205 break; // Character is extracted but not appended.
209 if (__nread == 0 || __nread >= __s.max_size())
210 __is.setstate(__istream::failbit);
215 #elif ! defined ( _STLP_USE_NO_IOSTREAMS )
217 // (reg) For Watcom IO, _OSTREAM_DLL tells if ostream class is in .exe or in .dll
219 template <class _CharT, class _Traits, class _Alloc>
220 _OSTREAM_DLL& _STLP_CALL operator<<(_OSTREAM_DLL& __os,
221 const basic_string<_CharT,_Traits,_Alloc>& __s)
224 streambuf* __buf = __os.rdbuf();
226 size_t __n = __s.size();
227 size_t __pad_len = 0;
228 const bool __left = (__os.flags() & ios::left) !=0;
229 const size_t __w = __os.width();
232 __pad_len = __w - __n;
236 __stlp_string_fill(__os, __buf, __pad_len);
238 const size_t __nwritten = __buf->sputn(__s.data(), __n);
241 __stlp_string_fill(__os, __buf, __pad_len);
243 if (__nwritten != __n)
244 __os.clear(__os.rdstate() | ios::failbit);
249 __os.clear(__os.rdstate() | ios::badbit);
254 template <class _CharT, class _Traits, class _Alloc>
255 _ISTREAM_DLL& _STLP_CALL operator>>(_ISTREAM_DLL& __is, basic_string<_CharT,_Traits,_Alloc>& __s)
261 streambuf* __buf = __is.rdbuf();
264 if (__is.flags() & ios::skipws) {
268 __c = __buf->sbumpc();
270 while (__c != EOF && isspace((unsigned char)__c));
273 __is.clear(__is.rdstate() | ios::eofbit | ios::failbit);
276 if (__buf->sputbackc(__c) == EOF)
277 __is.clear(__is.rdstate() | ios::failbit);
281 // If we arrive at end of file (or fail for some other reason) while
282 // still discarding whitespace, then we don't try to read the string.
286 size_t __n = __is.width();
288 __n = __STATIC_CAST(size_t,-1);
293 int __c1 = __buf->sbumpc();
295 __is.clear(__is.rdstate() | ios::eofbit);
299 _CharT __c = _Traits::to_char_type(__c1);
301 if (isspace((unsigned char) __c)) {
302 if (__buf->sputbackc(__c) == EOF)
303 __is.clear(__is.rdstate() | ios::failbit);
311 // If we have read no characters, then set failbit.
313 __is.clear(__is.rdstate() | ios::failbit);
318 else // We have no streambuf.
319 __is.clear(__is.rdstate() | ios::badbit);
324 template <class _CharT, class _Traits, class _Alloc>
325 _ISTREAM_DLL& _STLP_CALL getline(_ISTREAM_DLL& __is,
326 basic_string<_CharT,_Traits,_Alloc>& __s,
330 streambuf* __buf = __is.rdbuf();
336 while (__nread < __s.max_size()) {
337 int __c1 = __buf->sbumpc();
339 __is.clear(__is.rdstate() | ios::eofbit);
344 _CharT __c = _Traits::to_char_type(__c1);
345 if (!_Traits::eq(__c, __delim))
348 break; // Character is extracted but not appended.
353 if (__nread == 0 || __nread >= __s.max_size())
354 __is.clear(__is.rdstate() | ios::failbit);
357 __is.clear(__is.rdstate() | ios::badbit);
362 # endif /* _STLP_NEW_IOSTREAMS */
366 // # undef _STLP_USING_IO