当前位置: 首页>>代码示例>>C++>>正文


C++ istream::rdbuf方法代码示例

本文整理汇总了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);
}
开发者ID:aemanov,项目名称:seiscomp3,代码行数:7,代码来源:binaryrecord.cpp

示例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;
}
开发者ID:faldah,项目名称:nt2,代码行数:13,代码来源:move_reuse.cpp

示例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;
}
开发者ID:PADrend,项目名称:Util,代码行数:30,代码来源:StreamerSDL.cpp

示例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;
}
开发者ID:freudi74,项目名称:mfimage,代码行数:27,代码来源:ImageCoder.cpp

示例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 );
}
开发者ID:edymanoloiu,项目名称:FotbalRobotic,代码行数:7,代码来源:gzstream.cpp

示例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() );
}
开发者ID:j-jorge,项目名称:bear,代码行数:7,代码来源:shader_program.cpp

示例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 );
        }
开发者ID:Kurdakov,项目名称:emscripten_OSG,代码行数:25,代码来源:ReaderWriterGLSL.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例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 );
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:7,代码来源:itemfactoryimpl.cpp

示例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;
}
开发者ID:greythane,项目名称:slitechat,代码行数:26,代码来源:llsdserialize.cpp

示例11: LoadData

bool CPlayList::LoadData(std::istream &stream)
{
  // try to read as a string
  std::ostringstream ostr;
  ostr << stream.rdbuf();
  return LoadData(ostr.str());
}
开发者ID:Sithisackt,项目名称:kodi,代码行数:7,代码来源:PlayList.cpp

示例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);
}
开发者ID:alexleutgoeb,项目名称:core,代码行数:8,代码来源:InputProvider.cpp

示例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;
}
开发者ID:soroush,项目名称:ait,代码行数:8,代码来源:constraint-parameters_scanner.cpp

示例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();
}
开发者ID:david-guerrero,项目名称:MITK,代码行数:8,代码来源:berryCodeCache.cpp

示例15: getDataFromIStream

std::string getDataFromIStream(std::istream& stream) {
    std::stringstream data;
    data << stream.rdbuf();

    stream.clear();

    return data.str();
}
开发者ID:bigsergey,项目名称:psi-toolkit,代码行数:8,代码来源:stream_helpers.cpp


注:本文中的std::istream::rdbuf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。