Example #1
0
bool
_M_init(basic_ostream<_CharT, _Traits>& __str) {
  if (__str.good()) {
    // boris : check if this is needed !
    if (!__str.rdbuf())
      __str.setstate(ios_base::badbit);
    if (__str.tie())
      __str.tie()->flush();
    return __str.good();
  } else
    return false;
}
Example #2
0
basic_ostream<_CharT, _Traits>& __STL_CALL
operator<<(basic_ostream<_CharT, _Traits>& __os,
           const basic_string<_CharT,_Traits,_Alloc>& __s)
{

    __STL_USING_VENDOR_STD
    typedef basic_ostream<_CharT, _Traits> __ostream;
    typename __ostream::sentry __sentry(__os);
    bool __ok = false;

    if (__sentry) {
        __ok = true;
        size_t __n = __s.size();
        size_t __pad_len = 0;
        const bool __left = (__os.flags() & __ostream::left) != 0;
        const size_t __w = __os.width(0);
        basic_streambuf<_CharT, _Traits>* __buf = __os.rdbuf();

        if (__w > 0 && __n < __w) {
            __pad_len = __w - __n;
        }

        if (!__left)
            __ok = __sgi_string_fill(__os, __buf, __pad_len);

        __ok = __ok && (__buf->sputn(__s.data(), streamsize(__n)) == streamsize(__n));

        if (__left)
            __ok = __ok && __sgi_string_fill(__os, __buf, __pad_len);
    }

    if (!__ok)
        __os.setstate(__ostream::failbit);

    return __os;
}