当前位置: 首页>>代码示例>>C++>>正文


C++ String::length方法代码示例

本文整理汇总了C++中mautil::String::length方法的典型用法代码示例。如果您正苦于以下问题:C++ String::length方法的具体用法?C++ String::length怎么用?C++ String::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mautil::String的用法示例。


在下文中一共展示了String::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fillReceiptDialog

/**
 * Fill the items in the receipt dialog with values.
 */
void MainScreen::fillReceiptDialog(MAUtil::String appID, MAUtil::String productID,
		int transactionDate, MAUtil::String transactionId,
		MAUtil::String versionExternalId, MAUtil::String BID)
{
	// If the field is unavailable, print a line character instead.
	if ( appID.length() == 0 )
		appID = "-";
	if ( productID.length() == 0 )
		productID = "-";
	if ( transactionDate == 0 )
		mReceiptTransactionDate->setText("-");
	else
	{
		tm transaction;
		split_time(transactionDate, &transaction);
		mReceiptTransactionDate->setText(
				MAUtil::integerToString(transaction.tm_mday) + "." +
				MAUtil::integerToString(transaction.tm_mon +1) + "." +
				MAUtil::integerToString(transaction.tm_year +1900) + " / " +
				MAUtil::integerToString(transaction.tm_hour +1) + ":" +
				MAUtil::integerToString(transaction.tm_min +1) + ":" +
				MAUtil::integerToString(transaction.tm_sec +1) );
	}
	mReceiptProductId->setText(productID);
	mReceiptAppId->setText(appID);
	if ( getPlatform() == IOS )
	{
		mReceiptTransactionId->setText(transactionId);
		mReceiptVersionExternalId->setText(versionExternalId);
		mReceiptBid->setText(BID);
	}

	mReceiptDialog->show();
}
开发者ID:,项目名称:,代码行数:37,代码来源:

示例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;
}
开发者ID:donggx,项目名称:mobilelua,代码行数:34,代码来源:LuaEngine.cpp

示例3: EscapeHelper

/**
 * Helper function that escapes a string.
 */
static MAUtil::String EscapeHelper(const MAUtil::String& str)
{
	// The encoded string.
	MAUtil::String result = "";
    char buf[8];

    for (int i = 0; i < str.length(); ++i)
    {
    	char c = str[i];
        if ((48 <= c && c <= 57) ||  // 0-9
            (65 <= c && c <= 90) ||  // a..z
            (97 <= c && c <= 122))   // A..Z
        {
        	result.append(&str[i], 1);
        }
        else
        {
        	result += "%";
            sprintf(buf, "%02X", str[i]);
            result += buf;
        }
    }

    return result;
}
开发者ID:donggx,项目名称:mobilelua,代码行数:28,代码来源:LuaEngine.cpp

示例4: 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");
		}
	}
开发者ID:Felard,项目名称:MoSync,代码行数:35,代码来源:MainScreen.cpp

示例5: CreateRoot

void XML::CreateRoot(MAUtil::String filename)
{
	MAUtil::String root("<root filename=\"");
	
	root.append(filename.c_str(), filename.length());
	root.append("\">", 2);

	maFileWrite(file, root.c_str(), root.size());
}
开发者ID:xcyanx,项目名称:Ptyxiakh,代码行数:9,代码来源:XML.cpp

示例6: saveSettings

void SettingsScreen::saveSettings() {
	//return;
	// Construct the filename.
	this->mScreen->initalizeHelper(mAppCodeBox->getText(), mAppUniqBox->getText(), Cloudbase::MD5(mAppPwdBox->getText()).hexdigest());
	return;

	MAUtil::String filename = getLocalPath() + SETTINGS_FILE_NAME;

	// Open the file handle.
	printf("Open '%s'\n", filename.c_str());
	MAHandle file = maFileOpen(filename.c_str(), MA_ACCESS_READ_WRITE);
	if(file < 0) {
		printf("Error opening file %i\n", file);
		return;
	}

	// If the file exists...
	int res = maFileExists(file);
	MAASSERT(res >= 0);
	if(res) {
		// Truncate it, deleting any old data.
		printf("Truncating file...\n");
		res = maFileTruncate(file, 0);
		MAASSERT(res == 0);
	} else {
		// Otherwise, create it.
		printf("Creating file...\n");
		res = maFileCreate(file);
		MAASSERT(res >= 0);
	}
	// In either case, we now have an empty file at our disposal.

	// Write some data.
	MAUtil::String settingsData = "";
	settingsData += mAppCodeBox->getText();
	settingsData += ",";
	settingsData += mAppUniqBox->getText();
	settingsData += ",";
	settingsData += Cloudbase::MD5(mAppPwdBox->getText()).hexdigest();

	//static const char data[] = strdup(settingsData.c_str());

	res = maFileWrite(file, settingsData.c_str(), settingsData.length());
	MAASSERT(res == 0);

	// Close the file.
	printf("Closing...\n");
	res = maFileClose(file);
	MAASSERT(res == 0);

	printf("Done.\n");
	this->loadSettings();
	//return true;
}
开发者ID:cloudbase-io,项目名称:CBHelper-MoSync,代码行数:54,代码来源:SettingsScreen.cpp

示例7: setUri

void UriNdefRecord::setUri(byte prefixCode, MAUtil::String& remainingUri) {
	int length = remainingUri.length();
	setTnf(MA_NFC_NDEF_TNF_WELL_KNOWN);
	byte type[] = { (byte) 0x55 }; // URI
	maNFCSetNDEFType(fHandle, type, 1);
	Vector<byte> payload(length * sizeof(char) + 1);
	payload.add(prefixCode);
	const char* szRemainingUri = remainingUri.c_str();
	for (int i = 0; i < length; i++) {
		payload.insert(1 + sizeof(char) * i, szRemainingUri[i]);
	}
	setPayload(payload);
}
开发者ID:NeqHealthcare,项目名称:MoSync,代码行数:13,代码来源:nfcutil.cpp

示例8: canStringBeConvertedToColor

/**
 * Checks if the given string can be converted to a color.
 * @return True if the string is in the format 0xRRGGBB.
 */
bool CreateNotificationScreen::canStringBeConvertedToColor(const MAUtil::String& string)
{
	if ( string.length() == 8)
	{
		if ( 0 == MAUtil::lowerString(string).find("0x",0) )
		{
			return true;
		}
		else
			return false;
	}
	return false;
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例9: addDataToListView

	/**
	 * Add data from database into list view.
	 */
	void CountriesListScreen::addDataToListView()
	{
		// Clear data from map.
		mCountryMap.clear();

		// Create first section.
		NativeUI::ListViewSection* section = NULL;
		MAUtil::String sectionTitle("A");

		// For each country read create and add an ListViewItem widget.
		int countCountries = mDatabase.countCountries();
		for (int index = 0; index < countCountries; index++)
		{
			// If index is invalid skip this country.
			Country* country = mDatabase.getCountryByIndex(index);
			if (!country)
			{
				continue;
			}

			// If country's name is an empty string skip this country.
			MAUtil::String countryName = country->getName();
			if (countryName.length() == 0)
			{
				continue;
			}

			// Check if current country can go into current section.
			if (!section || countryName[0] != sectionTitle[0])
			{
				// Create new section.
				sectionTitle[0] = countryName[0];
				section = new NativeUI::ListViewSection(
					NativeUI::LIST_VIEW_SECTION_TYPE_ALPHABETICAL);
				section->setTitle(sectionTitle);
				section->setHeaderText(sectionTitle);
				mListView->addChild(section);
			}

			// Create and add list item for this country.
			NativeUI::ListViewItem* item = new NativeUI::ListViewItem();
			item->setText(countryName);
			item->setFontColor(COLOR_WHITE);
			item->setSelectionStyle(NativeUI::LIST_VIEW_ITEM_SELECTION_STYLE_GRAY);
			item->setIcon(country->getFlagID());
			section->addItem(item);

			mCountryMap.insert(item->getWidgetHandle(), country->getID());
		}
	}
开发者ID:Ginox,项目名称:MoSync,代码行数:53,代码来源:CountriesListScreen.cpp

示例10: handleFileGetLocalPath

/**
 * Handle the getLocalPath message.
 */
void MessageHandler::handleFileGetLocalPath(
    WebViewMessage& message)
{
    FileUtil fileUtil;
    MAUtil::String path = fileUtil.getLocalPath();
    if (0 == path.length())
    {
        replyNull(message);
    }
    else
    {
        replyString(message, path);
    }
}
开发者ID:NeqHealthcare,项目名称:MoSync,代码行数:17,代码来源:MessageHandler.cpp

示例11: canStringBeConvertedToInteger

/**
 * Checks if a given string can be converted to integer.
 * @return True if string contains only characters between [0-9], false
 * otherwise.
 */
bool CreateNotificationScreen::canStringBeConvertedToInteger(
	const MAUtil::String& string)
{
	for (int i = 0;i < string.length(); i++)
	{
		char character = string[i] - '0';
		if (ZERO > character || NINE < character)
		{
			return false;
		}
	}

	return true;
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例12: 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 == "");
	}
开发者ID:,项目名称:,代码行数:36,代码来源:

示例13: writeTextToFile

	/**
	 * Write a text string to a file.
	 * @return true on success, false on error.
	 */
	bool FileUtil::writeTextToFile(
		const MAUtil::String& filePath,
		const MAUtil::String& outText)
	{
		MAHandle file = openFileForWriting(filePath);
		if (file < 0)
		{
			return false;
		}

		int result = maFileWrite(file, outText.c_str(), outText.length());

		maFileClose(file);

		return result == 0;
	}
开发者ID:GregorGullwi,项目名称:MoSync,代码行数:20,代码来源:FileUtil.cpp

示例14: 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);
}
开发者ID:cloudbase-io,项目名称:CBHelper-MoSync,代码行数:64,代码来源:SettingsScreen.cpp

示例15: handleLog

/**
 * Handle the log message.
 */
void MessageHandler::handleLog(WebViewMessage& message)
{
    MAUtil::String s = message.getParam("message");
    maWriteLog(s.c_str(), s.length());
}
开发者ID:NeqHealthcare,项目名称:MoSync,代码行数:8,代码来源:MessageHandler.cpp


注:本文中的mautil::String::length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。