MRPT  1.9.9
xsbytearray.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef XSBYTEARRAY_H
10 #define XSBYTEARRAY_H
11 
12 #include "pstdint.h"
13 #include "xsarray.h"
14 
15 #ifdef __cplusplus
16 #include "xsstring.h"
17 extern "C"
18 {
19 #endif
20 
22 
23 #ifndef __cplusplus
24 #define XSBYTEARRAY_INITIALIZER XSARRAY_INITIALIZER(&g_xsByteArrayDescriptor)
26  typedef struct XsByteArray XsByteArray;
28  XsByteArray* thisPtr, XsSize count, uint8_t const* src);
29 
30 // obsolete:
31 #define XsByteArray_ref(thisPtr, sz, src, flags) \
32  XsArray_ref(thisPtr, sz, src, flags)
33 #define XsByteArray_assign(thisPtr, sz, src) XsArray_assign(thisPtr, sz, src)
34 #define XsByteArray_destruct(thisPtr) XsArray_destruct(thisPtr)
35 #define XsByteArray_copy(thisPtr, copy) XsArray_copy(copy, thisPtr)
36 #define XsByteArray_append(thisPtr, other) XsArray_append(thisPtr, other)
37 #define XsByteArray_popFront(thisPtr, count) XsArray_erase(thisPtr, 0, count)
38 #define XsByteArray_popBack(thisPtr, count) \
39  XsArray_erase(thisPtr, (XsSize)-1, count)
40 #define XsByteArray_fromString(str, copy) \
41  XsArray_assign( \
42  copy, str->m_size ? str->m_size : 1, str->m_size ? str->m_data : "\0")
43 #define XsByteArray_swap(a, b) XsArray_swap(a, b)
44 #define XsByteArray_erase(thisPtr, index, count) \
45  XsArray_erase(thisPtr, index, count)
46 
47 #else
48 } // extern "C"
49 #endif
50 
51 #ifdef __cplusplus
52  struct XsByteArray
53  : public XsArrayImpl<uint8_t, g_xsByteArrayDescriptor, XsByteArray>
54  {
55  //! \brief Constructs an XsByteArray
56  inline explicit XsByteArray(XsSize sz = 0, uint8_t const* src = 0)
57  : ArrayImpl(sz, src)
58  {
59  }
60 
61  //! \brief Constructs an XsByteArray as a copy of \a other
62  inline XsByteArray(XsByteArray const& other) : ArrayImpl(other) {}
63  //! \brief Constructs an XsByteArray that references the data supplied
64  //! in \a ref
65  inline explicit XsByteArray(
66  uint8_t* ref, XsSize sz, XsDataFlags flags = XSDF_None)
67  : ArrayImpl(ref, sz, flags)
68  {
69  }
70 #ifndef XSENS_NOITERATOR
71  //! \brief Constructs an XsByteArray with the array bound by the
72  //! supplied iterators \a beginIt and \a endIt
73  template <typename Iterator>
74  inline XsByteArray(Iterator beginIt, Iterator endIt)
75  : ArrayImpl(beginIt, endIt)
76  {
77  }
78 #endif
79  //! \brief Constructs an XsByteArray as a copy of the supplied XsString,
80  //! including the terminating 0
81  inline XsByteArray(XsString const& src) : ArrayImpl()
82  {
83  assign(
84  src.size() + 1, reinterpret_cast<uint8_t const*>(src.c_str()));
85  }
86 
87  //! \brief Return a pointer to the internal data buffer
88  inline uint8_t* data() { return begin().operator->(); }
89  //! \brief Return a pointer to the internal data buffer
90  inline uint8_t const* data() const { return begin().operator->(); }
91  };
92 #endif
93 #endif // file guard
GLuint GLuint GLsizei count
Definition: glext.h:3532
This object describes how to treat the data in an array.
Definition: xsarray.h:63
GLenum GLint ref
Definition: glext.h:4062
struct XsByteArray XsByteArray
Definition: xsbytearray.h:26
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:19
GLuint src
Definition: glext.h:7397
No flag set.
Definition: xstypedefs.h:44
unsigned char uint8_t
Definition: rptypes.h:44
XsArrayDescriptor const XSTYPES_DLL_API g_xsByteArrayDescriptor
XSARRAY_STRUCT(XsByteArray, uint8_t)
#define XSTYPES_DLL_API
Definition: xstypesconfig.h:9
const_iterator begin() const
Definition: ts_hash_map.h:229
XSTYPES_DLL_API void XsByteArray_construct(XsByteArray *thisPtr, XsSize count, uint8_t const *src)
struct XsString XsString
Definition: xsstring.h:35
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3550
XsDataFlags
These flags define the behaviour of data contained by Xsens data structures.
Definition: xstypedefs.h:41



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019