ReactOS  0.4.14-dev-833-g5f692ed
basic_stringbuf< _CharT, _Traits, _Alloc > Class Template Reference

#include <_iosfwd.h>

Inheritance diagram for basic_stringbuf< _CharT, _Traits, _Alloc >:
Collaboration diagram for basic_stringbuf< _CharT, _Traits, _Alloc >:

Public Types

typedef _CharT char_type
 
typedef _Traits::int_type int_type
 
typedef _Traits::pos_type pos_type
 
typedef _Traits::off_type off_type
 
typedef _Traits traits_type
 
typedef basic_streambuf< _CharT, _Traits > _Base
 
typedef basic_stringbuf< _CharT, _Traits, _Alloc_Self
 
typedef basic_string< _CharT, _Traits, _Alloc_String
 
- Public Types inherited from basic_streambuf< _CharT, _Traits >
typedef _CharT char_type
 
typedef _Traits::int_type int_type
 
typedef _Traits::pos_type pos_type
 
typedef _Traits::off_type off_type
 
typedef _Traits traits_type
 

Public Member Functions

 basic_stringbuf (ios_base::openmode __mode=ios_base::in|ios_base::out)
 
 basic_stringbuf (const _String &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
 
virtual ~basic_stringbuf ()
 
_String str () const
 
void str (const _String &__s)
 
- Public Member Functions inherited from basic_streambuf< _CharT, _Traits >
virtual ~basic_streambuf ()
 
char_type_M_eback () const
 
char_type_M_gptr () const
 
char_type_M_egptr () const
 
void _M_gbump (int __n)
 
void _M_setg (char_type *__gbegin, char_type *__gnext, char_type *__gend)
 
basic_streambuf< _CharT, _Traits > * pubsetbuf (char_type *__s, streamsize __n)
 
pos_type pubseekoff (off_type __offset, ios_base::seekdir __way, ios_base::openmode __mod=ios_base::in|ios_base::out)
 
pos_type pubseekpos (pos_type __sp, ios_base::openmode __mod=ios_base::in|ios_base::out)
 
int pubsync ()
 
int_type sputc (char_type __c)
 
streamsize sputn (const char_type *__s, streamsize __n)
 
streamsize _M_sputnc (char_type __c, streamsize __n)
 
streamsize in_avail ()
 
int_type snextc ()
 
int_type sbumpc ()
 
int_type sgetc ()
 
streamsize sgetn (char_type *__s, streamsize __n)
 
int_type sputbackc (char_type __c)
 
int_type sungetc ()
 
locale pubimbue (const locale &)
 
locale getloc () const
 
void stossc ()
 

Protected Member Functions

virtual int_type underflow ()
 
virtual int_type uflow ()
 
virtual int_type pbackfail (int_type __c)
 
virtual int_type overflow (int_type __c)
 
int_type pbackfail ()
 
int_type overflow ()
 
virtual streamsize xsputn (const char_type *__s, streamsize __n)
 
virtual streamsize _M_xsputnc (char_type __c, streamsize __n)
 
virtual _Basesetbuf (_CharT *__buf, streamsize __n)
 
virtual pos_type seekoff (off_type __off, ios_base::seekdir __dir, ios_base::openmode __mode=ios_base::in|ios_base::out)
 
virtual pos_type seekpos (pos_type __pos, ios_base::openmode __mode=ios_base::in|ios_base::out)
 
- Protected Member Functions inherited from basic_streambuf< _CharT, _Traits >
 basic_streambuf ()
 
char_typeeback () const
 
char_typegptr () const
 
char_typeegptr () const
 
void gbump (int __n)
 
void setg (char_type *__gbegin, char_type *__gnext, char_type *__gend)
 
char_typepbase () const
 
char_typepptr () const
 
char_typeepptr () const
 
void pbump (int __n)
 
void setp (char_type *__pbegin, char_type *__pend)
 
virtual int sync ()
 
virtual streamsize showmanyc ()
 
virtual streamsize xsgetn (char_type *__s, streamsize __n)
 
virtual void imbue (const locale &)
 

Private Member Functions

void _M_set_ptrs ()
 

Static Private Member Functions

static _CharT * _S_start (const _String &__str)
 
static _CharT * _S_finish (const _String &__str)
 

Private Attributes

ios_base::openmode _M_mode
 
_String _M_str
 

Detailed Description

template<class _CharT, class _Traits, class _Alloc>
class basic_stringbuf< _CharT, _Traits, _Alloc >

Definition at line 46 of file _iosfwd.h.

Member Typedef Documentation

◆ _Base

template<class _CharT, class _Traits, class _Alloc>
typedef basic_streambuf<_CharT, _Traits> basic_stringbuf< _CharT, _Traits, _Alloc >::_Base

Definition at line 63 of file _sstream.h.

◆ _Self

template<class _CharT, class _Traits, class _Alloc>
typedef basic_stringbuf<_CharT, _Traits, _Alloc> basic_stringbuf< _CharT, _Traits, _Alloc >::_Self

Definition at line 64 of file _sstream.h.

◆ _String

template<class _CharT, class _Traits, class _Alloc>
typedef basic_string<_CharT, _Traits, _Alloc> basic_stringbuf< _CharT, _Traits, _Alloc >::_String

Definition at line 65 of file _sstream.h.

◆ char_type

template<class _CharT, class _Traits, class _Alloc>
typedef _CharT basic_stringbuf< _CharT, _Traits, _Alloc >::char_type

Definition at line 57 of file _sstream.h.

◆ int_type

template<class _CharT, class _Traits, class _Alloc>
typedef _Traits::int_type basic_stringbuf< _CharT, _Traits, _Alloc >::int_type

Definition at line 58 of file _sstream.h.

◆ off_type

template<class _CharT, class _Traits, class _Alloc>
typedef _Traits::off_type basic_stringbuf< _CharT, _Traits, _Alloc >::off_type

Definition at line 60 of file _sstream.h.

◆ pos_type

template<class _CharT, class _Traits, class _Alloc>
typedef _Traits::pos_type basic_stringbuf< _CharT, _Traits, _Alloc >::pos_type

Definition at line 59 of file _sstream.h.

◆ traits_type

template<class _CharT, class _Traits, class _Alloc>
typedef _Traits basic_stringbuf< _CharT, _Traits, _Alloc >::traits_type

Definition at line 61 of file _sstream.h.

Constructor & Destructor Documentation

◆ basic_stringbuf() [1/2]

template<class _CharT , class _Traits , class _Alloc >
_STLP_BEGIN_NAMESPACE basic_stringbuf< _CharT, _Traits, _Alloc >::basic_stringbuf ( ios_base::openmode  __mode = ios_base::in | ios_base::out)
explicit

Definition at line 45 of file _sstream.c.

47 {}
_String _M_str
Definition: _sstream.h:103
ios_base::openmode _M_mode
Definition: _sstream.h:102

◆ basic_stringbuf() [2/2]

template<class _CharT , class _Traits , class _Alloc >
basic_stringbuf< _CharT, _Traits, _Alloc >::basic_stringbuf ( const _String __s,
ios_base::openmode  __mode = ios_base::in | ios_base::out 
)
explicit

Definition at line 51 of file _sstream.c.

53 {
54  _M_set_ptrs();
55 }
_String _M_str
Definition: _sstream.h:103
void _M_set_ptrs()
Definition: _sstream.c:72
ios_base::openmode _M_mode
Definition: _sstream.h:102

◆ ~basic_stringbuf()

template<class _CharT , class _Traits , class _Alloc >
basic_stringbuf< _CharT, _Traits, _Alloc >::~basic_stringbuf ( )
virtual

Definition at line 58 of file _sstream.c.

59 {}

Member Function Documentation

◆ _M_set_ptrs()

template<class _CharT , class _Traits , class _Alloc >
void basic_stringbuf< _CharT, _Traits, _Alloc >::_M_set_ptrs ( )
private

Definition at line 72 of file _sstream.c.

73 {
74  _CharT* __data_ptr = _S_start(_M_str);
75  _CharT* __data_end = _S_finish(_M_str);
76  // The initial read position is the beginning of the string.
77  if (_M_mode & ios_base::in) {
78  this->setg(__data_ptr, (_M_mode & ios_base::ate) ? __data_end : __data_ptr, __data_end);
79  }
80 
81  // The initial write position is the beginning of the string.
82  if (_M_mode & ios_base::out) {
83  if ( _M_mode & (ios_base::app | ios_base::ate) ) {
84  this->setp( __data_end, __data_end );
85  } else {
86  this->setp( __data_ptr, __data_end );
87  this->pbump((int)_M_str.size()); // initial write position, if we initialized with string
88  }
89  // this->setp((_M_mode & (ios_base::app | ios_base::ate))? __data_end : __data_ptr, __data_end);
90  }
91 }
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
_String _M_str
Definition: _sstream.h:103
void pbump(int __n)
Definition: _streambuf.h:115
size_type size() const
Definition: _string.h:400
static _CharT * _S_start(const _String &__str)
Definition: _sstream.h:98
static _CharT * _S_finish(const _String &__str)
Definition: _sstream.h:99
static FILE * out
Definition: regtests2xml.c:44
ios_base::openmode _M_mode
Definition: _sstream.h:102
GLuint in
Definition: glext.h:9616

◆ _M_xsputnc()

template<class _CharT , class _Traits , class _Alloc >
streamsize basic_stringbuf< _CharT, _Traits, _Alloc >::_M_xsputnc ( char_type  __c,
streamsize  __n 
)
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 213 of file _sstream.c.

214  {
215  streamsize __nwritten = 0;
216 
217  if ((_M_mode & ios_base::out) && __n > 0) {
218  // If the put pointer is somewhere in the middle of the string,
219  // then overwrite instead of append.
220  if (this->pbase() == _S_start(_M_str)) {
221  ptrdiff_t __avail = _S_finish(_M_str) - this->pptr();
222  if (__avail > __n) {
223  _Traits::assign(this->pptr(), __STATIC_CAST(size_t, __n), __c);
224  this->pbump(__STATIC_CAST(int, __n));
225  return __n;
226  }
227  else {
228  _Traits::assign(this->pptr(), __avail, __c);
229  __nwritten += __avail;
230  __n -= __avail;
231  }
232  }
233 
234  // At this point we know we're appending.
235  size_t __app_size = sizeof(streamsize) > sizeof(size_t) ? __STATIC_CAST(size_t, (min)(__n, __STATIC_CAST(streamsize, _M_str.max_size())))
236  : __STATIC_CAST(size_t, __n);
237  _CharT* __data_ptr;
238  if (this->_M_mode & ios_base::in) {
239  ptrdiff_t __get_offset = this->gptr() - this->eback();
240  _M_str.append(__app_size, __c);
241  __data_ptr = _S_start(_M_str);
242  this->setg(__data_ptr, __data_ptr + __get_offset, _S_finish(_M_str));
243  } else {
244  _M_str.append(__app_size, __c);
245  __data_ptr = _S_start(_M_str);
246  }
247 
248  this->setp(__data_ptr, _S_finish(_M_str));
249  this->pbump((int)_M_str.size());
250  __nwritten += __app_size;
251  }
252 
253  return __nwritten;
254 }
char_type * eback() const
Definition: _streambuf.h:87
return __n
Definition: _algo.h:75
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
char_type * pbase() const
Definition: _streambuf.h:111
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
char_type * pptr() const
Definition: _streambuf.h:112
#define __c
Definition: schilyio.h:209
_String _M_str
Definition: _sstream.h:103
void pbump(int __n)
Definition: _streambuf.h:115
size_type size() const
Definition: _string.h:400
static _CharT * _S_start(const _String &__str)
Definition: _sstream.h:98
static _CharT * _S_finish(const _String &__str)
Definition: _sstream.h:99
static FILE * out
Definition: regtests2xml.c:44
_Self & append(const _CharT *__first, const _CharT *__last)
Definition: _string.h:509
ios_base::openmode _M_mode
Definition: _sstream.h:102
char_type * gptr() const
Definition: _streambuf.h:88
GLuint in
Definition: glext.h:9616
#define min(a, b)
Definition: monoChain.cc:55
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
ptrdiff_t streamsize
Definition: char_traits.h:81
size_type max_size() const
Definition: _string.h:402

◆ _S_finish()

template<class _CharT, class _Traits, class _Alloc>
static _CharT* basic_stringbuf< _CharT, _Traits, _Alloc >::_S_finish ( const _String __str)
inlinestaticprivate

Definition at line 99 of file _sstream.h.

99 { return __CONST_CAST(_CharT*, __str.data()) + __str.size(); }
#define __CONST_CAST(__x, __y)
Definition: features.h:584

◆ _S_start()

template<class _CharT, class _Traits, class _Alloc>
static _CharT* basic_stringbuf< _CharT, _Traits, _Alloc >::_S_start ( const _String __str)
inlinestaticprivate

Definition at line 98 of file _sstream.h.

98 { return __CONST_CAST(_CharT*, __str.data()); }
#define __CONST_CAST(__x, __y)
Definition: features.h:584

◆ overflow() [1/2]

template<class _CharT , class _Traits , class _Alloc >
__BSB_int_type__ basic_stringbuf< _CharT, _Traits, _Alloc >::overflow ( int_type  __c)
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 142 of file _sstream.c.

143 {
144  if (!_Traits::eq_int_type(__c, _Traits::eof())) {
145  if (_M_mode & ios_base::out) {
146  if ( this->pptr() < this->epptr() ) { // just put back in any case
147  _M_str.push_back( _Traits::to_char_type(__c) );
148  this->pbump(1);
149  } else if ( _M_mode & ios_base::in ) {
150  ptrdiff_t __offset = this->gptr() - this->eback();
151  _M_str.push_back(_Traits::to_char_type(__c));
152  _CharT* __data_ptr = _S_start(_M_str);
153  this->setg(__data_ptr, __data_ptr + __offset, _S_finish(_M_str));
154  this->setp(__data_ptr, _S_finish(_M_str));
155  this->pbump((int)_M_str.size());
156  } else {
157  _M_str.push_back( _Traits::to_char_type(__c) );
158  this->setp(_S_start(_M_str), _S_finish(_M_str));
159  this->pbump((int)_M_str.size());
160  }
161  return __c;
162  }
163  return _Traits::eof(); // Overflow always fails if it's read-only
164  }
165  return _Traits::not_eof(__c); // __c is EOF, so we don't have to do anything
166 }
char_type * eback() const
Definition: _streambuf.h:87
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
char_type * pptr() const
Definition: _streambuf.h:112
#define __c
Definition: schilyio.h:209
char_type * epptr() const
Definition: _streambuf.h:113
_String _M_str
Definition: _sstream.h:103
void pbump(int __n)
Definition: _streambuf.h:115
size_type size() const
Definition: _string.h:400
static _CharT * _S_start(const _String &__str)
Definition: _sstream.h:98
static _CharT * _S_finish(const _String &__str)
Definition: _sstream.h:99
static FILE * out
Definition: regtests2xml.c:44
ios_base::openmode _M_mode
Definition: _sstream.h:102
void push_back(_CharT __c)
Definition: _string.h:534
char_type * gptr() const
Definition: _streambuf.h:88
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
GLuint in
Definition: glext.h:9616
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247

◆ overflow() [2/2]

template<class _CharT, class _Traits, class _Alloc>
int_type basic_stringbuf< _CharT, _Traits, _Alloc >::overflow ( )
inlineprotected

Definition at line 84 of file _sstream.h.

84 {return overflow(_Traits::eof());}
int_type overflow()
Definition: _sstream.h:84
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)

Referenced by basic_stringbuf< _CharT, _Traits, _Alloc >::overflow().

◆ pbackfail() [1/2]

template<class _CharT , class _Traits , class _Alloc >
__BSB_int_type__ basic_stringbuf< _CharT, _Traits, _Alloc >::pbackfail ( int_type  __c)
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 117 of file _sstream.c.

117  {
118  if (this->gptr() != this->eback()) {
119  if (!_Traits::eq_int_type(__c, _Traits::eof())) {
120  if (_Traits::eq(_Traits::to_char_type(__c), this->gptr()[-1])) {
121  this->gbump(-1);
122  return __c;
123  }
124  else if (_M_mode & ios_base::out) {
125  this->gbump(-1);
126  *this->gptr() = _Traits::to_char_type(__c);
127  return __c;
128  }
129  else
130  return _Traits::eof();
131  }
132  else {
133  this->gbump(-1);
134  return _Traits::not_eof(__c);
135  }
136  }
137  else
138  return _Traits::eof();
139 }
char_type * eback() const
Definition: _streambuf.h:87
void gbump(int __n)
Definition: _streambuf.h:91
#define eq(received, expected, label, type)
Definition: locale.c:144
#define __c
Definition: schilyio.h:209
static FILE * out
Definition: regtests2xml.c:44
ios_base::openmode _M_mode
Definition: _sstream.h:102
char_type * gptr() const
Definition: _streambuf.h:88
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)

◆ pbackfail() [2/2]

template<class _CharT, class _Traits, class _Alloc>
int_type basic_stringbuf< _CharT, _Traits, _Alloc >::pbackfail ( )
inlineprotected

Definition at line 83 of file _sstream.h.

83 {return pbackfail(_Traits::eof());}
int_type pbackfail()
Definition: _sstream.h:83
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)

Referenced by basic_stringbuf< _CharT, _Traits, _Alloc >::pbackfail().

◆ seekoff()

template<class _CharT , class _Traits , class _Alloc >
__BSB_pos_type__ basic_stringbuf< _CharT, _Traits, _Alloc >::seekoff ( off_type  __off,
ios_base::seekdir  __dir,
ios_base::openmode  __mode = ios_base::in | ios_base::out 
)
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 300 of file _sstream.c.

302  {
303  __mode &= _M_mode;
304 
305  bool __imode = (__mode & ios_base::in) != 0;
306  bool __omode = (__mode & ios_base::out) != 0;
307 
308  if ( !(__imode || __omode) )
309  return pos_type(off_type(-1));
310 
311  if ( (__imode && (this->gptr() == 0)) || (__omode && (this->pptr() == 0)) )
312  return pos_type(off_type(-1));
313 
314  streamoff __newoff;
315  switch(__dir) {
316  case ios_base::beg:
317  __newoff = 0;
318  break;
319  case ios_base::end:
320  __newoff = _M_str.size();
321  break;
322  case ios_base::cur:
323  __newoff = __imode ? this->gptr() - this->eback() : this->pptr() - this->pbase();
324  if ( __off == 0 ) {
325  return pos_type(__newoff);
326  }
327  break;
328  default:
329  return pos_type(off_type(-1));
330  }
331 
332  __off += __newoff;
333 
334  if (__imode) {
335  ptrdiff_t __n = this->egptr() - this->eback();
336 
337  if (__off < 0 || __off > __n)
338  return pos_type(off_type(-1));
339  this->setg(this->eback(), this->eback() + __STATIC_CAST(ptrdiff_t, __off),
340  this->eback() + __STATIC_CAST(ptrdiff_t, __n));
341  }
342 
343  if (__omode) {
344  ptrdiff_t __n = this->epptr() - this->pbase();
345 
346  if (__off < 0 || __off > __n)
347  return pos_type(off_type(-1));
348  this->setp(this->pbase(), this->pbase() + __n);
349  this->pbump((int)__off);
350  }
351 
352  return pos_type(__off);
353 }
off_t streamoff
Definition: char_traits.h:74
char_type * eback() const
Definition: _streambuf.h:87
return __n
Definition: _algo.h:75
char_type * egptr() const
Definition: _streambuf.h:89
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
GLuint GLuint end
Definition: gl.h:1545
char_type * pbase() const
Definition: _streambuf.h:111
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
char_type * pptr() const
Definition: _streambuf.h:112
char_type * epptr() const
Definition: _streambuf.h:113
_String _M_str
Definition: _sstream.h:103
void pbump(int __n)
Definition: _streambuf.h:115
size_type size() const
Definition: _string.h:400
_Traits::off_type off_type
Definition: _sstream.h:60
static FILE * out
Definition: regtests2xml.c:44
ios_base::openmode _M_mode
Definition: _sstream.h:102
_Traits::pos_type pos_type
Definition: _sstream.h:59
char_type * gptr() const
Definition: _streambuf.h:88
GLuint in
Definition: glext.h:9616
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247

◆ seekpos()

template<class _CharT , class _Traits , class _Alloc >
__BSB_pos_type__ basic_stringbuf< _CharT, _Traits, _Alloc >::seekpos ( pos_type  __pos,
ios_base::openmode  __mode = ios_base::in | ios_base::out 
)
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 358 of file _sstream.c.

358  {
359  __mode &= _M_mode;
360 
361  bool __imode = (__mode & ios_base::in) != 0;
362  bool __omode = (__mode & ios_base::out) != 0;
363 
364  if ( !(__imode || __omode) )
365  return pos_type(off_type(-1));
366 
367  if ( (__imode && (this->gptr() == 0)) || (__omode && (this->pptr() == 0)) )
368  return pos_type(off_type(-1));
369 
370  const off_type __n = __pos - pos_type(off_type(0));
371 
372  if (__imode) {
373  if (__n < 0 || __n > this->egptr() - this->eback())
374  return pos_type(off_type(-1));
375  this->setg(this->eback(), this->eback() + __STATIC_CAST(ptrdiff_t, __n), this->egptr());
376  }
377 
378  if (__omode) {
379  if (__n < 0 || size_t(__n) > _M_str.size())
380  return pos_type(off_type(-1));
381 
382  this->setp(_S_start(_M_str), _S_finish(_M_str));
383  this->pbump((int)__n);
384  }
385 
386  return __pos;
387 }
char_type * eback() const
Definition: _streambuf.h:87
return __n
Definition: _algo.h:75
char_type * egptr() const
Definition: _streambuf.h:89
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
char_type * pptr() const
Definition: _streambuf.h:112
_String _M_str
Definition: _sstream.h:103
void pbump(int __n)
Definition: _streambuf.h:115
size_type size() const
Definition: _string.h:400
_Traits::off_type off_type
Definition: _sstream.h:60
static _CharT * _S_start(const _String &__str)
Definition: _sstream.h:98
static _CharT * _S_finish(const _String &__str)
Definition: _sstream.h:99
static FILE * out
Definition: regtests2xml.c:44
ios_base::openmode _M_mode
Definition: _sstream.h:102
_Traits::pos_type pos_type
Definition: _sstream.h:59
char_type * gptr() const
Definition: _streambuf.h:88
GLuint in
Definition: glext.h:9616
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247

◆ setbuf()

template<class _CharT , class _Traits , class _Alloc >
basic_streambuf< _CharT, _Traits > * basic_stringbuf< _CharT, _Traits, _Alloc >::setbuf ( _CharT *  __buf,
streamsize  __n 
)
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 262 of file _sstream.c.

262  {
263  if (__n > 0) {
264  bool __do_get_area = false;
265  bool __do_put_area = false;
266  ptrdiff_t __offg = 0;
267  ptrdiff_t __offp = 0;
268 
269  if (this->pbase() == _S_start(_M_str)) {
270  __do_put_area = true;
271  __offp = this->pptr() - this->pbase();
272  }
273 
274  if (this->eback() == _S_start(_M_str)) {
275  __do_get_area = true;
276  __offg = this->gptr() - this->eback();
277  }
278 
279  _M_str.reserve(sizeof(streamsize) > sizeof(size_t) ? __STATIC_CAST(size_t, (min)(__n, __STATIC_CAST(streamsize, _M_str.max_size())))
280  : __STATIC_CAST(size_t, __n));
281 
282  _CharT* __data_ptr = _S_start(_M_str);
283 
284  if (__do_get_area) {
285  this->setg(__data_ptr, __data_ptr + __offg, _S_finish(_M_str));
286  }
287 
288  if (__do_put_area) {
289  this->setp(__data_ptr, _S_finish(_M_str));
290  this->pbump((int)__offp);
291  }
292  }
293 
294  return this;
295 }
char_type * eback() const
Definition: _streambuf.h:87
return __n
Definition: _algo.h:75
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
char_type * pbase() const
Definition: _streambuf.h:111
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
char_type * pptr() const
Definition: _streambuf.h:112
_String _M_str
Definition: _sstream.h:103
void pbump(int __n)
Definition: _streambuf.h:115
static _CharT * _S_start(const _String &__str)
Definition: _sstream.h:98
static _CharT * _S_finish(const _String &__str)
Definition: _sstream.h:99
char_type * gptr() const
Definition: _streambuf.h:88
#define min(a, b)
Definition: monoChain.cc:55
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
ptrdiff_t streamsize
Definition: char_traits.h:81
void reserve(size_type=0)
Definition: _string.c:158
size_type max_size() const
Definition: _string.h:402

◆ str() [1/2]

template<class _CharT, class _Traits, class _Alloc>
_String basic_stringbuf< _CharT, _Traits, _Alloc >::str ( ) const
inline

Definition at line 75 of file _sstream.h.

75 { return _M_str; }
_String _M_str
Definition: _sstream.h:103

◆ str() [2/2]

template<class _CharT , class _Traits , class _Alloc >
void basic_stringbuf< _CharT, _Traits, _Alloc >::str ( const _String __s)

Definition at line 64 of file _sstream.c.

65 {
66  _M_str = __s;
67  _M_set_ptrs();
68 }
_String _M_str
Definition: _sstream.h:103
void _M_set_ptrs()
Definition: _sstream.c:72

◆ uflow()

template<class _CharT , class _Traits , class _Alloc >
__BSB_int_type__ basic_stringbuf< _CharT, _Traits, _Alloc >::uflow ( )
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 105 of file _sstream.c.

105  {
106  if (this->gptr() != this->egptr()) {
107  int_type __c = _Traits::to_int_type(*this->gptr());
108  this->gbump(1);
109  return __c;
110  }
111  else
112  return _Traits::eof();
113 }
void gbump(int __n)
Definition: _streambuf.h:91
char_type * egptr() const
Definition: _streambuf.h:89
#define __c
Definition: schilyio.h:209
_Traits::int_type int_type
Definition: _sstream.h:58
char_type * gptr() const
Definition: _streambuf.h:88
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)

◆ underflow()

template<class _CharT , class _Traits , class _Alloc >
__BSB_int_type__ basic_stringbuf< _CharT, _Traits, _Alloc >::underflow ( )
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 96 of file _sstream.c.

96  {
97  return this->gptr() != this->egptr()
98  ? _Traits::to_int_type(*this->gptr())
99  : _Traits::eof();
100 }
char_type * egptr() const
Definition: _streambuf.h:89
char_type * gptr() const
Definition: _streambuf.h:88
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)

◆ xsputn()

template<class _CharT , class _Traits , class _Alloc >
streamsize basic_stringbuf< _CharT, _Traits, _Alloc >::xsputn ( const char_type __s,
streamsize  __n 
)
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 170 of file _sstream.c.

171  {
172  streamsize __nwritten = 0;
173 
174  if ((_M_mode & ios_base::out) && __n > 0) {
175  // If the put pointer is somewhere in the middle of the string,
176  // then overwrite instead of append.
177  if ( !_M_str.empty() && this->pbase() == _S_start(_M_str)) {
178  ptrdiff_t __avail = _S_finish(_M_str) - this->pptr();
179  if (__avail > __n) {
180  _Traits::copy(this->pptr(), __s, __STATIC_CAST(size_t, __n));
181  this->pbump((int)__n);
182  return __n;
183  } else {
184  _Traits::copy(this->pptr(), __s, __avail);
185  __nwritten += __avail;
186  __n -= __avail;
187  __s += __avail;
188  }
189  }
190 
191  // At this point we know we're appending.
192  _CharT* __data_ptr;
193  if (_M_mode & ios_base::in) {
194  ptrdiff_t __get_offset = this->gptr() - this->eback();
195  _M_str.append(__s, __s + __STATIC_CAST(ptrdiff_t, __n));
196  __data_ptr = _S_start(_M_str);
197  this->setg(__data_ptr, __data_ptr + __get_offset, _S_finish(_M_str));
198  } else {
199  _M_str.append(__s, __s + __STATIC_CAST(ptrdiff_t, __n));
200  __data_ptr = _S_start(_M_str);
201  }
202 
203  this->setp(__data_ptr, _S_finish(_M_str));
204  this->pbump((int)_M_str.size());
205  __nwritten += __n;
206  }
207 
208  return __nwritten;
209 }
char_type * eback() const
Definition: _streambuf.h:87
return __n
Definition: _algo.h:75
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
char_type * pbase() const
Definition: _streambuf.h:111
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
char_type * pptr() const
Definition: _streambuf.h:112
_String _M_str
Definition: _sstream.h:103
void pbump(int __n)
Definition: _streambuf.h:115
size_type size() const
Definition: _string.h:400
bool empty() const
Definition: _string.h:428
static _CharT * _S_start(const _String &__str)
Definition: _sstream.h:98
static _CharT * _S_finish(const _String &__str)
Definition: _sstream.h:99
static FILE * out
Definition: regtests2xml.c:44
_Self & append(const _CharT *__first, const _CharT *__last)
Definition: _string.h:509
ios_base::openmode _M_mode
Definition: _sstream.h:102
char_type * gptr() const
Definition: _streambuf.h:88
GLuint in
Definition: glext.h:9616
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
ptrdiff_t streamsize
Definition: char_traits.h:81

Member Data Documentation

◆ _M_mode

template<class _CharT, class _Traits, class _Alloc>
ios_base::openmode basic_stringbuf< _CharT, _Traits, _Alloc >::_M_mode
private

Definition at line 102 of file _sstream.h.

◆ _M_str

template<class _CharT, class _Traits, class _Alloc>
_String basic_stringbuf< _CharT, _Traits, _Alloc >::_M_str
private

Definition at line 103 of file _sstream.h.

Referenced by basic_stringbuf< _CharT, _Traits, _Alloc >::str().


The documentation for this class was generated from the following files: