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;
130 : m_data(0),
m_size(0), m_reserved(0), m_flags(0), m_descriptor(0)
137 : m_data(0),
m_size(0), m_reserved(0), m_flags(0), m_descriptor(0)
151 m_descriptor(descriptor)
185 template <
typename T, XsArrayDescriptor const& D,
typename I>
186 struct XsArrayImpl :
protected XsArray 189 typedef T value_type;
192 typedef XsArrayImpl<T, D, I> ArrayImpl;
205 inline XsArrayImpl<T, D, I>(ArrayImpl
const& other) :
XsArray(other) {}
206 #ifndef XSENS_NOITERATOR 209 template <
typename Iterator>
210 inline XsArrayImpl<T, D, I>(Iterator
const& beginIt, Iterator
const& endIt)
217 for (Iterator it = beginIt; it != endIt; ++it) push_back(*it);
222 inline explicit XsArrayImpl<T, D, I>(
237 inline bool operator==(ArrayImpl
const& other)
const 247 inline bool operator!=(ArrayImpl
const& other)
const 260 #ifndef XSENS_NOITERATOR 262 template <ptrdiff_t F,
typename R,
typename Derived>
263 struct IteratorImplBase
269 typedef T value_type;
273 typedef T& reference;
276 typedef std::random_access_iterator_tag iterator_category;
279 typedef Derived this_type;
285 inline explicit IteratorImplBase(
void*
p = 0) : m_ptr((T*)
p) {}
287 inline explicit IteratorImplBase(T*
p) : m_ptr(
p) {}
289 inline IteratorImplBase(this_type
const& i) : m_ptr(i.m_ptr) {}
293 inline this_type operator=(
void*
p)
296 return this_type(m_ptr);
299 inline this_type operator=(T*
p)
302 return this_type(m_ptr);
305 inline this_type operator=(this_type
const& i)
308 return this_type(m_ptr);
313 m_ptr = (T*)ptrAt(m_ptr, F);
314 return this_type(m_ptr);
320 m_ptr = (T*)ptrAt(m_ptr, F);
324 inline this_type operator--()
326 m_ptr = (T*)ptrAt(m_ptr, -F);
327 return this_type(m_ptr);
330 inline this_type operator--(
int)
333 m_ptr = (T*)ptrAt(m_ptr, -F);
339 m_ptr = ptrAt(m_ptr, F *
count);
340 return this_type(m_ptr);
345 m_ptr = ptrAt(m_ptr, -F *
count);
346 return this_type(m_ptr);
351 return this_type(ptrAt(m_ptr, F *
count));
356 return this_type(ptrAt(m_ptr, -F *
count));
368 inline difference_type
operator-(
const this_type& other)
const 370 return (F * (reinterpret_cast<char*>(m_ptr) -
371 reinterpret_cast<char*>(other.m_ptr))) /
375 inline bool operator==(this_type
const& i)
const 377 return m_ptr == i.m_ptr;
380 inline bool operator<=(this_type
const& i)
const 382 return (F == 1) ? (m_ptr <= i.m_ptr) : (m_ptr >= i.m_ptr);
385 inline bool operator<(this_type
const& i)
const 387 return (F == 1) ? (m_ptr < i.m_ptr) : (m_ptr > i.m_ptr);
390 inline bool operator!=(this_type
const& i)
const 392 return m_ptr != i.m_ptr;
395 inline bool operator>=(this_type
const& i)
const 397 return (F == 1) ? (m_ptr >= i.m_ptr) : (m_ptr <= i.m_ptr);
400 inline bool operator>(this_type
const& i)
const 402 return (F == 1) ? (m_ptr > i.m_ptr) : (m_ptr < i.m_ptr);
407 inline R* operator->()
const {
return (
R*)ptr(); }
409 inline T* ptr()
const {
return m_ptr; }
418 #ifndef XSENS_NOITERATOR 420 template <ptrdiff_t F>
421 struct IteratorImpl :
public IteratorImplBase<F, T, IteratorImpl<F>>
425 typedef IteratorImplBase<F, T, IteratorImpl<F>> ParentType;
429 inline IteratorImpl(
void*
p = 0) : ParentType(
p) {}
431 inline IteratorImpl(T*
p) : ParentType(
p) {}
433 inline IteratorImpl(
const IteratorImpl& i) : ParentType(i) {}
437 template <ptrdiff_t F>
438 struct IteratorImplConst
439 :
public IteratorImplBase<F, T const, IteratorImplConst<F>>
443 typedef IteratorImplBase<F, T const, IteratorImplConst<F>> ParentType;
447 inline IteratorImplConst(
void*
p = 0) : ParentType(
p) {}
449 inline IteratorImplConst(T*
p) : ParentType(
p) {}
451 inline IteratorImplConst(IteratorImpl<F>
const& i) : ParentType(i.ptr())
455 inline IteratorImplConst(IteratorImplConst
const& i) : ParentType(i) {}
459 typedef IteratorImpl<1> iterator;
461 typedef IteratorImpl<-1> reverse_iterator;
463 typedef IteratorImplConst<1> const_iterator;
465 typedef IteratorImplConst<-1> const_reverse_iterator;
468 inline const_iterator
begin()
const {
return const_iterator(m_data); }
474 inline const_reverse_iterator rbegin()
const 480 inline const_reverse_iterator rend()
const 482 return const_reverse_iterator(m_data) + (
ptrdiff_t)1;
486 inline iterator
begin() {
return iterator(m_data); }
492 inline reverse_iterator rbegin() {
return rend() - (
ptrdiff_t)
size(); }
495 inline reverse_iterator rend()
497 return reverse_iterator(m_data) + (
ptrdiff_t)1;
504 return *ptrAt(m_data,
index);
516 #ifdef XSENS_NO_EXCEPTIONS 519 if (
index >=
m_size)
throw std::out_of_range(
"index out of range");
521 return *ptrAt(m_data,
index);
527 #ifdef XSENS_NO_EXCEPTIONS 530 if (
index >=
m_size)
throw std::out_of_range(
"index out of range");
532 return *ptrAt(m_data,
index);
540 inline void insert(T
const& item,
XsSize index) { insert(&item,
index, 1); }
553 #ifndef XSENS_NOITERATOR 559 inline void insert(T
const& item, const_iterator it)
561 insert(&item, indexOf(it), 1);
568 inline void insert(T
const& item, const_reverse_iterator it)
570 insert(&item, indexOf(it), 1);
579 inline void insert(T
const* items, const_iterator it,
XsSize count)
581 insert(items, indexOf(it),
count);
589 inline void insert(T
const* items, const_reverse_iterator it,
XsSize count)
591 insert(items, indexOf(it),
count);
597 inline void push_back(T
const& item) { insert(&item, (
XsSize)-1, 1); }
609 inline void push_front(T
const& item) { insert(&item, 0, 1); }
625 #ifndef XSENS_NOITERATOR 629 inline iterator erase(iterator it)
633 return (idx <
size()) ? ptrAt(m_data, idx) :
end();
638 inline reverse_iterator erase(reverse_iterator it)
642 return (idx <
size()) ? ptrAt(m_data, idx) : rend();
660 inline void append(ArrayImpl
const& other) {
XsArray_append(
this, &other); }
664 inline ArrayImpl& operator=(ArrayImpl
const& other)
672 inline bool empty()
const 677 #ifndef XSENS_NOITERATOR 679 inline I
const& inherited()
const {
return *
static_cast<I const*
>(
this); }
681 inline I& inherited() {
return *
static_cast<I*
>(
this); }
685 inline void swap(ArrayImpl& other) {
XsArray_swap(
this, &other); }
693 #ifndef XSENS_NOITERATOR 702 inline int find(T
const& needle)
const 706 #ifndef XSENS_NOITERATOR 714 template <ptrdiff_t F,
typename R,
typename Derived>
715 XsSize indexOf(IteratorImplBase<F, R, Derived>
const& it)
const 717 ptrdiff_t d = ((
char const*)it.ptr() - (
char const*)m_data);
721 if (
r <=
size())
return r;
748 return (T*)(
void*)(((
char*)ptr) +
count * D.itemSize);
std::ostream & operator<<(std::ostream &o, const TFTDIDevice &d)
Print out all the information of a FTDI device in textual form.
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)
GLuint GLuint GLsizei count
This object describes how to treat the data in an array.
const_iterator find(const KEY &key) const
GLsizei const GLvoid * pointer
XSTYPES_DLL_API void XsArray_resize(void *thisPtr, XsSize count)
XSTYPES_DLL_API void XsArray_destruct(void *thisPtr)
void(* itemSwap)(void *a, void *b)
The function to use for swapping the data of two array items.
size_t XsSize
XsSize must be unsigned number!
TColor operator+(const TColor &first, const TColor &second)
Pairwise addition of their corresponding RGBA members.
VALUE & operator[](const KEY &key)
Write/read via [i] operator, that creates an element if it didn't exist already.
XSTYPES_DLL_API int XsArray_compareSet(void const *a, void const *b)
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)
void(* itemCopy)(void *to, void const *from)
The function to use for copying the data of from to to.
const XsSize itemSize
The size of an array item in bytes.
void(* itemDestruct)(void *e)
The function to use for destructing a array item.
XSTYPES_DLL_API void * XsArray_atIndex(void *thisPtr, XsSize index)
bool operator==(const mrpt::img::TCamera &a, const mrpt::img::TCamera &b)
XSTYPES_DLL_API int XsArray_compare(void const *a, void const *b)
const_iterator begin() const
GLdouble GLdouble GLdouble r
XSTYPES_DLL_API void XsArray_copyConstruct(void *thisPtr, void const *src)
TColor operator-(const TColor &first, const TColor &second)
Pairwise substraction of their corresponding RGBA members.
XSTYPES_DLL_API void XsArray_assign(void *thisPtr, XsSize count, void const *src)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
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_reserve(void *thisPtr, XsSize count)
XSTYPES_DLL_API void XsArray_copy(void *thisPtr, void const *src)
bool operator<(const COccupancyGridMap2D::TPairLikelihoodIndex &e1, const COccupancyGridMap2D::TPairLikelihoodIndex &e2)
bool operator!=(const mrpt::img::TCamera &a, const mrpt::img::TCamera &b)
GLubyte GLubyte GLubyte a
XSTYPES_DLL_API void XsArray_swap(void *a, void *b)
void clear()
Clear the contents of this container.
XSTYPES_DLL_API void XsArray_append(void *thisPtr, void const *other)
size_t m_size
Number of elements accessed with write access so far.
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.