本文整理汇总了C++中TextFile::readLine方法的典型用法代码示例。如果您正苦于以下问题:C++ TextFile::readLine方法的具体用法?C++ TextFile::readLine怎么用?C++ TextFile::readLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextFile
的用法示例。
在下文中一共展示了TextFile::readLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
bool EncodingTable::load(const std::wstring& fileName, TextFile::Encoding encoding)
{
unsigned char hexBuffer[MAXHEXLENGTH];
TextFile input;
if (input.open(fileName,TextFile::Read,encoding) == false)
return false;
hexData.clear();
valueData.clear();
entries.clear();
setTerminationEntry((unsigned char*)"\0",1);
while (!input.atEnd())
{
std::wstring line = input.readLine();
if (line.empty() || line[0] == '*') continue;
if (line[0] == '/')
{
std::wstring hex = line.substr(1);
if (hex.empty() || hex.length() > 2*MAXHEXLENGTH)
{
// error
continue;
}
int length = parseHexString(hex,hexBuffer);
if (length == -1)
{
// error
continue;
}
setTerminationEntry(hexBuffer,length);
} else {
size_t pos = line.find(L'=');
std::wstring hex = line.substr(0,pos);
std::wstring value = line.substr(pos+1);
if (hex.empty() || value.empty() || hex.length() > 2*MAXHEXLENGTH)
{
// error
continue;
}
int length = parseHexString(hex,hexBuffer);
if (length == -1)
{
// error
continue;
}
addEntry(hexBuffer,length,value);
}
}
return true;
}
示例2: load
void SynonymMap::load(const string& sFileName)
{
close();
TextFile tf;
tf.open(sFileName.c_str(), "r");
char szLine[512];
if(tf.isFileOpen())
{
while(!tf.isEof() && tf.readLine(szLine, 512, true) > 0)
{
StringTokenizer st(szLine, ":", StringTokenizer::TOKEN_TRIM
| StringTokenizer::TOKEN_IGNORE_EMPTY );
if(st.getNumTokens() != 2)
continue;
addSynonyms(st[0].c_str(), st[1].c_str());
}
}
}
示例3: GetLine
bool GetLine(TextFile& Input, std::wstring& dest)
{
std::wstring Buffer = Input.readLine();
dest = L"";
if (Input.hasError())
Logger::printError(Logger::Warning,Input.getErrorText());
int InputPos = 0;
while (InputPos < (int)Buffer.size() && (Buffer[InputPos] == '\t' || Buffer[InputPos] == ' ')) InputPos++;
while (InputPos < (int)Buffer.size() && CheckEndLine(Buffer,InputPos) == false)
{
switch (Buffer[InputPos])
{
case ' ':
case '\t':
while (InputPos < (int)Buffer.size() && (Buffer[InputPos] == '\t' || Buffer[InputPos] == ' ')) InputPos++;
if (CheckEndLine(Buffer,InputPos) == true)
{
return true;
}
dest += ' ';
break;
case '"': // string
dest += towlower(Buffer[InputPos++]);
while (InputPos < (int)Buffer.size() && Buffer[InputPos] != '"')
{
if (InputPos+1 < (int)Buffer.size() && Buffer[InputPos] == '\\' && Buffer[InputPos+1] == '"')
{
dest += '\\';
dest += '"';
InputPos += 2;
continue;
}
if (InputPos+1 < (int)Buffer.size() && Buffer[InputPos] == '\\' && Buffer[InputPos+1] == '\\')
{
dest += '\\';
dest += '\\';
InputPos += 2;
continue;
}
if (Buffer[InputPos] == '\n' || Buffer[InputPos] == 0)
{
Logger::printError(Logger::Error,L"Unexpected end of line in string constant");
return false;
}
dest += Buffer[InputPos++];
}
if (InputPos == (int)Buffer.size())
{
Logger::printError(Logger::Error,L"Unexpected end of line in string constant");
return false;
}
dest += towlower(Buffer[InputPos++]);
break;
case '\'':
if (Buffer[InputPos+2] == '\'')
{
dest += Buffer[InputPos++];
dest += Buffer[InputPos++];
dest += Buffer[InputPos++];
} else {
Logger::printError(Logger::Error,L"Invalid character constant");
return false;
}
break;
default:
dest += towlower(Buffer[InputPos++]);
break;
}
}
return true;
}