ReactOS  0.4.13-dev-563-g0561610
_string_io.h File Reference
#include <stl/_ostream.h>
#include <stl/_istream.h>
#include <stl/_string_io.c>
Include dependency graph for _string_io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<class _CharT , class _Traits , class _Alloc >
_STLP_BEGIN_NAMESPACE basic_ostream< _CharT, _Traits > &_STLP_CALL operator<< (basic_ostream< _CharT, _Traits > &__os, const basic_string< _CharT, _Traits, _Alloc > &__s)
 
template<class _CharT , class _Traits , class _Alloc >
basic_istream< _CharT, _Traits > &_STLP_CALL operator>> (basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__s)
 
template<class _CharT , class _Traits , class _Alloc >
basic_istream< _CharT, _Traits > &_STLP_CALL getline (basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__s, _CharT __delim)
 
template<class _CharT , class _Traits , class _Alloc >
basic_istream< _CharT, _Traits > &_STLP_CALL getline (basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__s)
 

Function Documentation

◆ getline() [1/2]

template<class _CharT , class _Traits , class _Alloc >
basic_istream<_CharT, _Traits>& _STLP_CALL getline ( basic_istream< _CharT, _Traits > &  __is,
basic_string< _CharT, _Traits, _Alloc > &  __s,
_CharT  __delim 
)

Definition at line 133 of file _string_io.c.

135  {
136  typedef basic_istream<_CharT, _Traits> __istream;
137  typedef typename basic_string<_CharT, _Traits, _Alloc>::size_type size_type;
138  size_type __nread = 0;
139  typename basic_istream<_CharT, _Traits>::sentry __sentry(__is, true);
140  if (__sentry) {
141  basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
142  __s.clear();
143 
144  while (__nread < __s.max_size()) {
145  int __c1 = __buf->sbumpc();
146  if (_Traits::eq_int_type(__c1, _Traits::eof())) {
147  __is.setstate(__istream::eofbit);
148  break;
149  }
150  else {
151  ++__nread;
152  _CharT __c = _Traits::to_char_type(__c1);
153  if (!_Traits::eq(__c, __delim))
154  __s.push_back(__c);
155  else
156  break; // Character is extracted but not appended.
157  }
158  }
159  }
160  if (__nread == 0 || __nread >= __s.max_size())
161  __is.setstate(__istream::failbit);
162 
163  return __is;
164 }
basic_streambuf< _CharT, _Traits > * rdbuf() const
Definition: _ios.h:72
void clear()
Definition: _string.h:421
#define eq(received, expected, label, type)
Definition: locale.c:144
#define __c
Definition: schilyio.h:209
int_type sbumpc()
Definition: _streambuf.h:227
_Base::size_type size_type
Definition: _string.h:138
void push_back(_CharT __c)
Definition: _string.h:534
void setstate(iostate __state)
Definition: _ios.h:95
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
size_type max_size() const
Definition: _string.h:402

Referenced by getline().

◆ getline() [2/2]

template<class _CharT , class _Traits , class _Alloc >
basic_istream<_CharT, _Traits>& _STLP_CALL getline ( basic_istream< _CharT, _Traits > &  __is,
basic_string< _CharT, _Traits, _Alloc > &  __s 
)
inline

Definition at line 65 of file _string_io.h.

66  {
67  return getline(__is, __s, __is.widen('\n'));
68 }
_CharT widen(char) const
Definition: _ios.h:150
basic_istream< _CharT, _Traits > &_STLP_CALL getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__s, _CharT __delim)
Definition: _string_io.c:133

◆ operator<<()

template<class _CharT , class _Traits , class _Alloc >
_STLP_BEGIN_NAMESPACE basic_ostream<_CharT, _Traits>& _STLP_CALL operator<< ( basic_ostream< _CharT, _Traits > &  __os,
const basic_string< _CharT, _Traits, _Alloc > &  __s 
)

Definition at line 30 of file _string_io.c.

31  {
32  typedef basic_ostream<_CharT, _Traits> __ostream;
33  typedef typename basic_string<_CharT, _Traits, _Alloc>::size_type size_type;
34 
35  // The hypothesis of this implementation is that size_type is unsigned:
36  _STLP_STATIC_ASSERT(__STATIC_CAST(size_type, -1) > 0)
37 
38  typename __ostream::sentry __sentry(__os);
39  bool __ok = false;
40 
41  if (__sentry) {
42  __ok = true;
43  size_type __n = __s.size();
44  const bool __left = (__os.flags() & __ostream::left) != 0;
45  const streamsize __w = __os.width(0);
46  basic_streambuf<_CharT, _Traits>* __buf = __os.rdbuf();
47 
48  const bool __need_pad = (((sizeof(streamsize) > sizeof(size_t)) && (__STATIC_CAST(streamsize, __n) < __w)) ||
49  ((sizeof(streamsize) <= sizeof(size_t)) && (__n < __STATIC_CAST(size_t, __w))));
50  streamsize __pad_len = __need_pad ? __w - __n : 0;
51 
52  if (!__left)
53  __ok = __stlp_string_fill(__os, __buf, __pad_len);
54 
55  __ok = __ok && (__buf->sputn(__s.data(), streamsize(__n)) == streamsize(__n));
56 
57  if (__left)
58  __ok = __ok && __stlp_string_fill(__os, __buf, __pad_len);
59  }
60 
61  if (!__ok)
62  __os.setstate(__ostream::failbit);
63 
64  return __os;
65 }
return __n
Definition: _algo.h:75
char typename[32]
Definition: main.c:84
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
const _CharT * data() const
Definition: _string.h:950
size_type size() const
Definition: _string.h:400
_STLP_BEGIN_NAMESPACE bool _STLP_CALL __stlp_string_fill(basic_ostream< _CharT, _Traits > &__os, basic_streambuf< _CharT, _Traits > *__buf, streamsize __n)
Definition: _string_io.c:16
_Base::size_type size_type
Definition: _string.h:138
if(!(yy_init))
Definition: macro.lex.yy.c:714
_STLP_STATIC_ASSERT(sizeof(nl_catd_type)<=sizeof(int)) class _STLP_CLASS_DECLSPEC _Catalog_nl_catd_map
GLint left
Definition: glext.h:7726
#define false
Definition: stdbool.h:38
streamsize sputn(const char_type *__s, streamsize __n)
Definition: _streambuf.h:204
ptrdiff_t streamsize
Definition: char_traits.h:81

◆ operator>>()

template<class _CharT , class _Traits , class _Alloc >
basic_istream<_CharT, _Traits>& _STLP_CALL operator>> ( basic_istream< _CharT, _Traits > &  __is,
basic_string< _CharT, _Traits, _Alloc > &  __s 
)