Ejemplo n.º 1
0
bool _STLP_CALL
__stlp_string_fill(basic_ostream<_CharT, _Traits>& __os,
                  basic_streambuf<_CharT, _Traits>* __buf,
                  size_t __n)
{
  _CharT __f = __os.fill();
  size_t __i;
  bool __ok = true;

  for (__i = 0; __i < __n; ++__i)
    __ok = __ok && !_Traits::eq_int_type(__buf->sputc(__f), _Traits::eof());
  return __ok;
}
Ejemplo n.º 2
0
bool __STL_CALL
__sgi_string_fill(basic_ostream<_CharT, _Traits>& __os,
_Buf* __buf,		//*TY 02/27/2000 - simplified parameter type
size_t __n)
#endif											//*TY 02/27/2000 - 
{
_CharT __f = __os.fill();
size_t __i;
bool __ok = true;

for (__i = 0; __i < __n; ++__i)
    __ok = __ok && !_Traits::eq_int_type(__buf->sputc(__f), _Traits::eof());
return __ok;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
/// <summary>
/// Function to create in data from a file and search for a given string writing all lines containing the string to memory_buffer.
/// </summary>
static pplx::task<void> find_matches_in_file(const string_t &fileName, const std::string &searchString, basic_ostream<char> results)
{
    return file_stream<char>::open_istream(fileName).then([=](basic_istream<char> inFile)
    {
        auto lineNumber = std::make_shared<int>(1);
        return ::do_while([=]()
        {
            container_buffer<std::string> inLine;
            return inFile.read_line(inLine).then([=](size_t bytesRead)
            {
                if(bytesRead == 0 && inFile.is_eof())
                {
                    return pplx::task_from_result(false);
                }

                else if(inLine.collection().find(searchString) != std::string::npos)
                {
                    results.print("line ");
                    results.print((*lineNumber)++);
                    return results.print(":").then([=](size_t)
                    {
                        container_buffer<std::string> outLine(std::move(inLine.collection()));
                        return results.write(outLine, outLine.collection().size());
                    }).then([=](size_t)
                    {
                        return results.print("\r\n");
                    }).then([=](size_t)
                    {
                        return true;
                    });
                }

                else
                {
                    ++(*lineNumber);
                    return pplx::task_from_result(true);
                }
            });
        }).then([=]()
        {
            // Close the file and results stream.
            return inFile.close() && results.close();
        });
    });
}
Ejemplo n.º 6
0
// {{{ p. 342
//void printAddress(ostream& os, const address& addr, locale loc) // !!! addr
void printAddress(basic_ostream<char>& os, address<char> addr, locale loc) // !!! addr
{
	locale original = os.imbue(loc);
	os << addr << endl; // !!! addr
	os.imbue(original);
}