本文整理汇总了C++中WStringAutoPtr::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ WStringAutoPtr::substr方法的具体用法?C++ WStringAutoPtr::substr怎么用?C++ WStringAutoPtr::substr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WStringAutoPtr
的用法示例。
在下文中一共展示了WStringAutoPtr::substr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParameterAsWideString
FMX_PROC(errcode) BE_ExtractScriptVariables ( short /* funcId */, const ExprEnv& /* environment */, const DataVect& data_vect, Data& results)
{
errcode error_result = kNoError;
try {
BEWStringVector variables;
WStringAutoPtr calculation = ParameterAsWideString ( data_vect, 0 );
wstring search_for = L"$/\""; // variables, comments and strings (including escaped strings)
size_t found = calculation->find_first_of ( search_for );
while ( found != wstring::npos )
{
size_t end = 0;
size_t search_from = found + 1;
switch ( calculation->at ( found ) ) {
case L'$': // variables
{
/*
find the end of the variable
+ - * / ^ & = ≠ < > ≤ ≥ ( , ; ) [ ] " :: $ }
unicode escapes are required on Windows
*/
end = calculation->find_first_of ( L" ;+-=*/&^<>\t\r[]()\u2260\u2264\u2265,", search_from );
if ( end == wstring::npos ) {
end = calculation->size();
}
// add the variable to the list
wstring wanted = calculation->substr ( found, end - found );
variables.PushBack ( wanted );
search_from = end + 1;
}
break;
case L'/': // comments
switch ( calculation->at ( search_from ) ) {
case L'/':
end = calculation->find ( L"\r", search_from );
search_from = end + 1;
break;
case L'*':
end = calculation->find ( L"*/", search_from );
search_from = end + 2;
break;
default:
break;
}
break;
case L'\"': // escaped strings
end = calculation->find ( L"\"", search_from );
while ( (end != string::npos) && (calculation->at ( end - 1 ) == L'\\') ) {
end = calculation->find ( L"\"", end + 1 );
}
search_from = end + 1;
break;
// default:
}
// this is not on an eternal quest
if ( (end != string::npos) && (search_from < calculation->size()) ) {
found = calculation->find_first_of ( search_for, search_from );
} else {
found = string::npos;
}
}
results.SetAsText( *(variables.AsValueList()), data_vect.At(0).GetLocale() );
} catch ( bad_alloc e ) {
error_result = kLowMemoryError;
} catch ( exception e ) {
error_result = kErrorUnknown;
}
return error_result;
} // BE_ExtractScriptVariables