std::basic_istream<_CharT, _Traits> & operator>>(std::basic_istream<_CharT, _Traits> & __is, const get_time_manip<_CharT> & __x) { if (!reinterpret_cast<stream_buf_impl<_CharT, _Traits> *>(__is.rdbuf())->parse(__x)) __is.setstate(std::ios_base::failbit); return __is; }
void load(std::basic_istream<char> &stream, xml_node &node) { stream.unsetf(std::ios::skipws); std::vector<char> v(std::istreambuf_iterator<char>(stream.rdbuf()), std::istreambuf_iterator<char>()); if (!stream.good()) { throw config_error("Could not load map file", 0, filename_); } v.push_back(0); // zero-terminate try { // Parse using appropriate flags const int f_tws = rapidxml::parse_normalize_whitespace | rapidxml::parse_trim_whitespace; rapidxml::xml_document<> doc; doc.parse<f_tws>(&v.front()); for (rapidxml::xml_node<char> *child = doc.first_node(); child; child = child->next_sibling()) { populate_tree(child, node); } } catch (rapidxml::parse_error &e) { long line = static_cast<long>( std::count(&v.front(), e.where<char>(), '\n') + 1); throw config_error(e.what(), line, filename_); } }
inline SPROUT_NON_CONSTEXPR std::basic_istream<Char, Traits>& operator>>(std::basic_istream<Char, Traits>& lhs, sprout::bitset<N>& rhs) { typedef typename Traits::char_type char_type; typedef std::basic_istream<Char, Traits> istream_type; typedef typename istream_type::ios_base ios_base; std::basic_string<Char, Traits> tmp; tmp.reserve(N); char_type const zero = lhs.widen('0'); char_type const one = lhs.widen('1'); typename ios_base::iostate state = ios_base::goodbit; typename istream_type::sentry sentry(lhs); if (sentry) { try { for (std::size_t i = N; i > 0; --i) { static typename Traits::int_type eof = Traits::eof(); typename Traits::int_type c1 = lhs.rdbuf()->sbumpc(); if (Traits::eq_int_type(c1, eof)) { state |= ios_base::eofbit; break; } else { char_type const c2 = Traits::to_char_type(c1); if (Traits::eq(c2, zero)) { tmp.push_back(zero); } else if (Traits::eq(c2, one)) { tmp.push_back(one); } else if (Traits::eq_int_type(lhs.rdbuf()->sputbackc(c2), eof)) { state |= ios_base::failbit; break; } } } } catch(...) { lhs.setstate(ios_base::badbit); } } if (tmp.empty() && N) { state |= ios_base::failbit; } else { rhs.copy_from_string(tmp, static_cast<std::size_t>(0), N, zero, one); if (state) { lhs.setstate(state); return lhs; } } return lhs; }
std::basic_istream<stream_char_type, stream_char_traits> & operator >>(std::basic_istream<stream_char_type, stream_char_traits> & is, basic_string_facade<storage, char_traits> & str) { typedef std::ctype<stream_char_type> ctype_type; typedef std::basic_istream<stream_char_type, stream_char_traits> istream_type; typedef ext::basic_string_facade<storage, char_traits> string_type; typedef typename string_type::size_type size_type; std::ios_base::iostate state = std::ios_base::goodbit; const typename istream_type::sentry ok(is); if (ok) { const auto & lc = is.getloc(); auto * buf = is.rdbuf(); const ctype_type & ctype_fac = std::use_facet<ctype_type>(lc); str.clear(); std::streamsize w = is.width(); size_type size = 0 < w && static_cast<size_type>(w) < str.max_size() ? w : str.max_size(); try { auto meta = buf->sgetc(); for (; 0 < size; --size, meta = buf->snextc()) { if (stream_char_traits::eq_int_type(stream_char_traits::eof(), meta)) { // end of file state |= std::ios_base::eofbit; break; } auto ch = stream_char_traits::to_char_type(meta); if (ctype_fac.is(ctype_type::space, ch)) { break; } str.push_back(ch); } // for } catch (...) { is.setstate(std::ios::badbit); } } // if ok is.width(0); if (str.empty()) // read nothing state |= std::ios_base::failbit; is.setstate(state); return is; }
void read_xml_internal(std::basic_istream< typename Ptree::key_type::value_type> &stream, Ptree &pt, int flags, const std::string &filename) { typedef typename Ptree::key_type::value_type Ch; using namespace detail::pdalboostrapidxml; // Load data into vector stream.unsetf(std::ios::skipws); std::vector<Ch> v(std::istreambuf_iterator<Ch>(stream.rdbuf()), std::istreambuf_iterator<Ch>()); if (!stream.good()) BOOST_PROPERTY_TREE_THROW( xml_parser_error("read error", filename, 0)); v.push_back(0); // zero-terminate try { // Parse using appropriate flags const int f_tws = parse_normalize_whitespace | parse_trim_whitespace; const int f_c = parse_comment_nodes; // Some compilers don't like the bitwise or in the template arg. const int f_tws_c = parse_normalize_whitespace | parse_trim_whitespace | parse_comment_nodes; xml_document<Ch> doc; if (flags & no_comments) { if (flags & trim_whitespace) doc.BOOST_NESTED_TEMPLATE parse<f_tws>(&v.front()); else doc.BOOST_NESTED_TEMPLATE parse<0>(&v.front()); } else { if (flags & trim_whitespace) doc.BOOST_NESTED_TEMPLATE parse<f_tws_c>(&v.front()); else doc.BOOST_NESTED_TEMPLATE parse<f_c>(&v.front()); } // Create ptree from nodes Ptree local; for (xml_node<Ch> *child = doc.first_node(); child; child = child->next_sibling()) read_xml_node(child, local, flags); // Swap local and result ptrees pt.swap(local); } catch (parse_error &e) { long line = static_cast<long>( std::count(&v.front(), e.where<Ch>(), Ch('\n')) + 1); BOOST_PROPERTY_TREE_THROW( xml_parser_error(e.what(), filename, line)); } }
inline SPROUT_NON_CONSTEXPR std::basic_istream<T, StreamTraits>& operator>>(std::basic_istream<T, StreamTraits>& lhs, sprout::basic_string<T, N, Traits>& rhs) { typedef T elem_type; typedef StreamTraits traits_type; typedef std::basic_istream<T, StreamTraits> istream_type; typedef sprout::basic_string<T, N, Traits> string_type; typedef std::ctype<elem_type> ctype_type; typedef typename string_type::size_type size_type; std::ios_base::iostate state = std::ios_base::goodbit; bool changed = false; size_type current = 0; if (typename istream_type::sentry(lhs)) { ctype_type const& ctype_fac = std::use_facet<ctype_type>(lhs.getloc()); try { size_type remain = 0 < lhs.width() && static_cast<size_type>(lhs.width()) < rhs.max_size() ? static_cast<size_type>(lhs.width()) : rhs.max_size() ; typename traits_type::int_type meta = lhs.rdbuf()->sgetc(); for (; remain; --remain, meta = lhs.rdbuf()->snextc()) if (traits_type::eq_int_type(traits_type::eof(), meta)) { state |= std::ios_base::eofbit; break; } else if (ctype_fac.is(ctype_type::space, traits_type::to_char_type(meta))) { break; } else { rhs[current] = traits_type::to_char_type(meta); changed = true; ++current; } } catch (...) { state |= std::ios_base::badbit; } } lhs.width(0); if (!changed) { state |= std::ios_base::failbit; } lhs.setstate(state); rhs.resize(current); return lhs; }
binary_iarchive_impl( std::basic_istream<Elem, Tr> & is, unsigned int flags ) : basic_binary_iprimitive<Archive, Elem, Tr>( * is.rdbuf(), 0 != (flags & no_codecvt) ), basic_binary_iarchive<Archive>(flags) { init(flags); }
std::basic_istream<CharT>& operator>>(std::basic_istream<CharT>& is, RMap<StrType>& param){ size_t bufferSize = is.rdbuf()->in_avail(); char* buffer = new CharT[bufferSize+1]; is.read(buffer, bufferSize); buffer[bufferSize] = '\0'; StrType str(buffer); typename StrType::iterator it = str.begin(); parseMap<StrType>(param, it); delete[] buffer; return is; }
std::streamsize ignore_line ( std::basic_istream<CharT>& in, bool always_discard = false ) { std::streamsize nread = 0; if ( always_discard || ( in.rdbuf()->sungetc() != std::char_traits<CharT>::eof() && in.get() != in.widen ( '\n' ) ) ) { // The stream is good, and we haven't // read a full line yet, so clear it out in.ignore ( std::numeric_limits<std::streamsize>::max(), in.widen ( '\n' ) ); nread = in.gcount(); } return nread; }
std::basic_string< Ch, Traits > const stream_to_string( std::basic_istream< Ch, Traits > &_stream ) { std::basic_stringstream< Ch, Traits > string_stream; string_stream << _stream.rdbuf(); return string_stream.str(); }
static data parse(std::basic_istream<Char> &is) { data data; DataParser<Throw>().parse(data, std::istreambuf_iterator<Char>(is.rdbuf()), std::istreambuf_iterator<Char>()); return data; }
JSON_StreamParser(std::basic_istream<CharType> &stream) : m_streambuf(stream.rdbuf()) { }
void use_byte_order_mark ( std::basic_istream <codepoint, char_traits <codepoint> > & stream) { std::fpos<utf_mbstate> original_position = stream.tellg (); if (!stream.good()) { imbue_default (stream); return; } try { stream.imbue (std::locale (stream.getloc(), new trivial_codecvt)); /* We now start looking for a byte order mark. The following must be recognised: 00 00 FE FF: UTF-32BE FF FE 00 00: UTF-32LE FE FF: UTF-16BE FF FE: UTF-16LE EF BB BF: UTF-8 */ codepoint byte = stream.rdbuf()->sbumpc(); switch (byte) { case 0x00: if (stream.rdbuf()->sbumpc() == 0x00 && stream.rdbuf()->sbumpc() == 0xfe && stream.rdbuf()->sbumpc() == 0xff) { imbue_and_eat_bom (stream, original_position, new utf32be_codecvt); return; } break; case 0xef: if (stream.rdbuf()->sbumpc() == 0xbb && stream.rdbuf()->sbumpc() == 0xbf) { imbue_and_eat_bom (stream, original_position, new utf8_codecvt); return; } break; case 0xfe: if (stream.rdbuf()->sbumpc() == 0xff) { imbue_and_eat_bom (stream, original_position, new utf16be_codecvt); return; } break; case 0xff: if (stream.rdbuf()->sbumpc() == 0xfe) { // This is either UTF-16LE or UTF-32LE. if (stream.rdbuf()->sbumpc() == 0x00 && stream.rdbuf()->sbumpc() == 0x00) { imbue_and_eat_bom (stream, original_position, new utf32le_codecvt); } else { imbue_and_eat_bom (stream, original_position, new utf16le_codecvt); } return; } break; } } // If anything has gone wrong, just return to the original position and // state and imbue the default codecvt. catch (std::ios_base::failure &) {} stream.seekg (original_position); stream.clear(); imbue_default (stream); }
explicit basic_ibstream(std::basic_istream<_CharT, _Traits> &in) : std::basic_istream<_CharT, _Traits>(in.rdbuf()) { }