本文整理汇总了C++中nlmisc::CSString::readFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CSString::readFromFile方法的具体用法?C++ CSString::readFromFile怎么用?C++ CSString::readFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nlmisc::CSString
的用法示例。
在下文中一共展示了CSString::readFromFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseFile
bool CCharScanScriptFile::parseFile(const std::string& fileName, CCharScanScript* container)
{
_FileName= fileName;
// read the content of the input file
bool result;
NLMISC::CSString fileContent;
result=fileContent.readFromFile(fileName);
if (result==false)
{
nlwarning("Failed to read script file: %s",fileName.c_str());
return false;
}
// split the file into lines and execute them one by one
NLMISC::CVectorSString lines;
fileContent.splitLines(lines);
for (uint32 i=0;i<lines.size();++i)
{
// strip comments and leading and trailing blanks
CSString theLine= lines[i].replace("//","\xff").splitTo('\xff').strip();
if (theLine.empty())
continue;
CCharScanScriptCommandRegistry::getInstance()->execute(*this,theLine,container);
}
return true;
}
示例2:
CStateManager::CStateManager()
{
// read the states from a file
NLMISC::CSString stateTxt;
if (NLMISC::CFile::fileExists(StateFileName))
{
stateTxt.readFromFile(StateFileName);
stateTxt.splitLines(_States);
}
// display the loaded state list
display();
}
示例3: readFileList
static void readFileList(const NLMISC::CSString& fileListName, CFileDescriptionContainer& result)
{
// read the file list from disk (the result will be empty if the file list didn't exist)
NLMISC::CSString fileList;
fileList.readFromFile(fileListName);
// split the file list text block into lines
NLMISC::CVectorSString files;
fileList.splitLines(files);
// iterate over the lies in the input file
for(uint32 i=0;i<files.size();++i)
{
// clean lines up, stripping spaces and quotes
NLMISC::CSString theFile= files[i].strip().unquoteIfQuoted();
// skip empty lines and comments
if (theFile.empty() || theFile.left(1)=="#")
continue;
// add the file name to the result
result.addFile(theFile);
}
}