LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
boost::python::container_utils Namespace Reference

Functions

template<typename Container >
void extend_container (Container &container, object l)
 

Function Documentation

template<typename Container >
void boost::python::container_utils::extend_container ( Container &  container,
object  l 
)

Definition at line 18 of file container_utils.hpp.

References x.

Referenced by boost::python::vector_indexing_suite< Container, NoProxy, final_vector_derived_policies< Container, NoProxy > >::base_extend().

19  {
20  typedef typename Container::value_type data_type;
21 
22  // l must be a list or some container
23 
24  for (int i = 0; i < l.attr("__len__")(); i++)
25  {
26  object elem(l[i]);
27  extract<data_type const&> x(elem);
28  // try if elem is an exact data_type type
29  if (x.check())
30  {
31  container.push_back(x());
32  }
33  else
34  {
35  // try to convert elem to data_type type
36  extract<data_type> x(elem);
37  if (x.check())
38  {
39  container.push_back(x());
40  }
41  else
42  {
43  PyErr_SetString(PyExc_TypeError, "Incompatible Data Type");
44  throw_error_already_set();
45  }
46  }
47  }
48  }
Float_t x
Definition: compare.C:6