Example #1
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);
  }
Example #2
0
inline std::basic_istream<C>& operator >> (std::basic_istream<C>& is, basic_vector2<T>& v)
{
	C op;

	is >> v.x;
	is >> op;
	is >> v.y;

	if((op != C(',') && op != C('x') && op != C('|')) || is.bad())
	{
		throw std::runtime_error("Not able to convert from stream to vector!");
	}

	return is;
}