Ejemplo n.º 1
0
	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 == "");
	}
Ejemplo n.º 2
0
/*
 * PublishingListener overwrite
 * FacebookPublisher2 registers itself as a PublishingListener of the mFacebook object. This will call the
 * FacebookPublisher2::publishingResponseReceived, sending the response from server in the "newId" param. The newId is
 * the id of new created object.
 * @param newId - the id of the new object.
 * @param path - contains the id of the object on which the publish request was made and the request name.
 * 				  e.g: id/feed, id/likes
 * This function is called when a new object is created (Album, Like, Comment, StatusMessage ect).
 */
void FacebookPublisher2::publishingResponseReceived(const MAUtil::String  &data, const MAUtil::String &path)
{
	MAUtil::String id;
	int found = data.find(":",0);
	if(found != MAUtil::String::npos)
	{
		found = data.find("\"", found);
		int last = data.findLastOf('"');
		if( (found != MAUtil::String::npos) && (last != MAUtil::String::npos))
		{
			id = data.substr(found+1, last-found);
		}

	}
	mListener->publishingResponseReceived(id, path);
}