14 #define XSARRAY_DECL(T) \ 16 const XsSize m_size; \ 20 XsArrayDescriptor const* const \ 23 #define XSARRAY_STRUCT(S, T) \ 28 #define XSARRAY_INITIALIZER(D) \ 30 0, 0, 0, XSDF_Managed, D \ 34 typedef void (*XsArrayItemSwapFunc)(
void*,
void*);
35 typedef void (*XsArrayItemStructFunc)(
void*);
36 typedef void (*XsArrayItemCopyFunc)(
void*,
void const*);
37 typedef int (*XsArrayItemCompareFunc)(
void const*,
void const*);
39 #define XSEXPCASTITEMSWAP (XsArrayItemSwapFunc) 40 #define XSEXPCASTITEMMAKE (XsArrayItemStructFunc) 41 #define XSEXPCASTITEMCOPY (XsArrayItemCopyFunc) 42 #define XSEXPCASTITEMCOMP (XsArrayItemCompareFunc) 44 #define XSEXPCASTITEMSWAP 45 #define XSEXPCASTITEMMAKE 46 #define XSEXPCASTITEMCOPY 47 #define XSEXPCASTITEMCOMP 62 template <
typename T, XsArrayDescriptor const& D,
typename I>
63 friend struct XsArrayImpl;
128 : m_data(0),
m_size(0), m_reserved(0), m_flags(0), m_descriptor(0)
135 : m_data(0),
m_size(0), m_reserved(0), m_flags(0), m_descriptor(0)
149 m_descriptor(descriptor)
183 template <
typename T, XsArrayDescriptor const& D,
typename I>
184 struct XsArrayImpl :
protected XsArray 187 typedef T value_type;
190 typedef XsArrayImpl<T, D, I> ArrayImpl;
203 inline XsArrayImpl<T, D, I>(ArrayImpl
const& other) :
XsArray(other) {}
204 #ifndef XSENS_NOITERATOR 207 template <
typename Iterator>
208 inline XsArrayImpl<T, D, I>(Iterator
const& beginIt, Iterator
const& endIt)
215 for (Iterator it = beginIt; it != endIt; ++it)
push_back(*it);
220 inline explicit XsArrayImpl<T, D, I>(
235 inline bool operator==(ArrayImpl
const& other)
const 245 inline bool operator!=(ArrayImpl
const& other)
const 257 #ifndef XSENS_NOITERATOR 259 template <ptrdiff_t F,
typename R,
typename Derived>
260 struct IteratorImplBase
266 typedef T value_type;
270 typedef T& reference;
273 typedef std::random_access_iterator_tag iterator_category;
276 typedef Derived this_type;
282 inline explicit IteratorImplBase(
void*
p = 0) : m_ptr((T*)
p) {}
284 inline explicit IteratorImplBase(T*
p) : m_ptr(
p) {}
286 inline IteratorImplBase(this_type
const& i) : m_ptr(i.m_ptr) {}
289 inline this_type operator=(
void*
p)
292 return this_type(m_ptr);
295 inline this_type operator=(T*
p)
298 return this_type(m_ptr);
301 inline this_type operator=(this_type
const& i)
304 return this_type(m_ptr);
309 m_ptr = (T*)ptrAt(m_ptr, F);
310 return this_type(m_ptr);
316 m_ptr = (T*)ptrAt(m_ptr, F);
320 inline this_type operator--()
322 m_ptr = (T*)ptrAt(m_ptr, -F);
323 return this_type(m_ptr);
326 inline this_type operator--(
int)
329 m_ptr = (T*)ptrAt(m_ptr, -F);
335 m_ptr = ptrAt(m_ptr, F *
count);
336 return this_type(m_ptr);
341 m_ptr = ptrAt(m_ptr, -F *
count);
342 return this_type(m_ptr);
347 return this_type(ptrAt(m_ptr, F *
count));
352 return this_type(ptrAt(m_ptr, -F *
count));
364 inline difference_type
operator-(
const this_type& other)
const 366 return (F * (reinterpret_cast<char*>(m_ptr) -
367 reinterpret_cast<char*>(other.m_ptr))) /
371 inline bool operator==(this_type
const& i)
const 373 return m_ptr == i.m_ptr;
376 inline bool operator<=(this_type
const& i)
const 378 return (F == 1) ? (m_ptr <= i.m_ptr) : (m_ptr >= i.m_ptr);
381 inline bool operator<(this_type
const& i)
const 383 return (F == 1) ? (m_ptr < i.m_ptr) : (m_ptr > i.m_ptr);
386 inline bool operator!=(this_type
const& i)
const 388 return m_ptr != i.m_ptr;
391 inline bool operator>=(this_type
const& i)
const 393 return (F == 1) ? (m_ptr >= i.m_ptr) : (m_ptr <= i.m_ptr);
396 inline bool operator>(this_type
const& i)
const 398 return (F == 1) ? (m_ptr > i.m_ptr) : (m_ptr < i.m_ptr);
403 inline R* operator->()
const {
return (
R*)ptr(); }
405 inline T* ptr()
const {
return m_ptr; }
413 #ifndef XSENS_NOITERATOR 415 template <ptrdiff_t F>
416 struct IteratorImpl :
public IteratorImplBase<F, T, IteratorImpl<F>>
420 typedef IteratorImplBase<F, T, IteratorImpl<F>> ParentType;
424 inline IteratorImpl(
void*
p = 0) : ParentType(
p) {}
426 inline IteratorImpl(T*
p) : ParentType(
p) {}
428 inline IteratorImpl(
const IteratorImpl& i) : ParentType(i) {}
432 template <ptrdiff_t F>
433 struct IteratorImplConst
434 :
public IteratorImplBase<F, T const, IteratorImplConst<F>>
438 typedef IteratorImplBase<F, T const, IteratorImplConst<F>> ParentType;
442 inline IteratorImplConst(
void*
p = 0) : ParentType(
p) {}
444 inline IteratorImplConst(T*
p) : ParentType(
p) {}
446 inline IteratorImplConst(IteratorImpl<F>
const& i) : ParentType(i.ptr())
450 inline IteratorImplConst(IteratorImplConst
const& i) : ParentType(i) {}
456 typedef IteratorImpl<-1> reverse_iterator;
460 typedef IteratorImplConst<-1> const_reverse_iterator;
469 inline const_reverse_iterator rbegin()
const 475 inline const_reverse_iterator rend()
const 477 return const_reverse_iterator(m_data) + (
ptrdiff_t)1;
487 inline reverse_iterator rbegin() {
return rend() - (
ptrdiff_t)
size(); }
490 inline reverse_iterator rend()
492 return reverse_iterator(m_data) + (
ptrdiff_t)1;
499 return *ptrAt(m_data,
index);
511 #ifdef XSENS_NO_EXCEPTIONS 514 if (
index >=
m_size)
throw std::out_of_range(
"index out of range");
516 return *ptrAt(m_data,
index);
522 #ifdef XSENS_NO_EXCEPTIONS 525 if (
index >=
m_size)
throw std::out_of_range(
"index out of range");
527 return *ptrAt(m_data,
index);
535 inline void insert(T
const& item,
XsSize index) { insert(&item,
index, 1); }
548 #ifndef XSENS_NOITERATOR 556 insert(&item, indexOf(it), 1);
563 inline void insert(T
const& item, const_reverse_iterator it)
565 insert(&item, indexOf(it), 1);
576 insert(items, indexOf(it),
count);
584 inline void insert(T
const* items, const_reverse_iterator it,
XsSize count)
586 insert(items, indexOf(it),
count);
604 inline void push_front(T
const& item) { insert(&item, 0, 1); }
620 #ifndef XSENS_NOITERATOR 628 return (idx <
size()) ? ptrAt(m_data, idx) :
end();
633 inline reverse_iterator erase(reverse_iterator it)
637 return (idx <
size()) ? ptrAt(m_data, idx) : rend();
655 inline void append(ArrayImpl
const& other) {
XsArray_append(
this, &other); }
659 inline ArrayImpl& operator=(ArrayImpl
const& other)
667 inline bool empty()
const 672 #ifndef XSENS_NOITERATOR 674 inline I
const& inherited()
const {
return *
static_cast<I const*
>(
this); }
676 inline I& inherited() {
return *
static_cast<I*
>(
this); }
680 inline void swap(ArrayImpl& other) {
XsArray_swap(
this, &other); }
688 #ifndef XSENS_NOITERATOR 697 inline int find(T
const& needle)
const 701 #ifndef XSENS_NOITERATOR 709 template <ptrdiff_t F,
typename R,
typename Derived>
710 XsSize indexOf(IteratorImplBase<F, R, Derived>
const& it)
const 712 ptrdiff_t d = ((
char const*)it.ptr() - (
char const*)m_data);
716 if (
r <=
size())
return r;
742 return (T*)(
void*)(((
char*)ptr) +
count * D.itemSize);
XSTYPES_DLL_API void const * XsArray_at(void const *thisPtr, XsSize index)
XSTYPES_DLL_API void XsArray_insert(void *thisPtr, XsSize index, XsSize count, void const *src)
bool operator==(const TPoint2D &p1, const TPoint2D &p2)
Exact comparison between 2D points.
GLuint GLuint GLsizei count
This object describes how to treat the data in an array.
EIGEN_STRONG_INLINE bool empty() const
GLsizei const GLvoid * pointer
XSTYPES_DLL_API void XsArray_resize(void *thisPtr, XsSize count)
iterator operator++(int)
A thread-safe (ts) container which minimally emulates a std::map<>'s [] and find() methods but which ...
XSTYPES_DLL_API void XsArray_destruct(void *thisPtr)
bool operator!=(const TPoint2D &p1, const TPoint2D &p2)
Exact comparison between 2D points.
void(* itemSwap)(void *a, void *b)
The function to use for swapping the data of two array items.
EIGEN_STRONG_INLINE iterator begin()
EIGEN_STRONG_INLINE void push_back(Scalar val)
Insert an element at the end of the container (for 1D vectors/arrays)
size_t XsSize
XsSize must be unsigned number!
const Scalar * const_iterator
const_iterator find(const KEY &key) const
void clear()
Clear the contents of this container.
XSTYPES_DLL_API int XsArray_compareSet(void const *a, void const *b)
std::vector< T1 > operator+(const std::vector< T1 > &a, const std::vector< T2 > &b)
a+b (element-wise sum)
XSTYPES_DLL_API void XsArray_erase(void *thisPtr, XsSize index, XsSize count)
XSTYPES_DLL_API int XsArray_find(void const *thisPtr, void const *needle)
void(* itemCopyConstruct)(void *e, void const *s)
The function to use for constructing a new array item with a source initializer.
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
a+=b (element-wise sum)
XSTYPES_DLL_API void XsArray_removeDuplicates(void *thisPtr)
VALUE & operator[](const KEY &key)
Write/read via [i] operator, that creates an element if it didn't exist already.
EIGEN_STRONG_INLINE void setSize(size_t row, size_t col)
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where...
void(* itemCopy)(void *to, void const *from)
The function to use for copying the data of from to to.
EIGEN_STRONG_INLINE void assign(const Scalar v)
size_t m_size
Number of elements accessed with write access so far.
const XsSize itemSize
The size of an array item in bytes.
void(* itemDestruct)(void *e)
The function to use for destructing a array item.
std::ostream & operator<<(std::ostream &out, MD5 md5)
XSTYPES_DLL_API void * XsArray_atIndex(void *thisPtr, XsSize index)
XSTYPES_DLL_API int XsArray_compare(void const *a, void const *b)
GLdouble GLdouble GLdouble r
XSTYPES_DLL_API void XsArray_copyConstruct(void *thisPtr, void const *src)
bool operator<(const CPoint< DERIVEDCLASS > &a, const CPoint< DERIVEDCLASS > &b)
Used by STL algorithms.
XSTYPES_DLL_API void XsArray_assign(void *thisPtr, XsSize count, void const *src)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
XSTYPES_DLL_API void XsArray_reserve(void *thisPtr, XsSize count)
XSTYPES_DLL_API void XsArray_copy(void *thisPtr, void const *src)
GLubyte GLubyte GLubyte a
TPoint3D operator-(const TPoint3D &p1)
Unary minus operator for 3D points.
XSTYPES_DLL_API void XsArray_swap(void *a, void *b)
XSTYPES_DLL_API void XsArray_append(void *thisPtr, void const *other)
XSTYPES_DLL_API void XsArray_construct(void *thisPtr, XsArrayDescriptor const *const descriptor, XsSize count, void const *src)
XsDataFlags
These flags define the behaviour of data contained by Xsens data structures.
std::vector< T1 > operator*(const std::vector< T1 > &a, const std::vector< T2 > &b)
a*b (element-wise multiplication)
void(* itemConstruct)(void *e)
The function to use for constructing a new array item.
int(* itemCompare)(void const *a, void const *b)
The function to use for comparing two items.