int InputFile::readTilChar(const std::string& stopChars, std::string& stringRef) { int charRead = 0; size_t pos = std::string::npos; // Loop until the character was not found in the stop characters. while(pos == std::string::npos) { charRead = ifgetc(); // First Check for EOF. If EOF is found, just return -1 if(charRead == EOF) { return(-1); } // Try to find the character in the stopChars. pos = stopChars.find(charRead); if(pos == std::string::npos) { // Didn't find a stop character and it is not an EOF, // so add it to the string. stringRef += charRead; } } return(pos); }
int InputFile::discardLine() { int charRead = 0; // Loop until the character was not found in the stop characters. while((charRead != EOF) && (charRead != '\n')) { charRead = ifgetc(); } // First Check for EOF. If EOF is found, just return -1 if(charRead == EOF) { return(-1); } return(0); }
int InputFile::readLine(std::string& line) { int charRead = 0; while(!ifeof()) { charRead = ifgetc(); if(charRead == EOF) { return(-1); } if(charRead == '\n') { return(0); } line += charRead; } // Should never get here. return(-1); }
int InputFile::readTilChar(const std::string& stopChars) { int charRead = 0; size_t pos = std::string::npos; // Loop until the character was not found in the stop characters. while(pos == std::string::npos) { charRead = ifgetc(); // First Check for EOF. If EOF is found, just return -1 if(charRead == EOF) { return(-1); } // Try to find the character in the stopChars. pos = stopChars.find(charRead); } return(pos); }
int InputFile::readTilTab(std::string& field) { int charRead = 0; while(!ifeof()) { charRead = ifgetc(); if(charRead == EOF) { return(-1); } if(charRead == '\n') { return(0); } if(charRead == '\t') { return(1); } field += charRead; } return(-1); }
bool VcfRecord::readTilTab(IFILE filePtr, std::string& stringRef) { int charRead = 0; while(1) { charRead = ifgetc(filePtr); if((charRead == '\n') || (charRead == EOF)) { // Didn't find a tab, found a '\n' or eof // It still populated the string with values up // until the tab. return(false); } if(charRead == '\t') { // hit the tab character, so exit the loop. break; } stringRef += charRead; } return(true); }