6 #ifndef TURI_UNITY_TOOLKIT_UTIL_HPP 8 #define TURI_UNITY_TOOLKIT_UTIL_HPP 11 #include <model_server/lib/variant.hpp> 20 T safe_varmap_get(
const variant_map_type& kv, std::string key) {
21 if (kv.count(key) == 0) {
22 log_and_throw(
"Required Key " + key +
" not found");
24 return variant_get_value<T>(kv.at(key));
26 __builtin_unreachable();
33 inline std::map<std::string, flexible_type>
varmap_to_flexmap(
const variant_map_type& map) {
34 std::map<std::string, flexible_type> ret;
35 for (
const auto& kv : map) {
37 ret[kv.first] = boost::get<flexible_type>(kv.second);
46 inline std::map<std::string, variant_type>
flexmap_to_varmap(
const std::map<std::string, flexible_type>& map) {
47 std::map<std::string, variant_type> ret;
48 for (
const auto& kv : map) {
boost::make_recursive_variant< flexible_type, std::shared_ptr< unity_sgraph_base >, dataframe_t, std::shared_ptr< model_base >, std::shared_ptr< unity_sframe_base >, std::shared_ptr< unity_sarray_base >, std::map< std::string, boost::recursive_variant_ >, std::vector< boost::recursive_variant_ >, boost::recursive_wrapper< function_closure_info > >::type variant_type
std::map< std::string, variant_type > flexmap_to_varmap(const std::map< std::string, flexible_type > &map)
std::map< std::string, flexible_type > varmap_to_flexmap(const variant_map_type &map)