13 #ifndef BOOST_SK_ALT_SSTREAM_IMPL_HPP 14 #define BOOST_SK_ALT_SSTREAM_IMPL_HPP 20 template<
class Ch,
class Tr,
class Alloc>
23 const Ch *
p = pptr();
24 const Ch *
b = pbase();
25 if(p !=
NULL && p != b) {
30 if(p !=
NULL && p != b) {
31 seekpos(0, ::std::ios_base::in);
35 template<
class Ch,
class Tr,
class Alloc>
40 #ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC 41 void *vd_ptr = alloc_.allocate(sz, is_allocated_? eback() : 0);
42 Ch *new_ptr =
static_cast<Ch *
>(vd_ptr);
44 Ch *new_ptr = alloc_.allocate(sz, is_allocated_? eback() : 0);
48 sz = s.copy(new_ptr, sz);
49 putend_ = new_ptr + sz;
50 if(mode_ & ::std::ios_base::in)
51 streambuf_t::setg(new_ptr, new_ptr, new_ptr + sz);
53 streambuf_t::setp(new_ptr, new_ptr + sz);
54 if(mode_ & (::std::ios_base::app | ::std::ios_base::ate))
55 streambuf_t::pbump(static_cast<int>(sz));
57 streambuf_t::setg(new_ptr,
NULL, new_ptr);
64 template<
class Ch,
class Tr,
class Alloc>
69 else if(mode_ & ::std::ios_base::in && gptr() !=
NULL)
74 template<
class Ch,
class Tr,
class Alloc>
75 typename std::basic_string<Ch,Tr,Alloc>::size_type
79 return static_cast<size_type>(pend() - pbase());
80 else if(mode_ & ::std::ios_base::in && gptr())
81 return static_cast<size_type>(egptr() - eback());
86 template<
class Ch,
class Tr,
class Alloc>
87 typename std::basic_string<Ch,Tr,Alloc>::size_type
91 return static_cast<streamsize>( pptr() - pbase());
92 else if(mode_ & ::std::ios_base::in && gptr())
93 return static_cast<streamsize>( gptr() - eback());
98 template<
class Ch,
class Tr,
class Alloc>
101 seekoff (
off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) {
102 if(pptr() !=
NULL && putend_ < pptr())
104 if(which & ::std::ios_base::in && gptr() !=
NULL) {
107 off +=
static_cast<off_type>(putend_ - gptr());
108 else if(way == ::std::ios_base::beg)
109 off +=
static_cast<off_type>(eback() - gptr());
113 if(eback() <= off+gptr() && off+gptr() <= putend_ ) {
115 streambuf_t::gbump(static_cast<int>(off));
116 if(which & ::std::ios_base::out && pptr() !=
NULL)
118 streambuf_t::pbump(static_cast<int>(gptr()-pptr()));
126 off +=
static_cast<off_type>(putend_ - pptr());
127 else if(way == ::std::ios_base::beg)
128 off +=
static_cast<off_type>(pbase() - pptr());
129 else if(way != ::std::ios_base::beg)
131 if(pbase() <= off+pptr() && off+pptr() <= putend_)
133 streambuf_t::pbump(static_cast<int>(off));
144 template<
class Ch,
class Tr,
class Alloc>
149 if(pptr() !=
NULL && putend_ < pptr())
152 if(which & ::std::ios_base::in && gptr() !=
NULL) {
154 if(0 <= off && off <= putend_ - eback()) {
155 streambuf_t::gbump(static_cast<int>(eback() - gptr() + off));
158 streambuf_t::pbump(static_cast<int>(gptr()-pptr()));
166 if(0 <= off && off <= putend_ - eback())
167 streambuf_t::pbump(static_cast<int>(eback() - pptr() + off));
183 template<
class Ch,
class Tr,
class Alloc>
188 return (compat_traits_type::eof());
189 else if(gptr() < egptr())
190 return (compat_traits_type::to_int_type(*gptr()));
191 else if(mode_ & ::std::ios_base::in && pptr() !=
NULL 192 && (gptr() < pptr() || gptr() < putend_) )
196 streambuf_t::setg(eback(), gptr(), putend_);
197 return (compat_traits_type::to_int_type(*gptr()));
200 return (compat_traits_type::eof());
205 template<
class Ch,
class Tr,
class Alloc>
209 if(gptr() !=
NULL && (eback() < gptr())
211 || compat_traits_type::eq_int_type(compat_traits_type::eof(), meta)
213 streambuf_t::gbump(-1);
214 if(!compat_traits_type::eq_int_type(compat_traits_type::eof(), meta))
216 *gptr() = compat_traits_type::to_char_type(meta);
217 return (compat_traits_type::not_eof(meta));
220 return (compat_traits_type::eof());
225 template<
class Ch,
class Tr,
class Alloc>
230 #pragma warning(push) 231 #pragma warning(disable:4996) 233 if(compat_traits_type::eq_int_type(compat_traits_type::eof(), meta))
234 return compat_traits_type::not_eof(meta);
235 else if(pptr() !=
NULL && pptr() < epptr()) {
236 streambuf_t::sputc(compat_traits_type::to_char_type(meta));
241 return compat_traits_type::eof();
243 std::size_t prev_size = pptr() ==
NULL ? 0 : epptr() - eback();
244 std::size_t new_size = prev_size;
246 std::size_t add_size = new_size / 2;
247 if(add_size < alloc_min)
248 add_size = alloc_min;
249 Ch * newptr =
NULL, *oldptr = eback();
252 while (0 < add_size && ((std::numeric_limits<std::size_t>::max)()
253 - add_size < new_size) )
256 new_size += add_size;
257 #ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC 258 void *vdptr = alloc_.allocate(new_size, is_allocated_? oldptr : 0);
259 newptr =
static_cast<Ch *
>(vdptr);
261 newptr = alloc_.allocate(new_size, is_allocated_? oldptr : 0);
268 alloc_.deallocate(oldptr, prev_size);
273 streambuf_t::setp(newptr, newptr + new_size);
274 if(mode_ & ::std::ios_base::in)
275 streambuf_t::setg(newptr, newptr, newptr + 1);
277 streambuf_t::setg(newptr, 0, newptr);
280 putend_ = putend_ - oldptr + newptr;
281 int pptr_count =
static_cast<int>(pptr()-pbase());
282 int gptr_count =
static_cast<int>(gptr()-eback());
283 streambuf_t::setp(pbase() - oldptr + newptr, newptr + new_size);
284 streambuf_t::pbump(pptr_count);
285 if(mode_ & ::std::ios_base::in)
286 streambuf_t::setg(newptr, newptr + gptr_count, pptr() + 1);
288 streambuf_t::setg(newptr, 0, newptr);
290 streambuf_t::sputc(compat_traits_type::to_char_type(meta));
299 template<
class Ch,
class Tr,
class Alloc>
302 alloc_.deallocate(eback(), (pptr() !=
NULL ? epptr() : egptr()) - eback());
303 is_allocated_ =
false;
304 streambuf_t::setg(0, 0, 0);
305 streambuf_t::setp(0, 0);
312 #endif // include guard
::std::streamsize streamsize
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
compat_traits_type::pos_type pos_type
virtual pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which=::std::ios_base::in|::std::ios_base::out)
string_type::size_type size_type
compat_traits_type::off_type off_type
virtual int_type overflow(int_type meta=compat_traits_type::eof())
compat_traits_type::int_type int_type
size_type cur_size() const
virtual int_type pbackfail(int_type meta=compat_traits_type::eof())
virtual int_type underflow()
GLboolean GLboolean GLboolean b
bool eq(float3 const &a, float3 const &b)
#define BOOST_ASSERT(expr)
void copy(void *dst, void const *src, size_t size)
virtual pos_type seekpos(pos_type pos, ::std::ios_base::openmode which=::std::ios_base::in|::std::ios_base::out)
::std::basic_string< Ch, Tr, Alloc > string_type