casacore
PycBasicData.h
Go to the documentation of this file.
1 //# PycBasicData.h: Convert casa data types to/from python
2 //# Copyright (C) 2006
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: PycBasicData.h,v 1.5 2006/10/25 01:42:13 gvandiep Exp $
27 
28 #ifndef PYRAP_PYCBASICDATA_H
29 #define PYRAP_PYCBASICDATA_H
30 
31 // include python first to avoid _POSIX_C_SOURCE redefined warnings
32 #include <boost/python.hpp>
33 #include <boost/python/object.hpp>
34 #include <casacore/python/Converters/PycArray.h>
35 #include <casacore/casa/BasicSL/String.h>
36 #include <casacore/casa/Arrays/IPosition.h>
37 #include <casacore/casa/Arrays/Vector.h>
38 #include <casacore/casa/Utilities/Assert.h>
39 #include <casacore/casa/Exceptions/Error.h>
40 #include <vector>
41 #include <map>
42 
43 #if PY_MAJOR_VERSION >= 3
44 #define IS_PY3K
45 #endif
46 
47 // Define classes and functions to convert the basic data types and
48 // containers to and from Python.
49 
50 namespace casacore { namespace python {
51 
52  // Prevent a converter from being registered multiple times.
53  class pyregistry
54  {
55  public:
56  static bool get (const std::string& name);
57  static void set (const std::string& name);
58  private:
59  static std::map<std::string,bool> _registry;
60  };
61 
62  // Check if the given object is a sequence object.
63  // If so, return true.
64  // py_obj gets changed if the given object was a scalar numpy/numarray.
65  // In that case it is flattened.
66  bool getSeqObject (boost::python::object& py_obj);
67 
68  // Convert a String object to python.
70  {
71  static boost::python::object makeobject(String const& s)
72  { return boost::python::object((const std::string&)s); }
73  static PyObject* convert(String const& s)
74  { return boost::python::incref(makeobject(s).ptr()); }
75  };
76 
77  // Convert a String object from python.
79  {
81  {
82  boost::python::converter::registry::push_back(
83  &convertible,
84  &construct,
85  boost::python::type_id<String>());
86  }
87 
88  static void* convertible(PyObject* obj_ptr)
89  {
90 #ifdef IS_PY3K
91  if (!PyUnicode_Check(obj_ptr)) return 0;
92 #else
93  if (!PyString_Check(obj_ptr)) return 0;
94 #endif
95  return obj_ptr;
96  }
97 
98  static void construct(
99  PyObject* obj_ptr,
100  boost::python::converter::rvalue_from_python_stage1_data* data)
101  {
102 #ifdef IS_PY3K
103  PyObject * temp_bytes = PyUnicode_AsEncodedString(obj_ptr, "ASCII", "strict"); // Owned reference
104  char* value;
105  if (temp_bytes != NULL) {
106  value = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
107  value = strdup(value);
108  Py_DECREF(temp_bytes);
109  } else {
110  boost::python::throw_error_already_set();
111  }
112 #else
113  const char* value = PyString_AsString(obj_ptr);
114 #endif
115  if (value == 0) boost::python::throw_error_already_set();
116  void* storage = (
117  (boost::python::converter::rvalue_from_python_storage<String>*)
118  data)->storage.bytes;
119  new (storage) String(value);
120  data->convertible = storage;
121  }
122  };
123 
124 
125  // Default operations on all containers for conversion from Python
126  // container to C++ one.
127 
128  // Copied from
129  // scitbx/include/scitbx/boost_python/container_conversions.h that is
130  // described in the <a
131  // href="http://www.boost.org/libs/python/doc/v2/faq.html">
132  // Boost.Python FAQ. </a>
133 
134  // @author Ralf W. Grosse-Kunstleve <rwgk@yahoo.com> of
135  // <a href="http://www.lbl.gov/">Lawrence Berkeley National Laboratory</a>
137  {
138  static bool check_convertibility_per_element() { return true; }
139 
140  template <typename ContainerType>
141  static bool check_size(boost::type<ContainerType>, std::size_t)
142  {
143  return true;
144  }
145 
146  template <typename ContainerType>
147  static void assert_size(boost::type<ContainerType>, std::size_t)
148  {}
149 
150  template <typename ContainerType>
151  static void reserve(ContainerType&, std::size_t)
152  {}
153  };
154 
155  // Operations on containers that have variable capacity for
156  // conversion from Python container to C++ one.
157 
158  // Copied from
159  // scitbx/include/scitbx/boost_python/container_conversions.h that is
160  // described in the <a
161  // href="http://www.boost.org/libs/python/doc/v2/faq.html">
162  // Boost.Python FAQ. </a>
163 
164  // @author Ralf W. Grosse-Kunstleve <rwgk@yahoo.com> of
165  // <a href="http://www.lbl.gov/">Lawrence Berkeley National Laboratory</a>
167  {
168  template <typename ContainerType>
169  static void reserve(ContainerType& a, std::size_t sz)
170  {
171  a.reserve(sz);
172  }
173 
174  template <typename ContainerType, typename ValueType>
175  static void set_value(ContainerType& a, std::size_t i, ValueType const& v)
176  {
177  AlwaysAssert(a.size() == i, AipsError);
178  a.push_back(v);
179  }
180  };
181 
183  {
184  template <typename ContainerType>
185  static void reserve(ContainerType& a, std::size_t sz)
186  {
187  a.resize(sz);
188  }
189 
190  template <typename ContainerType, typename ValueType>
191  static void set_value(ContainerType& a, std::size_t i, ValueType const& v)
192  {
193  assert(a.size() > i);
194  a[i] = v;
195  }
196  };
197 
199  {
200  template <typename ContainerType>
201  static void reserve(ContainerType& a, std::size_t sz)
202  {
203  a.resize(sz);
204  }
205 
206  template <typename ContainerType, typename ValueType>
207  static void set_value(ContainerType& a, std::size_t i, ValueType const& v)
208  {
209  assert(a.size() > i);
210  a[a.size() - i - 1] = v;
211  }
212  };
213 
214 
215  // A wrapper of a conversion function to convert a STL vector to a
216  // Python list. This class satisfies the requirements of the
217  // boost::python::to_python_converter conversion template argument.
218 
219  // Copied from
220  // scitbx/include/scitbx/boost_python/container_conversions.h that is
221  // described in the <a
222  // href="http://www.boost.org/libs/python/doc/v2/faq.html">
223  // Boost.Python FAQ. </a>
224 
225  // @author Ralf W. Grosse-Kunstleve <rwgk@yahoo.com> of
226  // <a href="http://www.lbl.gov/">Lawrence Berkeley National Laboratory</a>
227  template < typename ContainerType >
228  struct to_list
229  {
230  // Creates and returns a Python list from the elements copied
231  // from a STL container. The ContainerType must be a container
232  // with STL iterators defined on it.
233  // It may contain any type of object supported by the
234  // boost::python::object constructor.
235  static boost::python::object makeobject (ContainerType const& c)
236  {
237  boost::python::list result;
238  typename ContainerType::const_iterator i = c.begin();
239  typename ContainerType::const_iterator iEnd = c.end();
240  for( ; i != iEnd; ++i) {
241  result.append(*i);
242  }
243  return result;
244  }
245  static PyObject* convert (ContainerType const& c)
246  {
247  return boost::python::incref(makeobject(c).ptr());
248  }
249  };
250  //# Make specialisations for various types.
251  template <>
253  {
255  static boost::python::list makeobject (ContainerType const& c)
256  {
257  // Reverse IPosition values.
258  boost::python::list result;
259  for (int i=c.size()-1; i>=0; --i) {
260  result.append(c[i]);
261  }
262  return result;
263  }
264  static PyObject* convert (ContainerType const& c)
265  {
266  return boost::python::incref(makeobject(c).ptr());
267  }
268  };
269  //# This specialisation is needed because on OS-X 10.9 clang-3.5 with
270  //# Boost-Python 1.57 gives a compile error
271  //# /opt/casa/01/include/boost/python/converter/arg_to_python.hpp:209:9:
272  //# error: no matching constructor for initialization of
273  //# 'boost::python::converter::detail::arg_to_python_base'
274  //# : arg_to_python_base(&x, registered<T>::converters)
275  template <>
276  struct to_list <std::vector <bool> >
277  {
278  typedef std::vector <bool> ContainerType;
279  static boost::python::list makeobject (ContainerType const& c)
280  {
281  boost::python::list result;
282  ContainerType::const_iterator i = c.begin();
283  ContainerType::const_iterator iEnd = c.end();
284  for( ; i != iEnd; ++i) {
285  bool b = *i;
286  result.append(b);
287  }
288  return result;
289  }
290  static PyObject* convert (ContainerType const& c)
291  {
292  return boost::python::incref(makeobject(c).ptr());
293  }
294  };
295  template <>
296  struct to_list <std::vector <casacore::String> >
297  {
298  typedef std::vector <casacore::String> ContainerType;
299  static boost::python::list makeobject (ContainerType const& c)
300  {
301  boost::python::list result;
302  ContainerType::const_iterator i = c.begin();
303  ContainerType::const_iterator iEnd = c.end();
304  for( ; i != iEnd; ++i) {
305  result.append((std::string const&)(*i));
306  }
307  return result;
308  }
309  static PyObject* convert (ContainerType const& c)
310  {
311  return boost::python::incref(makeobject(c).ptr());
312  }
313  };
314  template <>
315  struct to_list <casacore::Array <casacore::String> >
316  {
318  static boost::python::object makeobject (ContainerType const& c)
319  {
320  boost::python::list result;
323  for( ; i != iEnd; ++i) {
324  result.append((std::string const&)(*i));
325  }
326  return result;
327  }
328  static PyObject* convert (ContainerType const& c)
329  {
330  return boost::python::incref(makeobject(c).ptr());
331  }
332  };
333  template <>
334  struct to_list <casacore::Vector <casacore::String> >
335  {
337  static boost::python::object makeobject (ContainerType const& c)
338  {
339  boost::python::list result;
342  for( ; i != iEnd; ++i) {
343  result.append((std::string const&)(*i));
344  }
345  return result;
346  }
347  static PyObject* convert (ContainerType const& c)
348  {
349  return boost::python::incref(makeobject(c).ptr());
350  }
351  };
352 
353  // Converts an STL vector or casa Array of T objects to Python list.
354  // Copied from
355  // scitbx/include/scitbx/boost_python/container_conversions.h that is
356  // described in the <a
357  // href="http://www.boost.org/libs/python/doc/v2/faq.html">
358  // Boost.Python FAQ. </a>
359  // @author Ralf W. Grosse-Kunstleve <rwgk@yahoo.com> of
360  // <a href="http://www.lbl.gov/">Lawrence Berkeley National Laboratory</a>
361  template < typename T >
363  {
365  {
366  boost::python::to_python_converter < std::vector < T >,
368  }
369  };
370  template < typename T >
372  {
374  {
375  boost::python::to_python_converter < casacore::Array < T >,
377  }
378  };
379  template < typename T >
381  {
383  {
384  boost::python::to_python_converter < casacore::Vector < T >,
386  }
387  };
389  {
391  {
392  boost::python::to_python_converter < casacore::IPosition,
394  }
395  };
396 
397 
398  // Conversion of Python sequence to C++ container.
399 
400  // Copied from
401  // scitbx/include/scitbx/boost_python/container_conversions.h that is
402  // described in the <a
403  // href="http://www.boost.org/libs/python/doc/v2/faq.html">
404  // Boost.Python FAQ. </a>
405  // @author Ralf W. Grosse-Kunstleve <rwgk@yahoo.com> of
406  // <a href="http://www.lbl.gov/">Lawrence Berkeley National Laboratory</a>
407  template <typename ContainerType, typename ConversionPolicy>
409  {
410  typedef typename ContainerType::value_type container_element_type;
411 
413  {
414  boost::python::converter::registry::push_back(
415  &convertible,
416  &construct,
417  boost::python::type_id<ContainerType>());
418  }
419 
420  // Appears to return @a obj_ptr if it is type of Python sequence
421  // that can be convertible to C++ container.
422  static void* convertible(PyObject* obj_ptr)
423  {
424  using namespace boost::python;
425  handle<> py_hdl(obj_ptr);
426  if (PyErr_Occurred()) {
427  PyErr_Clear();
428  return 0;
429  }
430  object py_obj(py_hdl);
431  incref(obj_ptr); // incr refcount, because ~object decrements it
432  // Accept single values.
433  if (PyBool_Check(obj_ptr)
434 #ifdef IS_PY3K
435  || PyLong_Check(obj_ptr)
436 #else
437  || PyInt_Check(obj_ptr)
438 #endif
439  || PyLong_Check(obj_ptr)
440  || PyFloat_Check(obj_ptr)
441  || PyComplex_Check(obj_ptr)
442 #ifdef IS_PY3K
443  || PyUnicode_Check(obj_ptr)) {
444 #else
445  || PyString_Check(obj_ptr)) {
446 #endif
447 
448  extract<container_element_type> elem_proxy(py_obj);
449  if (!elem_proxy.check()) return 0;
450  return obj_ptr;
451  }
452  // An array scalar is accepted.
453  if (PycArrayScalarCheck(obj_ptr)) {
454  return obj_ptr;
455  }
456  // Get the sequence object.
457  // It can be a numarray/numpy scalar in which case
458  // it fills py_obj with a flattened array.
459  if (! getSeqObject (py_obj)) {
460  return 0;
461  }
462  // Check the sequence.
463  // It must be convertible to an iterator.
464  handle<> obj_iter(allow_null(PyObject_GetIter(py_obj.ptr())));
465  if (!obj_iter.get()) {
466  PyErr_Clear();
467  return 0;
468  }
469  if (!check_convertibility (py_obj.ptr())) {
470  return 0;
471  }
472  return obj_ptr;
473  }
474 
475  // Constructs a C++ container from a Python sequence.
476  static void construct(
477  PyObject* obj_ptr,
478  boost::python::converter::rvalue_from_python_stage1_data* data)
479  {
480  using namespace boost::python;
481  using boost::python::converter::rvalue_from_python_storage;
482  void* storage = (
483  (rvalue_from_python_storage<ContainerType>*)
484  data)->storage.bytes;
485  new (storage) ContainerType();
486  data->convertible = storage;
487  ContainerType& result = *((ContainerType*)storage);
488  if (PyBool_Check(obj_ptr)
489 #ifndef IS_PY3K
490  || PyInt_Check(obj_ptr)
491 #endif
492  || PyLong_Check(obj_ptr)
493  || PyFloat_Check(obj_ptr)
494  || PyComplex_Check(obj_ptr)
495 #ifdef IS_PY3K
496  || PyUnicode_Check(obj_ptr)
497 #else
498  || PyString_Check(obj_ptr)
499 #endif
500  || PycArrayScalarCheck(obj_ptr)) {
501  extract<container_element_type> elem_proxy(obj_ptr);
502  ConversionPolicy::reserve(result, 1);
503  ConversionPolicy::set_value(result, 0, elem_proxy());
504  return;
505  }
506  handle<> py_hdl(obj_ptr);
507  object py_obj = object(py_hdl);
508  incref(obj_ptr); // incr refcount, because ~object decrements it
509  assert (getSeqObject (py_obj));
510  fill_container (result, py_obj.ptr());
511  // ConversionPolicy::reserve(result, 1);
512  // ConversionPolicy::set_value(result, 0,
513  // extract<container_element_type>(py_flat.attr("__getitem__")(0)));
514  }
515 
516  // Constructs a C++ container from a Python sequence.
517  static ContainerType make_container(PyObject* obj_ptr)
518  {
519  ContainerType result;
520  fill_container (result, obj_ptr);
521  return result;
522  }
523 
524  private:
525  static void fill_container (ContainerType& result, PyObject* obj_ptr)
526  {
527  using namespace boost::python;
528  int obj_size = PyObject_Length(obj_ptr);
529  handle<> obj_iter(PyObject_GetIter(obj_ptr));
530  ConversionPolicy::reserve(result, obj_size);
531  std::size_t i=0;
532  for(;;i++) {
533  handle<> py_elem_hdl(allow_null(PyIter_Next(obj_iter.get())));
534  if (PyErr_Occurred()) throw_error_already_set();
535  if (!py_elem_hdl.get()) break; // end of iteration
536  object py_elem_obj(py_elem_hdl);
537  extract<container_element_type> elem_proxy(py_elem_obj);
538  ConversionPolicy::set_value(result, i, elem_proxy());
539  }
540  ConversionPolicy::assert_size(boost::type<ContainerType>(), i);
541  }
542 
543  static bool check_convertibility(PyObject* obj_ptr)
544  {
545  using namespace boost::python;
546  handle<> obj_iter(allow_null(PyObject_GetIter(obj_ptr)));
547  if (!obj_iter.get()) { // must be convertible to an iterator
548  PyErr_Clear();
549  return false;
550  }
551  int obj_size = PyObject_Length(obj_ptr);
552  if (obj_size < 0) { // must be a measurable sequence
553  PyErr_Clear();
554  return false;
555  }
556  if (ConversionPolicy::check_convertibility_per_element()) {
557  if (!ConversionPolicy::check_size(
558  boost::type<ContainerType>(), obj_size)) return false;
559  // All elements in a range and array have the same type, so
560  // need to check the first element only.
561  bool is_same = PyRange_Check(obj_ptr) ||
562  (PySequence_Check(obj_ptr)
563  && !PyTuple_Check(obj_ptr) && !PyList_Check(obj_ptr));
564  int i = 0;
565  for (;;i++) {
566  handle<> py_elem_hdl(allow_null(PyIter_Next(obj_iter.get())));
567  if (PyErr_Occurred()) {
568  PyErr_Clear();
569  return false;
570  }
571  if (!py_elem_hdl.get()) break; // end of iteration
572  object py_elem_obj(py_elem_hdl);
573  extract<container_element_type> elem_proxy(py_elem_obj);
574  if (!elem_proxy.check()) return false;
575  if (is_same) break; // all elements are of the same type
576  }
577  if (!is_same) assert(i == obj_size );
578  }
579  return true;
580  }
581  };
582 
583  // Register the String conversion.
585  {
586  static void reg();
587  };
590 
591  // Register the IPosition conversion.
593  {
594  static void reg();
595  };
598 
599  // Register the std::vector conversions.
600  template < typename T >
602  {
603  static void reg()
604  {
605  std::string tname(typeid(std::vector<T>).name());
606  if (! pyregistry::get (tname)) {
607  pyregistry::set (tname);
611  }
612  }
613  };
614  template < typename T >
617 
618  // Register the casacore::Vector conversions.
619  template < typename T >
621  {
622  static void reg()
623  {
624  std::string tname(typeid(casacore::Vector<T>).name());
625  if (! pyregistry::get (tname)) {
626  pyregistry::set (tname);
631  }
632  }
633  };
634  template < typename T >
637 
638 
639  // Register all standard basic conversions.
640  // These are String, IPosition, Vector<String>, Vector<Int>,
641  // Vector<Double>, Vector<DComplex>.
643 }}
644 
645 #endif
static void set_value(ContainerType &a, std::size_t i, ValueType const &v)
Definition: PycBasicData.h:191
static PyObject * convert(ContainerType const &c)
Definition: PycBasicData.h:264
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
Register the casacore::Vector conversions.
Definition: PycBasicData.h:620
A 1-D Specialization of the Array class.
Definition: ArrayIO.h:45
void register_convert_casa_string()
Definition: PycBasicData.h:588
static bool check_size(boost::type< ContainerType >, std::size_t)
Definition: PycBasicData.h:141
Convert a String object to python.
Definition: PycBasicData.h:69
static boost::python::list makeobject(ContainerType const &c)
Definition: PycBasicData.h:255
static boost::python::object makeobject(String const &s)
Definition: PycBasicData.h:71
void register_convert_basicdata()
Register all standard basic conversions.
static boost::python::list makeobject(ContainerType const &c)
Definition: PycBasicData.h:279
Define real & complex conjugation for non-complex types and put comparisons into std namespace...
Definition: Complex.h:344
iterator begin()
Get the begin iterator object for any array.
Definition: Array.h:855
static boost::python::object makeobject(ContainerType const &c)
Definition: PycBasicData.h:337
static void assert_size(boost::type< ContainerType >, std::size_t)
Definition: PycBasicData.h:147
uInt size() const
Definition: IPosition.h:536
void register_convert_std_vector()
Definition: PycBasicData.h:615
Register the String conversion.
Definition: PycBasicData.h:584
static void construct(PyObject *obj_ptr, boost::python::converter::rvalue_from_python_stage1_data *data)
Constructs a C++ container from a Python sequence.
Definition: PycBasicData.h:476
Register the std::vector conversions.
Definition: PycBasicData.h:601
static void * convertible(PyObject *obj_ptr)
Appears to return obj_ptr if it is type of Python sequence that can be convertible to C++ container...
Definition: PycBasicData.h:422
bool getSeqObject(boost::python::object &py_obj)
Check if the given object is a sequence object.
static void reserve(ContainerType &a, std::size_t sz)
Definition: PycBasicData.h:201
static boost::python::object makeobject(ContainerType const &c)
Creates and returns a Python list from the elements copied from a STL container.
Definition: PycBasicData.h:235
static void fill_container(ContainerType &result, PyObject *obj_ptr)
Definition: PycBasicData.h:525
static void set_value(ContainerType &a, std::size_t i, ValueType const &v)
Definition: PycBasicData.h:175
static void reserve(ContainerType &a, std::size_t sz)
Definition: PycBasicData.h:185
#define AlwaysAssert(expr, exception)
These marcos are provided for use instead of simply using the constructors of assert_ to allow additi...
Definition: Assert.h:157
Bool PycArrayScalarCheck(PyObject *obj_ptr)
Check if the PyObject is an array scalar object.
Converts an STL vector or casa Array of T objects to Python list.
Definition: PycBasicData.h:362
void register_convert_casa_iposition()
Definition: PycBasicData.h:596
static bool check_convertibility(PyObject *obj_ptr)
Definition: PycBasicData.h:543
void register_convert_casa_vector()
Definition: PycBasicData.h:635
static PyObject * convert(ContainerType const &c)
Definition: PycBasicData.h:328
template <class T, class U> class vector;
Definition: Array.h:169
static boost::python::object makeobject(ContainerType const &c)
Definition: PycBasicData.h:318
static std::map< std::string, bool > _registry
Definition: PycBasicData.h:59
static void construct(PyObject *obj_ptr, boost::python::converter::rvalue_from_python_stage1_data *data)
Definition: PycBasicData.h:98
Register the IPosition conversion.
Definition: PycBasicData.h:592
iterator end()
Definition: Array.h:859
Operations on containers that have variable capacity for conversion from Python container to C++ one...
Definition: PycBasicData.h:166
Base class for all Casacore library errors.
Definition: Error.h:135
static void * convertible(PyObject *obj_ptr)
Definition: PycBasicData.h:88
static ContainerType make_container(PyObject *obj_ptr)
Constructs a C++ container from a Python sequence.
Definition: PycBasicData.h:517
const Double c
Fundamental physical constants (SI units):
Prevent a converter from being registered multiple times.
Definition: PycBasicData.h:53
A wrapper of a conversion function to convert a STL vector to a Python list.
Definition: PycBasicData.h:228
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Default operations on all containers for conversion from Python container to C++ one.
Definition: PycBasicData.h:136
static void reserve(ContainerType &, std::size_t)
Definition: PycBasicData.h:151
static PyObject * convert(ContainerType const &c)
Definition: PycBasicData.h:245
static void set(const std::string &name)
static PyObject * convert(String const &s)
Definition: PycBasicData.h:73
static bool get(const std::string &name)
static PyObject * convert(ContainerType const &c)
Definition: PycBasicData.h:290
ContainerType::value_type container_element_type
Definition: PycBasicData.h:410
static boost::python::list makeobject(ContainerType const &c)
Definition: PycBasicData.h:299
static bool check_convertibility_per_element()
Definition: PycBasicData.h:138
Conversion of Python sequence to C++ container.
Definition: PycBasicData.h:408
static void reserve(ContainerType &a, std::size_t sz)
Definition: PycBasicData.h:169
this file contains all the compiler specific defines
Definition: mainpage.dox:28
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Convert a String object from python.
Definition: PycBasicData.h:78
static void set_value(ContainerType &a, std::size_t i, ValueType const &v)
Definition: PycBasicData.h:207
static PyObject * convert(ContainerType const &c)
Definition: PycBasicData.h:309
ConstIteratorSTL const_iterator
Definition: Array.h:849