void Properties::load(InputStreamPtr inStream) { Pool pool; InputStreamReaderPtr lineReader( new InputStreamReader(inStream, CharsetDecoder::getISOLatinDecoder())); LogString contents = lineReader->read(pool); properties->clear(); PropertyParser parser; parser.parse(contents, *this); }
PropertiesUtil::Properties PropertiesUtil::readPropertiesFromFileStream(::std::ifstream& stream) { if (!stream.is_open()) { BOOST_THROW_EXCEPTION(::std::runtime_error("file input stream not opened")); } Properties props; ::std::string contents; //preallocate enough space for contents stream.seekg(0, std::ios::end); contents.reserve(stream.tellg()); stream.seekg(0, std::ios::beg); //read contents contents.assign((::std::istreambuf_iterator<char>(stream)), ::std::istreambuf_iterator<char>()); PropertyParser parser; parser.parse(contents, props); return props; }