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


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

本文整理汇总了C++中std::ifstream::rdbuf方法的典型用法代码示例。如果您正苦于以下问题:C++ ifstream::rdbuf方法的具体用法?C++ ifstream::rdbuf怎么用?C++ ifstream::rdbuf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::ifstream的用法示例。


在下文中一共展示了ifstream::rdbuf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

		Logger(string outFile) 
		{
			fileName=outFile;
			std::filebuf* buf = is.rdbuf();
			buf->open(fileName.c_str(),std::ios_base::out|std::ios_base::app);
			std::clog.rdbuf(buf);
		}
开发者ID:sakthivelk22,项目名称:AmazingHackCH1,代码行数:7,代码来源:logger.hpp

示例2: redirect_cin

bool redirect_cin (const std::string& fn)
{
	static std::ifstream alt_cin;
	alt_cin.open (fn.c_str(), std::ios::in | std::ios::binary);
	if (alt_cin.fail() ) return false;
	std::cin.rdbuf (alt_cin.rdbuf() );
	return true;
}
开发者ID:frankwz,项目名称:codecrypt,代码行数:8,代码来源:iohelpers.cpp

示例3: appendSingleFile

bool FileTemplater::appendSingleFile(std::ofstream* outputFile, const std::ifstream& inputFile)
{
    // read input file into a string
    std::stringstream ss;
    ss << inputFile.rdbuf();
    std::string str = ss.str();
    // output it to file
    outputFile->write(str.c_str(), str.size());
    return true;
}
开发者ID:schnet25,项目名称:file-templater,代码行数:10,代码来源:FileTemplater.cpp

示例4: readWholeFileStream

inline std::string readWholeFileStream(std::ifstream& fileStream) {
  std::stringstream stringStream;
  stringStream << fileStream.rdbuf();
  fileStream.close();
  return stringStream.str();
}
开发者ID:HariSeldon,项目名称:coarsening_pass,代码行数:6,代码来源:FileUtils.cpp

示例5: readFile

std::string readFile(std::ifstream& in) {
  std::stringstream sstr;
  sstr << in.rdbuf();
  return sstr.str();
}
开发者ID:AlenWang,项目名称:licode,代码行数:5,代码来源:SdpTest.cpp

示例6: LoadFrom_ifstream

// This code reads up the file, discards the bookends, and saves only the gibberish itself.
bool OTASCIIArmor::LoadFrom_ifstream(std::ifstream & fin)
{
	std::stringstream buffer;
	buffer << fin.rdbuf();
	
	std::string contents(buffer.str());
	
	OTString theString;
	theString.Set(contents.c_str());
	
	return LoadFromString(theString);
}
开发者ID:9cat,项目名称:Open-Transactions,代码行数:13,代码来源:OTASCIIArmor.cpp

示例7: cout

	StdHandleSaver(const char* in, const char* out) :
		cin(std::cin.rdbuf()), cout(std::cout.rdbuf()), cerr(std::cerr.rdbuf()), clog(std::clog.rdbuf()),
		csh(in, out),
//	NOTE: Using undocumented constructor accepting FILE*
//	      Only constructor accepts FILE* and swap is specified since C++11, so we need to use constructor
		ifs(stdin), ofs(stdout)
	{
		std::cin.rdbuf(ifs.rdbuf());
		std::cout.rdbuf(ofs.rdbuf());
		std::cerr.rdbuf(ofs.rdbuf());
		std::clog.rdbuf(ofs.rdbuf());
	}
开发者ID:yak1ex,项目名称:ccf,代码行数:12,代码来源:sandbox.cpp

示例8: loadObstacle

    VirtualRobot::ObstaclePtr ObjectIO::loadObstacle(const std::ifstream& xmlFile, const std::string& basePath /*= ""*/)
    {
        // load file
        THROW_VR_EXCEPTION_IF(!xmlFile.is_open(), "Could not open XML file");

        std::stringstream buffer;
        buffer << xmlFile.rdbuf();
        std::string objectXML(buffer.str());

        VirtualRobot::ObstaclePtr res = createObstacleFromString(objectXML, basePath);
        THROW_VR_EXCEPTION_IF(!res, "Error while parsing file.");
        return res;
    }
开发者ID:gkalogiannis,项目名称:simox,代码行数:13,代码来源:ObjectIO.cpp

示例9: appendToAllFiles

bool FileTemplater::appendToAllFiles(std::vector<std::ofstream*> outputFiles, const std::ifstream& inputFile)
{
    // read input file into a string
    std::stringstream ss;
    ss << inputFile.rdbuf();
    std::string str = ss.str();
    // output it to file
    for (std::vector<std::ofstream*>::iterator it=outputFiles.begin(); it!=outputFiles.end(); ++it)
    {
        (*it)->write(str.c_str(), str.size());
    }
    return true;
}
开发者ID:schnet25,项目名称:file-templater,代码行数:13,代码来源:FileTemplater.cpp

示例10:

    Newick::Newick(const std::ifstream& file_stream) {
		if(file_stream) {								// if file stream is open
			std::stringstream buffer;					// create a buffer
			buffer << file_stream.rdbuf();				// and read into it

			if ( check_newick_format(buffer.str()) ) {	// if string looks fine
				newick_string_m = buffer.str();			// copy the string
            }
            else {
                std::cout << "Newick string has the wrong format!" << std::endl;
            }
		}
		else {
            std::cout << "Could not open the file!" << std::endl;
        }
    }
开发者ID:meireles,项目名称:TreePlusPlus,代码行数:16,代码来源:newick.cpp

示例11: ReadRLE

void Targa::ReadRLE(std::ifstream &i)
{
	assert(header.imageType == Header::RGBRLE); // For use loading run length encoded RGB files only

	assert(pixelData.size() == 0);
	unsigned bytesPerPixel = header.pixelSize/8;
	pixelData.resize( header.width * header.height * 4 );

	assert(i.good());
	assert(i.is_open());

	int x = 0;
	int y = 0;	

	std::vector<char> restOfFile(std::istreambuf_iterator<char>(i.rdbuf()), std::istreambuf_iterator<char>());
	for (std::vector<char>::const_iterator itt = restOfFile.begin(); itt != restOfFile.end(); )
	//for(std::istreambuf_iterator<char> itt(i.rdbuf()); itt != std::istreambuf_iterator<char>();)
	{
		const bool runLengthPacket = (*itt & 0x80) != 0;
		const int packetSize = 1 + (*itt & 0x7f);

		++itt;
		if (runLengthPacket)
		{
			// get the pixel, and paste packetSize into the data
			const unsigned char b = *(itt++);
			const unsigned char g = *(itt++);
			const unsigned char r = *(itt++);
			const unsigned char a = (bytesPerPixel == 4) ? *(itt++) : 255;

			for (int p = 0; p < packetSize; ++p)
			{
				const int coord = x + y * 4;
				pixelData[ 0 + coord ] = r;
				pixelData[ 1 + coord ] = g;
				pixelData[ 2 + coord ] = b;
				pixelData[ 3 + coord ] = a;
				if (++x == header.width)
				{
					++y;
					x = 0;
				}
			}
		}
		else
		{
			for (int p = 0; p < packetSize; ++p)
			{
				const unsigned char b = *(itt++);
				const unsigned char g = *(itt++);
				const unsigned char r = *(itt++);
				const unsigned char a = (bytesPerPixel == 4) ? *(itt++) : 255;

				const int coord = x + y * 4;
				pixelData[ 0 + coord ] = r;
				pixelData[ 1 + coord ] = g;
				pixelData[ 2 + coord ] = b;
				pixelData[ 3 + coord ] = a;
				if (++x == header.width)
				{
					++y;
					x = 0;
				}
			}
		}
	}
}
开发者ID:dave-hillier,项目名称:davehillier,代码行数:67,代码来源:Targa.cpp

示例12: stream

#include "vector_tile_util.hpp"
#include "vector_tile_projection.hpp"
#include "vector_tile_geometry_decoder.hpp"
#include "vector_tile_datasource.hpp"
#include "vector_tile_datasource_pbf.hpp"
#include "protozero/pbf_reader.hpp"

#include <boost/optional/optional_io.hpp>

#include <fstream>

TEST_CASE( "vector tile rasterize", "should try to decode windfail tile" ) {
    // open vtile
    std::ifstream stream("./test/data/0.0.0.vector.pbf",std::ios_base::in|std::ios_base::binary);
    REQUIRE(stream.is_open());
    std::string buffer(std::istreambuf_iterator<char>(stream.rdbuf()),(std::istreambuf_iterator<char>()));
    REQUIRE(buffer.size() == 3812);

    // uncompress gzip data
    std::string uncompressed;
    mapnik::vector_tile_impl::zlib_decompress(buffer,uncompressed);
    REQUIRE(uncompressed.size() == 4934);

    typedef vector_tile::Tile tile_type;
    tile_type tile;
    unsigned tile_size = 256;
    mapnik::box2d<double> bbox(-20037508.342789,-20037508.342789,20037508.342789,20037508.342789);

    // first we render the raw tile directly to an image
    {
        mapnik::Map map(tile_size,tile_size,"+init=epsg:3857");
开发者ID:lyf-wxy,项目名称:mapnik-vector-tile,代码行数:31,代码来源:vector_tile_rasterize.cpp

示例13:

/// Read the entire content of given file to string
inline const std::string read_file(std::ifstream& a_in) {
    return static_cast<std::stringstream const&>(std::stringstream() << a_in.rdbuf()).str();
}
开发者ID:greenalpha,项目名称:utxx,代码行数:4,代码来源:path.hpp

示例14:

g_property_file_parser::g_property_file_parser(std::ifstream& t) {

	std::stringstream buffer;
	buffer << t.rdbuf();
	initialize(buffer.str());
}
开发者ID:besiano15,项目名称:ghost,代码行数:6,代码来源:property_file_parser.cpp

示例15: read

void PGPCleartextSignature::read(std::ifstream & file){
    std::stringstream s;
    s << file.rdbuf();
    std::string data = s.str();
    read(data);
}
开发者ID:aksalj,项目名称:OpenPGP,代码行数:6,代码来源:PGPCleartextSignature.cpp


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