LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies > Class Template Reference

#include "vector_indexing_suite.hpp"

Inheritance diagram for boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >:
boost::python::indexing_suite< Container, DerivedPolicies, NoProxy >

Public Types

typedef Container::value_type data_type
 
typedef Container::value_type key_type
 
typedef Container::size_type index_type
 
typedef Container::size_type size_type
 
typedef Container::difference_type difference_type
 

Public Member Functions

void visit (Class &cl) const
 

Static Public Member Functions

template<class Class >
static void extension_def (Class &cl)
 
static mpl::if_< is_class< data_type >, data_type &, data_type >::type get_item (Container &container, index_type i)
 
static object get_slice (Container &container, index_type from, index_type to)
 
static void set_item (Container &container, index_type i, data_type const &v)
 
static void set_slice (Container &container, index_type from, index_type to, data_type const &v)
 
template<class Iter >
static void set_slice (Container &container, index_type from, index_type to, Iter first, Iter last)
 
static void delete_item (Container &container, index_type i)
 
static void delete_slice (Container &container, index_type from, index_type to)
 
static size_t size (Container &container)
 
static bool contains (Container &container, key_type const &key)
 
static index_type get_min_index (Container &container)
 
static index_type get_max_index (Container &container)
 
static bool compare_index (Container &container, index_type a, index_type b)
 
static index_type convert_index (Container &container, PyObject *i_)
 
static void append (Container &container, data_type const &v)
 
template<class Iter >
static void extend (Container &container, Iter first, Iter last)
 

Static Private Member Functions

static void base_append (Container &container, object v)
 
static void base_extend (Container &container, object v)
 

Detailed Description

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
class boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >

Definition at line 17 of file vector_indexing_suite.hpp.

Member Typedef Documentation

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
typedef Container::value_type boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::data_type

Definition at line 53 of file vector_indexing_suite.hpp.

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
typedef Container::difference_type boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::difference_type

Definition at line 57 of file vector_indexing_suite.hpp.

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
typedef Container::size_type boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::index_type

Definition at line 55 of file vector_indexing_suite.hpp.

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
typedef Container::value_type boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::key_type

Definition at line 54 of file vector_indexing_suite.hpp.

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
typedef Container::size_type boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::size_type

Definition at line 56 of file vector_indexing_suite.hpp.

Member Function Documentation

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static void boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::append ( Container &  container,
data_type const &  v 
)
inlinestatic

Definition at line 192 of file vector_indexing_suite.hpp.

193  {
194  container.push_back(v);
195  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static void boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::base_append ( Container &  container,
object  v 
)
inlinestaticprivate

Definition at line 207 of file vector_indexing_suite.hpp.

208  {
209  extract<data_type&> elem(v);
210  // try if elem is an exact Data
211  if (elem.check())
212  {
213  DerivedPolicies::append(container, elem());
214  }
215  else
216  {
217  // try to convert elem to data_type
218  extract<data_type> elem(v);
219  if (elem.check())
220  {
221  DerivedPolicies::append(container, elem());
222  }
223  else
224  {
225  PyErr_SetString(PyExc_TypeError,
226  "Attempting to append an invalid type");
227  throw_error_already_set();
228  }
229  }
230  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static void boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::base_extend ( Container &  container,
object  v 
)
inlinestaticprivate

Definition at line 233 of file vector_indexing_suite.hpp.

234  {
235  std::vector<data_type> temp;
237  DerivedPolicies::extend(container, temp.begin(), temp.end());
238  }
void extend_container(Container &container, object l)
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static bool boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::compare_index ( Container &  container,
index_type  a,
index_type  b 
)
inlinestatic

Definition at line 164 of file vector_indexing_suite.hpp.

165  {
166  return a < b;
167  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static bool boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::contains ( Container &  container,
key_type const &  key 
)
inlinestatic

Definition at line 145 of file vector_indexing_suite.hpp.

146  {
147  return std::find(container.begin(), container.end(), key)
148  != container.end();
149  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static index_type boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::convert_index ( Container &  container,
PyObject *  i_ 
)
inlinestatic

Definition at line 170 of file vector_indexing_suite.hpp.

171  {
172  extract<long> i(i_);
173  if (i.check())
174  {
175  long index = i();
176  if (index < 0)
177  index += DerivedPolicies::size(container);
178  if (index >= long(container.size()) || index < 0)
179  {
180  PyErr_SetString(PyExc_IndexError, "Index out of range");
181  throw_error_already_set();
182  }
183  return index;
184  }
185 
186  PyErr_SetString(PyExc_TypeError, "Invalid index type");
187  throw_error_already_set();
188  return index_type();
189  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static void boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::delete_item ( Container &  container,
index_type  i 
)
inlinestatic

Definition at line 123 of file vector_indexing_suite.hpp.

124  {
125  container.erase(container.begin()+i);
126  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static void boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::delete_slice ( Container &  container,
index_type  from,
index_type  to 
)
inlinestatic

Definition at line 129 of file vector_indexing_suite.hpp.

130  {
131  if (from > to) {
132  // A null-op.
133  return;
134  }
135  container.erase(container.begin()+from, container.begin()+to);
136  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
template<class Iter >
static void boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::extend ( Container &  container,
Iter  first,
Iter  last 
)
inlinestatic

Definition at line 199 of file vector_indexing_suite.hpp.

200  {
201  container.insert(container.end(), first, last);
202  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
template<class Class >
static void boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::extension_def ( Class &  cl)
inlinestatic

Definition at line 61 of file vector_indexing_suite.hpp.

62  {
63  cl
64  .def("append", &base_append)
65  .def("push_back", &base_append)
66  .def("extend", &base_extend)
67  ;
68  }
static void base_extend(Container &container, object v)
static void base_append(Container &container, object v)
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static mpl::if_< is_class<data_type> , data_type& , data_type >::type boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::get_item ( Container &  container,
index_type  i 
)
inlinestatic

Definition at line 76 of file vector_indexing_suite.hpp.

77  {
78  return container[i];
79  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static index_type boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::get_max_index ( Container &  container)
inlinestatic

Definition at line 158 of file vector_indexing_suite.hpp.

159  {
160  return container.size();
161  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static index_type boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::get_min_index ( Container &  container)
inlinestatic

Definition at line 152 of file vector_indexing_suite.hpp.

153  {
154  return 0;
155  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static object boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::get_slice ( Container &  container,
index_type  from,
index_type  to 
)
inlinestatic

Definition at line 82 of file vector_indexing_suite.hpp.

83  {
84  if (from > to)
85  return object(Container());
86  return object(Container(container.begin()+from, container.begin()+to));
87  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static void boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::set_item ( Container &  container,
index_type  i,
data_type const &  v 
)
inlinestatic

Definition at line 90 of file vector_indexing_suite.hpp.

91  {
92  container[i] = v;
93  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static void boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::set_slice ( Container &  container,
index_type  from,
index_type  to,
data_type const &  v 
)
inlinestatic

Definition at line 96 of file vector_indexing_suite.hpp.

98  {
99  if (from > to) {
100  return;
101  }
102  else {
103  container.erase(container.begin()+from, container.begin()+to);
104  container.insert(container.begin()+from, v);
105  }
106  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
template<class Iter >
static void boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::set_slice ( Container &  container,
index_type  from,
index_type  to,
Iter  first,
Iter  last 
)
inlinestatic

Definition at line 110 of file vector_indexing_suite.hpp.

112  {
113  if (from > to) {
114  container.insert(container.begin()+from, first, last);
115  }
116  else {
117  container.erase(container.begin()+from, container.begin()+to);
118  container.insert(container.begin()+from, first, last);
119  }
120  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_vector_derived_policies<Container, NoProxy>>
static size_t boost::python::vector_indexing_suite< Container, NoProxy, DerivedPolicies >::size ( Container &  container)
inlinestatic

Definition at line 139 of file vector_indexing_suite.hpp.

140  {
141  return container.size();
142  }
void boost::python::indexing_suite< Container, DerivedPolicies, NoProxy, false , typename Container::value_type , typename Container::size_type , typename Container::value_type >::visit ( Class &  cl) const
inlineinherited

Definition at line 173 of file indexing_suite.hpp.

References boost::python::indexing_suite< Container, DerivedPolicies, NoProxy, NoSlice, Data, Index, Key >::base_contains(), boost::python::indexing_suite< Container, DerivedPolicies, NoProxy, NoSlice, Data, Index, Key >::base_delete_item(), boost::python::indexing_suite< Container, DerivedPolicies, NoProxy, NoSlice, Data, Index, Key >::base_get_item(), boost::python::indexing_suite< Container, DerivedPolicies, NoProxy, NoSlice, Data, Index, Key >::base_set_item(), and boost::python::indexing_suite< Container, DerivedPolicies, NoProxy, NoSlice, Data, Index, Key >::base_size().

174  {
175  // Hook into the class_ generic visitation .def function
176  proxy_handler::register_container_element();
177 
178  cl
179  .def("__len__", base_size)
180  .def("__setitem__", &base_set_item)
181  .def("__delitem__", &base_delete_item)
182  .def("__getitem__", &base_get_item)
183  .def("__contains__", &base_contains)
184  .def("__iter__", def_iterator())
185  ;
186 
187  DerivedPolicies::extension_def(cl);
188  }
static object base_get_item(back_reference< Container & > container, PyObject *i)
static void base_set_item(Container &container, PyObject *i, PyObject *v)
static void base_delete_item(Container &container, PyObject *i)
mpl::if_< no_proxy, iterator< Container >, iterator< Container, return_policy > >::type def_iterator
static bool base_contains(Container &container, PyObject *key)

The documentation for this class was generated from the following file: