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


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

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


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

示例1: find_capture_pattern

bool OggPage::find_capture_pattern(std::istream& from)
{
	char ch;
	while(from)
	{
		while(from.get(ch) && (ch != 'O'));
		if(from.get(ch) && (ch != 'g'))
		{
			from.putback(ch);
			continue;
		}
		if(from.get(ch) && (ch != 'g'))
		{
			from.putback(ch);
			continue;
		}
		if(from.get(ch) && (ch != 'S'))
		{
			from.putback(ch);
			continue;
		}
		from.putback('S');
		from.putback('g');
		from.putback('g');
		from.putback('O');
		return bool(from);
	}
	return false;
}
开发者ID:thechampion,项目名称:gametools,代码行数:29,代码来源:ogg_page.cpp

示例2: cargar

void Sistema::cargar(std::istream & is)
{
  std::string non;
  //adelanto hasta el campo
  getline(is, non, '{');
  getline(is, non, '{');
  is.putback('{');
  //cargo el campo
  _campo.cargar(is);

  // cargo todos los drones
  // adelanto hasta encontrar donde empieza cada drone ({) o hasta llegar al ] que
  // es donde termina la lista de drones
  char c;
  while (c != ']') {
    is.get(c);
    if (c == '{') {
      is.putback('{');
      Drone d;
      d.cargar(is);
      _enjambre.push_back(d);
    }
  }

  // despues de los drones obtengo todo hasta el final que son los estados de cultivos
  getline(is, non);
  Secuencia<std::string> estadosCultivosFilas;
  // con el substr saco el " " inicial y el } final!
  estadosCultivosFilas = cargarLista(non.substr(1, non.length()-2), "[", "]");

  // este vector va a tener todos los estados pero "aplanado", todos en hilera
  // y cuando los asigne voy accediendolo como todosEstadosCultivos[n_fila*ancho + posicion en Y]
  Secuencia<std::string> todosEstadosCultivos;

  int n = 0;
  while (n < estadosCultivosFilas.size()) {
    Secuencia<string> tmp = splitBy(estadosCultivosFilas[n].substr(1, estadosCultivosFilas[n].length() - 2), ",");
    todosEstadosCultivos.insert(todosEstadosCultivos.end(), tmp.begin(), tmp.end());
    n++;
  }

  // creo la grilla de estados con las dimensiones correctas
  Dimension dim;
  dim.ancho = estadosCultivosFilas.size();
  dim.largo = todosEstadosCultivos.size() / estadosCultivosFilas.size();
  _estado = Grilla<EstadoCultivo>(dim);

  // asigno todos los estados dentro de la grilla
  int x = 0;
  while (x < dim.ancho) {
    int y = 0;
    while (y < dim.largo) {
      _estado.parcelas[x][y] = dameEstadoCultivoDesdeString(todosEstadosCultivos[x*dim.ancho+y]);
      y++;
    }
    x++;
  }
  //gane :)
}
开发者ID:burzak,项目名称:tp-algo1,代码行数:59,代码来源:sistema.cpp

示例3: TheGrid

void partitioning<Grid>::read_partition(std::istream& in)
{ 
 int p;
 partial_mapping<int,int> part_nums(-1);
 CellIterator C = TheGrid().FirstCell();
 
 
 char c;
 in >> c;
 in.putback(c);
 if(isdigit(c)) {
   while(in && ! C.IsDone()) {
     in >> p;
     int np = ranges.size()-1; //NumOfPartitions();
     for( int pp = 0; pp <= p - np; ++pp)
       add_partition();
     // if( part_nums(p) == -1) {
     //  part_nums[p] = add_partition();
     // }
     add_cell(p,*C);
     ++C;
   }
   if(!in && ! C.IsDone()) {
     std::cerr << "partitioning<Grid>::read_partition(): input ended prematurely!\n"
	       << "creating new partition for the remaining cells.\n";
     p = add_partition();
     while(! C.IsDone()) {
       add_cell(p,*C);
       ++C;
     }
   }
 }
 else {
开发者ID:BackupTheBerlios,项目名称:gral,代码行数:33,代码来源:partitioning.C

示例4: readSelf

/**
 * Standard input for a Fuzzy SOM
 * Parameter: _is The input stream
 */
void FuzzyMap::readSelf(std::istream& _is, const unsigned _size)
{
    clear();
    int dim;
    std::string layout, str;
    _is >> dim;
    _is >> layout;
    if (layout == "HEXA")
    {
        HEXALayout *tmpLayout = new HEXALayout();
        somLayout = tmpLayout;
    }
    else
    {
        RECTLayout *tmpLayout = new RECTLayout();
        somLayout = tmpLayout;
    }
    _is >> somWidth;
    _is >> somHeight;
    str = integerToString(dim);
    str += " ";
    str += integerToString(somWidth * somHeight);
    str += " ";
    for (int i = str.size() - 1; i >= 0; i--)
        if (_is)
            _is.putback((char) str[i]);
    FuzzyCodeBook::readSelf(_is, _size);

}
开发者ID:josegutab,项目名称:scipion,代码行数:33,代码来源:map.cpp

示例5: getFirstCharacter

			static int getFirstCharacter(std::istream & in)
			{
				int const c = in.peek();
				if ( c >= 0 )
					in.putback(c);
				return c;
			}
开发者ID:srl147,项目名称:libmaus,代码行数:7,代码来源:isFastQ.hpp

示例6: readTemplateCommand

std::string Template::readTemplateCommand(std::istream& in)
{
	std::string command;

	readWhiteSpace(in);

	int c = in.get();
	while(c != -1)
	{
		if ( Ascii::isSpace(c) )
			break;

		if ( c == '?' && in.peek() == '>' )
		{
			in.putback(c);
			break;
		}

		if ( c == '=' && command.length() == 0 )
		{
			command = "echo";
			break;
		}

		command += c;

		c = in.get();
	}

	return command;
}
开发者ID:12307,项目名称:poco,代码行数:31,代码来源:Template.cpp

示例7: read

void MessageHeader::read(std::istream& istr)
{
	static const int eof = std::char_traits<char>::eof();
	int ch = istr.get();
	while (ch != eof && ch != '\r' && ch != '\n')
	{
		std::string name;
		std::string value;
		while (ch != eof && ch != ':' && ch != '\n' && name.length() < MAX_NAME_LENGTH) { name += ch; ch = istr.get(); }
		if (ch == '\n') { ch = istr.get(); continue; } // ignore invalid header lines
		if (ch != ':') throw MessageException("Field name too long/no colon found");
		if (ch != eof) ch = istr.get(); // ':'
		while (std::isspace(ch)) ch = istr.get();
		while (ch != eof && ch != '\r' && ch != '\n' && value.length() < MAX_VALUE_LENGTH) { value += ch; ch = istr.get(); }
		if (ch == '\r') ch = istr.get();
		if (ch == '\n')
			ch = istr.get();
		else if (ch != eof)
			throw MessageException("Field value too long/no CRLF found");
		while (ch == ' ' || ch == '\t') // folding
		{
			while (ch != eof && ch != '\r' && ch != '\n' && value.length() < MAX_VALUE_LENGTH) { value += ch; ch = istr.get(); }
			if (ch == '\r') ch = istr.get();
			if (ch == '\n')
				ch = istr.get();
			else if (ch != eof)
				throw MessageException("Folded field value too long/no CRLF found");
		}
		add(name, value);
	}
	istr.putback(ch);
}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:32,代码来源:MessageHeader.cpp

示例8: parseExpression

void parseExpression(Node *&node, std::istream &in)
{
	char ch = in.get();
	while (!isNumber(ch) && !isOperator(ch) && !in.eof())
	{
		ch = in.get();
	}
	if (in.eof())
	{
		node = createNode('?', true);
		return;
	}
	else
	{
		bool isOperatorCh = isOperator(ch);
		int added = 0;
		if (isOperatorCh)
		{
			added = static_cast<int>(ch);
		}
		else
		{
			in.putback(ch);
			in >> added;
		}
		node = createNode(added, isOperatorCh);
		if (isOperatorCh)
		{
			parseExpression(node->leftChild, in);
			parseExpression(node->rightChild, in);
		}
	}
}
开发者ID:eucpp,项目名称:HomeworkSemester1,代码行数:33,代码来源:parseTree.cpp

示例9: readNext

	bool Lexer::readNext( LexToken &tk, std::istream &is ) {
		bool reading = true;
		char ch;
		tk.t_ = T_UNDEFINED;
		tk.s_.clear();

		while( reading ) {
			ch = is.get();
			/*std::cout << "char: " << ch;
			std::cout << " tok: " << tk.t_;
			std::cout << " state: " << state_;
			std::cout << " str: " << tk.s_;
			std::cout << std::endl;*/
			
			
			if( is.bad() || is.eof() ) {
				ch = I_EOF;
				reading = false;
			}

			const Action& a = getAction_(state_,ch);
			switch( a.charAction ) {
				case A_ADD:
					tk.s_ += ch;
					break;
				
				case A_PUTBACK:
					if(ch != I_EOF )
						is.putback(ch);
					break;
				
				case A_IGNORE:
					break;
				
				case A_ERROR:
					tk.t_ = T_UNDEFINED;
					tk.s_.clear();
					reset();
					throw IncorrectTextException();
					break;
			}

			switch( a.bufferAction ) {
				case A_UNCHANGED: break;
				case A_CLEAR: tk.s_.clear(); break;
				case A_RETURN: reading = false; break;
			}

			if( a.newTokenType != T_UNCHANGED )
				tk.t_ = a.newTokenType;

			state_ = a.toState;
		}

		if( ch == I_EOF )
			return false;
		else
			return true;
	}
开发者ID:cristicbz,项目名称:AdventureMiner,代码行数:59,代码来源:Lexer.cpp

示例10: setDataToIStream

void setDataToIStream(std::istream& stream, std::string data) {
    int dataSize = data.size();
    const char* rawData = data.c_str();

    for (int i = dataSize; i > 0; i--) {
        stream.putback(rawData[i - 1]);
    }
}
开发者ID:bigsergey,项目名称:psi-toolkit,代码行数:8,代码来源:stream_helpers.cpp

示例11: tok

Token tok(std::istream& in) {
  char c;

restart:
  c = in.get();

  if(c == '(') {
    return Token::open();
  }

  if(c == ')') {
    return Token::close();
  }

  if(isnumber(c)) {
    int val = (int)(c - 48);

    c = in.get();

    while(isnumber(c)) {
      val *= 10;
      val += (int)(c - 48);
      c = in.get();
    }

    in.putback(c);

    return Token::number(val);
  }

  if(!isspace(c) && isprint(c)) {
    std::ostringstream ss;

    while(!isspace(c) && isprint(c) && c != '(' && c != ')') {
      ss.put(c);
      c = in.get();
    }

    in.putback(c);
    return Token::sym(ss.str().c_str());
  }

  if(isspace(c)) goto restart;

  return Token::fin();
}
开发者ID:evanphx,项目名称:ficus,代码行数:46,代码来源:main.cpp

示例12: eatSpaces

 inline void eatSpaces(std::istream& inStream){
     char c = '\0';
     while(inStream.good()){
         inStream.get(c);
         if(c != ' ' && c != '\t'){
             inStream.putback(c);
             break;
         }
     }
 }
开发者ID:LovelyPanda,项目名称:hydra_project,代码行数:10,代码来源:OBJModelLoader.cpp

示例13: readToDelimiter

void CdTreeStream::readToDelimiter(std::istream& is, std::string& str)
{
	//str.erase();
	char ch;
	while (is.get(ch) && (!isDelimiter(ch)))
		//if (!isspace((unsigned char) ch))
			str += ch;
	if (isDelimiter(ch))
		is.putback(ch);
}
开发者ID:jackgopack4,项目名称:pico-blast,代码行数:10,代码来源:cuSeqTreeStream.cpp

示例14: skip_comments

 // skip_comments(is) utilise la fonction précédente pour sauter zéro, une ou plusieurs lignes
 // de commentaires débutées par '#' et allant jusqu'à '\n'.
 static void skip_comments(std::istream& is)
 {
  char c;
  is.get(c);       // Lire un caractère.
  while(c=='#')    // Tant que c'est un '#'.
   {
    skip_line(is); // On élimine les caractères jusqu'à la fin de ligne,
    is.get(c);     // Et on lit un nouveau caractère.
   }
  is.putback(c);   // On remet le caractère lu puisqu'il n'est pas un '#'.
 }
开发者ID:guillaume-gomez,项目名称:Rep-Code,代码行数:13,代码来源:Image.hpp

示例15: skip_comment_lines

 void skip_comment_lines( std::istream &in, const char comment_start)
 {
   char c, line[256];
   
   while (in.get(c), c==comment_start) 
     in.getline (line, 255);
   
   // put back first character of
   // first non-comment line
   in.putback (c);
 }
开发者ID:DominicWade,项目名称:grins,代码行数:11,代码来源:input_utils.C


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