本文整理汇总了C++中StringVar::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ StringVar::GetLength方法的具体用法?C++ StringVar::GetLength怎么用?C++ StringVar::GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringVar
的用法示例。
在下文中一共展示了StringVar::GetLength方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
static void __stdcall DoExtractString(char* scriptData, UInt32 dataLen, char* dest, ScriptEventList* eventList)
{
// copy the string
memcpy(dest, scriptData, dataLen);
dest[dataLen] = 0;
if (dataLen && dest[0] == '$' && eventList && eventList->m_script) // variable name
{
Script::VariableInfo* varInfo = NULL;
varInfo = eventList->m_script->GetVariableByName(dest + 1);
if (varInfo)
{
ScriptEventList::Var* var;
var = eventList->GetVariable(varInfo->idx);
if (var)
{
StringVar* strVar;
strVar = g_StringMap.Get(var->data);
if (strVar)
if (strVar->GetLength() < 0x100) // replace string with contents of string var
strcpy_s(dest, strVar->GetLength() + 1, strVar->GetCString());
}
}
} // "%e" becomes an empty string
else if (dataLen == 2 && dest[0] == '%' && toupper(dest[1]) == 'E')
dest[0] = 0;
}
示例2: AssignableStringToken
AssignableStringVarToken::AssignableStringVarToken(UInt32 _id, UInt32 lbound, UInt32 ubound) : AssignableStringToken(_id, lbound, ubound)
{
StringVar* strVar = g_StringMap.Get(value.arrID);
if (strVar) {
upper = (upper > strVar->GetLength()) ? strVar->GetLength() - 1 : upper;
substring = strVar->SubString(lower, upper - lower + 1);
}
}
示例3: Cmd_sv_Length_Execute
bool Cmd_sv_Length_Execute(COMMAND_ARGS)
{
*result = -1; // sentinel value if extraction fails
UInt32 strID = 0;
if (ExtractArgs(EXTRACT_ARGS, &strID))
{
StringVar* str = g_StringMap.Get(strID);
if (str)
*result = str->GetLength();
}
return true;
}
示例4: StringVar_Find_Execute
bool StringVar_Find_Execute(COMMAND_ARGS, UInt32 mode, CommandInfo* commandInfo)
{
*result = -1;
UInt32 strID = 0;
UInt32 startPos = 0;
UInt32 numChars = -1;
UInt32 bCaseSensitive = 0;
UInt32 numToReplace = -1; //replace all by default
char toFind[kMaxMessageLength] = { 0 };
UInt32 intResult = -1;
if (!ExtractFormatStringArgs(0, toFind, PASS_FMTSTR_ARGS, commandInfo->numParams, &strID, &startPos, &numChars, &bCaseSensitive, &numToReplace))
return true;
StringVar* strVar = g_StringMap.Get(strID);
if (strVar)
{
if (numChars == -1)
numChars = strVar->GetLength() - startPos;
switch (mode)
{
case eMode_svFind:
intResult = strVar->Find(toFind, startPos, numChars, bCaseSensitive ? true : false);
break;
case eMode_svCount:
intResult = strVar->Count(toFind, startPos, numChars, bCaseSensitive ? true : false);
break;
case eMode_svReplace:
{
std::string str(toFind);
UInt32 splitPoint = str.find(GetSeparatorChar(scriptObj));
if (splitPoint != -1 && splitPoint < str.length())
{
toFind[splitPoint] = '\0';
char* replaceWith = (splitPoint == str.length() - 1) ? "" : toFind + splitPoint + 1;
intResult = strVar->Replace(toFind, replaceWith, startPos, numChars, bCaseSensitive ? true : false, numToReplace);
}
break;
}
}
}
if (intResult != -1)
*result = intResult;
return true;
}
示例5: if
static UInt32 __stdcall DoExtractString(char* scriptData, UInt32 dataLen, char* dest, ScriptEventList* eventList)
{
// copy the string
memcpy(dest, scriptData, dataLen);
UInt32 newDataLen = dataLen;
if (newDataLen && dest[0] == '$' && eventList && eventList->m_script) // variable name
{
VariableInfo* varInfo = NULL;
if ((newDataLen < 0x100) && (dest[newDataLen]))
dest[newDataLen] = 0;
varInfo = eventList->m_script->GetVariableByName(dest + 1);
if (varInfo)
{
ScriptEventList::Var* var;
var = eventList->GetVariable(varInfo->idx);
if (var)
{
StringVar* strVar;
strVar = g_StringMap.Get(var->data);
if (strVar)
if (strVar->GetLength() < 0x100) { // replace string with contents of string var
strcpy_s(dest, strVar->GetLength() + 1, strVar->GetCString());
newDataLen = strVar->GetLength();
}
}
}
} // "%e" becomes an empty string
else if (newDataLen == 2 && dest[0] == '%' && toupper(dest[1]) == 'E') {
newDataLen = 0;
}
// force zero terminated string
if ((newDataLen < 0x100) && (dest[newDataLen]))
dest[newDataLen] = 0;
return dataLen;
}
示例6: Assign
bool AssignableStringVarToken::Assign(const char* str)
{
StringVar* strVar = g_StringMap.Get(value.arrID);
if (strVar) {
UInt32 len = strVar->GetLength();
if (lower <= upper && upper < len) {
strVar->Erase(lower, upper-lower + 1);
if (str) {
strVar->Insert(str, lower);
substring = strVar->String();
}
return true;
}
}
return false;
}
示例7: Cmd_sv_Erase_Execute
bool Cmd_sv_Erase_Execute(COMMAND_ARGS)
{
*result = 0;
UInt32 strID = 0;
UInt32 startPos = 0;
UInt32 howMany = -1;
if (!ExtractArgs(EXTRACT_ARGS, &strID, &startPos, &howMany))
return true;
StringVar* strVar = g_StringMap.Get(strID);
if (strVar)
{
if (howMany == -1)
howMany = strVar->GetLength() - startPos;
strVar->Erase(startPos, howMany);
}
return true;
}
示例8: Cmd_sv_SubString_Execute
bool Cmd_sv_SubString_Execute(COMMAND_ARGS)
{
UInt32 rhStrID = 0;
UInt32 startPos = 0;
UInt32 howMany = -1;
std::string subStr;
if (ExtractArgs(EXTRACT_ARGS, &rhStrID, &startPos, &howMany))
{
StringVar* rhVar = g_StringMap.Get(rhStrID);
if (!rhVar)
return true;
if (howMany == -1)
howMany = rhVar->GetLength() - startPos;
subStr = rhVar->SubString(startPos, howMany);
}
AssignToStringVar(PASS_COMMAND_ARGS, subStr.c_str());
return true;
}