bool checkContains(struct BTNode *p,struct BTNode *t2) { if (t2 == NULL) return true; if (p == NULL || p->val != t2->val) return false; return checkContains(p->pLeft,t2->pLeft) && checkContains(p->pRight,t2->pRight); }
bool JsonObject::boolean(const QString& key) const { checkContains(key); QJsonValue value = o.value(key); if ( ! value.isBool()) wrongType("'true' or 'false'", key); return value.toBool(); }
JsonArray JsonObject::array(const QString& key) const { checkContains(key); QJsonValue value = o.value(key); if ( ! value.isArray()) wrongType("array", key); return JsonArray(value.toArray()); }
JsonObject JsonObject::object(const QString& key) const { checkContains(key); QJsonValue value = o.value(key); if ( ! value.isObject()) wrongType("object", key); return JsonObject(value.toObject()); }
double JsonObject::number(const QString& key) const { checkContains(key); QJsonValue value = o.value(key); if ( ! value.isDouble()) wrongType("number", key); return value.toDouble(); }
QString JsonObject::string(const QString& key) const { checkContains(key); QJsonValue value = o.value(key); if ( ! value.isString()) wrongType("string", key); return value.toString(); }
bool BTree::subTreeIsContains(struct BTNode *t1,struct BTNode *t2) { return checkContains(t1,t2) || checkContains(t1->pLeft,t2) || checkContains(t2->pRight,t2); }
bool JsonObject::isNull(const QString& key) const { checkContains(key); return o.value(key).isNull(); }