本文整理汇总了C++中nlmisc::CSString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ CSString::size方法的具体用法?C++ CSString::size怎么用?C++ CSString::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nlmisc::CSString
的用法示例。
在下文中一共展示了CSString::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getFileVersion
uint32 getFileVersion(const NLMISC::CSString& fileName)
{
// start at the back of the file name and scan forwards until we find a '/' or '\\' or ':' or a digit
uint32 i= fileName.size();
while (i--)
{
char c= fileName[i];
// if we've hit a directory name separator then we haven't found a version number so drop out
if (c=='/' || c=='\\' || c==':')
return ~0u;
// if we've found a digit then construct the rest of the version number and return
if (isdigit(c))
{
uint32 firstDigit= i;
while (firstDigit!=0 && isdigit(fileName[firstDigit-1]))
{
--firstDigit;
}
return fileName.leftCrop(firstDigit).left(i-firstDigit+1).atoui();
}
}
// default to our 'invalid' value
return ~0u;
}
示例2: setScenarioToLoad
bool CScenarioValidator::setScenarioToLoad( const std::string& filename, CScenarioValidator::TValues& values, std::string& md5, std::string& signature, bool checkMD5)
{
values.clear();
_Filename = filename;
_Values.clear();
// open our input file
NLMISC::CIFile inf;
if (!inf.open(_Filename, true) )
{
nlwarning("Can't load scenario %s", _Filename.c_str());
return false;
}
try
{
static const char * header = "---- Header\n";
static const char * slashheader = "---- /Header\n\n";
static const char * comment = "-- ";
static const unsigned int headerLen = (unsigned int)strlen(header);
static const unsigned int slasheaderLen = (unsigned int)strlen(slashheader);
static const unsigned int commentLen = (unsigned int)strlen(comment);
NLMISC::CSString tmp;
tmp.resize( inf.getFileSize() );
inf.serialBuffer((uint8*)&tmp[0], (uint)tmp.size());
_ScenarioBody = tmp.replace("\r\n", "\n");
// Scenario without header
if (_ScenarioBody.size() < headerLen ||_ScenarioBody.substr(0, headerLen) != header )
{
md5 = "";
signature = "";
inf.close();
return true;
}
std::string::size_type endHeader = _ScenarioBody.find(slashheader, headerLen);
if (endHeader == std::string::npos ) {
inf.close();
return false;
}
std::string::size_type startHeader = headerLen;
std::vector<std::string> lines;
NLMISC::splitString( _ScenarioBody.substr(startHeader, endHeader - startHeader), "'\n", lines);
std::vector<std::string>::const_iterator firstLine(lines.begin()), lastLine(lines.end());
std::vector<std::string> result;
for (; firstLine != lastLine ; ++firstLine)
{
result.clear();
NLMISC::splitString(*firstLine, " = '", result);
if (result.size() == 1)
{
result.push_back("");
}
if (result.size() == 2)
{
if (result[0].find(comment) != std::string::npos)
{
//>result[1]"\\n" => "\n"
NLMISC::CSString tmp = result[1];
tmp = tmp.replace("\\n", "\n");
values.push_back( std::make_pair( result[0].substr(commentLen), tmp));
}
}
}
if (values.size() >=2
&& values[0].first == "Version"
&& values[1].first == "Signature"
&& values[2].first == "HeaderMD5" && values[3].first =="BodyMD5")
{
std::string headerBodyMd5;
std::string::size_type subHeader = _ScenarioBody.find("-- BodyMD5", startHeader);
if (checkMD5)
{
std::string md5Id1 = NLMISC::getMD5((uint8*)(_ScenarioBody.data() + subHeader), (uint32)(endHeader - subHeader)).toString();
if (values[2].second != md5Id1 )
{
return false;
}
std::string md5Id2 = NLMISC::getMD5((uint8*)(_ScenarioBody.data() + endHeader + slasheaderLen), (uint32)(_ScenarioBody.size() - (endHeader + slasheaderLen))).toString();
if (values[3].second != md5Id2)
{
return false;
}
}
md5 = values[2].second;
signature = values[1].second;
//.........这里部分代码省略.........