void BinaryRecord::read(std::istream &in) throw(Core::StreamException) { BinaryArchive ar(in.rdbuf(), true); ar & NAMED_OBJECT("GenericRecord", *this); // Setting the eof bit causes the input to abort the reading if ( in.rdbuf()->sgetc() == EOF ) in.setstate(std::ios_base::eofbit); }
bool equal_streams(std::istream& s1, std::istream& s2) { typedef std::istreambuf_iterator<char, std::char_traits<char> > iterator; iterator begin1(s1.rdbuf()); iterator begin2(s2.rdbuf()); iterator end; for(; begin1 != end && begin2 != end; ++begin1, ++begin2) if(*begin1 != *begin2) return false; return begin1 == end && begin2 == end; }
Reference<Bitmap> StreamerSDL::loadBitmap(std::istream & input) { // Save the bitmap to a file temporarily. static TemporaryDirectory tempDir("StreamerSDL"); FileName fileName(tempDir.getPath()); do { fileName.setFile(StringUtils::createRandomString(16) + ".bmp"); } while(FileUtils::isFile(fileName)); std::ofstream fileOutput(fileName.getPath().c_str(), std::ios_base::binary); if(!fileOutput.good()) { fileOutput.close(); FileUtils::remove(fileName); return nullptr; } fileOutput << input.rdbuf(); fileOutput.close(); SDL_Surface * surface = SDL_LoadBMP(fileName.getPath().c_str()); if (surface == nullptr) { FileUtils::remove(fileName); return nullptr; } auto bitmap = BitmapUtils::createBitmapFromSDLSurface(surface); SDL_FreeSurface(surface); FileUtils::remove(fileName); return bitmap; }
std::string ImageCoder::storeStreamToTempFile(std::istream & stream) { std::string fileName; { char fileNameBuffer[L_tmpnam]; char * result = tmpnam(fileNameBuffer); if (result == nullptr) return fileName; // empty file name indicates a problem ... fileName.assign(result); } std::ofstream file(fileName, std::ofstream::binary); if (file.fail()) std::runtime_error("failed to create temp file: '" + fileName + "'"); try { file << stream.rdbuf(); if (file.fail() || stream.fail()) std::runtime_error("failed to write to temp file: '" + fileName + "'"); } catch (const std::iostream::failure &) { std::runtime_error("failed to write to temp file: '" + fileName + "', caught failure"); } return fileName; }
gzistream::gzistream( std::istream & src, unsigned int buffer_size ) : std::istream( static_cast< std::streambuf * >( 0 ) ) , M_gzstreambuf( *(src.rdbuf()), buffer_size ) { this->init( &M_gzstreambuf ); }
void bear::visual::shader_program::restore( std::istream& fragment ) { std::ostringstream oss; oss << fragment.rdbuf(); restore( oss.str(), detail::get_default_vertex_shader_code() ); }
virtual ReadResult readShader(std::istream& fin,const Options* options) const { // create shader osg::ref_ptr<osg::Shader> shader = new osg::Shader(); { std::stringstream ss; ss << fin.rdbuf(); shader->setShaderSource( ss.str() ); } // check options which can define the type of the shader program if (options) { if (options->getOptionString().find("fragment")!=std::string::npos) shader->setType(osg::Shader::FRAGMENT); if (options->getOptionString().find("vertex")!=std::string::npos) shader->setType(osg::Shader::VERTEX); if (options->getOptionString().find("geometry")!=std::string::npos) shader->setType(osg::Shader::GEOMETRY); if (options->getOptionString().find("tesscontrol")!=std::string::npos) shader->setType(osg::Shader::TESSCONTROL); if (options->getOptionString().find("tessevaluation")!=std::string::npos) shader->setType(osg::Shader::TESSEVALUATION); if (options->getOptionString().find("compute")!=std::string::npos) shader->setType(osg::Shader::COMPUTE); } // return valid shader return processIncludes( shader.get(), options ); }
void entropy_decoder_kernel_2:: set_stream ( std::istream& in_ ) { r = 0; low = initial_low; high = initial_high; target = 0x00000000; in = &in_; streambuf = in_.rdbuf(); unsigned char ch; streambuf->sgetn((char*)&ch,1); target = ch; target <<= 8; if (streambuf->sgetn((char*)&ch,1)) target += ch; target <<= 8; if (streambuf->sgetn((char*)&ch,1)) target += ch; target <<= 8; if (streambuf->sgetn((char*)&ch,1)) target += ch; }
Item ItemFactoryImpl::createBase64Binary(std::istream& aEncodedStream) { std::ostringstream oss; oss << aEncodedStream.rdbuf(); std::string const temp( oss.str() ); return createBase64Binary( temp.data(), temp.size(), true ); }
// virtual S32 LLSDJSONParser::doParse(std::istream& istr, LLSD& data) const { // Read into string buffer first // std::stringstream my_buf; my_buf << istr.rdbuf(); std::string str_buf = my_buf.str(); std::cout << "GoogleDetectResponder: " << str_buf.c_str() << std::endl; // S32 object_count = 0; // try { variant_t var = json::parse( str_buf.begin(), str_buf.end() ); object_t obj = boost::any_cast<object_t>(*var); // object_count = parseObject( obj, data ); } catch( const std::exception& x ) { std::cout << "caught exception: " << x.what() << std::endl; } return object_count; }
bool CPlayList::LoadData(std::istream &stream) { // try to read as a string std::ostringstream ostr; ostr << stream.rdbuf(); return LoadData(ostr.str()); }
void InputProvider::addStreamInput(std::istream& i, const std::string& contentname) { // read the input before adding it to pimpl->stream (otherwise empty input seems to make the overall stream corrupt) std::stringstream inp; inp << i.rdbuf(); pimpl->stream << inp.str(); pimpl->contentNames.push_back(contentname); }
void ConstraintParametersLexerBase::switchStream__(std::istream &in, size_t lineNr) { d_input.close(); d_state = 0; d_input = Input(new std::istream(in.rdbuf()), lineNr); d_sawEOF = false; d_atBOL = true; }
void CodeCache::InstallLibrary(const std::string& name, std::istream& istr) { //BERRY_INFO << "Installing library " << name << " to " << this->GetPathForLibrary(name).toString() << std::endl; std::ofstream ostr(this->GetPathForLibrary(name).toString().c_str(), std::ios::binary | std::ios::trunc); ostr << istr.rdbuf(); }
std::string getDataFromIStream(std::istream& stream) { std::stringstream data; data << stream.rdbuf(); stream.clear(); return data.str(); }
void tokenizer_kernel_1:: set_stream ( std::istream& in_ ) { in = &in_; streambuf = in_.rdbuf(); have_peeked = false; }
ZipInputStream::ZipInputStream( std::istream &is, std::streampos pos ) : std::istream( 0 ), // SGIs basic_ifstream calls istream with 0, but calls basic_ios constructor first?? ifs( 0 ) { izf = new ZipInputStreambuf( is.rdbuf(), pos ) ; // this->rdbuf( izf ) ; is replaced by: this->init( izf ) ; }
/*! */ gzifilterstream::gzifilterstream( std::istream & src, int level, std::size_t buf_size ) : std::istream( static_cast< std::streambuf * >( 0 ) ) , M_filter_buf( *(src.rdbuf()), level, buf_size ) { // std::basic_ios::init( basic_streambuf<charT,traits>* sb ); this->init( &M_filter_buf ); }
void bash_ast::read_script(const std::istream& source, bool trim) { std::stringstream stream; stream << source.rdbuf(); script = stream.str(); boost::algorithm::erase_all(script, "\\\n"); if(trim) boost::trim_if(script, boost::is_any_of(" \t\n")); }
bool OSGA_Archive::open(std::istream& fin) { SERIALIZER(); _archiveFileName = ""; OSG_NOTICE<<"OSGA_Archive::open"<<std::endl; static_cast<std::istream&>(_input).rdbuf(fin.rdbuf()); return _open(_input); }
void set(std::istream& in, std::ostream& out, std::ostream& err) { if (not activated) { using namespace std; in_buf = cin.rdbuf(); out_buf = cout.rdbuf(); err_buf = cerr.rdbuf(); in_state = cin.rdstate(); out_state = cin.rdstate(); err_state = cerr.rdstate(); cin.rdbuf(in.rdbuf()); cout.rdbuf(out.rdbuf()); cerr.rdbuf(err.rdbuf()); cin.exceptions(ios_base::goodbit); cout.exceptions(ios_base::goodbit); cerr.exceptions(ios_base::goodbit); cin.clear(in.rdstate()); cout.clear(out.rdstate()); cerr.clear(err.rdstate()); } }
portable_binary_iarchive(std::istream & is, unsigned flags = 0) : primitive_base_t( * is.rdbuf(), 0 != (flags & boost::archive::no_codecvt) ), archive_base_t(flags), m_flags(0) { init(flags); }
bool enigma::writeToZip(std::ostream &zipStream, std::string filename, unsigned size, std::istream &contents) { ZipOutputStreambuf zos(zipStream.rdbuf()); ZipCDirEntry ze(filename); ze.setSize(size); ze.setTime(time(NULL)); // seems not to be implemented in zipios ! zos.putNextEntry(ze); std::ostream ozs( &zos ); ozs << contents.rdbuf(); return true; }
IniFilePtr IniFile::ConstructFromStream(std::istream& stream) { // Read the whole stream into a string std::string buffer; std::ostringstream ors; ors << stream.rdbuf(); buffer = ors.str(); return ConstructFromString(buffer); }
void load_file(std::string& s, std::istream& is) { s.erase(); if(is.bad()) return; s.reserve(static_cast<std::string::size_type>(is.rdbuf()->in_avail())); char c; while(is.get(c)) { if(s.capacity() == s.size()) s.reserve(s.capacity() * 3); s.append(1, c); } }
bool parseFromStream( CharReader::Factory const& fact, std::istream& sin, Value* root, std::string* errs) { std::ostringstream ssin; ssin << sin.rdbuf(); std::string doc = ssin.str(); char const* begin = doc.data(); char const* end = begin + doc.size(); // Note that we do not actually need a null-terminator. CharReaderPtr const reader(fact.newCharReader()); return reader->parse(begin, end, root, errs); }
void MemoryTriplet::fromStream(std::istream &is) { KLVStream kis(is.rdbuf()); this->key = kis.readAUID(); size_t len = kis.readBERLength(); value.resize(len); kis.readBytes(this->value.data(), value.size()); }
intermediate_type parse_intermediate(std::istream &stream) { std::shared_ptr<spv_context_t> context( spvContextCreate(SPV_ENV_VULKAN_1_0), spvContextDestroy); assert(context); const std::string content(std::istreambuf_iterator<char>(stream.rdbuf()), std::istreambuf_iterator<char>()); intermediate_type intermediate; spv_diagnostic diagnostic; spvBinaryParse(context.get(), &intermediate, (uint32_t *) content.c_str(), content.size() / sizeof(uint32_t), &parsed_header, &parsed_instruction, &diagnostic); return intermediate; }
void property_tree::from_unknown( std::istream& stream, boost::property_tree::ptree& ptree, property_tree::path_value::check_repeated_paths check_type, char equal_sign, char delimiter, bool use_index ) { if( is_seekable( stream ) ) { from_unknown_seekable( stream, ptree, check_type, equal_sign, delimiter, use_index ); } else { std::stringstream buffer; buffer << stream.rdbuf(); from_unknown_seekable( buffer, ptree, check_type, equal_sign, delimiter, use_index ); } }
void istream_or_ifstream::open(std::istream& is, const std::string& is_name, const std::string& filename, const std::string& description) { if (buf) throw myexception()<<"Cannot reopen file!\n"; if (filename == is_name) this->init(is.rdbuf()); else { buf = claim(new checked_filebuf(description)); this->init(buf.get()); buf->open(filename, ios_base::in); } }