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)"); } }
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; }