std::vector<std::string> mastermind_t::data::create_elliptics_remotes(const std::string &name , const kora::dynamic_t &raw_value) { (void) name; std::vector<std::string> result; const auto &raw_value_array = raw_value.as_array(); for (auto p_it = raw_value_array.begin(), p_end = raw_value_array.end(); p_it != p_end; ++p_it) { const auto &tuple = p_it->as_array(); const auto &name = tuple[0].to<std::string>(); const auto &port = tuple[1].to<int>(); const auto &family = tuple[2].to<int>(); std::ostringstream oss; oss << name << ':' << port << ':' << family; result.emplace_back(oss.str()); } if (result.empty()) { throw std::runtime_error("elliptics-remotes list is empty"); } return result; }
std::map<std::string, groups_t> mastermind_t::data::create_cache_groups(const std::string &name , const kora::dynamic_t &raw_value) { (void) name; std::map<std::string, groups_t> result; const auto &raw_value_array = raw_value.as_array(); for (auto p_it = raw_value_array.begin(), p_end = raw_value_array.end(); p_it != p_end; ++p_it) { const auto &pair = p_it->as_array(); const auto &name = pair[0].to<std::string>(); const auto &raw_groups = pair[1].as_array(); groups_t groups; for (auto it = raw_groups.begin(), end = raw_groups.end(); it != end; ++it) { groups.emplace_back(it->to<group_t>()); } result.insert(std::make_pair(name, groups)); } if (result.empty()) { throw std::runtime_error("cache-groups list is empty"); } return result; }
bp::object convert(const kora::dynamic_t &d, const gil_guard_t &gil_guard) { if (d.is_null()) { return bp::object{}; } else if (d.is_bool()) { return bp::object{d.as_bool()}; } else if (d.is_int()) { return bp::object{d.as_int()}; } else if (d.is_uint()) { return bp::object{d.as_uint()}; } else if (d.is_double()) { return bp::object{d.as_double()}; } else if (d.is_string()) { return bp::object{d.as_string()}; } else if (d.is_array()) { return convert(d.as_array(), gil_guard); } else if (d.is_object()) { return convert(d.as_object(), gil_guard); } return bp::object{}; }