本文整理汇总了C++中MojObject::end方法的典型用法代码示例。如果您正苦于以下问题:C++ MojObject::end方法的具体用法?C++ MojObject::end怎么用?C++ MojObject::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojObject
的用法示例。
在下文中一共展示了MojObject::end方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emptyTest
MojErr MojObjectTest::emptyTest(MojObject& obj)
{
MojObject obj2;
MojString str1;
MojString str2;
bool found = false;
MojTestAssert(obj.size() == 0);
MojTestAssert(obj.empty());
MojTestAssert(obj.boolValue() == false);
MojTestAssert(obj.intValue() == 0);
MojTestAssert(obj.decimalValue() == MojDecimal());
MojTestAssert(obj.begin() == obj.end());
MojTestAssert(!obj.contains(_T("hello")));
MojTestAssert(!obj.get(_T("hi"), obj2));
MojErr err = obj.del(_T("hello"), found);
MojTestErrCheck(err);
obj2.assign(obj);
MojTestAssert(obj2.type() == obj.type());
MojTestAssert(obj2 == obj);
MojTestAssert(!(obj2 != obj));
err = obj.stringValue(str1);
MojTestErrCheck(err);
err = obj2.stringValue(str2);
MojTestErrCheck(err);
MojTestAssert(str1 == str2);
return MojErrNone;
}
示例2: mergeInto
MojErr MojDb::mergeInto(MojObject& dest, const MojObject& obj, const MojObject& prev)
{
MojLogTrace(s_log);
// TODO: support field deletion
// TODO: move merge fn out of db
MojErr err;
MojObject::ConstIterator objIter = obj.begin();
MojObject::ConstIterator prevIter = prev.begin();
while (objIter != obj.end() || prevIter != prev.end()) {
// compare keys from two iters
int comp;
if (objIter == obj.end()) {
comp = 1;
} else if (prevIter == prev.end()) {
comp = -1;
} else {
comp = objIter.key().compare(prevIter.key());
}
// put the appropriate value into dest
if (comp > 0) {
err = dest.put(prevIter.key(), prevIter.value());
MojErrCheck(err);
++prevIter;
} else if (comp < 0) {
err = dest.put(objIter.key(), objIter.value());
MojErrCheck(err);
++objIter;
} else {
MojObject::Type newType = objIter.value().type();
MojObject::Type prevType = prevIter.value().type();
if (newType == MojObject::TypeObject && prevType == MojObject::TypeObject) {
MojObject merged(MojObject::TypeObject);
err = mergeInto(merged, objIter.value(), prevIter.value());
MojErrCheck(err);
err = dest.put(objIter.key(), merged);
MojErrCheck(err);
} else {
err = dest.put(objIter.key(), objIter.value());
MojErrCheck(err);
}
++prevIter;
++objIter;
}
}
return MojErrNone;
}
示例3: configure
MojErr MojLogEngine::configure(const MojObject& conf, const MojChar* name)
{
MojAssert(name);
MojErr err = MojErrNone;
MojLogger::Level defaultLevel = MojLogger::LevelDefault;
MojAutoPtr<MojLogAppender> appender;
LevelMap levels;
// validate entire configuration before we apply any changes
MojObject logConf;
if (conf.get(LogKey, logConf)) {
// appender
MojObject obj;
if (logConf.get(AppenderKey, obj)) {
err = createAppender(obj, name, appender);
MojErrCheck(err);
}
// levels
if (logConf.get(LevelsKey, obj)) {
// configure loggers
MojString str;
for (MojObject::ConstIterator i = obj.begin(); i != obj.end(); ++i) {
MojLogger::Level level = MojLogger::LevelNone;
err = i.value().stringValue(str);
MojErrCheck(err);
err = MojLogger::levelFromString(str, level);
MojErrCheck(err);
if (i.key() == DefaultKey) {
defaultLevel = level;
} else {
err = levels.put(i.key(), level);
MojErrCheck(err);
}
}
}
}
// apply changes
MojThreadGuard guard(m_mutex);
// update name
err = m_name.assign(name);
MojErrCheck(err);
// update appender
updateAppender(appender);
// update levels
m_levels = levels;
m_defaultLogger.level(defaultLevel);
updateLoggers();
return MojErrNone;
}
示例4: valsImpl
MojErr MojDbPropExtractor::valsImpl(const MojObject& obj, KeySet& valsOut, MojSize idx) const
{
LOG_TRACE("Entering function %s", __FUNCTION__);
MojAssert(!m_prop.empty() && idx < m_prop.size());
MojErr err = MojErrNone;
const MojString& propKey = m_prop[idx];
if (propKey == WildcardKey) {
// get all prop vals if we have a wildcard
for (MojObject::ConstIterator i = obj.begin(); i != obj.end(); ++i) {
err = handleVal(*i, valsOut, idx);
MojErrCheck(err);
}
} else {
// get object corresponding to the current component in the prop path
MojObject::ConstIterator i = obj.find(propKey);
if (i == obj.end()) {
err = valsOut.put(m_default);
MojErrCheck(err);
} else {
if (i->type() == MojObject::TypeArray) {
// if the value is an array, act on its elements rather than the array object itself
MojObject::ConstArrayIterator end = i->arrayEnd();
for (MojObject::ConstArrayIterator j = i->arrayBegin(); j != end; ++j) {
err = handleVal(*j, valsOut, idx);
MojErrCheck(err);
}
} else {
// not an array
err = handleVal(*i, valsOut, idx);
MojErrCheck(err);
}
}
}
return MojErrNone;
}
示例5:
MojoObjectString::MojoObjectString(const MojObject& obj, const MojChar *key)
{
MojErr err;
MojObject::ConstIterator found = obj.find(key);
if (found != obj.end()) {
err = found.value().stringValue(m_str);
if (err) {
m_str.assign("(error retreiving value)");
}
} else {
m_str.assign("(not found)");
}
}