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


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

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


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

示例1: skip_quals

  // Skip quals header and qual values (read_len) of them.
  void skip_quals(std::istream& is, size_t read_len) {
    ignore_line(is);
    size_t quals = 0;
    while(is.good() && quals < read_len) {
      skip_newlines(is);
      is.ignore(read_len - quals + 1, '\n');
      quals += is.gcount();
      if(is)
        ++read_len;
    }
    skip_newlines(is);
    if(quals == read_len && (is.peek() == '@' || is.peek() == EOF))
      return;

    throw std::runtime_error("Invalid fastq sequence");
  }
开发者ID:dfajar2,项目名称:KAT,代码行数:17,代码来源:mer_overlap_sequence_parser.hpp

示例2: verificarFirma

bool Verificador::verificarFirma(ParDeClaves& parDeClaves,const std::string& firma,std::istream& mensaje){
    RSA* rsa = parDeClaves;

    EVP_PKEY* pk = EVP_PKEY_new();
    EVP_MD_CTX ctx;

    EVP_PKEY_set1_RSA(pk,parDeClaves);

    EVP_MD_CTX_init(&ctx);
    M_EVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_PAD_PKCS1/*EVP_MD_CTX_FLAG_PAD_X931*/);
    EVP_VerifyInit_ex(&ctx, EVP_get_digestbynid(NID_sha1), NULL);

    while(!mensaje.eof()){
        unsigned char buffer[tamanio_de_buffer_default];
        mensaje.read((char*)buffer,tamanio_de_buffer_default);
        EVP_VerifyUpdate(&ctx, buffer, mensaje.gcount());
        mensaje.peek();
    }

    int ok = EVP_VerifyFinal(&ctx, (unsigned char*)firma.c_str(), firma.size(), pk);
    EVP_MD_CTX_cleanup(&ctx);

    // El free esta en el constructor de ParDeClaves no puede
    // liberarse aca
    //FIPS_rsa_free(pk.pkey.rsa);

    EVP_PKEY_free(pk);

    return ok==1;
}
开发者ID:marianoheller,项目名称:itni_crypto,代码行数:30,代码来源:verificador.cpp

示例3: readHeader

void MailMessage::readHeader(std::istream& istr)
{
	clear();
	MessageHeader::read(istr);
	istr.get(); // \r
	if ('\n' == istr.peek()) istr.get(); // \n
}
开发者ID:1514louluo,项目名称:poco,代码行数:7,代码来源:MailMessage.cpp

示例4: cmnDataDeSerializeText

void cmnDataDeSerializeText(std::string & data,
                            std::istream & inputStream,
                            const char delimiter)
    throw (std::runtime_error)
{
    // reset string content
    data = "";
    bool lastCharWasEscape = false;
    char newChar;
    
    // seek around to figure how many characters are left in input stream
    std::streampos currentPosition = inputStream.tellg();
    inputStream.seekg(0, inputStream.end);
    std::streamoff charactersLeft = inputStream.tellg() - currentPosition;
    inputStream.seekg(currentPosition);
    
    // keep reading as long as we don't run into comma
    while (charactersLeft > 0                     // there is still something to read
           && ((inputStream.peek() != delimiter)  // we are not finding the delimiter
               || lastCharWasEscape)              // unless the delimiter has been "escaped"
           ) {
        inputStream.get(newChar);
        --charactersLeft;
        if ((newChar == '\\')
            && !lastCharWasEscape) {
            lastCharWasEscape = true;
        } else {
            lastCharWasEscape = false;
            data.append(1, newChar);
        }
    }
}
开发者ID:Shuyoung,项目名称:cisst,代码行数:32,代码来源:cmnDataFunctionsString.cpp

示例5: while

boost::shared_ptr<Token> Tokenizer::next(std::istream &is, SymbolTablePtr symbols) {
  // Clear any whitespace until the next token. This works because no token
  // depends on _leading_ whitespace, as long as it is separated from the
  // previous token.
  while(std::isspace(is.peek())) is.get();

  // Now that we've cleared whitespace, may be at EOF.
  if(!is.good()) return NULL;

  for(size_t i = 0; i < TOKEN_PARSING_FUNCS_LENGTH; i++) {
    std::streampos pos = is.tellg();

    TokenParsingFunc f = TOKEN_PARSING_FUNCS[i];
    boost::shared_ptr<Token> token = f(is, symbols);

    if(token) {
      return token;
    } else {
      is.seekg(pos);
    }
  }

  std::cerr << "Tokenizer error!" << std::endl;
  exit(0);

  return NULL;
}
开发者ID:kylc,项目名称:compiler,代码行数:27,代码来源:Tokenizer.cpp

示例6: parse

bool Configuration::parse(std::istream& in) {
    try {
        /* It looks like BOM */
        if(in.peek() == Bom[0]) {
            char bom[4];
            in.get(bom, 4);

            /* This is not a BOM, rewind back */
            if(bom[0] != Bom[0] || bom[1] != Bom[1] || bom[2] != Bom[2]) in.seekg(0);

            /* Or set flag */
            else _flags |= InternalFlag::HasBom;
        }

        /* Parse file */
        CORRADE_INTERNAL_ASSERT_OUTPUT(parse(in, this, {}).empty());

    } catch(std::string e) {
        Error() << "Utility::Configuration::Configuration():" << e;
        clear();
        return false;
    }

    return true;
}
开发者ID:NextGenIntelligence,项目名称:corrade,代码行数:25,代码来源:Configuration.cpp

示例7: 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

示例8: chomp

void chomp(std::istream& data)
{
  if (data.peek() == '\n') {
    std::string junk;
    std::getline(data, junk);
  }
}
开发者ID:Adapts,项目名称:SimpleEdi,代码行数:7,代码来源:files.cpp

示例9: getlinePortable

 /*!
  * @if jp
  * @brief 入力ストリームから1行読み込む
  * @else
  * @brief Read a line from input stream
  * @endif
  */
 int getlinePortable(std::istream& istr, std::string& line)
 {
   char c;
   std::stringstream s;
   
   while (istr.get(c))
     {
       if (c == '\n')
         {
           break;
         }
       else if (c == '\r')
         {
           if (istr.peek() == '\n')
             {
               istr.ignore();
             }
           break;
         }
       else
         {
           s << c;
         }
     }
   line = s.str();
   return static_cast<int>(line.size());
 }
开发者ID:thomas-moulard,项目名称:openrtm-aist-deb,代码行数:34,代码来源:stringutil.cpp

示例10: memset

//----------------------------------------------------------------------
//! \brief Read an InboxListItem from an istream
//! \param aStream The stream to read from
//----------------------------------------------------------------------
void InboxListItem::readFromStream
    (
    std::istream &aStream
    )
{
    int             i;
    int             num;
    char            dummy;
    uint8           idSize;
    uint8           id[16];

    i = 0;
    aStream >> num;
    idSize = (uint8)num;
    aStream >> dummy;    // ignore '-' inserted between id size and id
    memset( id, 0, 16 );
    while( aStream.peek() != '\n' && !aStream.eof() )
    {
        aStream >> num;
        aStream >> dummy; //ignore',' inserted between chars of id
        if( i < 16 )
            id[i++] = (uint8)num;
    }
    aStream >> dummy; // ignore '\n' inserted after item
    messageId = MessageId( idSize, id );
    mIsValid = TRUE;
}
开发者ID:Qasemt,项目名称:teltonikaRes,代码行数:31,代码来源:InboxListItem.cpp

示例11: readChar

int PropertyFileConfiguration::readChar(std::istream& istr)
{
	for (;;)
	{
		int c = istr.get();
		if (c == '\\')
		{
			c = istr.get();
			switch (c)
			{
			case 't':
				return '\t';
			case 'r':
				return '\r';
			case 'n':
				return '\n';
			case 'f':
				return '\f';
			case '\r':
				if (istr.peek() == '\n')
					istr.get();
				continue;
			case '\n':
				continue;
			default:
				return c;
			}
		}
		else if (c == '\n' || c == '\r')
			return 0;
		else
			return c;
	}
}
开发者ID:12307,项目名称:poco,代码行数:34,代码来源:PropertyFileConfiguration.cpp

示例12: eatArray

		static Value eatArray(std::istream& stream)
		{
			Value obj(Type::arrayValue);
			while (!stream.eof())
			{
				ltrim(stream);
				if (stream.peek() == ']')
				{
					stream.get();
					break;
				}
				obj.push_back(eatValue(stream));
				ltrim(stream);
				char token = stream.get();
				if (token == '/')
				{
					eatComment(stream);
					token = stream.get();
				}
				if (token == ']')
					break;
				assert(token == ',');
			}
			return obj;
		};
开发者ID:kevintjuh93,项目名称:VrLib,代码行数:25,代码来源:json.cpp

示例13: 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

示例14: readInTrips

void BarGeraImporter::readInTrips(InputGraph& graph, std::istream& is)
{
	skipComments(is);
	is.ignore(numeric_limits<streamsize>::max(),'>');//Skip to #zones
	unsigned z;
	is >> z;
	
	skipComments(is);
	is.ignore(numeric_limits<streamsize>::max(),'\n');//Skip next line
	skipComments(is);
	endMetadata(is);
	
	int currentNode = -1;
	vector<pair<unsigned, double> > currentDestinations;
	while(true) {
		skipComments(is);
		if(!is.good()) break;
		if(is.peek() == 'O') {
			is.ignore(6);
			//New origin. Add the old one to the graph if it has destinations.
			if (!currentDestinations.empty()) {
				for(vector<pair<unsigned,double> >::iterator i = currentDestinations.begin(); i != currentDestinations.end(); ++i)
					graph.addDemand(currentNode-1, i->first, i->second);
				currentDestinations.clear();
			}
			is >> currentNode;
			continue;
		} else {
开发者ID:Haiyang0921,项目名称:EquilibriumSolver,代码行数:28,代码来源:BarGeraImporter.cpp

示例15: next_is_between

bool Parser::next_is_between(char c1, char c2) {
  if (is->eof()) return false;

  char c = is->peek();

  return ((c >= c1) && (c <= c2));
}
开发者ID:Crikka,项目名称:Abject-Language,代码行数:7,代码来源:parse.cpp


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