STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
basic_stringbuf< _Elem, _Traits, _Alloc > Class Template Reference
Inheritance diagram for basic_stringbuf< _Elem, _Traits, _Alloc >:
basic_streambuf< _Elem, _Traits >

Public Types

enum  {
  _Allocated = 1, _Constant = 2, _Noread = 4, _Append = 8,
  _Atend = 16
}
 
typedef basic_stringbuf< _Elem, _Traits, _Alloc > _Myt
 
typedef _Alloc allocator_type
 
typedef basic_streambuf< _Elem, _Traits > _Mysb
 
typedef basic_string< _Elem, _Traits, _Alloc > _Mystr
 
typedef int _Strstate
 
typedef _Traits::int_type int_type
 
typedef _Traits::pos_type pos_type
 
typedef _Traits::off_type off_type
 
- Public Types inherited from basic_streambuf< _Elem, _Traits >
typedef _Elem char_type
 
typedef _Traits traits_type
 
typedef _Traits::int_type int_type
 
typedef _Traits::pos_type pos_type
 
typedef _Traits::off_type off_type
 

Public Member Functions

 basic_stringbuf (ios_base::openmode _Mode=ios_base::in|ios_base::out)
 
 basic_stringbuf (const _Mystr &_Str, ios_base::openmode _Mode=ios_base::in|ios_base::out)
 
 basic_stringbuf (_Myt &&_Right)
 
_Mytoperator= (_Myt &&_Right)
 
void _Assign_rv (_Myt &&_Right)
 
void swap (_Myt &_Right)
 
 basic_stringbuf (const _Myt &)=delete
 
_Mytoperator= (const _Myt &)=delete
 
virtual ~basic_stringbuf () _NOEXCEPT
 
_Mystr str () const
 
void str (const _Mystr &_Newstr)
 
- Public Member Functions inherited from basic_streambuf< _Elem, _Traits >
virtual __CLR_OR_THIS_CALL ~basic_streambuf () _NOEXCEPT
 
pos_type __CLR_OR_THIS_CALL pubseekoff (off_type _Off, ios_base::seekdir _Way, ios_base::openmode _Mode=ios_base::in|ios_base::out)
 
pos_type __CLR_OR_THIS_CALL pubseekoff (off_type _Off, ios_base::seek_dir _Way, ios_base::open_mode _Mode)
 
pos_type __CLR_OR_THIS_CALL pubseekpos (pos_type _Pos, ios_base::openmode _Mode=ios_base::in|ios_base::out)
 
pos_type __CLR_OR_THIS_CALL pubseekpos (pos_type _Pos, ios_base::open_mode _Mode)
 
_Myt *__CLR_OR_THIS_CALL pubsetbuf (_Elem *_Buffer, streamsize _Count)
 
locale __CLR_OR_THIS_CALL pubimbue (const locale &_Newlocale)
 
locale __CLR_OR_THIS_CALL getloc () const
 
streamsize __CLR_OR_THIS_CALL in_avail ()
 
int __CLR_OR_THIS_CALL pubsync ()
 
int_type __CLR_OR_THIS_CALL sbumpc ()
 
int_type __CLR_OR_THIS_CALL sgetc ()
 
streamsize __CLR_OR_THIS_CALL sgetn (_Elem *_Ptr, streamsize _Count)
 
int_type __CLR_OR_THIS_CALL snextc ()
 
int_type __CLR_OR_THIS_CALL sputbackc (_Elem _Ch)
 
void __CLR_OR_THIS_CALL stossc ()
 
int_type __CLR_OR_THIS_CALL sungetc ()
 
int_type __CLR_OR_THIS_CALL sputc (_Elem _Ch)
 
streamsize __CLR_OR_THIS_CALL sputn (const _Elem *_Ptr, streamsize _Count)
 
virtual void __CLR_OR_THIS_CALL _Lock ()
 
virtual void __CLR_OR_THIS_CALL _Unlock ()
 

Protected Member Functions

virtual int_type overflow (int_type _Meta=_Traits::eof())
 
virtual int_type pbackfail (int_type _Meta=_Traits::eof())
 
virtual int_type underflow ()
 
virtual pos_type seekoff (off_type _Off, ios_base::seekdir _Way, ios_base::openmode _Which=ios_base::in|ios_base::out)
 
virtual pos_type seekpos (pos_type _Ptr, ios_base::openmode _Mode=ios_base::in|ios_base::out)
 
void _Init (const _Elem *_Ptr, size_t _Count, _Strstate _State)
 
void _Tidy ()
 
- Protected Member Functions inherited from basic_streambuf< _Elem, _Traits >
__CLR_OR_THIS_CALL basic_streambuf ()
 
__CLR_OR_THIS_CALL basic_streambuf (_Uninitialized)
 
__CLR_OR_THIS_CALL basic_streambuf (const _Myt &_Right)
 
_Myt &__CLR_OR_THIS_CALL operator= (const _Myt &_Right)
 
void __CLR_OR_THIS_CALL swap (_Myt &_Right)
 
_Elem *__CLR_OR_THIS_CALL eback () const
 
_Elem *__CLR_OR_THIS_CALL gptr () const
 
_Elem *__CLR_OR_THIS_CALL pbase () const
 
_Elem *__CLR_OR_THIS_CALL pptr () const
 
_Elem *__CLR_OR_THIS_CALL egptr () const
 
void __CLR_OR_THIS_CALL gbump (int _Off)
 
void __CLR_OR_THIS_CALL setg (_Elem *_First, _Elem *_Next, _Elem *_Last)
 
_Elem *__CLR_OR_THIS_CALL epptr () const
 
_Elem *__CLR_OR_THIS_CALL _Gndec ()
 
_Elem *__CLR_OR_THIS_CALL _Gninc ()
 
_Elem *__CLR_OR_THIS_CALL _Gnpreinc ()
 
streamsize __CLR_OR_THIS_CALL _Gnavail () const
 
void __CLR_OR_THIS_CALL pbump (int _Off)
 
void __CLR_OR_THIS_CALL setp (_Elem *_First, _Elem *_Last)
 
void __CLR_OR_THIS_CALL setp (_Elem *_First, _Elem *_Next, _Elem *_Last)
 
_Elem *__CLR_OR_THIS_CALL _Pninc ()
 
streamsize __CLR_OR_THIS_CALL _Pnavail () const
 
void __CLR_OR_THIS_CALL _Init ()
 
void __CLR_OR_THIS_CALL _Init (_Elem **_Gf, _Elem **_Gn, int *_Gc, _Elem **_Pf, _Elem **_Pn, int *_Pc)
 
virtual streamsize __CLR_OR_THIS_CALL showmanyc ()
 
virtual int_type __CLR_OR_THIS_CALL uflow ()
 
virtual streamsize __CLR_OR_THIS_CALL xsgetn (_Elem *_Ptr, streamsize _Count)
 
virtual streamsize __CLR_OR_THIS_CALL xsputn (const _Elem *_Ptr, streamsize _Count)
 
virtual _Myt *__CLR_OR_THIS_CALL setbuf (_Elem *, streamsize)
 
virtual int __CLR_OR_THIS_CALL sync ()
 
virtual void __CLR_OR_THIS_CALL imbue (const locale &)
 

Private Types

enum  { _MINSIZE = 32 }
 

Private Member Functions

_Strstate _Getstate (ios_base::openmode _Mode)
 

Private Attributes

_Elem * _Seekhigh
 
_Strstate _Mystate
 
allocator_type _Al
 

Additional Inherited Members

- Protected Attributes inherited from basic_streambuf< _Elem, _Traits >
locale_Plocale
 

Member Typedef Documentation

template<class _Elem, class _Traits, class _Alloc>
typedef basic_streambuf<_Elem, _Traits> basic_stringbuf< _Elem, _Traits, _Alloc >::_Mysb
template<class _Elem, class _Traits, class _Alloc>
typedef basic_string<_Elem, _Traits, _Alloc> basic_stringbuf< _Elem, _Traits, _Alloc >::_Mystr
template<class _Elem, class _Traits, class _Alloc>
typedef basic_stringbuf<_Elem, _Traits, _Alloc> basic_stringbuf< _Elem, _Traits, _Alloc >::_Myt
template<class _Elem, class _Traits, class _Alloc>
typedef int basic_stringbuf< _Elem, _Traits, _Alloc >::_Strstate
template<class _Elem, class _Traits, class _Alloc>
typedef _Alloc basic_stringbuf< _Elem, _Traits, _Alloc >::allocator_type
template<class _Elem, class _Traits, class _Alloc>
typedef _Traits::int_type basic_stringbuf< _Elem, _Traits, _Alloc >::int_type
template<class _Elem, class _Traits, class _Alloc>
typedef _Traits::off_type basic_stringbuf< _Elem, _Traits, _Alloc >::off_type
template<class _Elem, class _Traits, class _Alloc>
typedef _Traits::pos_type basic_stringbuf< _Elem, _Traits, _Alloc >::pos_type

Member Enumeration Documentation

template<class _Elem, class _Traits, class _Alloc>
anonymous enum
Enumerator
_Allocated 
_Constant 
_Noread 
_Append 
_Atend 
80  { // constants for bits in stream state
81  _Allocated = 1, // set if character array storage has been allocated
82  _Constant = 2, // set if character array nonmutable
83  _Noread = 4, // set if character array cannot be read
84  _Append = 8, // set if all writes are appends
85  _Atend = 16}; // set if initial writes are appends
Definition: sstream:84
Definition: sstream:85
Definition: sstream:81
Definition: sstream:82
Definition: sstream:83
template<class _Elem, class _Traits, class _Alloc>
anonymous enum
private
Enumerator
_MINSIZE 
350  { // constant for minimum buffer size
351  _MINSIZE = 32};
Definition: sstream:351

Constructor & Destructor Documentation

template<class _Elem, class _Traits, class _Alloc>
basic_stringbuf< _Elem, _Traits, _Alloc >::basic_stringbuf ( ios_base::openmode  _Mode = ios_base::in | ios_base::out)
inlineexplicit
30  { // construct empty character buffer from mode
31  _Init(0, 0, _Getstate(_Mode));
32  }
_Check_return_ _In_ int _Mode
Definition: io.h:338
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:311
_Strstate _Getstate(ios_base::openmode _Mode)
Definition: sstream:353
template<class _Elem, class _Traits, class _Alloc>
basic_stringbuf< _Elem, _Traits, _Alloc >::basic_stringbuf ( const _Mystr _Str,
ios_base::openmode  _Mode = ios_base::in | ios_base::out 
)
inlineexplicit
36  { // construct character buffer from string, mode
37  _Init(_Str.c_str(), _Str.size(), _Getstate(_Mode));
38  }
_Check_return_ _In_ int _Mode
Definition: io.h:338
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:311
_Strstate _Getstate(ios_base::openmode _Mode)
Definition: sstream:353
template<class _Elem, class _Traits, class _Alloc>
basic_stringbuf< _Elem, _Traits, _Alloc >::basic_stringbuf ( _Myt &&  _Right)
inline
41  { // construct by moving _Right
42  _Assign_rv(_STD forward<_Myt>(_Right));
43  }
void _Assign_rv(_Myt &&_Right)
Definition: sstream:51
const _Ty & _Right
Definition: algorithm:4087
template<class _Elem, class _Traits, class _Alloc>
basic_stringbuf< _Elem, _Traits, _Alloc >::basic_stringbuf ( const _Myt )
delete
template<class _Elem, class _Traits, class _Alloc>
virtual basic_stringbuf< _Elem, _Traits, _Alloc >::~basic_stringbuf ( )
inlinevirtual
75  { // destroy the object
76  _Tidy();
77  }
void _Tidy()
Definition: sstream:336

Member Function Documentation

template<class _Elem, class _Traits, class _Alloc>
void basic_stringbuf< _Elem, _Traits, _Alloc >::_Assign_rv ( _Myt &&  _Right)
inline
52  { // assign by moving _Right
53  if (this != &_Right)
54  { // different, worth moving
55  _Tidy();
56  this->swap(_Right);
57  }
58  }
void swap(_Myt &_Right)
Definition: sstream:60
void _Tidy()
Definition: sstream:336
const _Ty & _Right
Definition: algorithm:4087
template<class _Elem, class _Traits, class _Alloc>
_Strstate basic_stringbuf< _Elem, _Traits, _Alloc >::_Getstate ( ios_base::openmode  _Mode)
inlineprivate
354  { // convert open mode to stream state bits
355  _Strstate _State = (_Strstate)0;
356  if (!(_Mode & ios_base::in))
357  _State |= _Noread;
358  if (!(_Mode & ios_base::out))
359  _State |= _Constant;
360  if (_Mode & ios_base::app)
361  _State |= _Append;
362  if (_Mode & ios_base::ate)
363  _State |= _Atend;
364  return (_State);
365  }
static const _Openmode out
Definition: xiosbase:98
_Check_return_ _In_ int _Mode
Definition: io.h:338
Definition: sstream:84
Definition: sstream:85
static const _Openmode ate
Definition: xiosbase:99
static const _Openmode in
Definition: xiosbase:97
static const _Openmode app
Definition: xiosbase:100
Definition: sstream:82
int _Strstate
Definition: sstream:86
Definition: sstream:83
template<class _Elem, class _Traits, class _Alloc>
void basic_stringbuf< _Elem, _Traits, _Alloc >::_Init ( const _Elem *  _Ptr,
size_t  _Count,
_Strstate  _State 
)
inlineprotected
310  { // initialize buffer to [_Ptr, _Ptr + _Count), set state
311  _Seekhigh = 0;
312  _Mystate = _State;
313 
314  if (_Count != 0
315  && (_Mystate & (_Noread | _Constant)) != (_Noread | _Constant))
316  { // finite buffer that can be read or written, set it up
317  _Elem *_Pnew = _Al.allocate(_Count);
318  _Traits::copy(_Pnew, _Ptr, _Count);
319  _Seekhigh = _Pnew + _Count;
320 
321  if (!(_Mystate & _Noread))
322  _Mysb::setg(_Pnew, _Pnew,
323  _Pnew + _Count); // setup read buffer
324  if (!(_Mystate & _Constant))
325  { // setup write buffer, and maybe read buffer
326  _Mysb::setp(_Pnew,
327  (_Mystate & (_Atend | _Append)) ? _Pnew + _Count : _Pnew,
328  _Pnew + _Count);
329  if (_Mysb::gptr() == 0)
330  _Mysb::setg(_Pnew, 0, _Pnew);
331  }
332  _Mystate |= _Allocated;
333  }
334  }
_OutIt copy(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2072
void __CLR_OR_THIS_CALL setg(_Elem *_First, _Elem *_Next, _Elem *_Last)
Definition: streambuf:245
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:219
Definition: sstream:84
_Strstate _Mystate
Definition: sstream:368
allocator_type _Al
Definition: sstream:369
void __CLR_OR_THIS_CALL setp(_Elem *_First, _Elem *_Last)
Definition: streambuf:286
Definition: sstream:85
_Diff _Count
Definition: algorithm:1941
_Elem * _Seekhigh
Definition: sstream:367
Definition: sstream:81
Definition: sstream:82
Definition: sstream:83
template<class _Elem, class _Traits, class _Alloc>
void basic_stringbuf< _Elem, _Traits, _Alloc >::_Tidy ( )
inlineprotected
337  { // discard any allocated buffer and clear pointers
338  if (_Mystate & _Allocated)
339  _Al.deallocate(_Mysb::eback(),
340  (_Mysb::pptr() != 0 ? _Mysb::epptr()
341  : _Mysb::egptr()) - _Mysb::eback());
342  _Mysb::setg(0, 0, 0);
343  _Mysb::setp(0, 0);
344  _Seekhigh = 0;
345  _Mystate &= ~_Allocated;
346  }
_Elem *__CLR_OR_THIS_CALL egptr() const
Definition: streambuf:234
void __CLR_OR_THIS_CALL setg(_Elem *_First, _Elem *_Next, _Elem *_Last)
Definition: streambuf:245
_Elem *__CLR_OR_THIS_CALL epptr() const
Definition: streambuf:252
_Strstate _Mystate
Definition: sstream:368
_Elem *__CLR_OR_THIS_CALL pptr() const
Definition: streambuf:229
allocator_type _Al
Definition: sstream:369
void __CLR_OR_THIS_CALL setp(_Elem *_First, _Elem *_Last)
Definition: streambuf:286
_Elem * _Seekhigh
Definition: sstream:367
_Elem *__CLR_OR_THIS_CALL eback() const
Definition: streambuf:214
Definition: sstream:81
template<class _Elem, class _Traits, class _Alloc>
_Myt& basic_stringbuf< _Elem, _Traits, _Alloc >::operator= ( _Myt &&  _Right)
inline
46  { // assign from _Right
47  _Assign_rv(_STD forward<_Myt>(_Right));
48  return (*this);
49  }
void _Assign_rv(_Myt &&_Right)
Definition: sstream:51
const _Ty & _Right
Definition: algorithm:4087
template<class _Elem, class _Traits, class _Alloc>
_Myt& basic_stringbuf< _Elem, _Traits, _Alloc >::operator= ( const _Myt )
delete
template<class _Elem, class _Traits, class _Alloc>
virtual int_type basic_stringbuf< _Elem, _Traits, _Alloc >::overflow ( int_type  _Meta = _Traits::eof())
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

120  { // put an element to stream
121  if (_Mystate & _Constant)
122  return (_Traits::eof()); // array nonmutable, fail
123  else if (_Traits::eq_int_type(_Traits::eof(), _Meta))
124  return (_Traits::not_eof(_Meta)); // EOF, return success code
125 
126  if (_Mystate & _Append
127  && _Mysb::pptr() != 0 && _Mysb::pptr() < _Seekhigh)
129 
130  if (_Mysb::pptr() != 0
131  && _Mysb::pptr() < _Mysb::epptr())
132  { // room in buffer, store it
133  *_Mysb::_Pninc() = _Traits::to_char_type(_Meta);
134  return (_Meta);
135  }
136  else
137  { // grow buffer and store element
138  size_t _Oldsize = _Mysb::pptr() == 0
139  ? 0 : _Mysb::epptr() - _Mysb::eback();
140  size_t _Newsize = _Oldsize;
141  size_t _Inc = _Newsize / 2 < _MINSIZE
142  ? _MINSIZE : _Newsize / 2; // grow by 50 per cent
143 
144  while (0 < _Inc && INT_MAX - _Inc < _Newsize)
145  _Inc /= 2; // increment causes overflow, halve it
146  if (_Inc == 0)
147  return (_Traits::eof()); // buffer can't grow, fail
148 
149  _Newsize += _Inc;
150 
151  _Elem *_Newptr = _Al.allocate(_Newsize);
152  _Elem *_Oldptr = _Mysb::eback();
153 
154  if (0 < _Oldsize)
155  _Traits::copy(_Newptr, _Oldptr, _Oldsize);
156 
157  if (_Oldsize == 0)
158  { // first growth, set up pointers
159  _Seekhigh = _Newptr;
160  _Mysb::setp(_Newptr, _Newptr + _Newsize);
161  if (_Mystate & _Noread)
162  _Mysb::setg(_Newptr, 0, _Newptr);
163  else
164  _Mysb::setg(_Newptr, _Newptr, _Newptr + 1);
165  }
166  else
167  { // not first growth, adjust pointers
168  _Seekhigh = _Newptr + (_Seekhigh - _Oldptr);
169  _Mysb::setp(_Newptr + (_Mysb::pbase() - _Oldptr),
170  _Newptr + (_Mysb::pptr() - _Oldptr),
171  _Newptr + _Newsize);
172  if (_Mystate & _Noread)
173  _Mysb::setg(_Newptr, 0, _Newptr);
174  else
175  _Mysb::setg(_Newptr,
176  _Newptr + (_Mysb::gptr() - _Oldptr),
177  _Mysb::pptr() + 1);
178  }
179 
180  if (_Mystate & _Allocated)
181  _Al.deallocate(_Oldptr, _Oldsize);
182  _Mystate |= _Allocated;
183 
184  *_Mysb::_Pninc() = _Traits::to_char_type(_Meta);
185  return (_Meta);
186  }
187  }
_OutIt copy(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2072
void __CLR_OR_THIS_CALL setg(_Elem *_First, _Elem *_Next, _Elem *_Last)
Definition: streambuf:245
Definition: sstream:351
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:219
Definition: sstream:84
_Elem *__CLR_OR_THIS_CALL epptr() const
Definition: streambuf:252
_Strstate _Mystate
Definition: sstream:368
_Elem *__CLR_OR_THIS_CALL pptr() const
Definition: streambuf:229
allocator_type _Al
Definition: sstream:369
void __CLR_OR_THIS_CALL setp(_Elem *_First, _Elem *_Last)
Definition: streambuf:286
_Elem *__CLR_OR_THIS_CALL pbase() const
Definition: streambuf:224
_Elem *__CLR_OR_THIS_CALL _Pninc()
Definition: streambuf:300
_Elem * _Seekhigh
Definition: sstream:367
_Elem *__CLR_OR_THIS_CALL eback() const
Definition: streambuf:214
Definition: sstream:81
#define INT_MAX
Definition: limits.h:40
Definition: sstream:82
Definition: sstream:83
template<class _Elem, class _Traits, class _Alloc>
virtual int_type basic_stringbuf< _Elem, _Traits, _Alloc >::pbackfail ( int_type  _Meta = _Traits::eof())
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

190  { // put an element back to stream
191  if (_Mysb::gptr() == 0
192  || _Mysb::gptr() <= _Mysb::eback()
193  || (!_Traits::eq_int_type(_Traits::eof(), _Meta)
194  && !_Traits::eq(_Traits::to_char_type(_Meta), _Mysb::gptr()[-1])
195  && _Mystate & _Constant))
196  return (_Traits::eof()); // can't put back, fail
197  else
198  { // back up one position and store put-back character
199  _Mysb::gbump(-1);
200  if (!_Traits::eq_int_type(_Traits::eof(), _Meta))
201  *_Mysb::gptr() = _Traits::to_char_type(_Meta);
202  return (_Traits::not_eof(_Meta));
203  }
204  }
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:219
_Strstate _Mystate
Definition: sstream:368
void __CLR_OR_THIS_CALL gbump(int _Off)
Definition: streambuf:239
_Elem *__CLR_OR_THIS_CALL eback() const
Definition: streambuf:214
Definition: sstream:82
template<class _Elem, class _Traits, class _Alloc>
virtual pos_type basic_stringbuf< _Elem, _Traits, _Alloc >::seekoff ( off_type  _Off,
ios_base::seekdir  _Way,
ios_base::openmode  _Which = ios_base::in | ios_base::out 
)
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

227  { // change position by _Off, according to _Way, _Mode
228  if (_Mysb::pptr() != 0 && _Seekhigh < _Mysb::pptr())
229  _Seekhigh = _Mysb::pptr(); // update high-water pointer
230 
231  if (_Which & ios_base::in && _Mysb::gptr() != 0)
232  { // position within read buffer
233  if (_Way == ios_base::end)
234  _Off += (off_type)(_Seekhigh - _Mysb::eback());
235  else if (_Way == ios_base::cur
236  && (_Which & ios_base::out) == 0)
237  _Off += (off_type)(_Mysb::gptr() - _Mysb::eback());
238  else if (_Way != ios_base::beg)
239  _Off = _BADOFF;
240 
241  if (0 <= _Off && _Off <= _Seekhigh - _Mysb::eback())
242  { // change read position
243  _Mysb::gbump((int)(_Mysb::eback() - _Mysb::gptr() + _Off));
244  if (_Which & ios_base::out && _Mysb::pptr() != 0)
246  _Mysb::epptr()); // change write position to match
247  }
248  else
249  _Off = _BADOFF;
250  }
251  else if (_Which & ios_base::out && _Mysb::pptr() != 0)
252  { // position within write buffer
253  if (_Way == ios_base::end)
254  _Off += (off_type)(_Seekhigh - _Mysb::eback());
255  else if (_Way == ios_base::cur)
256  _Off += (off_type)(_Mysb::pptr() - _Mysb::eback());
257  else if (_Way != ios_base::beg)
258  _Off = _BADOFF;
259 
260  if (0 <= _Off && _Off <= _Seekhigh - _Mysb::eback())
261  _Mysb::pbump((int)(_Mysb::eback()
262  - _Mysb::pptr() + _Off)); // change write position
263  else
264  _Off = _BADOFF;
265  }
266 
267  else if (_Off != 0)
268 
269 
270  _Off = _BADOFF; // neither read nor write buffer selected, fail
271  return (pos_type(_Off));
272  }
static const _Seekdir cur
Definition: xiosbase:111
static const _Openmode out
Definition: xiosbase:98
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:219
void __CLR_OR_THIS_CALL pbump(int _Off)
Definition: streambuf:280
_Elem *__CLR_OR_THIS_CALL epptr() const
Definition: streambuf:252
_Elem *__CLR_OR_THIS_CALL pptr() const
Definition: streambuf:229
static const _Seekdir beg
Definition: xiosbase:110
void __CLR_OR_THIS_CALL setp(_Elem *_First, _Elem *_Last)
Definition: streambuf:286
static const _Seekdir end
Definition: xiosbase:112
_Traits::off_type off_type
Definition: sstream:90
_Elem *__CLR_OR_THIS_CALL pbase() const
Definition: streambuf:224
_Traits::pos_type pos_type
Definition: sstream:89
void __CLR_OR_THIS_CALL gbump(int _Off)
Definition: streambuf:239
_CRTDATA2 _PGLOBAL const streamoff _BADOFF
_Elem * _Seekhigh
Definition: sstream:367
_Elem *__CLR_OR_THIS_CALL eback() const
Definition: streambuf:214
static const _Openmode in
Definition: xiosbase:97
template<class _Elem, class _Traits, class _Alloc>
virtual pos_type basic_stringbuf< _Elem, _Traits, _Alloc >::seekpos ( pos_type  _Ptr,
ios_base::openmode  _Mode = ios_base::in | ios_base::out 
)
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

276  { // change position to _Pos, according to _Mode
277  streamoff _Off = (streamoff)_Ptr;
278  if (_Mysb::pptr() != 0 && _Seekhigh < _Mysb::pptr())
279  _Seekhigh = _Mysb::pptr(); // update high-water pointer
280 
281  if (_Off == _BADOFF)
282  ;
283  else if (_Mode & ios_base::in && _Mysb::gptr() != 0)
284  { // position within read buffer
285  if (0 <= _Off && _Off <= _Seekhigh - _Mysb::eback())
286  { // change read position
287  _Mysb::gbump((int)(_Mysb::eback() - _Mysb::gptr() + _Off));
288  if (_Mode & ios_base::out && _Mysb::pptr() != 0)
290  _Mysb::epptr()); // change write position to match
291  }
292  else
293  _Off = _BADOFF;
294  }
295  else if (_Mode & ios_base::out && _Mysb::pptr() != 0)
296  { // position within write buffer
297  if (0 <= _Off && _Off <= _Seekhigh - _Mysb::eback())
298  _Mysb::pbump((int)(_Mysb::eback()
299  - _Mysb::pptr() + _Off)); // change write position
300  else
301  _Off = _BADOFF;
302  }
303  else
304  _Off = _BADOFF; // neither read nor write buffer selected, fail
305  return (streampos(_Off));
306  }
static const _Openmode out
Definition: xiosbase:98
_STD_BEGIN typedef _Longlong streamoff
Definition: iosfwd:21
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:219
_Check_return_ _In_ int _Mode
Definition: io.h:338
void __CLR_OR_THIS_CALL pbump(int _Off)
Definition: streambuf:280
_Elem *__CLR_OR_THIS_CALL epptr() const
Definition: streambuf:252
_Elem *__CLR_OR_THIS_CALL pptr() const
Definition: streambuf:229
void __CLR_OR_THIS_CALL setp(_Elem *_First, _Elem *_Last)
Definition: streambuf:286
_Elem *__CLR_OR_THIS_CALL pbase() const
Definition: streambuf:224
fpos< _Mbstatet > streampos
Definition: iosfwd:126
void __CLR_OR_THIS_CALL gbump(int _Off)
Definition: streambuf:239
_CRTDATA2 _PGLOBAL const streamoff _BADOFF
_Elem * _Seekhigh
Definition: sstream:367
_Elem *__CLR_OR_THIS_CALL eback() const
Definition: streambuf:214
static const _Openmode in
Definition: xiosbase:97
template<class _Elem, class _Traits, class _Alloc>
_Mystr basic_stringbuf< _Elem, _Traits, _Alloc >::str ( ) const
inline
93  { // return string copy of character array
94  if (!(_Mystate & _Constant) && _Mysb::pptr() != 0)
95  { // writable, make string from write buffer
98  return (_Str);
99  }
100  else if (!(_Mystate & _Noread) && _Mysb::gptr() != 0)
101  { // readable, make string from read buffer
103  return (_Str);
104  }
105  else
106  { // inaccessible, return empty string
107  _Mystr _Nul;
108  return (_Nul);
109  }
110  }
_Elem *__CLR_OR_THIS_CALL egptr() const
Definition: streambuf:234
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:219
_Strstate _Mystate
Definition: sstream:368
_Elem *__CLR_OR_THIS_CALL pptr() const
Definition: streambuf:229
basic_string< _Elem, _Traits, _Alloc > _Mystr
Definition: sstream:26
_Elem *__CLR_OR_THIS_CALL pbase() const
Definition: streambuf:224
_Elem * _Seekhigh
Definition: sstream:367
_Elem *__CLR_OR_THIS_CALL eback() const
Definition: streambuf:214
Definition: sstream:82
Definition: sstream:83
template<class _Elem, class _Traits, class _Alloc>
void basic_stringbuf< _Elem, _Traits, _Alloc >::str ( const _Mystr _Newstr)
inline
113  { // replace character array from string
114  _Tidy();
115  _Init(_Newstr.c_str(), _Newstr.size(), _Mystate);
116  }
_Strstate _Mystate
Definition: sstream:368
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:311
void _Tidy()
Definition: sstream:336
template<class _Elem, class _Traits, class _Alloc>
void basic_stringbuf< _Elem, _Traits, _Alloc >::swap ( _Myt _Right)
inline
61  { // swap with _Right
62  if (this != &_Right)
63  { // different, worth swapping
65  _STD swap(_Seekhigh, _Right._Seekhigh);
66  _STD swap(_Mystate, _Right._Mystate);
67  _Swap_adl(_Al, _Right._Al);
68  }
69  }
void __CLR_OR_THIS_CALL swap(_Myt &_Right)
Definition: streambuf:53
_Strstate _Mystate
Definition: sstream:368
allocator_type _Al
Definition: sstream:369
void swap(_Myt &_Right)
Definition: sstream:60
_Elem * _Seekhigh
Definition: sstream:367
const _Ty & _Right
Definition: algorithm:4087
template<class _Elem, class _Traits, class _Alloc>
virtual int_type basic_stringbuf< _Elem, _Traits, _Alloc >::underflow ( )
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

207  { // get an element from stream, but don't point past it
208  if (_Mysb::gptr() == 0)
209  return (_Traits::eof()); // no character buffer, fail
210  else if (_Mysb::gptr() < _Mysb::egptr())
211  return (_Traits::to_int_type(*_Mysb::gptr())); // return buffered
212  else if (_Mystate & _Noread || _Mysb::pptr() == 0
213  || (_Mysb::pptr() <= _Mysb::gptr() && _Seekhigh <= _Mysb::gptr()))
214  return (_Traits::eof()); // can't read, fail
215  else
216  { // extend read buffer into written area, then return buffered
217  if (_Seekhigh < _Mysb::pptr())
220  return (_Traits::to_int_type(*_Mysb::gptr()));
221  }
222  }
_Elem *__CLR_OR_THIS_CALL egptr() const
Definition: streambuf:234
void __CLR_OR_THIS_CALL setg(_Elem *_First, _Elem *_Next, _Elem *_Last)
Definition: streambuf:245
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:219
_Strstate _Mystate
Definition: sstream:368
_Elem *__CLR_OR_THIS_CALL pptr() const
Definition: streambuf:229
_Elem * _Seekhigh
Definition: sstream:367
_Elem *__CLR_OR_THIS_CALL eback() const
Definition: streambuf:214
Definition: sstream:83

Member Data Documentation

template<class _Elem, class _Traits, class _Alloc>
allocator_type basic_stringbuf< _Elem, _Traits, _Alloc >::_Al
private
template<class _Elem, class _Traits, class _Alloc>
_Strstate basic_stringbuf< _Elem, _Traits, _Alloc >::_Mystate
private
template<class _Elem, class _Traits, class _Alloc>
_Elem* basic_stringbuf< _Elem, _Traits, _Alloc >::_Seekhigh
private

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