MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/Imath / FixedArray

Class FixedArray

src/python/PyImath/PyImathFixedArray.h:89–825  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87
88template <class T>
89class FixedArray
90{
91 T * _ptr;
92 size_t _length;
93 size_t _stride;
94 bool _writable;
95
96 // this handle optionally stores a shared_array to allocated array data
97 // so that everything is freed properly on exit.
98 boost::any _handle;
99
100 boost::shared_array<size_t> _indices; // non-NULL iff I'm a masked reference
101 size_t _unmaskedLength;
102
103
104 public:
105 typedef T BaseType;
106
107 FixedArray(T *ptr, Py_ssize_t length, Py_ssize_t stride = 1, bool writable = true)
108 : _ptr(ptr), _length(length), _stride(stride), _writable(writable),
109 _handle(), _unmaskedLength(0)
110 {
111 if (length < 0)
112 {
113 throw std::domain_error ("Fixed array length must be non-negative");
114 }
115 if (stride <= 0)
116 {
117 throw std::domain_error ("Fixed array stride must be positive");
118 }
119 // nothing
120 }
121
122 FixedArray(T *ptr, Py_ssize_t length, Py_ssize_t stride,
123 boost::any handle, bool writable = true)
124 : _ptr(ptr), _length(length), _stride(stride), _writable(writable),
125 _handle(handle), _unmaskedLength(0)
126 {
127 if (_length < 0)
128 {
129 throw std::domain_error("Fixed array length must be non-negative");
130 }
131 if (stride <= 0)
132 {
133 throw std::domain_error("Fixed array stride must be positive");
134 }
135 // nothing
136 }
137
138 FixedArray(const T *ptr, Py_ssize_t length, Py_ssize_t stride = 1)
139 : _ptr(const_cast<T *>(ptr)), _length(length), _stride(stride),
140 _writable(false), _handle(), _unmaskedLength(0)
141 {
142 if (length < 0)
143 {
144 throw std::logic_error("Fixed array length must be non-negative");
145 }
146 if (stride <= 0)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected