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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST