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


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

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


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

示例1: import_stream

 void ConfigParser::import_stream(std::istream& stream) {
   while(!stream.eof()) {
     std::string line;
     getline(stream, line);
     ConfigParser::Entry* entry = parse_line(line.c_str());
     if(entry) {
       variables.push_back(std::pair<std::string, Entry*>(entry->variable, entry));
     }
   }
 }
开发者ID:Locke23rus,项目名称:rubinius,代码行数:10,代码来源:config_parser.cpp

示例2: import_stream

 void ConfigParser::import_stream(std::istream& stream) {
   while(!stream.eof()) {
     std::string line;
     getline(stream, line);
     ConfigParser::Entry* entry = parse_line(line.c_str());
     if(entry) {
       variables[entry->variable] = entry;
     }
   }
 }
开发者ID:MarkusQ,项目名称:rubinius,代码行数:10,代码来源:config_parser.cpp

示例3: num_of_questions

int TestWindow::num_of_questions(std::istream &input)
{
    int count = 0;
    std::string str;
    while(!input.eof()){
        std::getline(input, str);
        count++;
    }
    return count / 6;
}
开发者ID:MrBentCode,项目名称:FlowChart_trainer,代码行数:10,代码来源:testwindow.cpp

示例4: consume

void consume(std::istream &in, char ch) {
  while (in.good()) {
    int c;
    c = in.peek();
    if (in.eof()) return;
    if (std::isspace(c)) { in.ignore(); continue; }
    if (c == ch) { in.ignore(); }
    return;
  }
}
开发者ID:ManojRollo,项目名称:carve,代码行数:10,代码来源:extrude.cpp

示例5: rot13_stream

// function to output the rot13 of a file on std::cout
// returns false if an error occurred processing the file, true otherwise
// on entry, the argument is must be open for reading
int rot13_stream(std::istream& is)
{
  std::string line;
  while (std::getline(is, line))
  {
    if (!(std::cout << rot13(line) << "\n"))
      return false;
  }
  return is.eof();
}
开发者ID:Anatolt,项目名称:RosettaCodeData,代码行数:13,代码来源:rot-13-1.cpp

示例6: fileName

osgDB::ReaderWriter::ReadResult
ReaderWriterIV::readNode(std::istream& fin,
                         const osgDB::ReaderWriter::Options* options) const
{
    // Notify
    OSG_NOTICE << "osgDB::ReaderWriterIV::readNode() "
              "Reading from stream." << std::endl;
    OSG_INFO << "osgDB::ReaderWriterIV::readNode() "
              "Inventor version: " << SoDB::getVersion() << std::endl;

    // Open the file
    SoInput input;

    // Assign istream to SoInput
    // note: It seems there is no straightforward way to do that.
    // SoInput accepts only FILE by setFilePointer or memory buffer
    // by setBuffer. The FILE is dangerous on Windows, since it forces
    // the plugin and Inventor DLL to use the same runtime library
    // (otherwise there are app crashes).
    // The memory buffer seems much better option here, even although
    // there will not be a real streaming. However, the model data
    // are usually much smaller than textures, so we should not worry
    // about it and think how to stream textures instead.

    // Get the data to the buffer
    size_t bufSize = 126*1024; // let's make it something below 128KB
    char *buf = (char*)malloc(bufSize);
    size_t dataSize = 0;
    while (!fin.eof() && fin.good()) {
        fin.read(buf+dataSize, bufSize-dataSize);
        dataSize += fin.gcount();
        if (bufSize == dataSize) {
           bufSize *= 2;
           char* new_buf = (char*)realloc(buf, bufSize);
           if (!new_buf)
           {
               free(buf);
               return osgDB::ReaderWriter::ReadResult::INSUFFICIENT_MEMORY_TO_LOAD;
           }
           buf = new_buf;
        }
    }
    input.setBuffer(buf, dataSize);
    OSG_INFO << "osgDB::ReaderWriterIV::readNode() "
              "Stream size: " << dataSize << std::endl;

    // Perform reading from SoInput
    osgDB::ReaderWriter::ReadResult r;
    std::string fileName("");
    r = readNodeFromSoInput(input, fileName, options);

    // clean up and return
    free(buf);
    return r;
}
开发者ID:LaurensVoerman,项目名称:OpenSceneGraph,代码行数:55,代码来源:ReaderWriterIV.cpp

示例7: if

/***********************************************************************
 * Extract contiguous lines of comments
 **********************************************************************/
static std::vector<CodeBlock> extractContiguousBlocks(std::istream &is)
{
    std::vector<CodeBlock> contiguousCommentBlocks;
    CodeBlock currentCodeBlock;
    size_t lineNo = 0;
    std::string partial, line;

    bool inMultiLineComment = false;
    while (is.good() and not is.eof())
    {
        if (not partial.empty()) line = partial;
        else
        {
            lineNo++; //starts at 1
            std::getline(is, line);
        }
        partial.clear();
        if (line.empty()) continue;

        const std::string lineTrim = Poco::trimLeft(line);
        const auto openMulti = line.find("/*");
        const auto closeMulti = line.find("*/");
        if (not inMultiLineComment and lineTrim.size() >= 2 and lineTrim.substr(0, 2) == "//")
        {
            currentCodeBlock.push_back(CodeLine(line, lineNo));
        }
        else if (not inMultiLineComment and openMulti != std::string::npos)
        {
            inMultiLineComment = true;
            currentCodeBlock.push_back(CodeLine(line.substr(openMulti, std::string::npos), lineNo));
        }
        else if (inMultiLineComment and closeMulti != std::string::npos)
        {
            inMultiLineComment = false;
            currentCodeBlock.push_back(CodeLine(line.substr(0, closeMulti), lineNo));
            partial = line.substr(closeMulti+2);
        }
        else if (inMultiLineComment)
        {
            currentCodeBlock.push_back(CodeLine(line, lineNo));
        }
        else if (not currentCodeBlock.empty())
        {
            contiguousCommentBlocks.push_back(currentCodeBlock);
            currentCodeBlock.clear();
        }
    }

    if (not currentCodeBlock.empty())
    {
        contiguousCommentBlocks.push_back(currentCodeBlock);
    }

    return contiguousCommentBlocks;
}
开发者ID:,项目名称:,代码行数:58,代码来源:

示例8: while

////////////////////////////////////////////////////////////////////////////
// MemParser constructor
//////////////////////////////////////////////////////////////////////////////
MemParser::MemParser(std::istream& in, UInt32 bytes) 
{
  if (bytes == 0)
  {
    // -----------------------------------------------------------------------------
    // Read all available bytes from the stream
    // -----------------------------------------------------------------------------
    std::string  data;
    const int  chunkSize = 0x10000;
    char* chunkP = new char[chunkSize];
    while (!in.eof()) {
      in.read(chunkP, chunkSize);
      NTA_CHECK (in.good() || in.eof()) 
          << "MemParser::MemParser() - error reading data from stream";
      data.append (chunkP, in.gcount());
    }
    
    bytes_ = (UInt32)data.size();
    bufP_ = new char[bytes_+1];
    NTA_CHECK (bufP_ != NULL) << "MemParser::MemParser() - out of memory";
    ::memmove ((void*)bufP_, data.data(), bytes_);
    ((char*)bufP_)[bytes_] = 0;
    
    delete[] chunkP;
  }
  else
  {
    // -----------------------------------------------------------------------------
    // Read given # of bytes from the stream
    // -----------------------------------------------------------------------------
    bytes_ = bytes;
    bufP_ = new char[bytes_+1];  
    NTA_CHECK (bufP_ != NULL) << "MemParser::MemParser() - out of memory";
    
    in.read ((char*)bufP_, bytes);
    ((char*)bufP_)[bytes] = 0;
    NTA_CHECK (in.good()) << "MemParser::MemParser() - error reading data from stream";
  }
  // Setup start and end pointers
  startP_ = bufP_;
  endP_ = startP_ + bytes_;  
}  
开发者ID:AndreCAndersen,项目名称:nupic,代码行数:45,代码来源:MemParser.cpp

示例9: load

/* input table from csv file */ 
bool RamRelation::load(std::istream &is, SymbolTable& symTable, const SymbolMask& mask) {
    bool error = false; 
    auto arity = getArity();
    while (!is.eof()) {
        std::string line;
        RamDomain tuple[arity];

        getline(is,line);
        if (is.eof()) break;

        size_t start = 0, end = 0;
        for(uint32_t col=0;col<arity;col++) { 
            end = line.find('\t', start);
            if ((size_t)end == std::string::npos) {
                end = line.length();
            }
            std::string element;
            if (start <=  end && (size_t)end <= line.length() ) {
                element = line.substr(start,end-start);
                if (element == "") {
                    element = "n/a";
                }
            } else {
                error = true; 
                element = "n/a";
            }
            if (mask.isSymbol(col)) {
                tuple[col] = symTable.lookup(element.c_str());
            } else {
                tuple[col] = atoi(element.c_str());
            }
            start = end+1;
        }
        if (end != line.length()) {
            error = true; 
        } 
        if (!exists(tuple)) { 
            insert(tuple);
        }
    }
    return error;
}
开发者ID:cotsog,项目名称:souffle,代码行数:43,代码来源:RamRelation.cpp

示例10:

bool
Parser::strmErr( std::istream & is )
{
    if ( is.eof() )
    {
        M_handler.handleEOF();
        return false;
    }

    return false;
}
开发者ID:aijunbai,项目名称:rcg_player,代码行数:11,代码来源:parser.cpp

示例11: readHeader

bool LoadObj::readHeader(std::istream &is){
    std::string buf;
    //read only to the first line starting with "v"
    while(!is.eof() && is.peek() != 'v'){
        getline(is, buf);
    }
    if (is.good())
        return true;
    else
        return false;
}
开发者ID:Gvasa,项目名称:voronoi_fracture,代码行数:11,代码来源:LoadObj.cpp

示例12: deSerialize

void Player::deSerialize(std::istream &is)
{
	Settings args;
	
	for(;;)
	{
		if(is.eof())
			throw SerializationError
					("Player::deSerialize(): PlayerArgsEnd not found");
		std::string line;
		std::getline(is, line);
		std::string trimmedline = trim(line);
		if(trimmedline == "PlayerArgsEnd")
			break;
		args.parseConfigLine(line);
	}

	//args.getS32("version");
	std::string name = args.get("name");
	updateName(name.c_str());
	/*std::string password = "";
	if(args.exists("password"))
		password = args.get("password");
	updatePassword(password.c_str());*/
	m_pitch = args.getFloat("pitch");
	m_yaw = args.getFloat("yaw");
	m_position = args.getV3F("position");
	try{
		craftresult_is_preview = args.getBool("craftresult_is_preview");
	}catch(SettingNotFoundException &e){
		craftresult_is_preview = true;
	}
	try{
		hp = args.getS32("hp");
	}catch(SettingNotFoundException &e){
		hp = 20;
	}
	/*try{
		std::string sprivs = args.get("privs");
		if(sprivs == "all")
		{
			privs = PRIV_ALL;
		}
		else
		{
			std::istringstream ss(sprivs);
			ss>>privs;
		}
	}catch(SettingNotFoundException &e){
		privs = PRIV_DEFAULT;
	}*/

	inventory.deSerialize(is);
}
开发者ID:11ph22il,项目名称:minetest,代码行数:54,代码来源:player.cpp

示例13: deSerialize

void Player::deSerialize(std::istream &is, std::string playername)
{
	Settings args;
	
	for(;;)
	{
		if(is.eof())
			throw SerializationError
					(("Player::deSerialize(): PlayerArgsEnd of player \"" + playername + "\" not found").c_str());
		std::string line;
		std::getline(is, line);
		std::string trimmedline = trim(line);
		if(trimmedline == "PlayerArgsEnd")
			break;
		args.parseConfigLine(line);
	}

	//args.getS32("version"); // Version field value not used
	std::string name = args.get("name");
	updateName(name.c_str());
	setPitch(args.getFloat("pitch"));
	setYaw(args.getFloat("yaw"));
	setPosition(args.getV3F("position"));
	try{
		hp = args.getS32("hp");
	}catch(SettingNotFoundException &e){
		hp = 20;
	}
	try{
		m_breath = args.getS32("breath");
	}catch(SettingNotFoundException &e){
		m_breath = 11;
	}

	inventory.deSerialize(is);

	if(inventory.getList("craftpreview") == NULL)
	{
		// Convert players without craftpreview
		inventory.addList("craftpreview", 1);

		bool craftresult_is_preview = true;
		if(args.exists("craftresult_is_preview"))
			craftresult_is_preview = args.getBool("craftresult_is_preview");
		if(craftresult_is_preview)
		{
			// Clear craftresult
			inventory.getList("craftresult")->changeItem(0, ItemStack());
		}
	}

	// Set m_last_*
	checkModified();
}
开发者ID:Belugion,项目名称:minetest,代码行数:54,代码来源:player.cpp

示例14: ReadZStr

static string ReadZStr(std::istream& f)
{
	std::string s;
	char c;
	while(!f.eof ()) {
		f >> c;
		if (!c) break;
		s += c;
	}
	return s;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:11,代码来源:Serializer.cpp

示例15: getcontent

std::string getcontent(std::istream &in)
{
    std::string res;
    while(!in.eof()) {
        char c;
        in.get(c);
        if(in.gcount() == 1)
            res+=c;
    }
    return res;
}
开发者ID:,项目名称:,代码行数:11,代码来源:


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