本文整理汇总了C++中std::istream::rdbuf方法的典型用法代码示例。如果您正苦于以下问题:C++ istream::rdbuf方法的具体用法?C++ istream::rdbuf怎么用?C++ istream::rdbuf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::istream
的用法示例。
在下文中一共展示了istream::rdbuf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
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);
}
示例2: equal_streams
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;
}
示例3: tempDir
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;
}
示例4: storeStreamToTempFile
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;
}
示例5:
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 );
}
示例6: restore
void bear::visual::shader_program::restore( std::istream& fragment )
{
std::ostringstream oss;
oss << fragment.rdbuf();
restore( oss.str(), detail::get_default_vertex_shader_code() );
}
示例7: readShader
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 );
}
示例8:
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;
}
示例9: temp
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 );
}
示例10: doParse
// 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;
}
示例11: LoadData
bool CPlayList::LoadData(std::istream &stream)
{
// try to read as a string
std::ostringstream ostr;
ostr << stream.rdbuf();
return LoadData(ostr.str());
}
示例12: addStreamInput
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);
}
示例13: switchStream__
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;
}
示例14: ostr
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();
}
示例15: getDataFromIStream
std::string getDataFromIStream(std::istream& stream) {
std::stringstream data;
data << stream.rdbuf();
stream.clear();
return data.str();
}