ONE - On-device Neural Engine
Loading...
Searching...
No Matches
flatbuffers::Array< T, length > Class Template Reference

#include <array.h>

Public Types

typedef uint16_t size_type
 
typedef IndirectHelper< IndirectHelperType >::return_type return_type
 
typedef VectorConstIterator< T, return_type, uoffset_t > const_iterator
 
typedef VectorReverseIterator< const_iteratorconst_reverse_iterator
 

Public Member Functions

FLATBUFFERS_CONSTEXPR uint16_t size () const
 
return_type Get (uoffset_t i) const
 
return_type operator[] (uoffset_t i) const
 
template<typename E >
GetEnum (uoffset_t i) const
 
const_iterator begin () const
 
const_iterator end () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
flatbuffers::conditional< scalar_tag::value, void, T * >::type GetMutablePointer (uoffset_t i) const
 
void Mutate (uoffset_t i, const T &val)
 
const uint8_t * Data () const
 
uint8_t * Data ()
 
const T * data () const
 
T * data ()
 
void CopyFromSpan (flatbuffers::span< const T, length > src)
 

Static Public Attributes

static FLATBUFFERS_CONSTEXPR bool is_span_observable
 

Protected Member Functions

void MutateImpl (flatbuffers::true_type, uoffset_t i, const T &val)
 
void MutateImpl (flatbuffers::false_type, uoffset_t i, const T &val)
 
void CopyFromSpanImpl (flatbuffers::true_type, flatbuffers::span< const T, length > src)
 
void CopyFromSpanImpl (flatbuffers::false_type, flatbuffers::span< const T, length > src)
 
 Array ()
 

Protected Attributes

uint8_t data_ [length *sizeof(T)]
 

Detailed Description

template<typename T, uint16_t length>
class flatbuffers::Array< T, length >

Definition at line 30 of file array.h.

Member Typedef Documentation

◆ const_iterator

template<typename T , uint16_t length>
typedef VectorConstIterator<T, return_type, uoffset_t> flatbuffers::Array< T, length >::const_iterator

Definition at line 41 of file array.h.

◆ const_reverse_iterator

template<typename T , uint16_t length>
typedef VectorReverseIterator<const_iterator> flatbuffers::Array< T, length >::const_reverse_iterator

Definition at line 42 of file array.h.

◆ return_type

template<typename T , uint16_t length>
typedef IndirectHelper<IndirectHelperType>::return_type flatbuffers::Array< T, length >::return_type

Definition at line 40 of file array.h.

◆ size_type

template<typename T , uint16_t length>
typedef uint16_t flatbuffers::Array< T, length >::size_type

Definition at line 39 of file array.h.

Constructor & Destructor Documentation

◆ Array()

template<typename T , uint16_t length>
flatbuffers::Array< T, length >::Array ( )
protected

Member Function Documentation

◆ begin()

template<typename T , uint16_t length>
const_iterator flatbuffers::Array< T, length >::begin ( ) const
inline

Definition at line 65 of file array.h.

65{ return const_iterator(Data(), 0); }
const uint8_t * Data() const
Definition array.h:96
VectorConstIterator< T, return_type, uoffset_t > const_iterator
Definition array.h:41

References flatbuffers::Array< T, length >::Data().

Referenced by flatbuffers::Array< T, length >::cbegin(), and flatbuffers::Array< T, length >::rend().

◆ cbegin()

template<typename T , uint16_t length>
const_iterator flatbuffers::Array< T, length >::cbegin ( ) const
inline

Definition at line 75 of file array.h.

75{ return begin(); }
const_iterator begin() const
Definition array.h:65

References flatbuffers::Array< T, length >::begin().

◆ cend()

template<typename T , uint16_t length>
const_iterator flatbuffers::Array< T, length >::cend ( ) const
inline

Definition at line 76 of file array.h.

76{ return end(); }
const_iterator end() const
Definition array.h:66

References flatbuffers::Array< T, length >::end().

◆ CopyFromSpan()

template<typename T , uint16_t length>
void flatbuffers::Array< T, length >::CopyFromSpan ( flatbuffers::span< const T, length >  src)
inline

Definition at line 106 of file array.h.

106 {
107 const auto p1 = reinterpret_cast<const uint8_t *>(src.data());
108 const auto p2 = Data();
109 FLATBUFFERS_ASSERT(!(p1 >= p2 && p1 < (p2 + length)) &&
110 !(p2 >= p1 && p2 < (p1 + length)));
111 (void)p1;
112 (void)p2;
114 }
#define FLATBUFFERS_ASSERT
Definition base.h:21
void CopyFromSpanImpl(flatbuffers::true_type, flatbuffers::span< const T, length > src)
Definition array.h:126

References flatbuffers::Array< T, length >::CopyFromSpanImpl(), flatbuffers::Array< T, length >::Data(), and FLATBUFFERS_ASSERT.

◆ CopyFromSpanImpl() [1/2]

template<typename T , uint16_t length>
void flatbuffers::Array< T, length >::CopyFromSpanImpl ( flatbuffers::false_type  ,
flatbuffers::span< const T, length >  src 
)
inlineprotected

Definition at line 135 of file array.h.

136 {
137 for (size_type k = 0; k < length; k++) { Mutate(k, src[k]); }
138 }
void Mutate(uoffset_t i, const T &val)
Definition array.h:93
uint16_t size_type
Definition array.h:39

References flatbuffers::Array< T, length >::Mutate().

◆ CopyFromSpanImpl() [2/2]

template<typename T , uint16_t length>
void flatbuffers::Array< T, length >::CopyFromSpanImpl ( flatbuffers::true_type  ,
flatbuffers::span< const T, length >  src 
)
inlineprotected

Definition at line 126 of file array.h.

127 {
128 // Use std::memcpy() instead of std::copy() to avoid performance degradation
129 // due to aliasing if T is char or unsigned char.
130 // The size is known at compile time, so memcpy would be inlined.
131 std::memcpy(data(), src.data(), length * sizeof(T));
132 }
const T * data() const
Definition array.h:101

References flatbuffers::Array< T, length >::data().

Referenced by flatbuffers::Array< T, length >::CopyFromSpan().

◆ crbegin()

template<typename T , uint16_t length>
const_reverse_iterator flatbuffers::Array< T, length >::crbegin ( ) const
inline

Definition at line 78 of file array.h.

78{ return rbegin(); }
const_reverse_iterator rbegin() const
Definition array.h:68

References flatbuffers::Array< T, length >::rbegin().

◆ crend()

template<typename T , uint16_t length>
const_reverse_iterator flatbuffers::Array< T, length >::crend ( ) const
inline

Definition at line 79 of file array.h.

79{ return rend(); }
const_reverse_iterator rend() const
Definition array.h:71

References flatbuffers::Array< T, length >::rend().

◆ Data() [1/2]

template<typename T , uint16_t length>
uint8_t * flatbuffers::Array< T, length >::Data ( )
inline

Definition at line 98 of file array.h.

98{ return data_; }
uint8_t data_[length *sizeof(T)]
Definition array.h:151

References flatbuffers::Array< T, length >::data_.

◆ data() [1/2]

template<typename T , uint16_t length>
T * flatbuffers::Array< T, length >::data ( )
inline

Definition at line 102 of file array.h.

102{ return reinterpret_cast<T *>(Data()); }

References flatbuffers::Array< T, length >::Data().

◆ Data() [2/2]

◆ data() [2/2]

template<typename T , uint16_t length>
const T * flatbuffers::Array< T, length >::data ( ) const
inline

◆ end()

template<typename T , uint16_t length>
const_iterator flatbuffers::Array< T, length >::end ( ) const
inline

Definition at line 66 of file array.h.

66{ return const_iterator(Data(), size()); }
FLATBUFFERS_CONSTEXPR uint16_t size() const
Definition array.h:49

References flatbuffers::Array< T, length >::Data(), and flatbuffers::Array< T, length >::size().

Referenced by flatbuffers::Array< T, length >::cend(), and flatbuffers::Array< T, length >::rbegin().

◆ Get()

template<typename T , uint16_t length>
return_type flatbuffers::Array< T, length >::Get ( uoffset_t  i) const
inline

Definition at line 51 of file array.h.

51 {
53 return IndirectHelper<IndirectHelperType>::Read(Data(), i);
54 }

References flatbuffers::Array< T, length >::Data(), FLATBUFFERS_ASSERT, and flatbuffers::Array< T, length >::size().

Referenced by flatbuffers::Array< T, length >::GetEnum(), and flatbuffers::Array< T, length >::operator[]().

◆ GetEnum()

template<typename T , uint16_t length>
template<typename E >
E flatbuffers::Array< T, length >::GetEnum ( uoffset_t  i) const
inline

Definition at line 61 of file array.h.

61 {
62 return static_cast<E>(Get(i));
63 }
return_type Get(uoffset_t i) const
Definition array.h:51

References flatbuffers::Array< T, length >::Get().

◆ GetMutablePointer()

template<typename T , uint16_t length>
flatbuffers::conditional< scalar_tag::value, void, T * >::type flatbuffers::Array< T, length >::GetMutablePointer ( uoffset_t  i) const
inline

Definition at line 87 of file array.h.

87 {
89 return const_cast<T *>(&data()[i]);
90 }

References flatbuffers::Array< T, length >::data(), FLATBUFFERS_ASSERT, and flatbuffers::Array< T, length >::size().

Referenced by flatbuffers::Array< T, length >::MutateImpl().

◆ Mutate()

template<typename T , uint16_t length>
void flatbuffers::Array< T, length >::Mutate ( uoffset_t  i,
const T &  val 
)
inline

Definition at line 93 of file array.h.

93{ MutateImpl(scalar_tag(), i, val); }
void MutateImpl(flatbuffers::true_type, uoffset_t i, const T &val)
Definition array.h:117

References flatbuffers::Array< T, length >::MutateImpl().

Referenced by flatbuffers::Array< T, length >::CopyFromSpanImpl().

◆ MutateImpl() [1/2]

template<typename T , uint16_t length>
void flatbuffers::Array< T, length >::MutateImpl ( flatbuffers::false_type  ,
uoffset_t  i,
const T &  val 
)
inlineprotected

Definition at line 122 of file array.h.

122 {
123 *(GetMutablePointer(i)) = val;
124 }
flatbuffers::conditional< scalar_tag::value, void, T * >::type GetMutablePointer(uoffset_t i) const
Definition array.h:87

References flatbuffers::Array< T, length >::GetMutablePointer().

◆ MutateImpl() [2/2]

template<typename T , uint16_t length>
void flatbuffers::Array< T, length >::MutateImpl ( flatbuffers::true_type  ,
uoffset_t  i,
const T &  val 
)
inlineprotected

Definition at line 117 of file array.h.

117 {
119 WriteScalar(data() + i, val);
120 }

References flatbuffers::Array< T, length >::data(), FLATBUFFERS_ASSERT, and flatbuffers::Array< T, length >::size().

Referenced by flatbuffers::Array< T, length >::Mutate().

◆ operator[]()

template<typename T , uint16_t length>
return_type flatbuffers::Array< T, length >::operator[] ( uoffset_t  i) const
inline

Definition at line 56 of file array.h.

56{ return Get(i); }

References flatbuffers::Array< T, length >::Get().

◆ rbegin()

template<typename T , uint16_t length>
const_reverse_iterator flatbuffers::Array< T, length >::rbegin ( ) const
inline

Definition at line 68 of file array.h.

68 {
70 }
VectorReverseIterator< const_iterator > const_reverse_iterator
Definition array.h:42

References flatbuffers::Array< T, length >::end().

Referenced by flatbuffers::Array< T, length >::crbegin().

◆ rend()

template<typename T , uint16_t length>
const_reverse_iterator flatbuffers::Array< T, length >::rend ( ) const
inline

Definition at line 71 of file array.h.

71 {
73 }

References flatbuffers::Array< T, length >::begin().

Referenced by flatbuffers::Array< T, length >::crend().

◆ size()

template<typename T , uint16_t length>
FLATBUFFERS_CONSTEXPR uint16_t flatbuffers::Array< T, length >::size ( ) const
inline

Field Documentation

◆ data_

template<typename T , uint16_t length>
uint8_t flatbuffers::Array< T, length >::data_[length *sizeof(T)]
protected

◆ is_span_observable

template<typename T , uint16_t length>
FLATBUFFERS_CONSTEXPR bool flatbuffers::Array< T, length >::is_span_observable
static
Initial value:
=
(scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1)) ||
!scalar_tag::value

Definition at line 45 of file array.h.


The documentation for this class was generated from the following file: