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


C++ TextFile::readLine方法代码示例

本文整理汇总了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;
}
开发者ID:StraDaMa,项目名称:armips,代码行数:59,代码来源:EncodingTable.cpp

示例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());
        }
    }
}
开发者ID:Web5design,项目名称:firtex2,代码行数:18,代码来源:SynonymMap.cpp

示例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;
}
开发者ID:kabochi,项目名称:armips,代码行数:75,代码来源:Assembler.cpp


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