本文整理汇总了C++中MojObject::find方法的典型用法代码示例。如果您正苦于以下问题:C++ MojObject::find方法的具体用法?C++ MojObject::find怎么用?C++ MojObject::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojObject
的用法示例。
在下文中一共展示了MojObject::find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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)");
}
}
示例2: 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;
}