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


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

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


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

示例1:

std::vector<std::string> qdbbot::getBashNums(std::stringstream& src)
{
	std::vector<std::string> nums;
	std::cout << "qdbbot::getBashNums: entering loop" << std::endl;
	while(!src.eof())
	{
		//char* buf = new char[GLBUFFERSIZE];
		//src.getline(buf, GLBUFFERSIZE);
	
		std::string line;
		std::getline(src, line, '\n');

		if(src.bad()){}
			//try to fail gracefully

		//delete buf;


		if(line.find("<span class=qt") != std::string::npos)
		{
			std::cout << "qdbbot::getBashNums: found a num" << std::endl;
			nums.push_back(getNum(line));
		}
	}

	std::cout << "basbot::getBashNums: finished parseing nums" << std::endl;
	return nums;
}
开发者ID:the-maldridge,项目名称:Omnibot,代码行数:28,代码来源:qdbbot.cpp

示例2: while

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RifEclipseUserDataParserTools::headerReader(std::stringstream& streamData, std::string& line)
{
    std::vector<std::string> header;

    while (!isANumber(line) && !streamData.eof())
    {
        header.push_back(line);
        std::getline(streamData, line);
    }
    return header;
}
开发者ID:OPM,项目名称:ResInsight,代码行数:14,代码来源:RifEclipseUserDataParserTools.cpp

示例3: defined

void
print_stderr(std::stringstream& aStr)
{
#if defined(ANDROID)
  // On Android logcat output is truncated to 1024 chars per line, and
  // we usually use std::stringstream to build up giant multi-line gobs
  // of output. So to avoid the truncation we find the newlines and
  // print the lines individually.
  char line[1024];
  while (!aStr.eof()) {
    aStr.getline(line, sizeof(line));
    if (!aStr.eof() || strlen(line) > 0) {
      printf_stderr("%s\n", line);
    }
    if (aStr.fail()) {
      // line was too long, skip to next newline
      aStr.clear();
      aStr.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    }
  }
#else
  printf_stderr("%s", aStr.str().c_str());
#endif
}
开发者ID:dirkschulze,项目名称:gecko-dev,代码行数:24,代码来源:LayersLogging.cpp

示例4: fill_wml_messages_map

	/**
	 * Helper function for show_wml_messages(), which gathers
	 * the messages from a stringstream.
	 */
	void t_pump::fill_wml_messages_map(std::map<std::string, int>& msg_map, std::stringstream& source)
	{
		while(true) {
			std::string msg;
			std::getline(source, msg);

			if(source.eof()) {
				break;
			}

			if(msg == "") {
				continue;
			}

			if(msg_map.find(msg) == msg_map.end()) {
				msg_map[msg] = 1;
			} else {
				msg_map[msg]++;
			}
		}
		// Make sure the eof flag is cleared otherwise no new messages are shown
		source.clear();
	}
开发者ID:niegenug,项目名称:wesnoth,代码行数:27,代码来源:pump.cpp

示例5: DeserializeTree

// ---------------------------------------------------------------------------
// DeserializeTree
//		Given the functionset, and a stringstream to read from this will
//		deserialize a tree from its 'text' form. Returns true on success.
//
//	Limitations:
//		Function names cannot have spaces or it will give errors deserializing
//
bool DeserializeTree( const GPFunctionLookup& functions, GPTree*& tree, std::stringstream& in_serialized )
{
	tree = NULL;
	typedef std::map< int, IntermediateNode > IntermediateNodes;
	IntermediateNodes nodes;

	in_serialized.seekg( 0, std::ios::beg );

	while( !in_serialized.eof() )
	{
		// read in one node
		std::string functionName;
		int this_node_index = -1;

		try
		{
			in_serialized >> this_node_index;
		}
		catch( const std::exception &e )
		{
			continue;
		}

		if ( nodes.find( this_node_index ) != nodes.end() || this_node_index == -1 )
		{
			continue;
		}

		in_serialized >> functionName;
		
		// grab the delayed version since we might need it. we can get the original function from the delayed info.
		const GPFuncID delayed_function_id = functions.GetFunctionIDByName( functionName.c_str(), true );
		if ( delayed_function_id == GPFunctionLookup::NULLFUNC ) 
		{
			return false;
		}
		const GPFunctionDesc&	delayed_function		= functions.GetFunctionByID( delayed_function_id );
		const GPFuncID			original_function_id	= delayed_function.m_original_function_id;

		IntermediateNode int_node;
		int_node.delayedID			= delayed_function_id;
		int_node.functionID			= original_function_id;
		int_node.finalNode			= NULL;
		int_node.referencedByIndex	= -1;
		int_node.originalReturnType	= functions.GetFunctionByID( original_function_id ).m_return_type;
		int_node.delayedReturnType	= delayed_function.m_return_type;

		for( int i = 0; i < delayed_function.m_nparams; ++i )
		{
			in_serialized >> int_node.params[ i ];
		}
		
		nodes[ this_node_index ] = int_node;
	}

	//
	// Create some placeholder nodes for the entire tree
	for( IntermediateNodes::iterator iter = nodes.begin(); iter != nodes.end(); ++iter )
	{
		IntermediateNode&		this_node		= iter->second;

		this_node.finalNode = new GPTreeNode(	this_node.functionID, 
												NULL,
												NULL,
												NULL
											);
	}

	//
	// for every node found, set its parent
	bool tree_is_intact = true;
	for( IntermediateNodes::iterator iter = nodes.begin(); iter != nodes.end() && tree_is_intact; ++iter )
	{
		IntermediateNode&		this_node		= iter->second;
		const GPFunctionDesc&	this_function	= functions.GetFunctionByID( this_node.functionID );

		for( int i = 0; i < this_function.m_nparams; ++i )
		{
			// make sure the referenced node exists!
			if ( nodes.find( this_node.params[ i ] ) == nodes.end() ) 
			{
				tree_is_intact = false;
				break;
			}

			IntermediateNode&	parameter_node		= nodes[ this_node.params[ i ] ];
			GPTypeID		param_type_required	= this_function.m_param_types[ i ];

			//
			// up until now we dont know if any node needs to use the delayed version of its function
			// since we're now linking the tree together, we can swap a node if its parent requires
			// it to be delayed.
//.........这里部分代码省略.........
开发者ID:genix,项目名称:libGP,代码行数:101,代码来源:gpreporting.cpp

示例6: if

//------------------------------------------------------------------------------
LHDictionary::LHDictionary(std::stringstream& fileIN)
{     
    ++numberOfDicts;
    std::string lastKey = "";
    int objCounter = 0;
    std::string objText;
    
    //printf("DICT START\n");
    //printf("........................................................\n");
    //std::cout << fileIN.str() << std::endl;
    //printf("................................................................\n");    
    //file needs to start with <dict> else its not a LHDictionary file
        
    while(!fileIN.eof())
    {
        std::string line;
        getline(fileIN,line);
            
        //printf("D: c:%d %s\n", objCounter, line.c_str());
            
        if (std::string::npos != line.find("<key>")){
            if(1 < objCounter){
                objText+= line+"\n";
            }else{
                lastKey = valueForField(line);                    
            }
        }
        else if (std::string::npos != line.find("<string>")){
                
            if(1 < objCounter){
                objText+= line+"\n";
            }else{
                setObjectForKey(new LHObject(valueForField(line)), lastKey);
            }
        }
        else if (std::string::npos != line.find("<real>")){
            if(1 < objCounter){
                objText+= line+"\n";
            }else{
                setObjectForKey(new LHObject(floatFromString(valueForField(line))), lastKey);
            }
        }
        else if (std::string::npos != line.find("<integer>")){
            if(1 < objCounter){
                objText+= line+"\n";
            }else{
                setObjectForKey(new LHObject(intFromString(valueForField(line))), lastKey);
            }
        }
        else if (std::string::npos != line.find("<true/>")){
            if(1 < objCounter){
                objText+= line+"\n";
            }else{
                setObjectForKey(new LHObject(true), lastKey);
            }
        }
        else if (std::string::npos != line.find("<false/>")){
            if(1 < objCounter){
                objText+= line+"\n";
            }else{
                setObjectForKey(new LHObject(false), lastKey);
            }
        }
        else if (std::string::npos != line.find("<dict>")){
            ++objCounter;
            if(1 < objCounter){
                objText+= line+"\n";
            }
        }
        else if (std::string::npos != line.find("</dict>")){
            if(1 < objCounter){
                objText+= line+"\n";
            }
                
            --objCounter;
            if(1 == objCounter)
            {
                std::stringstream infoText(objText);
                setObjectForKey(new LHObject(new LHDictionary(infoText)), lastKey);
                objText = "";
            }
                
            if(0 > objCounter)
            {
                objText = "";
                objCounter = 1;
            }
        }
        else if (std::string::npos != line.find("<dict/>")){
            std::stringstream dummyText;
            setObjectForKey(new LHObject(new LHDictionary(dummyText)), lastKey);
        }
        else if (std::string::npos != line.find("<array>")){
            ++objCounter;
            if(1 != objCounter){
                    objText+= line+"\n";
            }
        }
        else if (std::string::npos != line.find("</array>")){
//.........这里部分代码省略.........
开发者ID:Johan08,项目名称:levelhelper-cocos2dx-box2d,代码行数:101,代码来源:LHDictionary.cpp


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