本文整理汇总了C++中mautil::String::size方法的典型用法代码示例。如果您正苦于以下问题:C++ String::size方法的具体用法?C++ String::size怎么用?C++ String::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mautil::String
的用法示例。
在下文中一共展示了String::size方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*
* Adds a Checkin object for a User
* @param PROFILE_ID - the id of the User for which the Checkin object is created.
* @param placeId - the id of the place to which the checkin is made.
* @param coord - the coordinates of the checkin place.
* @param tags - list of tagged friends. String containing comma separated list of user id's.
* @param message - the message that will be posted along with the Checkin
*/
void FacebookPublisher2::addCheckin(const MAUtil::String &PROFILE_ID, const MAUtil::String &placeId,
const Coordinate &coord, const MAUtil::String &tags,
const MAUtil::String &message)
{
MAUtil::Map<MAUtil::String, MAUtil::String> params;
params["place"] = placeId;
MAUtil::String coordStr = "{\"latitude\":\"" + coord.mLatitude +"\",";
coordStr += "\"longitude\":\"" + coord.mLongitude + "\"}";
params["coordinates"] = coordStr;
MAUtil::String postdata = "method=POST" + mPostdataSeparator;
postdata += "place=";
postdata += placeId + mPostdataSeparator;
postdata += coordStr;
if(tags.size()>0)
{
postdata = mPostdataSeparator + "tags=" + tags;
}
if(message.size()>0)
{
postdata = mPostdataSeparator + "message=" + message;
}
mFacebook->requestGraph(PUBLISH, STRING, PROFILE_ID + "/checkins", HTTP_POST, params, postdata);
}
示例2: actionSubmit
void Login::actionSubmit(const MAUtil::String& mail, const MAUtil::String& pwd)
{
auth_token = "";
memset(buffer, 0, sizeof(buffer));
int res = mHttp.create((MAUtil::String(Manager::main->host) + "/" + qLogin).c_str(), HTTP_POST);
if (res < 0)
{
manager->view->callbackAuthentication();
return;
}
// escape input
static MAUtil::String jsonQuery;
jsonQuery = "{\"email\": " + Wormhole::Encoder::JSONStringify(mail.c_str()) + ", \"password\": " + Wormhole::Encoder::JSONStringify(pwd.c_str()) + "}";
mHttp.setRequestHeader("Accept", "application/json");
mHttp.setRequestHeader("Content-type", "application/json");
char buf[32];
sprintf(buf, "%d", jsonQuery.size());
mHttp.setRequestHeader("Content-length", buf);
mHttp.write(jsonQuery.c_str(), jsonQuery.size());
}
示例3: 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);
}
示例4: readCountryTableFile
/**
* Reads the CountryTable file.
* Data will be written into mCountryFileNames.
*/
void DatabaseManager::readCountryTableFile()
{
// Reset array.
mCountryFileNames.clear();
// Open CountryTable file.
MAUtil::String filePath = mFileUtil->getLocalPath() + COUNTRY_TABLE_FILE_NAME;
MAUtil::String fileContent;
if (!mFileUtil->readTextFromFile(filePath, fileContent))
{
printf("Cannot read text from CountryTable");
return;
}
//Read file content.
MAUtil::YAJLDom::Value* root = MAUtil::YAJLDom::parse(
(const unsigned char*)fileContent.c_str(), fileContent.size());
MAUtil::YAJLDom::Value* countries = root->getValueForKey(sCountriesKey);
MAUtil::YAJLDom::ArrayValue* countriesArray = (MAUtil::YAJLDom::ArrayValue*) countries;
MAUtil::Vector<MAUtil::YAJLDom::Value*> allCountries = countriesArray->getValues();
// Get all country files that we should read next.
for (int index = 0; index < allCountries.size(); index++)
{
MAUtil::YAJLDom::Value* countryValue = allCountries[index];
MAUtil::String countryFileName = countryValue->toString();
mCountryFileNames.add(countryFileName);
}
delete root;
}
示例5: writeAFile
static bool writeAFile(const MAUtil::String& dir) {
// find a root path
printf("Dir: '%s'\n", dir.c_str());
FileLister fl;
int res = fl.start(dir.c_str());
if(res < 0) {
printf("Error %i\n", res);
return false;
}
MAUtil::String file;
while(1) {
res = fl.next(file);
printf("%i: '%s'\n", res, file.c_str());
if(res < 0) {
printf("Error %i\n", res);
return false;
}
if(res == 0) {
printf("Dir '%s' ends.\n", dir.c_str());
return false;
}
if(file[file.size()-1] == '/') {
if(tryToWrite(dir + file))
return true;
if(writeAFile(dir + file))
return true;
}
}
}
示例6: maPanic
/**
* The constructor creates the user interface and the FacebookManager
*/
FacebookDemoMoblet::FacebookDemoMoblet(const MAUtil::String &appId)
{
if(appId.size()==0)
{
maPanic(1, "This application requires an application id. Please see file config.h");
}
initializeFacebook(appId);
createGUI();
login();
}
示例7: if
/**
* Constructor.
*/
ApplicationController::ApplicationController() :
mMainScreen(NULL),
mDatabase(NULL),
mCountSucceededTests(0)
{
mMainScreen = new MainScreen();
mMainScreen->show();
this->log("Application started!");
mDatabase = new DatabaseManager();
DatabaseProduct* dbProduct = new DatabaseProduct();
int platform = getPlatform();
if (platform != IOS &&
platform != ANDROID)
{
maAlert("Error", "This program runs only on Android and iOS devices",
"OK", NULL, NULL);
}
else if ( PurchaseManager::getInstance()->checkPurchaseSupported() != MA_PURCHASE_RES_OK )
{
maAlert("Error", "Billing is not supported on this device",
"OK", NULL, NULL);
}
else
{
MAUtil::String developerKey = DEVELOPER_PUBLIC_KEY;
if ( developerKey.size() == 0 &&
platform == ANDROID )
{
maAlert("Error", "You need to set developer key in Config.h ",
"OK", NULL, NULL);
}
else
{
this->log("Creating tests...");
this->createTests();
this->log("Tests are created!");
this->runNextTest();
}
}
}
示例8: readCountryFile
/**
* Read a given country file.
* Data will be added into mCountries.
* @param countryFileName File name to read.
*/
void DatabaseManager::readCountryFile(MAUtil::String& countryFileName)
{
// Open and read file content.
MAUtil::String filePath = mFileUtil->getLocalPath() + countryFileName;
MAUtil::String fileContent;
if (!mFileUtil->readTextFromFile(filePath, fileContent))
{
printf("Cannot read text from %s", filePath.c_str());
return;
}
// Extract JSON values.
MAUtil::YAJLDom::Value* root = MAUtil::YAJLDom::parse(
(const unsigned char*)fileContent.c_str(), fileContent.size());
MAUtil::String name = root->getValueForKey(sCountryNameKey)->toString();
int flagID = root->getValueForKey(sCountryFlagIDKey)->toInt();
MAUtil::String population = root->getValueForKey(sCountryPopulationKey)->toString();
MAUtil::String area = root->getValueForKey(sCountryAreaKey)->toString();
MAUtil::String languages = root->getValueForKey(sCountryLanguagesKey)->toString();
MAUtil::String government = root->getValueForKey(sCountryGovernmentKey)->toString();
MAUtil::String capital = root->getValueForKey(sCountryCapitalKey)->toString();
// Create and fill Country object with read data.
Country* country = new Country();
country->setName(name);
country->setFlagID(flagID);
country->setPopulation(population);
country->setArea(area);
country->setLanguages(languages);
country->setGovernment(government);
country->setCapital(capital);
// Add object to map and array.
mCountriesMap.insert(country->getID(), country);
mCountriesArray.add(country);
// Delete JSON root object.
delete root;
}
示例9: if
/**
* Constructor that creates the UI.
* If billing is not supported, no screen is shown.
*/
NativeUIMoblet():
mController(NULL)
{
MAUtil::String developerKey = DEVELOPER_PUBLIC_KEY;
int platform = getPlatform();
int result = IAP::PurchaseManager::getInstance()->checkPurchaseSupported();
if (platform != IOS &&
platform != ANDROID)
{
maAlert("Error", "This program runs only on Android and iOS devices",
"OK", NULL, NULL);
}
else if ( result != MA_PURCHASE_RES_OK )
{
MAUtil::String errorMessage = "Billing is not supported on this device, because of error "
+ MAUtil::integerToString(result);
maAlert("Error", errorMessage.c_str(), "OK", NULL, NULL);
}
else
{
if ( platform == ANDROID && developerKey.size() == 0 )
{
maAlert("Error", "You need to set developer key in Config.h ",
"OK", NULL, NULL);
}
else if ( platform == ANDROID &&
PurchaseManager::getInstance()->setPublicKey(DEVELOPER_PUBLIC_KEY)
== MA_PURCHASE_RES_MALFORMED_PUBLIC_KEY )
{
maAlert("Error", "Malformed developer key in Config.h ",
"OK", NULL, NULL);
}
else
{
mController = new ApplicationController();
}
}
}
示例10: widgetClicked
/*
* Handle events on screen's widgets
* NOTE: take care to dismiss the Keyboard until you press other buttons,
* because it is not modal.
*/
void HomeScreen::widgetClicked(MAHandle widgetHandle)
{
if (widgetHandle == mSearchButton)
{
// Disable the search button until new search is made.
maWidgetSetProperty(mSearchButton, MAW_WIDGET_ENABLED, "false");
// Close the edit box forced.
maWidgetSetProperty(mEditBox, MAW_EDIT_BOX_SHOW_KEYBOARD, "false");
// Declare a buffer for the text contained in the edit box.
char textBuffer[256];
// Get the text from the edit box and put it into the buffer.
int textLength = maWidgetGetProperty(mEditBox, MAW_EDIT_BOX_TEXT,
textBuffer, 256);
// If the text does not fit in the buffer, textLength will be set
// to -1, therefore we need to check that the length is greater than
// or equal to 0, otherwise we just ignore the event.
if (textLength == MAW_RES_INVALID_STRING_BUFFER_SIZE
||
strcmp(textBuffer,"") == 0)
{
return;
}
MAUtil::String text = textBuffer;
// Now we can perform a wiki search.
// After the result is received and processed, go to next screen.
if (text.size() > 2)
{
// Show the progress bar and it's label.
maWidgetSetProperty(mProgressLabel,MAW_WIDGET_VISIBLE, "true");
maWidgetSetProperty(mProgressBar, MAW_WIDGET_VISIBLE, "true");
// This label is indicating that a search action is in progress.
maWidgetSetProperty(
mProgressLabel, MAW_LABEL_TEXT, MESSAGE_WAITNOTE.c_str());
// Initiate the search with a result limit.
mWiki->search(text, mSliderValue);
}
}
else if ( mCategoryBoxes[0] == widgetHandle)
{
// If All category is selected, all the other ones are selected also.
char buf[6];
maWidgetGetProperty(mCategoryBoxes[0], MAW_CHECK_BOX_CHECKED, buf, 6);
// make sure the first 4 chars are lower case so we can have our strcmp with "true"
for(int i = 0; i < 4; i++) {
buf[i] = tolower(buf[i]);
}
if (strcmp(buf,"true") == 0)
{
// Check the other ones.
for (int i=1; i < mCategoryBoxes.size(); i++)
{
maWidgetSetProperty(mCategoryBoxes[i], MAW_CHECK_BOX_CHECKED, "true");
}
}
else
{
// Uncheck all.
for (int i=1; i < mCategoryBoxes.size(); i++)
{
maWidgetSetProperty(mCategoryBoxes[i], MAW_CHECK_BOX_CHECKED, "false");
}
}
}
else
{
// If any other category then All is unchecked, than uncheck All also.
for (int i=1; i< mCategoryBoxes.size(); i++)
{
if ( mCategoryBoxes[i] == widgetHandle )
{
char buf[6];
maWidgetGetProperty
(mCategoryBoxes[i], MAW_CHECK_BOX_CHECKED, buf, 6);
if (strcmp(buf,"false") == 0)
{
maWidgetSetProperty(
mCategoryBoxes[0], MAW_CHECK_BOX_CHECKED, "false");
}
break;
}
}
}
}