本文整理汇总了C++中nlmisc::CSString::strip方法的典型用法代码示例。如果您正苦于以下问题:C++ CSString::strip方法的具体用法?C++ CSString::strip怎么用?C++ CSString::strip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nlmisc::CSString
的用法示例。
在下文中一共展示了CSString::strip方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildTimestampFromDateStr
// The following routine builds a timestamp value from a date string in the format <dd>/<mm>/<yyyy>
// If the text doesn't match the expected format then ~0u is returned
static uint32 buildTimestampFromDateStr(const NLMISC::CSString& dateStr)
{
// setup a new time structure, extracting the day, month and year values from the argument string
struct tm tmstruct;
NLMISC::CSString txt= dateStr.strip();
tmstruct.tm_mday = txt.splitTo('/',true,true).atoi();
tmstruct.tm_mon = txt.splitTo('/',true,true).atoi() -1;
tmstruct.tm_year = txt.atoi();
if (tmstruct.tm_year<100)
tmstruct.tm_year= ((tmstruct.tm_year+30)%100)+1970;
// make sure the day month and year are valid
DROP_IF(tmstruct.tm_year<1970 || tmstruct.tm_year>=2100,"FILE_LIST_BUILDER 'Since' invalid year: "+dateStr,return ~0u);
DROP_IF(tmstruct.tm_mon<0 || tmstruct.tm_mon>=12,"FILE_LIST_BUILDER 'Since' invalid month: "+dateStr,return ~0u);
DROP_IF(tmstruct.tm_mday<1 || tmstruct.tm_mday>31,"FILE_LIST_BUILDER 'Since' invalid day: "+dateStr,return ~0u);
// complete initialisation of tm struct (and map year into range from 1970 up
tmstruct.tm_year -= 1900;
tmstruct.tm_wday = 0;
tmstruct.tm_yday = 0;
tmstruct.tm_isdst = 0;
// build a time_t value for the start of the day
tmstruct.tm_sec = 0;
tmstruct.tm_min = 0;
tmstruct.tm_hour = 0;
return (uint32)mktime( &tmstruct );
}
示例2: beginState
bool CStateManager::beginState(const NLMISC::CSString& stateName)
{
// make sure the state is valid
if (_ValidStates.find(stateName.strip())==_ValidStates.end())
{
nlwarning("Cannot start state as it is not in valid state list: %s",stateName.c_str());
return false;
}
// make sure the state isn't already active
for (uint32 i=0;i<_States.size();++i)
{
if (_States[i]==stateName)
{
nlwarning("Cannot start state as it is already active: %s",stateName.c_str());
return false;
}
}
// set the state as active
_States.push_back(stateName);
// write the states to a file
NLMISC::CSString stateTxt;
stateTxt.join(_States,"\n");
stateTxt.writeToFile(StateFileName);
// execute the begin_state script
CScriptManager::getInstance()->runScript("begin_"+stateName);
return true;
}
示例3: addValidState
void CStateManager::addValidState(const NLMISC::CSString& stateName)
{
if (stateName.countWords()!=1)
{
nlwarning("Invalid state name: %s",stateName.c_str());
return;
}
_ValidStates.insert(stateName.strip());
}
示例4: extractNamedParameter
NLMISC::CSString extractNamedParameter(const NLMISC::CSString& argName,NLMISC::CSString rawArgs)
{
while (!rawArgs.empty())
{
NLMISC::CSString keyword;
NLMISC::CSString args;
keyword= rawArgs.firstWord(true);
rawArgs=rawArgs.strip();
if (rawArgs[0]=='(')
{
args=rawArgs.matchDelimiters(true).stripBlockDelimiters();
}
if (keyword==argName)
{
return args;
}
}
return NLMISC::CSString();
}