コード例 #1
0
  // 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");
  }
コード例 #2
0
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;
}
コード例 #3
0
ファイル: MailMessage.cpp プロジェクト: 1514louluo/poco
void MailMessage::readHeader(std::istream& istr)
{
	clear();
	MessageHeader::read(istr);
	istr.get(); // \r
	if ('\n' == istr.peek()) istr.get(); // \n
}
コード例 #4
0
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);
        }
    }
}
コード例 #5
0
ファイル: Tokenizer.cpp プロジェクト: kylc/compiler
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;
}
コード例 #6
0
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;
}
コード例 #7
0
ファイル: isFastQ.hpp プロジェクト: srl147/libmaus
			static int getFirstCharacter(std::istream & in)
			{
				int const c = in.peek();
				if ( c >= 0 )
					in.putback(c);
				return c;
			}
コード例 #8
0
ファイル: files.cpp プロジェクト: Adapts/SimpleEdi
void chomp(std::istream& data)
{
  if (data.peek() == '\n') {
    std::string junk;
    std::getline(data, junk);
  }
}
コード例 #9
0
 /*!
  * @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());
 }
コード例 #10
0
ファイル: InboxListItem.cpp プロジェクト: Qasemt/teltonikaRes
//----------------------------------------------------------------------
//! \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;
}
コード例 #11
0
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;
	}
}
コード例 #12
0
ファイル: json.cpp プロジェクト: kevintjuh93/VrLib
		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;
		};
コード例 #13
0
ファイル: Template.cpp プロジェクト: 12307/poco
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;
}
コード例 #14
0
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 {
コード例 #15
0
ファイル: parse.cpp プロジェクト: Crikka/Abject-Language
bool Parser::next_is_between(char c1, char c2) {
  if (is->eof()) return false;

  char c = is->peek();

  return ((c >= c1) && (c <= c2));
}
コード例 #16
0
ファイル: stan_csv_reader.hpp プロジェクト: PerryZh/stan
      static bool
      read_header(std::istream& in,
                  Eigen::Matrix<std::string, Eigen::Dynamic, 1>& header,
                  std::ostream* out) {
        std::string line;

        if (in.peek() != 'l')
          return false;

        std::getline(in, line);
        std::stringstream ss(line);

        header.resize(std::count(line.begin(), line.end(), ',') + 1);
        int idx = 0;
        while (ss.good()) {
          std::string token;
          std::getline(ss, token, ',');
          boost::trim(token);

          int pos = token.find('.');
          if (pos > 0) {
            token.replace(pos, 1, "[");
            std::replace(token.begin(), token.end(), '.', ',');
            token += "]";
          }
          header(idx++) = token;
        }
        return true;
      }
コード例 #17
0
ファイル: server_iostream_ex.cpp プロジェクト: 20337112/dlib
    void on_connect  (
        std::istream& in,
        std::ostream& out,
        const std::string& foreign_ip,
        const std::string& local_ip,
        unsigned short foreign_port,
        unsigned short local_port,
        uint64 connection_id
    )
    {
        // The details of the connection are contained in the last few arguments to
        // on_connect().  For more information, see the documentation for the
        // server_iostream.  However, the main arguments of interest are the two streams.
        // Here we also print the IP address of the remote machine.
        cout << "Got a connection from " << foreign_ip << endl;

        // Loop until we hit the end of the stream.  This happens when the connection
        // terminates.
        while (in.peek() != EOF)
        {
            // get the next character from the client
            char ch = in.get();

            // now echo it back to them
            out << (char)toupper(ch);
        }
    }
コード例 #18
0
void JSSPageReader::nextToken(std::istream& istr, std::string& token)
{
	token.clear();
	int ch = istr.get();
	if (ch != -1)
	{
		if (ch == '<' && istr.peek() == '%')
		{
			token += "<%";
			ch = istr.get();
			ch = istr.peek();
			switch (ch)
			{
			case '%':
			case '@':
			case '=':
				ch = istr.get();
				token += (char) ch;
				break;
			case '!':
				ch = istr.get();
				token += (char) ch;
				if (istr.peek() == '!')
				{
					ch = istr.get();
					token += (char) ch;
				}
				break;
			case '-':
				ch = istr.get();
				token += (char) ch;
				if (istr.peek() == '-')
				{
					ch = istr.get();
					token += (char) ch;
				}
				break;
			}
		}
		else if (ch == '%' && istr.peek() == '>')
		{
			token += "%>";
			ch = istr.get();
		}
		else token += (char) ch;
	}
}
コード例 #19
0
bool SAMReader<T_ReferenceSequence, T_ReadGroup, T_SAMAlignment>::PeekLineIsHeader(std::istream &in) {
  if (in and in.peek() == '@') {
    return true;
  }
  else {
    return false;
  }
}
コード例 #20
0
ファイル: parser.cpp プロジェクト: pawel-n/zad1
void Parser::parse(std::istream &in)
{
	stream = &in;
	while (in && in.peek() != EOF) {
		statement();
	}
	stream = nullptr;
}
コード例 #21
0
ファイル: Template.cpp プロジェクト: 12307/poco
void Template::readWhiteSpace(std::istream& in)
{
	int c;
	while((c = in.peek()) != -1 && Ascii::isSpace(c))
	{
		in.get();
	}
}
コード例 #22
0
bool parse_string(std::istream& input, String& value) {
    char ch = '\0', delimiter = '"';
    if (!match("\"", input))  {
        if (Parser == Strict) {
            return false;
        }
        delimiter = '\'';
        if (input.peek() != delimiter) {
            return false;
        }
        input.get(ch);
    }
    while(!input.eof() && input.good()) {
        input.get(ch);
        if (ch == delimiter) {
            break;
        }
        if (ch == '\\') {
            input.get(ch);
            switch(ch) {
                case '\\':
                case '/':
                    value.push_back(ch);
                    break;
                case 'b':
                    value.push_back('\b');
                    break;
                case 'f':
                    value.push_back('\f');
                    break;
                case 'n':
                    value.push_back('\n');
                    break;
                case 'r':
                    value.push_back('\r');
                    break;
                case 't':
                    value.push_back('\t');
                    break;
                case 'u': {
                        int i;
                        std::stringstream ss;
                        for( i = 0; (!input.eof() && input.good()) && i < 4; ++i ) {
                            input.get(ch);
                            ss << ch;
                        }
                        if( input.good() && (ss >> i) )
                            value.push_back(i);
                    }
                    break;
                default:
                    if (ch != delimiter) {
                        value.push_back('\\');
                        value.push_back(ch);
                    } else value.push_back(ch);
                    break;
            }
        } else {
コード例 #23
0
bool ObjIO::ReadData(std::istream & is){
  std::string lineBuf;
  int c;
  int i=0;
  while(!is.eof()){
    c = is.peek();
    switch (c) {
    case 'V':
    case 'v':{
      std::string startBuf;
      is >> startBuf; // get the start of the line
      getline(is, lineBuf); // get the rest of the line
      if(startBuf == "v"){
        loadData.verts.push_back(Vector3<float>(lineBuf));
      }
    }
      break;
    case 'F':
    case 'f':
      {
        std::stringstream buf;
        is.get(*buf.rdbuf(), '\n'); // read a line into buf
        is.get(); // read the not extracted \n
        buf << "\n"; // and add it to the string stream

        std::string tmp;
        buf >> tmp; // get the first f or F (+ whitespace)

        // count the number of faces, delimited by whitespace
        int count = 0;
        while (buf >> tmp){
          count++;
        }
        // reset stream
        buf.clear();
        buf.seekg(0, std::ios::beg);

        // Determine wheter we have a triangle or a quad
        if (count == 3){
          loadData.tris.push_back(ReadTri(buf));
        }
        else {
          std::cerr << "Encountered polygon with " << count << " faces. Bailing out.\n";
          return false;
        }
      }
      break;
    default:
      // otherwise just skip the row
      getline(is, lineBuf);
      // output it so we see what we miss :)
      // std::cerr << "\"" << lineBuf << "\"\n";
      break;
    }
    i++;
  }
  return true;
}
コード例 #24
0
ファイル: llstreamtools.cpp プロジェクト: Boy/rainbow
bool get_word(std::string& output_string, std::istream& input_stream, int n)
{
	skip_emptyspace(input_stream);
	int char_count = 0;
	char c = input_stream.peek();
	while (!isspace(c) 
			&& '\n' != c 
			&& '\r' != c 
			&& input_stream.good() 
			&& char_count < n)
	{
		char_count++;
		output_string += c;
		input_stream.get();
		c = input_stream.peek();
	}
	return input_stream.good();
}
コード例 #25
0
ファイル: NwaParser.cpp プロジェクト: pohmann/WALi-OpenNWA
 void
 read_state_block(std::istream & is, NwaRefPtr nwa)
 {
   // Figure out if it's "Q:", "Q0:", or "Qf:". Read over the block
   // intro. Set the initial/final variables appropriately.
   bool initial = false, final = false;
   read_lit(is, "Q");
   if(is.peek() == ':') {
     read_lit(is, ":");
   }
   else if(is.peek() == '0') {
     read_lit(is, "0:");
     initial = true;
   }
   else {
     read_lit(is, "f:");
     final = true;
   }
コード例 #26
0
ファイル: evaluate_nnue.cpp プロジェクト: ai5/YaneuraOu
// 評価関数パラメータを読み込む
bool ReadParameters(std::istream& stream) {
  std::uint32_t hash_value;
  std::string architecture;
  if (!ReadHeader(stream, &hash_value, &architecture)) return false;
  if (hash_value != kHashValue) return false;
  if (!Detail::ReadParameters(stream, feature_transformer)) return false;
  if (!Detail::ReadParameters(stream, network)) return false;
  return stream && stream.peek() == std::ios::traits_type::eof();
}
コード例 #27
0
std::string GetString(const char i_symbol, std::istream& io_is)
  {
  std::string str;
  while(io_is.peek() != i_symbol && io_is)
    {
    str += io_is.get();
    }
  return str;
  }
コード例 #28
0
ファイル: tsvdiff.cpp プロジェクト: mapleyustat/papaya
 static void eat_line (std::istream &is) {
     for (;;) {
         int c = is.peek ();
         if (c == EOF || c == '\n')
             return;
         else
             is.get ();
     }
 }
コード例 #29
0
ファイル: tsvdiff.cpp プロジェクト: mapleyustat/papaya
 static void eat_spaces (std::istream &is) {
     for (;;) {
         int c = is.peek ();
         if (c == ' ' || c == '\t')
             is.get ();
         else
             return;
     }
 }
コード例 #30
0
ファイル: ossimXmlNode.cpp プロジェクト: renyu310/ossim-svn
bool ossimXmlNode::readTag(std::istream& in,
                           ossimString& tag)
{
    if(traceDebug())
    {
        ossimNotify(ossimNotifyLevel_DEBUG)
                << "ossimXmlNode::readTag: entered ......\n";
    }
    xmlskipws(in);

    tag = "";
    int c = in.peek();

    // bool validTag = false;
    //    while(!validTag)
    {
        while( (c != ' ')&&
                (c != '\n')&&
                (c != '\t')&&
                (c != '\r')&&
                (c != '<')&&
                (c != '>')&&
                (c != '/')&&
                (!in.fail()))
        {
            tag += (char)c;
            in.ignore(1);
            c = in.peek();
            if(tag == "!--") // ignore comment tags
            {
                tag = "--";
                break;
            }
        }
    }

    if(traceDebug())
    {
        ossimNotify(ossimNotifyLevel_DEBUG)
                << "ossimXmlNode::readTag: leaving ......\n";
    }

    return ((tag != "")&&(!in.fail()));
}