inline void serialize(json_config_iarchive_cast& js, jubatus::util::data::serialization::named_value<T>& v) { if (js.get_config().contain(v.name)) { json_from_config(js.get_config()[v.name], v.v, js.errors()); } else { not_found e(js.get_config().path(), v.name); if (js.trace_error()) { js.push_error(e); } else { throw JUBATUS_EXCEPTION(e); } } }
inline bool check_json_type( json_config_iarchive_cast& js, jubatus::util::text::json::json::json_type_t t) { if (js.get().type() != t) { type_error e(js.get_config().path(), t, js.get().type()); if (js.trace_error()) { js.push_error(e); } else { throw JUBATUS_EXCEPTION(e); } return false; } return true; }
inline bool check_json_float(json_config_iarchive_cast& js) { if (js.get().type() != pfi::text::json::json::Float && js.get().type() != pfi::text::json::json::Integer) { type_error e( js.get_config().path(), pfi::text::json::json::Float, js.get().type()); if (js.trace_error()) { js.push_error(e); } else { throw JUBATUS_EXCEPTION(e); } return false; } return true; }
inline bool check_json_type( json_config_iarchive_cast& js, pfi::text::json::json::json_type_t t) { if (js.get().type() != t) { // int -> float is valid if (js.get().type() == pfi::text::json::json::Integer && t == pfi::text::json::json::Float) { return true; } type_error e(js.get_config().path(), t, js.get().type()); if (js.trace_error()) { js.push_error(e); } else { throw e; } return false; } return true; }
inline void serialize(json_config_iarchive_cast& js, T& v) { if (js.get().type() == jubatus::util::text::json::json::Object) { member_collector collector; jubatus::util::data::serialization::access::serialize(collector, v); std::set<std::string> members(collector.get_members().begin(), collector.get_members().end()); for (jubatus::util::text::json::json::const_iterator it = js.get().begin(); it != js.get().end(); ++it) { const std::string& key = it->first; if (members.count(key) == 0) { redundant_key e(js.get_config().path(), key); if (js.trace_error()) { js.push_error(e); } else { throw JUBATUS_EXCEPTION(e); } } } } jubatus::util::data::serialization::access::serialize(js, v); }