本文整理汇总了C++中mautil::String::findFirstOf方法的典型用法代码示例。如果您正苦于以下问题:C++ String::findFirstOf方法的具体用法?C++ String::findFirstOf怎么用?C++ String::findFirstOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mautil::String
的用法示例。
在下文中一共展示了String::findFirstOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractConnectionTypeAndId
bool Facebook::extractConnectionTypeAndId(FacebookRequest *req, MAUtil::String &connectionType, MAUtil::String &id) const
{
const MAUtil::String path = req->getPath();
int found = path.findFirstOf('/');
if(String::npos == found)
{
return false;
}
id = path.substr(0, found);
connectionType = path.substr(found+1);
return (connectionType.size()>0 && id.size()>0);
}
示例2: string
void string() {
MAUtil::String str = "test";
assert("String::==", str == "test");
assert("String::!=", str != "fest");
assert("String::<", !(str < "fest") && (MAUtil::String("fest") < str));
assert("String::>", !(MAUtil::String("fest") > str) && (str > "fest"));
assert("String::<=", str <= "test" && str <= "west");
assert("String::>=", str >= "test" && str >= "fest");
assert("String::+", (str + "ing") == "testing");
str+="ing";
assert("String::+=", str == "testing");
assert("String::find()", str.find("ing") == 4 && str.find("1") == MAUtil::String::npos);
str+=" string";
assert("String::findLastOf()", str.findLastOf('g') == 13 && str.findLastOf('1') == MAUtil::String::npos);
assert("String::findFirstOf()", str.findFirstOf('g') == 6 && str.findFirstOf('1') == MAUtil::String::npos);
assert("String::findFirstNotOf()", str.findFirstNotOf('t') == 1 && str.findFirstNotOf('1') == 0);
str.insert(7, " MAUtil::");
assert("String::insert(string)", str == "testing MAUtil:: string");
str.remove(16, 2);
assert("String::remove()", str == "testing MAUtil::tring");
str.insert(16, 'S');
assert("String::insert(char)", str == "testing MAUtil::String");
assert("String::substr()", str.substr(8, 6) == "MAUtil");
assert("String::length()", str.length() == 22);
str.reserve(32);
assert("String::reserve()", str == "testing MAUtil::String" && str.length() == 22);
assert("String::capacity()", str.capacity() == 32);
str.clear();
assert("String::clear()", str.length() == 0 && str == "");
}
示例3: loadSettings
void SettingsScreen::loadSettings() {
MAUtil::String filename = getLocalPath() + SETTINGS_FILE_NAME;
MAHandle file = maFileOpen(filename.c_str(), MA_ACCESS_READ);
if(file < 0) {
printf("Error opening file %i\n", file);
return;
}
// Check if the file exists.
int res = maFileExists(file);
MAASSERT(res >= 0);
if(!res) {
printf("File does not exist.\n");
maFileClose(file);
return;
}
// Get the file size.
int size = maFileSize(file);
printf("Size: %i\n", size);
MAASSERT(size >= 0);
// Read the file data.
static char data[200];
MAASSERT(size < (int)sizeof(data));
res = maFileRead(file, data, size);
MAASSERT(res == 0);
// Close the file.
printf("Closing...\n");
res = maFileClose(file);
MAASSERT(res == 0);
printf("Done.\n");
MAUtil::String contents = data;
printf("Loaded settings string %s", contents.c_str());
if (contents.findFirstOf(',', 0) <= 0)
return;
int commaPosition = contents.findFirstOf(',', 0);
MAUtil::String appCode = contents.substr(0, commaPosition);
mAppCodeBox->setText(appCode);
printf("app code: %s", appCode.c_str());
int prevCommaPosition = commaPosition + 1;
commaPosition = contents.findFirstOf(',', prevCommaPosition);
MAUtil::String appUniq = contents.substr(prevCommaPosition, commaPosition-prevCommaPosition);
mAppUniqBox->setText(appUniq);
printf("app uniq: %s", appUniq.c_str());
prevCommaPosition = commaPosition + 1;
commaPosition = contents.findFirstOf(',', prevCommaPosition);
MAUtil::String appPwd = contents.substr(prevCommaPosition, contents.length() - prevCommaPosition);
//mAppPwdBox->setText(appPwd);
printf("app pwd: %s", appPwd.c_str());
//helper = CBHelper(appCode, appUniq);
//helper.setPassword(appPwd);
this->mScreen->initalizeHelper(appCode, appUniq, appPwd);
}