本文整理汇总了C++中TextFile::GetLine方法的典型用法代码示例。如果您正苦于以下问题:C++ TextFile::GetLine方法的具体用法?C++ TextFile::GetLine怎么用?C++ TextFile::GetLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextFile
的用法示例。
在下文中一共展示了TextFile::GetLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FromFASTAFile
// Return true on end-of-file
bool Seq::FromFASTAFile(TextFile &File)
{
Clear();
char szLine[MAX_FASTA_LINE];
bool bEof = File.GetLine(szLine, sizeof(szLine));
if (bEof)
return true;
if ('>' != szLine[0])
Quit_Qscore("Expecting '>' in FASTA file %s line %u",
File.GetFileName(), File.GetLineNr());
// Truncate name at first blank
// TODO: This is a hack because readseq does MSF -> FASTA
// conversion in a very strange way with the annotation.
//char *ptrBlank = strchr(szLine, ' ');
//if (0 != ptrBlank)
// *ptrBlank = 0;
size_t n = strlen(szLine);
if (1 == n)
Quit_Qscore("Missing name following '>' in FASTA file %s line %u",
File.GetFileName(), File.GetLineNr());
m_ptrName = new char[n];
strcpy(m_ptrName, szLine + 1);
TEXTFILEPOS Pos = File.GetPos();
for (;;)
{
bEof = File.GetLine(szLine, sizeof(szLine));
if (bEof)
{
if (0 == size())
{
Quit_Qscore("Empty sequence in FASTA file %s line %u",
File.GetFileName(), File.GetLineNr());
return true;
}
return false;
}
if ('>' == szLine[0])
{
if (0 == size())
Quit_Qscore("Empty sequence in FASTA file %s line %u",
File.GetFileName(), File.GetLineNr());
// Rewind to beginning of this line, it's the start of the
// next sequence.
File.SetPos(Pos);
return false;
}
const char *ptrChar = szLine;
while (char c = *ptrChar++)
push_back(c);
Pos = File.GetPos();
}
}
示例2: LoadBatchList
/**
* Loads the user entered batchlist file into a private variable for later use
*
* @param file The batchlist file to load
*
* @history 2010-03-26 Sharmila Prasad - Remove the restriction of the number of
* columns in the batchlist file to 10.
* @throws Isis::IException::User - The batchlist does not contain any data
*/
void UserInterface::LoadBatchList(const QString file) {
// Read in the batch list
TextFile temp;
try {
temp.Open(file);
}
catch (IException &e) {
QString msg = "The batchlist file [" + file
+ "] could not be opened";
throw IException(IException::User, msg, _FILEINFO_);
}
p_batchList.resize(temp.LineCount());
for(int i = 0; i < temp.LineCount(); i ++) {
QString t;
temp.GetLine(t);
// Convert tabs to spaces but leave tabs inside quotes alone
t = IString(t).Replace("\t", " ", true).ToQt();
t = IString(t).Compress().ToQt().trimmed();
// Allow " ," " , " or ", " as a valid single seperator
t = IString(t).Replace(" ,", ",", true).ToQt();
t = IString(t).Replace(", ", ",", true).ToQt();
// Convert all spaces to "," the use "," as delimiter
t = IString(t).Replace(" ", ",", true).ToQt();
int j = 0;
QStringList tokens = t.split(",");
foreach(QString token, tokens) {
// removes quotes from tokens. NOTE: also removes escaped quotes.
token = token.remove(QRegExp("[\"']"));
p_batchList[i].push_back(token);
j ++ ;
}
p_batchList[i].resize(j);
// Every row in the batchlist must have the same number of columns
if(i == 0)
continue;
if(p_batchList[i - 1].size() != p_batchList[i].size()) {
QString msg =
"The number of columns must be constant in batchlist";
throw IException(IException::User, msg, _FILEINFO_);
}
}
示例3: FromFASTAFile
// Return true on end-of-file
bool Seq::FromFASTAFile(TextFile &File)
{
Clear();
char szLine[MAX_FASTA_LINE];
bool bEof = File.GetLine(szLine, sizeof(szLine));
if (bEof)
return true;
if ('>' != szLine[0])
Quit("Expecting '>' in FASTA file %s line %u",
File.GetFileName(), File.GetLineNr());
size_t n = strlen(szLine);
if (1 == n)
Quit("Missing annotation following '>' in FASTA file %s line %u",
File.GetFileName(), File.GetLineNr());
m_ptrName = new char[n];
strcpy(m_ptrName, szLine + 1);
TEXTFILEPOS Pos = File.GetPos();
for (;;)
{
bEof = File.GetLine(szLine, sizeof(szLine));
if (bEof)
{
if (0 == size())
{
Quit("Empty sequence in FASTA file %s line %u",
File.GetFileName(), File.GetLineNr());
return true;
}
return false;
}
if ('>' == szLine[0])
{
if (0 == size())
Quit("Empty sequence in FASTA file %s line %u",
File.GetFileName(), File.GetLineNr());
// Rewind to beginning of this line, it's the start of the
// next sequence.
File.SetPos(Pos);
return false;
}
const char *ptrChar = szLine;
while (char c = *ptrChar++)
{
if (isspace(c))
continue;
if (IsGapChar(c))
continue;
if (!IsResidueChar(c))
{
if (isprint(c))
{
char w = GetWildcardChar();
Warning("Invalid residue '%c' in FASTA file %s line %d, replaced by '%c'",
c, File.GetFileName(), File.GetLineNr(), w);
c = w;
}
else
Quit("Invalid byte hex %02x in FASTA file %s line %d",
(unsigned char) c, File.GetFileName(), File.GetLineNr());
}
c = toupper(c);
push_back(c);
}
Pos = File.GetPos();
}
}