Example #1
0
static void convert_object(const json_object& value, string& path, datum& ret_datum) {
  size_t len = path.size();
  for (json_object::const_iterator it = value.begin(); it != value.end(); ++it) {
    const string& key = it->first;
    const json& val = it->second;
    path += '/';
    path += key;
    iter_convert(val, path, ret_datum);
    path.resize(len);
  }
}
Example #2
0
pal::string_t deps_json_t::get_optional_path(
    const json_object& properties,
    const pal::string_t& key) const
{
    pal::string_t path;

    const auto& iter = properties.find(key);

    if (iter != properties.end())
    {
        path = iter->second.as_string();

        if (_X('/') != DIR_SEPARATOR)
        {
            replace_char(&path, _X('/'), DIR_SEPARATOR);
        }
    }

    return path;
}
Example #3
0
std::unique_ptr<builder> builder_factory::create_builder(json_object& object) const {
    auto type = parse_enum<builder_type>(object.get_string("type"));
    if (type != builder_type::invalid) {
        auto& builder_template_iter = _builder_templates.find(type);
        if (builder_template_iter == _builder_templates.end()) {
            ALERT("unknown builder type : {}", to_string(type));
        }
        else {
            return builder_template_iter->second->clone(object);
        }
    }
    return nullptr;
}
Example #4
0
 bool operator==(const json_object<Char,Storage>& rhs) const
 {
     if (size() != rhs.size())
     {
         return false;
     }
     for (const_iterator it = members_.begin(); it != members_.end(); ++it)
     {
         bool exists = std::binary_search(rhs.members_.begin(),rhs.members_.end(),*it,member_compare<Char,Storage>());
         if (!exists)
         {
             return false;
         }
     }
     return true;
 }