示例#1
0
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);
    }
  }
}
示例#2
0
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;
}
示例#3
0
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;
}
示例#4
0
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;
}
示例#5
0
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);
}