本文整理汇总了C++中mautil::String类的典型用法代码示例。如果您正苦于以下问题:C++ String类的具体用法?C++ String怎么用?C++ String使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eval
/**
* Evaluate a Lua script.
* @param script String with Lua code.
* @return Non-zero if successful, zero on error.
*/
int LuaEngine::eval(const char* script)
{
lua_State* L = (lua_State*) mLuaState;
// Evaluate Lua script.
int result = luaL_dostring(L, script);
// Was there an error?
if (0 != result)
{
MAUtil::String errorMessage;
if (lua_isstring(L, -1))
{
errorMessage = lua_tostring(L, -1);
// Pop the error message.
lua_pop(L, 1);
}
else
{
errorMessage =
"There was a Lua error condition, but no error message.";
}
lprintfln("Lua Error: %s\n", errorMessage.c_str());
// Print size of Lua stack (debug info).
lprintfln("Lua stack size: %i\n", lua_gettop(L));
reportLuaError(errorMessage.c_str());
}
return result == 0;
}
示例2: UnescapeHelper
/**
* Helper function that unescapes a string.
*/
static MAUtil::String UnescapeHelper(const MAUtil::String& str)
{
// The decoded string.
MAUtil::String result = "";
for (int i = 0; i < str.length(); ++i)
{
// If the current character is the '%' escape char...
if ('%' == (char) str[i])
{
// Get the char value of the two digit hex value.
MAUtil::String hex = str.substr(i + 1, 2);
long charValue = strtol(
hex.c_str(),
NULL,
16);
// Append to result.
result += (char) charValue;
// Skip over the hex chars.
i += 2;
}
else
{
// Not encoded, just copy the character.
result += str[i];
}
}
return result;
}
示例3: isPlayingSound
/**
* Check if the local notification is playing sound.
* @return True if the local notification is playing sound when it's
* shown, false otherwise.
*/
bool LocalNotification::isPlayingSound() const
{
MAUtil::String value =
this->getPropertyString(MA_NOTIFICATION_LOCAL_PLAY_SOUND);
return (0 == strcmp(value.c_str(), "true")) ? true : false;
}
示例4: isReorderControlShown
/**
* Check if the reorder control is shown.
* The reordering control is gray, multiple horizontal bar control
* on the right side of the cell.
* Platform: iOS.
* @return true if it's shown, false otherwise.
*/
bool SegmentedListViewItem::isReorderControlShown()
{
MAUtil::String value = this->getPropertyString(
MAW_SEGMENTED_LIST_VIEW_ITEM_SHOW_REORDER_CONTROL);
bool returnValue = (strcmp(value.c_str(), "true")) ? false : true;
return returnValue;
}
示例5: tryToRead
// Reads a log file from a s60v3 debug runtime.
static bool tryToRead() {
MAUtil::String filename = "C:/Data/msrlogold.txt";
printf("Open '%s'\n", filename.c_str());
MAHandle file = maFileOpen(filename.c_str(), MA_ACCESS_READ);
if(file < 0) {
printf("Error %i\n", file);
return false;
}
int res = maFileExists(file);
MAASSERT(res >= 0);
if(!res) {
printf("File does not exist.\n");
return false;
}
int size = maFileSize(file);
printf("Size: %i\n", size);
MAASSERT(size >= 0);
static char data[32*1024];
MAASSERT(size < (int)sizeof(data));
res = maFileRead(file, data, size);
MAASSERT(res == 0);
data[32] = 0;
printf("%s\n", data);
printf("Closing...\n");
res = maFileClose(file);
MAASSERT(res == 0);
printf("Done.\n");
return true;
}
示例6: customEvent
/**
* This function is called when an event that Moblet doesn't recognize is recieved.
*/
void TestMoblet::customEvent(const MAEvent& event)
{
if ( event.type == EVENT_TYPE_ALERT)
{
// printf("\n =========== Alert Event received ======\n");
MAUtil::String temp = "";
switch( event.alertButtonIndex)
{
case 1:
temp += "First ";
break;
case 2:
temp += "Second ";
break;
case 3:
temp += "Third ";
break;
default:
temp = "err";
}
temp += " button was clicked";
// maMessageBox("Alert Event received", temp.c_str());
printf(temp.c_str());
printf("\n ------------- This was all ------------- \n");
}
}
示例7: isShowingDeleteConfirmation
/**
* Check if the item is currently showing the delete-confirmation button.
* When users tap the deletion control (the red circle to the left of
* the cell), the cell displays a "Delete" button on the right side of
* the cell.
* Platform: iOS.
* @return True if it's showing the delete confirmation button, false
* otherwise.
*/
bool SegmentedListViewItem::isShowingDeleteConfirmation()
{
MAUtil::String value = this->getPropertyString(
MAW_SEGMENTED_LIST_VIEW_ITEM_IS_SHOWING_DELETE_CONFIRMATION);
bool returnValue = (strcmp(value.c_str(), "true")) ? false : true;
return returnValue;
}
示例8:
/*
* Adds a Post object to a to a User wall.
* @param message - the message to be posted
* @param link - the link to be included in post.
* @param pictureUrl - a picture url to be included in post.
* @param actions - a Vector of Action objects (objects containing name and link) to be included in the post.
* @param id - the id of the user on which wall the post will be displayed.
*/
void FacebookPublisher2::addPostOnWall(const MAUtil::String &ID, const MAUtil::String &message, const MAUtil::String &link,
const MAUtil::String &name, const MAUtil::String &caption, const MAUtil::String &description )
{
MAUtil::Map<MAUtil::String, MAUtil::String> params;
MAUtil::String postdata = "message=" + message;
if(link.size()>0)
{
postdata += mPostdataSeparator + "link=" + link;
}
// if(pictureUrl.size()>0)
// {
// postdata += mPostdataSeparator + "picture=" + pictureUrl;
// }
if(name.size()>0)
{
postdata += mPostdataSeparator + "name=" + name;
}
if(caption.size()>0)
{
postdata += mPostdataSeparator + "caption=" + caption;
}
if(description.size()>0)
{
postdata += mPostdataSeparator + "description=" + description;
}
mFacebook->requestGraph(PUBLISH, STRING, ID + "/feed", HTTP_POST, postdata);
}
示例9: submitEditBoxContent
/**
* This method is called when the Submit button is clicked, or edit box
* return button was hit.
*/
void MainScreen::submitEditBoxContent()
{
// Get the text from the password box.
MAUtil::String password = mPasswordBox->getText();
// Check if the text doesn't fit the buffer( the default size is 256).
if ( mPasswordBox->getLastError().errorCode ==
MAW_RES_INVALID_STRING_BUFFER_SIZE )
{
// If the password is too long we use the instructions label
// to inform the user. Note that C automatically concatenates
// strings split over multiple lines.
mInstructions->setText("Password too long. "
"Please enter a shorter password:");
}
// Check that the password is at least 6 characters long.
else if ( password.length() < 6 )
{
// If the password is too short we use the instructions label
// to inform the user. Note that C automatically concatenates
// strings split over multiple lines.
mInstructions->setText("Password too short. "
"Please enter a password of at least 6 characters:");
}
else
{
// The password is at least 6 characters long,
// we congratulate user.
mInstructions->setText("Password OK");
}
}
示例10: httpFinished
void ImageCache::httpFinished(MAUtil::HttpConnection* http, int result) {
if (result == 200) {
MAUtil::String *contentLengthStr = new MAUtil::String("-1");
int responseBytes = mHttp.getResponseHeader("content-length", contentLengthStr);
mContentLength = 0;
mDataOffset = 0;
mData = maCreatePlaceholder();
if(responseBytes == CONNERR_NOHEADER) {
} else {
mContentLength = atoi(contentLengthStr->c_str());
}
delete contentLengthStr;
if (maCreateData(mData, mContentLength) == RES_OK){
}
if(mContentLength >= 1024 || mContentLength == 0) {
mHttp.recv(mBuffer, 1024);
} else {
mBuffer[mContentLength] = 0;
mHttp.recv(mBuffer, mContentLength);
}
}
else {
finishedDownloading();
}
}
示例11: isSelectionAllowed
bool ListView::isSelectionAllowed()
{
MAUtil::String value = this->getPropertyString(
MAW_LIST_VIEW_ALLOW_SELECTION);
bool returnValue = (strcmp(value.c_str(), "true")) ? false : true;
return returnValue;
}
示例12: buttonClicked
void SMV::buttonClicked(Widget* button)
{
mEditBox->hideKeyboard();
MAUtil::String str;
str = mEditBox->getText();
strcpy(engine->url_path, str.c_str());
int str_c = strlen(engine->url_path);
if(engine->url_path[str_c-1] != '/')
{
engine->url_path[str_c++] = '/';
engine->url_path[str_c] = '\0';
//mEditBox->setText(engine->url_path);
}
MAHandle directory = maFileOpen(engine->url_path, MA_ACCESS_READ);
if (directory < 0)
maMessageBox("Uwaga!", "Blad FileOpen!");
else
{
if (!maFileExists(directory))
maMessageBox("Uwaga!", "Katalog nie istnieje!");
else
{
maWidgetScreenShow(0);
int res = maLocationStart();
if(res<0) maPanic(1, "No GPS available");
engine->read_conf_file();
engine->env_init();
engine->draw();
}
}
}
示例13: 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());
}
示例14: readStringFromResource
/*
* Read the only string from one string resource.
* Note: The parameter pos is used both for input and output
* of the position in the resource data.
* @param resID A valid resource id.
* @param pos In: The start position. Out: The position
* after the string in the resource.
* @param output The resulting string.
*/
bool ScreenImageSwiper::readStringFromResource(
MAHandle resID,
int& pos,
MAUtil::String& output) const
{
// Get all the characters on one read.
// Get the length of the string stored as a .pstring
// (Pascal string). The first byte contains the length.
byte stringLen = 0;
maReadData(resID, (void*) &stringLen, pos, sizeof(byte));
if (stringLen > maGetDataSize(resID) || stringLen <= 0)
{
return false;
}
// Read the string.
pos += sizeof(byte);
output.resize(stringLen);
maReadData(resID, (void*) output.c_str(), pos, stringLen);
// Update position to the byte after the string.
pos += stringLen;
return true;
}
示例15: 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;
}