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) {
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;
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>
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());
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());
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())
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())
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()));
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);
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);
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
GLboolean GLboolean GLboolean b
::std::streamsize streamsize
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
size_type cur_size() const
compat_traits_type::pos_type pos_type
string_type::size_type size_type
compat_traits_type::off_type off_type
virtual int_type overflow(int_type meta=compat_traits_type::eof())
virtual pos_type seekpos(pos_type pos,::std::ios_base::openmode which=::std::ios_base::in|::std::ios_base::out)
compat_traits_type::int_type int_type
virtual int_type pbackfail(int_type meta=compat_traits_type::eof())
virtual int_type underflow()
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)
bool eq(float3 const &a, float3 const &b)
#define BOOST_ASSERT(expr)
void copy(void *dst, void const *src, size_t size)
::std::basic_string< Ch, Tr, Alloc > string_type