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


C++ MojObject::arrayEnd方法代码示例

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


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

示例1: batchPutLargeArrayObj

MojErr MojDbPerfCreateTest::batchPutLargeArrayObj(MojDb& db, const MojChar* kindId, MojUInt64& lgArrayObjTime)
{
	timespec startTime;
	startTime.tv_nsec = 0;
	startTime.tv_sec = 0;
	timespec endTime;
	endTime.tv_nsec = 0;
	endTime.tv_sec = 0;

	MojObject objArray;

	for (MojUInt64 i = 0; i < numInsert; i++) {
		MojObject obj;
		MojErr err = obj.putString(MojDb::KindKey, kindId);
		MojTestErrCheck(err);
		err = createLargeArrayObj(obj, i);
		MojTestErrCheck(err);
		err = objArray.push(obj);
		MojTestErrCheck(err);
	}

	MojObject::ArrayIterator begin;
	MojErr err = objArray.arrayBegin(begin);
	MojTestErrCheck(err);
	MojObject::ConstArrayIterator end = objArray.arrayEnd();
	clock_gettime(CLOCK_REALTIME, &startTime);
	err = db.put(begin, end);
	MojTestErrCheck(err);
	clock_gettime(CLOCK_REALTIME, &endTime);
	lgArrayObjTime += timeDiff(startTime, endTime);
	totalTestTime += timeDiff(startTime, endTime);

	return MojErrNone;
}
开发者ID:leesangryong,项目名称:db8,代码行数:34,代码来源:MojDbPerfCreateTest.cpp

示例2: getTypes

static MojErr getTypes(MojObject typesArray, BusClient::ScanTypes &bitmask)
{
	MojObject::ConstArrayIterator it = typesArray.arrayBegin();
	if (it == NULL)
		MojErrThrowMsg(MojErrInvalidMsg, "'types' not an array");

	for (MojObject::ConstArrayIterator ni = typesArray.arrayEnd(); it != ni; it++) {
		const MojObject& element = *it;
		MojString type;
		MojErr err;

		err = element.stringValue(type);
		MojErrCheck(err);

		if (type == "dbkinds")
			bitmask |= BusClient::DBKINDS;
		else if (type == "dbpermissions")
			bitmask |= BusClient::DBPERMISSIONS;
		else if (type == "filecache")
			bitmask |= BusClient::FILECACHE;
		else if (type == "activities")
			bitmask |= BusClient::ACTIVITIES;
		else
			MojErrThrowMsg(MojErrInvalidMsg, "unrecognized type '%s'", type.data());
	}

	return MojErrNone;
}
开发者ID:feniksa,项目名称:configurator,代码行数:28,代码来源:BusClient.cpp

示例3: check

MojErr MojDbTextTokenizerTest::check(const MojChar* text, const MojChar* tokens)
{
	// tokenize string
	MojString textStr;
	MojErr err = textStr.assign(text);
	MojTestErrCheck(err);
	MojSet<MojDbKey> set;
	MojRefCountedPtr<MojDbTextTokenizer> tokenizer(new MojDbTextTokenizer);
	MojAllocCheck(tokenizer.get());
	err = tokenizer->init(_T("en_US"));
	MojTestErrCheck(err);
	err = tokenizer->tokenize(textStr, NULL, set);
	MojTestErrCheck(err);
	// check that tokens match
	MojObject obj;
	err = obj.fromJson(tokens);
	MojTestErrCheck(err);
	MojSize objSize = obj.size();
	MojSize setSize = set.size();
	MojTestAssert(objSize == setSize);
	for (MojObject::ConstArrayIterator i = obj.arrayBegin(); i != obj.arrayEnd(); ++i) {
		MojDbKey key;
		err = key.assign(*i);
		MojTestErrCheck(err);
		MojTestAssert(set.contains(key));
	}
	return MojErrNone;
}
开发者ID:ctbrowser,项目名称:db8,代码行数:28,代码来源:MojDbTextTokenizerTest.cpp

示例4: handleGet

MojErr MojDbServiceHandler::handleGet(MojServiceMessage* msg, MojObject& payload, MojDbReq& req)
{
	MojAssert(msg);
	MojLogTrace(s_log);

	MojObject ids;
	MojErr err = payload.getRequired(MojDbServiceDefs::IdsKey, ids);
	MojErrCheck(err);

	MojObjectVisitor& writer = msg->writer();
	err = writer.beginObject();
	MojErrCheck(err);
	err = writer.boolProp(MojServiceMessage::ReturnValueKey, true);
	MojErrCheck(err);
	err = writer.propName(MojDbServiceDefs::ResultsKey);
	MojErrCheck(err);
	err = writer.beginArray();
	MojErrCheck(err);
	err = m_db.get(ids.arrayBegin(), ids.arrayEnd(), writer, req);
	MojErrCheck(err);
	err = writer.endArray();
	MojErrCheck(err);
	err = writer.endObject();
	MojErrCheck(err);

	return MojErrNone;
}
开发者ID:anttiharju-owo,项目名称:db8,代码行数:27,代码来源:MojDbServiceHandler.cpp

示例5: CheckProperty

MojoNewWhereMatcher::MatchResult MojoNewWhereMatcher::CheckProperty(
	const MojObject& keyArray, MojObject::ConstArrayIterator keyIter,
	const MojObject& responseArray, MojObject::ConstArrayIterator responseIter,
	const MojObject& op, const MojObject& val, MatchMode mode) const
{
	/* Yes, this will iterate into arrays of arrays of arrays */
	for (; responseIter != responseArray.arrayEnd(); ++responseIter) {
		MatchResult result = CheckProperty(keyArray, keyIter, *responseIter,
			op, val, mode);

		if (mode == AndMode) {
			if (result != Matched) {
				return NotMatched;
			}
		} else {
			if (result == Matched) {
				return Matched;
			}
		}
	}

	if (mode == AndMode) {
		return Matched;
	} else {
		return NotMatched;
	}
}
开发者ID:ctbrowser,项目名称:activitymanager,代码行数:27,代码来源:MojoWhereMatcher.cpp

示例6: CheckMatches

MojoNewWhereMatcher::MatchResult MojoNewWhereMatcher::CheckMatches(
	const MojObject& rhsArray, const MojObject& op, const MojObject& val,
	MatchMode mode) const
{
	/* Matching a value against an array */
	for (MojObject::ConstArrayIterator iter = rhsArray.arrayBegin();
		iter != rhsArray.arrayEnd(); ++iter) {
		MatchResult result = CheckMatch(*iter, op, val);
		if (mode == AndMode) {
			if (result != Matched) {
				return NotMatched;
			}
		} else {
			if (result == Matched) {
				return Matched;
			}
		}
	}

	/* If we got here in And mode it means all the values matched.  If we
	 * got here in Or mode, it means none of them did. */
	if (mode == AndMode) {
		return Matched;
	} else {
		return NotMatched;
	}
}
开发者ID:ctbrowser,项目名称:activitymanager,代码行数:27,代码来源:MojoWhereMatcher.cpp

示例7: fromObject

MojErr MojDbMultiExtractor::fromObject(const MojObject& obj, const MojChar* locale)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);

	MojErr err = MojDbExtractor::fromObject(obj, locale);
	MojErrCheck(err);

	// load the default config
	MojDbPropExtractor defaultExtractor;
	err = defaultExtractor.fromObject(obj, locale);
	MojErrCheck(err);

	MojObject include;
	err = obj.getRequired(IncludeKey, include);
	MojErrCheck(err);

	for (MojObject::ConstArrayIterator i = include.arrayBegin();
		 i != include.arrayEnd(); ++i) {
		MojString includeName;
		err = i->stringValue(includeName);
		MojErrCheck(err);
		MojRefCountedPtr<MojDbPropExtractor> propExtractor(new MojDbPropExtractor);
		MojAllocCheck(propExtractor.get());
		err = propExtractor->fromObjectImpl(*i, defaultExtractor, locale);
		MojErrCheck(err);
		err = m_extractors.push(propExtractor);
		MojErrCheck(err);
	}
	return MojErrNone;
}
开发者ID:ctbrowser,项目名称:db8,代码行数:30,代码来源:MojDbExtractor.cpp

示例8: fromObjectImpl

MojErr MojDbPropExtractor::fromObjectImpl(const MojObject& obj, const MojDbPropExtractor& defaultConfig, const MojChar* locale)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);

	// super
	MojErr err = MojDbExtractor::fromObject(obj, locale);
	MojErrCheck(err);

	// default value
	m_default = defaultConfig.m_default;
	MojObject defaultVal;
	if (obj.get(DefaultKey, defaultVal)) {
		MojObject::Type type = defaultVal.type();
		MojDbKey key;
		if (type == MojObject::TypeArray) {
			// if the value is an array, act on its elements rather than the array object itself
			MojObject::ConstArrayIterator end = defaultVal.arrayEnd();
			for (MojObject::ConstArrayIterator j = defaultVal.arrayBegin(); j != end; ++j) {
				err = key.assign(*j);
				MojErrCheck(err);
				err = m_default.put(key);
				MojErrCheck(err);
			}
		} else {
			err = key.assign(defaultVal);
			MojErrCheck(err);
			err = m_default.put(key);
			MojErrCheck(err);
		}
	}

	// tokenizer
	m_tokenizer = defaultConfig.m_tokenizer;
	MojString tokenize;
	bool found = false;
	err = obj.get(TokenizeKey, tokenize, found);
	MojErrCheck(err);
	if (found) {
		if (tokenize == AllKey || tokenize == DefaultKey) {
			m_tokenizer.reset(new MojDbTextTokenizer);
			MojAllocCheck(m_tokenizer.get());
			err = m_tokenizer->init(locale);
			MojErrCheck(err);
		} else {
			MojErrThrow(MojErrDbInvalidTokenization);
		}
	}

	// collator
	if (m_collation == MojDbCollationInvalid)
		m_collation = defaultConfig.m_collation;
	err = updateLocale(locale);
	MojErrCheck(err);

	// set prop
	err = prop(m_name);
	MojErrCheck(err);

	return MojErrNone;
}
开发者ID:ctbrowser,项目名称:db8,代码行数:60,代码来源:MojDbExtractor.cpp

示例9: configureRevSets

MojErr MojDbKind::configureRevSets(const MojObject& obj)
{
	MojLogTrace(s_log);

	m_revSets.clear();
	MojSet<MojString> setNames;
	MojObject array;
	if (obj.get(RevisionSetsKey, array)) {
		MojObject::ConstArrayIterator end = array.arrayEnd();
		for (MojObject::ConstArrayIterator i = array.arrayBegin(); i != end; ++i) {
			MojRefCountedPtr<MojDbRevisionSet> set(new MojDbRevisionSet());
			MojAllocCheck(set.get());

			MojErr err = set->fromObject(*i);
			MojErrCheck(err);
			if (setNames.contains(set->name())) {
				MojErrThrowMsg(MojErrDbInvalidRevisionSet, _T("db: cannot repeat revSet name: '%s'"), set->name().data());
			}
			err = setNames.put(set->name());
			MojErrCheck(err);
			err = m_revSets.push(set);
			MojErrCheck(err);
		}
	}
	return MojErrNone;
}
开发者ID:webOS101,项目名称:db8,代码行数:26,代码来源:MojDbKind.cpp

示例10: ParseRecipients

void EmailAdapter::ParseRecipients(const MojObject& recipients, Email& email)
{
	MojErr err;
	
	EmailAddressListPtr to_list(new EmailAddressList);
	EmailAddressListPtr cc_list(new EmailAddressList);
	EmailAddressListPtr bcc_list(new EmailAddressList);
	
	MojObject::ConstArrayIterator it = recipients.arrayBegin();

	for (; it != recipients.arrayEnd(); ++it) {
		const MojObject& recipient = *it;

		MojString type;
		err = recipient.getRequired(Part::TYPE, type);
		ErrorToException(err);
		
		EmailAddressPtr addr = ParseAddress(recipient);

		if(type.compareCaseless("to") == 0)
			to_list->push_back(addr);
		else if(type.compareCaseless("cc") == 0)
			cc_list->push_back(addr);
		else if(type.compareCaseless("bcc") == 0)
			bcc_list->push_back(addr);
		else // not a valid recipient type
			throw MailException("invalid recipient type", __FILE__, __LINE__);
	}
	
	email.SetTo(to_list);
	email.SetCc(cc_list);
	email.SetBcc(bcc_list);
}
开发者ID:Garfonso,项目名称:app-services,代码行数:33,代码来源:EmailAdapter.cpp

示例11: batchPutLargeArrayObj

MojErr MojDbPerfCreateTest::batchPutLargeArrayObj(MojDb& db, const MojChar* kindId, MojTime& lgArrayObjTime)
{
	MojTime startTime;
	MojTime endTime;

	MojObject objArray;

	for (MojUInt64 i = 0; i < numInsert; i++) {
		MojObject obj;
		MojErr err = obj.putString(MojDb::KindKey, kindId);
		MojTestErrCheck(err);
		err = createLargeArrayObj(obj, i);
		MojTestErrCheck(err);
		err = objArray.push(obj);
		MojTestErrCheck(err);
	}

	MojObject::ArrayIterator begin;
	MojErr err = objArray.arrayBegin(begin);
	MojTestErrCheck(err);
	MojObject::ConstArrayIterator end = objArray.arrayEnd();
	err = MojGetCurrentTime(startTime);
	MojTestErrCheck(err);
	err = db.put(begin, end);
	MojTestErrCheck(err);
	err = MojGetCurrentTime(endTime);
	MojTestErrCheck(err);
	lgArrayObjTime += (endTime - startTime);
	totalTestTime += (endTime - startTime);

	return MojErrNone;
}
开发者ID:BigBlueHat,项目名称:db8,代码行数:32,代码来源:MojDbPerfCreateTest.cpp

示例12: if

MojErr BusClient::BusMethods::ScanRequest(MojServiceMessage* msg, MojObject& payload, ConfigurationMode confmode)
{
	try {
		MojErr err;
		if (payload.type() != MojObject::TypeArray) {
			MojErrThrowMsg(MojErrInternal, "invalid message format");
		}

		m_client.m_msg.reset(msg);

		for (MojObject::ConstArrayIterator it = payload.arrayBegin(); it != payload.arrayEnd(); it++) {
			const MojObject& request = *it;
			MojString locationStr;
			MojString typeStr;
			MojString app;
			BusClient::PackageType type;
			BusClient::PackageLocation location;

			err = request.getRequired("id", app);
			MojErrCheck(err);

			err = request.getRequired("type", typeStr);
			MojErrCheck(err);

			err = request.getRequired("location", locationStr);
			MojErrCheck(err);

			if (typeStr == "app") {
				type = BusClient::Application;
			} else if (typeStr == "service") {
				type = BusClient::Service;
			} else {
				MojErrThrow(MojErrInvalidMsg);
			}

			if (locationStr == "system") {
				location = BusClient::System;
			} else if (locationStr == "third party") {
				location = BusClient::ThirdParty;
			} else {
				MojErrThrow(MojErrInvalidMsg);
			}

			m_client.Scan(confmode, app, type, location);
		}

		m_client.RunNextConfigurator();
	} catch (const std::exception& e) {
		MojErrThrowMsg(MojErrInternal, "%s", e.what());
	} catch (...) {
		MojErrThrowMsg(MojErrInternal, "uncaught exception");
	}

	return MojErrNone;
}
开发者ID:feniksa,项目名称:configurator,代码行数:55,代码来源:BusClient.cpp

示例13: GetObjectValue

bool MojoWhereMatcher::GetObjectValue(const MojObject& key,
	const MojObject& response, MojObject& value) const
{
	if (key.type() == MojObject::TypeString) {
		MojString keyStr;
		MojErr err = key.stringValue(keyStr);
		if (err) {
			throw std::runtime_error("Error attempting to retrieve key name "
				"getting object value");
		}

		if (response.contains(keyStr)) {
			return response.get(keyStr, value);
		} else {
			return false;
		}
	} else if (key.type() == MojObject::TypeArray) {
		MojObject cur = response;
		for (MojObject::ConstArrayIterator iter = key.arrayBegin();
			iter != key.arrayEnd(); ++iter) {
			const MojObject& keyObj = *iter; 

			if (keyObj.type() != MojObject::TypeString) {
				throw std::runtime_error("Non-string found in property "
					"specifiction array");
			}

			MojString keyStr;
			MojErr err = keyObj.stringValue(keyStr);
			if (err) {
				throw std::runtime_error("Failed to access lookup key");
			}

			if (cur.contains(keyStr)) {
				MojObject tmp;
				if (!cur.get(keyStr, tmp)) {
					return false;
				} else {
					cur = tmp;
				}
			} else {
				return false;
			}
		}

		value = cur;
		return true;
	} else {
		throw std::runtime_error("Property specification must be the "
			"property name or array of property names");
	}
}
开发者ID:edwin12345pro,项目名称:activitymanager,代码行数:52,代码来源:MojoMatcher.cpp

示例14: ParseParts

void EmailAdapter::ParseParts(const MojObject& partsArray, EmailPartList& partList)
{
	MojObject::ConstArrayIterator it = partsArray.arrayBegin();

	for (; it != partsArray.arrayEnd(); ++it) {
		const MojObject& partObj = *it;

		EmailPartPtr emailPart = ParseEmailPart(partObj);

		// Add to the part list
		partList.push_back(emailPart);
	}
}
开发者ID:Garfonso,项目名称:app-services,代码行数:13,代码来源:EmailAdapter.cpp

示例15: handleMerge

MojErr MojDbServiceHandler::handleMerge(MojServiceMessage* msg, MojObject& payload, MojDbReq& req)
{
	MojAssert(msg);
	MojLogTrace(s_log);

	MojErr err = MojErrNone;
	MojUInt32 count = 0;
	MojObject obj;
	

	if (payload.get(MojDbServiceDefs::ObjectsKey, obj)) {
		if (payload.contains(MojDbServiceDefs::QueryKey))
			MojErrThrowMsg(MojErrInvalidArg, _T("db: cannot have both an objects param and a query param"));
		MojObject::ArrayIterator begin;
		bool ignoreM = false;
		payload.get(MojDbServiceDefs::IgnoreMissingKey, ignoreM);
		MojUInt32 mflags = MojDb::FlagNone;
		if (ignoreM)
			mflags = mflags | MojDb::FlagIgnoreMissing;
		err = obj.arrayBegin(begin);
		MojErrCheck(err);
		MojObject::ConstArrayIterator end = obj.arrayEnd();
		err = m_db.merge(begin, end, mflags, req);
		MojErrCheck(err);
		err = formatPut(msg, begin, end); // TO DO: we need to drop non-existing objects
		MojErrCheck(err);
	}
	else if (payload.get(MojDbServiceDefs::QueryKey, obj)) {
		MojObject props;
		err = payload.getRequired(MojDbServiceDefs::PropsKey, props);
		MojErrCheck(err);
		bool ignoreM = false;
		if (payload.get(MojDbServiceDefs::IgnoreMissingKey, ignoreM))
			MojErrThrowMsg(MojErrInvalidArg, _T("db: ignoreMissing - invalid option for merge query"));

		MojDbQuery query;
		err = query.fromObject(obj);
		MojErrCheck(err);
		MojUInt32 queryCount = 0;
		err = m_db.merge(query, props, queryCount, MojDb::FlagNone, req);
		MojErrCheck(err);
		count += queryCount;
		err = formatCount(msg, count);
		MojErrCheck(err);
	}
	else {
		MojErrThrowMsg(MojErrInvalidArg, _T("db: either objects or query param required for merge"));
	}

	return MojErrNone;
}
开发者ID:anttiharju-owo,项目名称:db8,代码行数:51,代码来源:MojDbServiceHandler.cpp


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