8 #ifndef PARAM_BINDING_HELPERS_HH_ 9 #define PARAM_BINDING_HELPERS_HH_ 26 if( isinstance< none >( an_object ) )
30 else if( isinstance< bool_ >( an_object ) )
34 else if( isinstance< int_ >( an_object ) )
38 else if( isinstance< float_ >( an_object ) )
42 else if( isinstance< str >( an_object ) )
46 else if( isinstance< list >( an_object ) )
50 for(
auto an_item = an_object.
begin(); an_item != an_object.
end(); ++an_item )
56 else if( isinstance< dict >( an_object ) )
60 const dict& a_dict =
static_cast< const dict&
>( an_object );
61 for(
auto an_item = a_dict.
begin(); an_item != a_dict.
end(); ++an_item )
70 std::replace( new_key.begin(), new_key.end(),
'_',
'-' );
72 the_return_arr.
add( new_key,
to_param( static_cast< const object& >(an_item->second) ) );
76 throw scarab::error() <<
"Unknown python type cannot be converted to param";
102 to_return.append(
to_python( *an_item ) );
112 std::string new_key = an_item.name();
113 if ( underscore_keys )
115 std::replace( new_key.begin(), new_key.end(),
'-',
'_' );
117 to_return[ new_key.c_str() ] =
to_python( *an_item );
121 throw scarab::error() <<
"Unknown param type cannot be converted to Python";
iterator end() const
Return a sentinel which ends iteration.
virtual bool is_value() const
bool isinstance< object >(handle obj)
pybind11::object to_python(const scarab::param &a_param, bool underscore_keys=false)
glibc defines I as a macro which breaks things, e.g., boost template names
boost::indirect_iterator< param_array_contents::const_iterator, const param > param_array_const_iterator
virtual bool is_null() const
detail::dict_iterator end() const
virtual bool is_array() const
scarab::param_ptr_t to_param(const pybind11::object &an_object, bool hyphenate_keys=false)
virtual bool is_node() const
std::unique_ptr< param > param_ptr_t
detail::enable_if_t<!detail::move_never< T >::value, T > move(object &&obj)
T cast(const handle &handle)
void push_back(const param &a_value)
bool add(const std::string &a_name, const param &a_value)
std::string as_string() const
detail::dict_iterator begin() const