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


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

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


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

示例1: processSearchResults

/**
 * Parse the received XML, and search for title& snippet attributes.
 */
void MediaWiki::processSearchResults()
{
	/* for ex, try this request for "bear" in your browser:
	 *   http://en.wikipedia.org/w/api.php?action=query&format=xml&
	 *   list=search&srwhat=text&srsearch=bear
	 * the output looks like this:
	 * ...
	 * <search>
	 * <p ns="0" title="title1" snippet="text.." size="10283"
	 * wordcount="1324" timestamp="2011-04-12T14:25:24Z" />
	 * more paragraphs
	 * </search>
	 * ...
	 */

	// Search for each p paragraph, and get the title & snippet.
	MAUtil::String input = mBuffer;
	int openTag = input.find("<p ",0);

	while( openTag != -1 )
	{
		int closeTag = input.find("/>", openTag+1);
		if (closeTag != -1 && closeTag > openTag)
		{
			MAUtil::String  record = input.substr(
				openTag+2, closeTag - openTag +1);
			// A record, ex: <p ns="0" title="title1" snippet="text.."
			// size="10283" wordcount="1324" timestamp="2011-04-12T14:25:24Z" />
			// Add the title if it doesn't exist yet.
			MAUtil::String newRecord = getTitle(record);
			bool canAdd(true);
			for (int i=0; i < mWiki->titleResults.size(); i++)
			{
				if ( mWiki->titleResults[i] == newRecord )
				{
					canAdd = false;
				}
			}
			if (canAdd)
			{
				mWiki->titleResults.add(newRecord);
				mWiki->snippetResults.add(getSnippet(record));
			}
		}
		input.remove(0,closeTag);

		// Get the next tag.
		openTag = input.find("<p ",0);
	}
}
开发者ID:comforx,项目名称:MoSync,代码行数:53,代码来源:WikiEngine.cpp

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


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