Пример #1
0
template <class Output, class Ch, class Tr, class IsSpecial> inline
Output
in_quote(std::basic_istream<Ch, Tr> &i, Output out, IsSpecial is_special = IsSpecial(),
         char quote_char='"', char escape_char='\\')
{
  char c;
  if (i.get(c)) {
    *out++=c;
    if (c==quote_char) { // quoted - end delimited by unescape quote
      for (;;) {
        if (!i.get(c))
          goto fail;
        if (c==quote_char)
          break;
        if (c==escape_char)
          if (!i.get(c))
            goto fail;
        *out++=c;
      }
    } else { // unquoted - end delimited by an is_special char
      while (i.get(c)) {
        if (is_special(c)) {
          i.unget();
          break;
        }
        *out++=c;
      }
    }
  } // else end of stream.  shouldn't interpret as empty token but not throwing exception either.  check status of i before you use.
  return out;
fail:
  throw std::runtime_error("end of file reached when parsing quoted string (in_quote)");
}
Пример #2
0
	int TablePaser::GetColumn(stringstream& ss_str, std::basic_istream<char>& in_put, string& column)
	{
		column = "";
		if (ss_str.eof())
			return -1;
		char cur_char[2];
		cur_char[1] = 0;
		char separator = '	';

		if (ss_str.get(cur_char[0]).eof())
			return 1;
		if (cur_char[0] == '	')
			return 1;
		else if (cur_char[0] == '"')
			separator = '"';
		else
			column += string(cur_char);


		while (1)
		{
			if (ss_str.eof())
			{
				if (separator == '"')
				{
					if (in_put.eof())
						return 0;

					column += string("\n\0");
					ss_str.clear();
					in_put.getline(LineData, LINE_DATA_MAX);
					ss_str << LineData;
				}
				else
					return 0;
			}
			ss_str.getline(LineData, 4096, separator);
			column += LineData;
			//column.append(LineData);
			if (ss_str.eof())
				continue;
			if (separator == '	')
				return 1;
			else if (separator == '"')
			{
				if (ss_str.eof())
					return 0;
				ss_str.get(cur_char[0]);
				if (ss_str.eof())
					return 1;
				else if (cur_char[0] == '	')
					return 1;
				else if (cur_char[0] != separator)
					separator = '	';
				//column.push_back(cur_char);
				column += string(cur_char);
			}
		}
		return -1;
	}
Пример #3
0
std::basic_istream<e,t>& operator>>(std::basic_istream<e,t>& in, const e& cliteral) {
        e buffer(0);  //get buffer
        in >> buffer; //read data
        if (buffer != cliteral) //if it failed
                in.setstate(in.rdstate() | std::ios::badbit); //set the state
        return in;
}
Пример #4
0
 void check_done()
 {
     while (!eof_)
     {
         if (!(index_ < buffer_length_))
         {
             if (!is_->eof())
             {
                 is_->read(buffer_.data(), buffer_capacity_);
                 buffer_length_ = static_cast<size_t>(is_->gcount());
                 if (buffer_length_ == 0)
                 {
                     eof_ = true;
                 }
                 index_ = 0;
             }
             else
             {
                 eof_ = true;
             }
         }
         if (!eof_)
         {
             parser_.check_done(buffer_.data(),index_,buffer_length_);
             index_ = parser_.index();
         }
     }
 }
Пример #5
0
	int TablePaser::GetLine(std::basic_istream<char>& in_put, vector<string>& columns)
	{
		if (in_put.eof())
			return -1;

		std::streamoff i = in_put.tellg();
		memset(LineData, 0, LINE_DATA_MAX);
		in_put.getline(LineData, LINE_DATA_MAX);
		char* r_ch = strchr(LineData, '\r');
		if (r_ch)
		{
			in_put.seekg(i + (r_ch - LineData) + 1);
			*r_ch = '\0';
		}

		if (strlen(LineData) == 0)
			return GetLine(in_put, columns);

		stringstream ss_str;
		ss_str << LineData;

		int ret = 1;
		string column;
		while (ret == 1)
		{
			if ((ret = GetColumn(ss_str, in_put, column)) == -1)
				break;
			columns.push_back(column);
		}
		if (in_put.eof())
			return 0;
		return 1;
	}
Пример #6
0
    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;

        // Create and load document from stream
        stream.unsetf(std::ios::skipws);

        if (!stream.good())
            throw xml_parser_error("read error", filename, 0);

        std::vector<Ch> buf;
        std::copy(std::istream_iterator<Ch>(stream), std::istream_iterator<Ch>(), std::back_inserter(buf));
        buf.push_back(0); // zero-terminate  

        unsigned int pugi_flags = pugi::parse_w3c;
        if ( flags & no_comments )
            pugi_flags = pugi_flags & ~pugi::parse_comments;

        pugi::xml_parser parser(&buf[0], pugi_flags);
        pugi::xml_node doc = parser.document();

        // Create ptree from nodes
        Ptree local;
        for ( pugi::xml_node child = doc.first_child(); child; child = child.next_sibling())
            read_xml_node( child, local, flags );

        // Swap local and result ptrees
        pt.swap(local);
    }
Пример #7
0
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;
}
Пример #8
0
inline std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, uuid& id)
{
    typedef typename std::basic_istream<CharT,Traits>::sentry sentry_t;
    sentry_t ok(is);
    if (ok)
    {
        CharT c;
        if (!is.get(c))
            return is;

        is.unget();

        if (c == is.widen('{'))
        {
            CharT buf[38+1];
            if (!is.read(buf, 38))
                return is;
            buf[38] = CharT();
            id = uuid(buf);
        }
        else
        {
            CharT buf[36+1];
            if (!is.read(buf, 36))
                return is;
            buf[36] = CharT();
            id = uuid(buf);
        }
    }
    return is;
}
Пример #9
0
 void read_next()
 {
     parser_.begin_parse();
     while (!eof_ && !parser_.done())
     {
         if (!(index_ < buffer_length_))
         {
             if (!is_->eof())
             {
                 is_->read(buffer_.data(), buffer_capacity_);
                 buffer_length_ = static_cast<size_t>(is_->gcount());
                 if (buffer_length_ == 0)
                 {
                     eof_ = true;
                 }
                 index_ = 0;
             }
             else
             {
                 eof_ = true;
             }
         }
         if (!eof_)
         {
             parser_.parse(buffer_.data(),index_,buffer_length_);
             index_ = parser_.index();
         }
     }
     parser_.end_parse();
 }
Пример #10
0
    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_);
        }
    }
Пример #11
0
    /**
     *  @brief Deserialize the integer value from the specified input stream.
     *  @param __s  Reference to the input stream.
     */
    void
    load(std::basic_istream<CharT, Traits> &__s)
    {
        // We must ensure that subsequent actions will be performed
        // for very likely integer value, otherwise and exception
        // should be raised.
        if (__s.peek() != basic_value_type::integer_token) {
            throw type_error(
                "bencode::integer::load the specified stream does "
                "not contain interpretable bencode integer value\n");
        }

        // Read the leading "i" symbol from the provided stream.
        __s.get();

        // Define the integer symbol representation placeholder.
        std::basic_stringstream<CharT, Traits> __i;

        // Define the input stream iterator of the provided stream to
        // be able to read the integer value symbol by symbol.
        auto __si = std::istream_iterator<CharT, CharT, Traits>(__s);

        // Define the output stream to as a buffer for the integer
        // value, which will be later converted.
        auto __ival = std::ostream_iterator<CharT, CharT, Traits>(__i);

        // Copy the values from the input stream into the integer
        // placeholder string stream.
        auto __result = copy_until(__si, __ival,
            [&__s](const CharT& __ch) {

            // Additionally, check that we did not exceed the
            // length of the stream to prevent hangs.
            return !__s.eof() && __ch != basic_value_type::end_token;
        }, basic_value_type::integer_length);

        // Covert the value from the string into the integer.
        __i >> _M_value;

        // The "e" symbol should be already extracted at this moment,
        // so validate that the iterator pointing right to it.
        if (*__result != basic_value_type::end_token) {
            std::ostringstream __error;

            __error << "bencode::integer::load the end of the integer "
                "`e` expected, but `" << CharT(*__result) << "` found\n";
            throw encoding_error(__error.str());
        }

        // Validate that decoded value is an actual integer.
        if (!_M_value && __i.str() != std::basic_string<
                CharT, Traits>(1, CharT('0'))) {
            std::ostringstream __error;

            __error << "bencode::integer::load the specified "
                "value is not a number\n";
            throw value_error(__error.str());
        }
    }
Пример #12
0
	inline std::basic_istream<Elem, Traits>&
	operator>>(std::basic_istream<Elem, Traits>& lhs, sprout::optional<T>& rhs) {
		if (lhs.good()) {
			int d = lhs.get();
			if (d == ' ') {
				T x;
				lhs >> x;
				rhs = x;
			} else {
Пример #13
0
std::basic_istream<e,t>& operator>>(std::basic_istream<e,t>& in, const e(&sliteral)[N]) {
        e buffer[N-1] = {}; //get buffer
        in >> buffer[0]; //skips whitespace
        if (N>2)
                in.read(buffer+1, N-2); //read the rest
        if (strncmp(buffer, sliteral, N-1)) //if it failed
                in.setstate(in.rdstate() | std::ios::badbit); //set the state
        return in;
}
Пример #14
0
  //! Loads file into the memory. Data will be automatically destroyed by the
  // destructor
  //! \param stream Stream to load from
  file(std::basic_istream<Ch> &stream) {
    using namespace std;

    // Load data and add terminating 0
    stream.unsetf(ios::skipws);
    m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());
    if (stream.fail() || stream.bad())
      throw runtime_error("error reading stream");
    m_data.push_back(0);
  }
std::basic_istream< CharT, TraitsT >& operator>> (std::basic_istream< CharT, TraitsT >& strm, point& p)
{
    if (strm.good())
    {
        CharT left_brace = static_cast< CharT >(0), comma = static_cast< CharT >(0), right_brace = static_cast< CharT >(0);
        strm.setf(std::ios_base::skipws);
        strm >> left_brace >> p.m_x >> comma >> p.m_y >> right_brace;
        if (left_brace != '(' || comma != ',' || right_brace != ')')
            strm.setstate(std::ios_base::failbit);
    }
Пример #16
0
    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));  
        }
    }
Пример #17
0
    std::basic_istream<ch, char_traits>& operator>>(std::basic_istream<ch, char_traits> &is, uuid &u)
{
    const typename std::basic_istream<ch, char_traits>::sentry ok(is);
    if (ok) {
        unsigned char data[16];

        typedef std::ctype<ch> ctype_t;
        ctype_t const& ctype = std::use_facet<ctype_t>(is.getloc());

        ch xdigits[16];
        {
            char szdigits[] = "0123456789ABCDEF";
            ctype.widen(szdigits, szdigits+16, xdigits);
        }
        ch*const xdigits_end = xdigits+16;

        ch c;
        for (std::size_t i=0; i<u.size() && is; ++i) {
            is >> c;
            c = ctype.toupper(c);

            ch* f = std::find(xdigits, xdigits_end, c);
            if (f == xdigits_end) {
                is.setstate(std::ios_base::failbit);
                break;
            }

            unsigned char byte = static_cast<unsigned char>(std::distance(&xdigits[0], f));

            is >> c;
            c = ctype.toupper(c);
            f = std::find(xdigits, xdigits_end, c);
            if (f == xdigits_end) {
                is.setstate(std::ios_base::failbit);
                break;
            }

            byte <<= 4;
            byte |= static_cast<unsigned char>(std::distance(&xdigits[0], f));

            data[i] = byte;

            if (is) {
                if (i == 3 || i == 5 || i == 7 || i == 9) {
                    is >> c;
                    if (c != is.widen('-')) is.setstate(std::ios_base::failbit);
                }
            }
        }

        if (is) {
            std::copy(data, data+16, u.begin());
        }
    }
Пример #18
0
inline
std::basic_istream<CharType, CharTrait>&
operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v)
{
  if (in.good())
  {
    int d = in.get();
    if (d == ' ')
    {
      T x;
      in >> x;
      v = x;
    }
Пример #19
0
		inline SPROUT_NON_CONSTEXPR std::basic_istream<Elem, Traits>&
		operator>>(std::basic_istream<Elem, Traits>& lhs, sprout::math::quaternion<T>& rhs) {
			std::ctype<Elem> const& ct = std::use_facet<std::ctype<Elem> >(lhs.getloc());
			T a = T();
			T b = T();
			T c = T();
			T d = T();
			sprout::complex<T> u = sprout::complex<T>();
			sprout::complex<T> v = sprout::complex<T>();
			Elem ch = Elem();
			char cc;
			lhs >> ch;
			if (!lhs.good()) {
				goto finish;
			}
			cc = ct.narrow(ch, char());
			if (cc == '(') {
				lhs >> ch;
				if (!lhs.good()) {
					goto finish;
				}
				cc = ct.narrow(ch, char());
				if (cc == '(') {
					lhs.putback(ch);
					lhs >> u;
					a = u.real();
					b = u.imag();
					if (!lhs.good()) {
						goto finish;
					}
					lhs >> ch;
					if (!lhs.good()) {
						goto finish;
					}
					cc = ct.narrow(ch, char());
					if (cc == ')') {
						rhs = sprout::math::quaternion<T>(a, b);
					} else if (cc == ',') {
						lhs >> v;
						c = v.real();
						d = v.imag();
						if (!lhs.good()) {
							goto finish;
						}
						lhs >> ch;
						if (!lhs.good()) {
							goto finish;
						}
						cc = ct.narrow(ch, char());
						if (cc == ')') {
							rhs = sprout::math::quaternion<T>(a, b, c, d);
						} else {
							lhs.setstate(std::ios_base::failbit);
						}
					} else {
Пример #20
0
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;
}
inline std::basic_istream<char_t, traits_t>& operator>>(std::basic_istream<char_t, traits_t>& is, std::tr1::basic_regex<char_t, rx_traits_t>& regex) {
    std::basic_string<char_t, traits_t> buff;
    std::getline(is, buff);
    if (!is.fail()) {
        try {
            regex.assign(buff);
        }
        catch (std::exception const&) {
            assert(false);
            is.setstate(std::ios_base::failbit);
        }
    }
    return is;
}
Пример #22
0
inline void ReadBSTRFromStream( std::basic_istream< CharT, CharTraitsT > &Istream, ATL::CComBSTR &Str )
{ 
   Str.Empty();

   CharT Buff[256];

   do 
   {
      Istream.read( Buff, APL_ARRSIZE(Buff) );
      ATL::CComBSTR TmpStr(Istream.gcount(), Buff);
      Str.Append(TmpStr);   

   } while(Istream.gcount() == APL_ARRSIZE(Buff));
}
void CDataSerializer::Read(std::basic_istream<char>& sStream, CData* pData)
{
	if (!sStream.good())
		return;

	if (!pData)
		return;

	char szLine[1024];
	string sLine;

	CData* pCurrentData = pData;
	CData* pLastData = NULL;

	while (sStream.getline(szLine, 1024))
	{
		sLine = string(szLine);

		size_t iComment = sLine.find("//");
		if (iComment != string::npos)
			sLine = sLine.substr(0, iComment);

		sLine = trim(sLine);

		if (sLine.length() == 0)
			continue;

		if (sLine[0] == '{')
		{
			pCurrentData = pLastData;
			continue;
		}

		if (sLine[0] == '}')
		{
			pCurrentData = pCurrentData->GetParent();
			continue;
		}

		vector<string> asTokens;
		explode(sLine, asTokens, ":");

		if (asTokens.size() == 1)
			pLastData = pCurrentData->AddChild(trim(sLine));
		else if (asTokens.size() >= 2)
			pLastData = pCurrentData->AddChild(trim(asTokens[0]), trim(sLine.substr(sLine.find(':')+1)));
	}
}
Пример #24
0
		inline std::basic_istream<Elem, Traits>&
		operator>>(std::basic_istream<Elem, Traits>& lhs, sprout::uuids::uuid& rhs) {
			typedef typename std::basic_ios<Elem, Traits>::char_type char_type;
			typename std::basic_istream<Elem, Traits>::sentry const ok(lhs);
			typedef std::ctype<Elem> ctype_type;
			if (ok) {
				sprout::uuids::uuid::value_type data[16];
				ctype_type const& ctype = std::use_facet<ctype_type>(lhs.getloc());
				char_type xdigits[16];
				{
					char const szdigits[] = "0123456789ABCDEF";
					ctype.widen(szdigits, szdigits + 16, xdigits);
				}
				char_type const* const xdigits_end = xdigits + 16;
				char_type c;
				for (sprout::uuids::uuid::size_type i = 0, last = rhs.size(); i < last && lhs; ++i) {
					lhs >> c;
					c = ctype.toupper(c);
					char_type const* f = std::find(xdigits, xdigits_end, c);
					if (f == xdigits_end) {
						lhs.setstate(std::ios_base::failbit);
						break;
					}
					sprout::uuids::uuid::value_type byte = static_cast<sprout::uuids::uuid::value_type>(std::distance(&xdigits[0], f));
					lhs >> c;
					c = ctype.toupper(c);
					f = std::find(xdigits, xdigits_end, c);
					if (f == xdigits_end) {
						lhs.setstate(std::ios_base::failbit);
						break;
					}
					byte <<= 4;
					byte |= static_cast<sprout::uuids::uuid::value_type>(std::distance(&xdigits[0], f));
					data[i] = byte;
					if (lhs) {
						if (i == 3 || i == 5 || i == 7 || i == 9) {
							lhs >> c;
							if (c != lhs.widen('-')) {
								lhs.setstate(std::ios_base::failbit);
								break;
							}
						}
					}
				}
				if (lhs) {
					std::copy(data, data + 16, rhs.begin());
				}
			}
Пример #25
0
int ReadHTTPMessage(std::basic_istream<char>& stream, map<string,
                    string>& mapHeadersRet, string& strMessageRet,
                    int nProto)
{
    mapHeadersRet.clear();
    strMessageRet = "";

    // Read header
    int nLen = ReadHTTPHeaders(stream, mapHeadersRet);
    if (nLen < 0 || nLen > (int)MAX_SIZE)
        return HTTP_INTERNAL_SERVER_ERROR;

    // Read message
    if (nLen > 0)
    {
        vector<char> vch(nLen);
        stream.read(&vch[0], nLen);
        strMessageRet = string(vch.begin(), vch.end());
    }

    string sConHdr = mapHeadersRet["connection"];

    if ((sConHdr != "close") && (sConHdr != "keep-alive"))
    {
        if (nProto >= 1)
            mapHeadersRet["connection"] = "keep-alive";
        else
            mapHeadersRet["connection"] = "close";
    }

    return HTTP_OK;
}
Пример #26
0
int ReadHTTP (std::basic_istream<char>& stream, std::map<std::string, std::string>& mapHeadersRet,
              std::string& strMessageRet)
{
    mapHeadersRet.clear ();
    strMessageRet = "";

    // Read status
    int nStatus = ReadHTTPStatus (stream);

    // Read header
    int nLen = ReadHTTPHeader (stream, mapHeadersRet);

    if (nLen < 0 || nLen > gMaxHTTPHeaderSize)
        return 500;

    // Read message
    if (nLen > 0)
    {
        std::vector<char> vch (nLen);
        stream.read (&vch[0], nLen);
        strMessageRet = std::string (vch.begin (), vch.end ());
    }

    return nStatus;
}
Пример #27
0
 inline std::basic_istream<Char>&
 operator >>(std::basic_istream<Char>& in, header_type& header) {
     in.read(
             util::cast::pointer_cast<char*>(&header),
             sizeof(header_type));
     return in;
 }
Пример #28
0
    bool parse_sexpr_list(
        std::basic_istream<Char>& is,
        utree& result,
        std::string const& source_file)
    {
        // no white space skipping in the stream!
        is.unsetf(std::ios::skipws);

        typedef
            boost::spirit::basic_istream_iterator<Char>
        stream_iterator_type;
        stream_iterator_type sfirst(is);
        stream_iterator_type slast;

        typedef boost::spirit::line_pos_iterator<stream_iterator_type>
          iterator_type;
        iterator_type first(sfirst);
        iterator_type last(slast);

        scheme::input::sexpr<iterator_type> p(source_file);
        scheme::input::sexpr_white_space<iterator_type> ws;

        using boost::spirit::qi::phrase_parse;
        bool ok = phrase_parse(first, last, +p, ws, result);
        result.tag(1); // line
        return ok;
    }
Пример #29
0
std::basic_istream<charT, traits> &
operator >> ( std::basic_istream<charT, traits> & s, boolean & b )
{
    std::string word;
    s >> word;
    std::transform(word.begin(), word.end(), word.begin(), ::tolower);
    if ( s )
    {
        if ( word == "true" || word == "yes" || word == "on" ||
             word == "1")
        {
            b = true;
        }
        else if ( word == "false" || word == "no" || word == "off" ||
                  word == "0")
        {
            b = false;
        }
        else
        {
            s.setstate( std::ios::failbit );
        }
    }
    return s;
}
Пример #30
0
inline void ReadBSTRFromStream( std::basic_istream< WCHAR, CharTraitsT > &Istream, ATL::CComBSTR &Str )
{ 
   //Оптимизация исключающая временные объекты
   Str.Empty();

   WCHAR Buff[256];

   do 
   {
      Istream.read( Buff, APL_ARRSIZE(Buff) );
      Str.Append(Buff, Istream.gcount());   

   }
   while(Istream.gcount() == APL_ARRSIZE(Buff));

}