Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | List of all members
uavcan::Array< T, ArrayMode, MaxSize_ > Class Template Reference

#include <array.hpp>

Inheritance diagram for uavcan::Array< T, ArrayMode, MaxSize_ >:
Inheritance graph
[legend]

Public Types

enum  { MaxSize = MaxSize_ }
 
enum  { MinBitLen }
 
enum  { MaxBitLen }
 
enum  { IsDynamic = ArrayMode == ArrayModeDynamic }
 
typedef T RawValueType
 This may be not the same as the element type. More...
 
typedef SizeType size_type
 
typedef Base::SizeType SizeType
 Minimal width size type. More...
 
typedef ValueType value_type
 
typedef StorageType< T >::Type ValueType
 This is the actual stored element type. More...
 
- Public Types inherited from uavcan::ArrayImpl< T, ArrayMode, MaxSize_ >
enum  
 
typedef ValueTypeiterator
 
typedef Base::SizeType SizeType
 
typedef StorageType< T >::Type ValueType
 

Public Member Functions

template<typename A >
void appendFormatted (const char *const format, const A value)
 
 Array ()
 
 Array (const char *str)
 
template<typename R >
EnableIf< sizeof((reinterpret_cast< const R * >0)) -> begin ()) &&sizeof((reinterpret_cast< const R * >(0)) -> size())>::Type packSquareMatrix(const R &src_row_major)
 
template<typename R >
EnableIf< sizeof((reinterpret_cast< const R * >0)) -> begin ()) &&sizeof((reinterpret_cast< const R * >(0)) -> size())>::Type unpackSquareMatrix(R &dst_row_major) const
 
void convertToLowerCaseASCII ()
 
void convertToUpperCaseASCII ()
 
bool empty () const
 
EnableIf< sizeof((reinterpret_cast< const R * >0)) -> bool ::Type isClose (const R &rhs) const
 
template<typename R >
bool operator!= (const R &rhs) const
 
template<uavcan::ArrayMode RhsArrayMode, unsigned RhsMaxSize>
SelfTypeoperator+= (const Array< T, RhsArrayMode, RhsMaxSize > &rhs)
 
SelfTypeoperator+= (const char *chr)
 
SelfTypeoperator= (const char *chr)
 
bool operator== (const char *chr) const
 
EnableIf< sizeof((reinterpret_cast< const R * >0)) -> bool ::Type operator== (const R &rhs) const
 
void packSquareMatrix ()
 
template<typename ScalarType >
void packSquareMatrix (const ScalarType(&src_row_major)[MaxSize])
 
void pop_back ()
 
void push_back (const ValueType &value)
 
void resize (SizeType new_size)
 
void resize (SizeType new_size, const ValueType &filler)
 
template<typename R >
EnableIf< sizeof((reinterpret_cast< const R * >0)) -> size ()) &&sizeof((*(reinterpret_cast< const R * >(0)))[0])
 
template<typename R >
EnableIf< sizeof((reinterpret_cast< const R * >0)) -> size ()) &&sizeof((*(reinterpret_cast< const R * >(0)))[0])
 
void unpackSquareMatrix ()
 
template<typename ScalarType >
void unpackSquareMatrix (ScalarType(&dst_row_major)[MaxSize]) const
 
- Public Member Functions inherited from uavcan::ArrayImpl< T, ArrayMode, MaxSize_ >
 ArrayImpl ()
 
ValueTypeat (SizeType pos)
 
const ValueTypeat (SizeType pos) const
 
ValueTypeback ()
 
const ValueTypeback () const
 
ValueTypebegin ()
 
const ValueTypebegin () const
 
const char * c_str () const
 
ValueTypeend ()
 
const ValueTypeend () const
 
ValueTypefront ()
 
const ValueTypefront () const
 
bool operator< (const R &rhs) const
 
ValueTypeoperator[] (SizeType pos)
 
const ValueTypeoperator[] (SizeType pos) const
 

Static Public Member Functions

static int decode (SelfType &array, ScalarCodec &codec, const TailArrayOptimizationMode tao_mode)
 
static int encode (const SelfType &array, ScalarCodec &codec, const TailArrayOptimizationMode tao_mode)
 
static void extendDataTypeSignature (DataTypeSignature &signature)
 

Private Types

typedef ArrayImpl< T, ArrayMode, MaxSize_ > Base
 
typedef Array< T, ArrayMode, MaxSize_ > SelfType
 

Private Member Functions

int decodeImpl (ScalarCodec &codec, const TailArrayOptimizationMode tao_mode, FalseType)
 Static. More...
 
int decodeImpl (ScalarCodec &codec, const TailArrayOptimizationMode tao_mode, TrueType)
 Dynamic. More...
 
int encodeImpl (ScalarCodec &codec, const TailArrayOptimizationMode tao_mode, FalseType) const
 Static. More...
 
int encodeImpl (ScalarCodec &codec, const TailArrayOptimizationMode tao_mode, TrueType) const
 Dynamic. More...
 
template<typename InputIter >
void packSquareMatrixImpl (const InputIter src_row_major)
 
template<typename ScalarType , typename OutputIter >
void unpackSquareMatrixImpl (const OutputIter dst_row_major) const
 

Static Private Member Functions

static bool isOptimizedTailArray (TailArrayOptimizationMode tao_mode)
 

Additional Inherited Members

- Public Attributes inherited from uavcan::ArrayImpl< T, ArrayMode, MaxSize_ >
const typedef ValueTypeconst_iterator
 
- Protected Member Functions inherited from uavcan::ArrayImpl< T, ArrayMode, MaxSize_ >
 ~ArrayImpl ()
 

Detailed Description

template<typename T, ArrayMode ArrayMode, unsigned MaxSize_>
class uavcan::Array< T, ArrayMode, MaxSize_ >

Generic array implementation. This class is compatible with most standard library functions operating on containers (e.g. std::sort(), std::lexicographical_compare(), etc.). No dynamic memory is used. All functions that can modify the array or access elements are range checking. If the range error occurs:

Definition at line 424 of file array.hpp.

Member Typedef Documentation

◆ Base

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
typedef ArrayImpl<T, ArrayMode, MaxSize_> uavcan::Array< T, ArrayMode, MaxSize_ >::Base
private

Definition at line 426 of file array.hpp.

◆ RawValueType

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
typedef T uavcan::Array< T, ArrayMode, MaxSize_ >::RawValueType

This may be not the same as the element type.

Definition at line 662 of file array.hpp.

◆ SelfType

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
typedef Array<T, ArrayMode, MaxSize_> uavcan::Array< T, ArrayMode, MaxSize_ >::SelfType
private

Definition at line 427 of file array.hpp.

◆ size_type

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
typedef SizeType uavcan::Array< T, ArrayMode, MaxSize_ >::size_type

Definition at line 1090 of file array.hpp.

◆ SizeType

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
typedef Base::SizeType uavcan::Array< T, ArrayMode, MaxSize_ >::SizeType

Minimal width size type.

Definition at line 664 of file array.hpp.

◆ value_type

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
typedef ValueType uavcan::Array< T, ArrayMode, MaxSize_ >::value_type

Aliases for compatibility with standard containers.

Definition at line 1089 of file array.hpp.

◆ ValueType

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
typedef StorageType<T>::Type uavcan::Array< T, ArrayMode, MaxSize_ >::ValueType

This is the actual stored element type.

Definition at line 663 of file array.hpp.

Member Enumeration Documentation

◆ anonymous enum

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
anonymous enum
Enumerator
MaxSize 

Definition at line 670 of file array.hpp.

◆ anonymous enum

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
anonymous enum
Enumerator
MinBitLen 

Definition at line 671 of file array.hpp.

◆ anonymous enum

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
anonymous enum
Enumerator
MaxBitLen 

Definition at line 677 of file array.hpp.

◆ anonymous enum

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
anonymous enum
Enumerator
IsDynamic 

Definition at line 669 of file array.hpp.

Constructor & Destructor Documentation

◆ Array() [1/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
uavcan::Array< T, ArrayMode, MaxSize_ >::Array ( )
inline

Default constructor zero-initializes the storage even if it consists of primitive types.

Definition at line 686 of file array.hpp.

◆ Array() [2/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
uavcan::Array< T, ArrayMode, MaxSize_ >::Array ( const char *  str)
inline

String constructor - only for string-like arrays. Refer to operator+=(const char*) for details.

Definition at line 692 of file array.hpp.

Member Function Documentation

◆ appendFormatted()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
template<typename A >
void uavcan::Array< T, ArrayMode, MaxSize_ >::appendFormatted ( const char *const  format,
const A  value 
)
inline

Formatting appender. This method doesn't raise an overflow error; instead it silently truncates the data to fit the array capacity. Works only with string-like arrays, otherwise fails to compile.

Parameters
formatFormat string for std::snprintf(), e.g. "%08x", "%f"
valueArbitrary value of a primitive type (should fail to compile if there's a non-primitive type)

Definition at line 888 of file array.hpp.

◆ begin() [1/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
template<typename R >
EnableIf<sizeof((reinterpret_cast<const R*>0))-> uavcan::Array< T, ArrayMode, MaxSize_ >::begin ( ) const && -> size())>::Type packSquareMatrix(const R& src_row_major)
inline

Fills this array as a packed square matrix from any container that has the following public entities:

  • method begin()
  • method size()
  • only for C++03: type value_type Please refer to the specification to learn more about matrix packing. Note that matrix packing code uses areClose() for comparison.

Definition at line 1006 of file array.hpp.

◆ begin() [2/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
template<typename R >
EnableIf<sizeof((reinterpret_cast<const R*>0))-> uavcan::Array< T, ArrayMode, MaxSize_ >::begin ( ) const && -> size())>::Type unpackSquareMatrix(R& dst_row_major) const
inline

Reconstructs full matrix, result will be saved into container that has the following public entities:

  • method begin()
  • method size()
  • only for C++03: type value_type Please refer to the specification to learn more about matrix packing.

Definition at line 1063 of file array.hpp.

◆ convertToLowerCaseASCII()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
void uavcan::Array< T, ArrayMode, MaxSize_ >::convertToLowerCaseASCII ( )
inline

Definition at line 940 of file array.hpp.

◆ convertToUpperCaseASCII()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
void uavcan::Array< T, ArrayMode, MaxSize_ >::convertToUpperCaseASCII ( )
inline

Converts the string to upper/lower case in place, assuming that encoding is ASCII. These methods can only be used with string-like arrays; otherwise compilation will fail.

Definition at line 926 of file array.hpp.

◆ decode()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
static int uavcan::Array< T, ArrayMode, MaxSize_ >::decode ( SelfType array,
ScalarCodec codec,
const TailArrayOptimizationMode  tao_mode 
)
inlinestatic

Definition at line 702 of file array.hpp.

◆ decodeImpl() [1/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
int uavcan::Array< T, ArrayMode, MaxSize_ >::decodeImpl ( ScalarCodec codec,
const TailArrayOptimizationMode  tao_mode,
FalseType   
)
inlineprivate

Static.

Definition at line 470 of file array.hpp.

◆ decodeImpl() [2/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
int uavcan::Array< T, ArrayMode, MaxSize_ >::decodeImpl ( ScalarCodec codec,
const TailArrayOptimizationMode  tao_mode,
TrueType   
)
inlineprivate

Dynamic.

Definition at line 491 of file array.hpp.

◆ empty()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
bool uavcan::Array< T, ArrayMode, MaxSize_ >::empty ( ) const
inline

Definition at line 712 of file array.hpp.

◆ encode()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
static int uavcan::Array< T, ArrayMode, MaxSize_ >::encode ( const SelfType array,
ScalarCodec codec,
const TailArrayOptimizationMode  tao_mode 
)
inlinestatic

Definition at line 697 of file array.hpp.

◆ encodeImpl() [1/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
int uavcan::Array< T, ArrayMode, MaxSize_ >::encodeImpl ( ScalarCodec codec,
const TailArrayOptimizationMode  tao_mode,
FalseType   
) const
inlineprivate

Static.

Definition at line 434 of file array.hpp.

◆ encodeImpl() [2/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
int uavcan::Array< T, ArrayMode, MaxSize_ >::encodeImpl ( ScalarCodec codec,
const TailArrayOptimizationMode  tao_mode,
TrueType   
) const
inlineprivate

Dynamic.

Definition at line 449 of file array.hpp.

◆ extendDataTypeSignature()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
static void uavcan::Array< T, ArrayMode, MaxSize_ >::extendDataTypeSignature ( DataTypeSignature signature)
inlinestatic

Definition at line 707 of file array.hpp.

◆ isClose()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
EnableIf<sizeof((reinterpret_cast<const R*>0))-> bool ::Type uavcan::Array< T, ArrayMode, MaxSize_ >::isClose ( const R &  rhs) const
inline

Definition at line 792 of file array.hpp.

◆ isOptimizedTailArray()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
static bool uavcan::Array< T, ArrayMode, MaxSize_ >::isOptimizedTailArray ( TailArrayOptimizationMode  tao_mode)
inlinestaticprivate

Definition at line 429 of file array.hpp.

◆ operator!=()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
template<typename R >
bool uavcan::Array< T, ArrayMode, MaxSize_ >::operator!= ( const R &  rhs) const
inline

operator==()

Definition at line 824 of file array.hpp.

◆ operator+=() [1/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
template<uavcan::ArrayMode RhsArrayMode, unsigned RhsMaxSize>
SelfType& uavcan::Array< T, ArrayMode, MaxSize_ >::operator+= ( const Array< T, RhsArrayMode, RhsMaxSize > &  rhs)
inline

Appends another Array<> with the same element type. Mode and max size can be different.

Definition at line 869 of file array.hpp.

◆ operator+=() [2/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
SelfType& uavcan::Array< T, ArrayMode, MaxSize_ >::operator+= ( const char *  chr)
inline

This operator can only be used with string-like arrays; otherwise it will fail to compile. c_str()

Definition at line 850 of file array.hpp.

◆ operator=()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
SelfType& uavcan::Array< T, ArrayMode, MaxSize_ >::operator= ( const char *  chr)
inline

This operator can only be used with string-like arrays; otherwise it will fail to compile. c_str()

Definition at line 830 of file array.hpp.

◆ operator==() [1/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
bool uavcan::Array< T, ArrayMode, MaxSize_ >::operator== ( const char *  chr) const
inline

This operator can only be used with string-like arrays; otherwise it will fail to compile. c_str()

Definition at line 812 of file array.hpp.

◆ operator==() [2/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
EnableIf<sizeof((reinterpret_cast<const R*>0))-> bool ::Type uavcan::Array< T, ArrayMode, MaxSize_ >::operator== ( const R &  rhs) const
inline

Definition at line 766 of file array.hpp.

◆ packSquareMatrix() [1/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
void uavcan::Array< T, ArrayMode, MaxSize_ >::packSquareMatrix ( )
inline

Fills this array as a packed square matrix in place. Please refer to the specification to learn more about matrix packing. Note that matrix packing code uses areClose() for comparison.

Definition at line 970 of file array.hpp.

◆ packSquareMatrix() [2/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
template<typename ScalarType >
void uavcan::Array< T, ArrayMode, MaxSize_ >::packSquareMatrix ( const ScalarType(&)  src_row_major[MaxSize])
inline

Fills this array as a packed square matrix from a static array. Please refer to the specification to learn more about matrix packing. Note that matrix packing code uses areClose() for comparison.

Definition at line 960 of file array.hpp.

◆ packSquareMatrixImpl()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
template<typename InputIter >
void uavcan::Array< T, ArrayMode, MaxSize_ >::packSquareMatrixImpl ( const InputIter  src_row_major)
inlineprivate

Definition at line 544 of file array.hpp.

◆ pop_back()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
void uavcan::Array< T, ArrayMode, MaxSize_ >::pop_back ( )
inline

Only for dynamic arrays. Range checking.

Definition at line 717 of file array.hpp.

◆ push_back()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
void uavcan::Array< T, ArrayMode, MaxSize_ >::push_back ( const ValueType value)
inline

Definition at line 718 of file array.hpp.

◆ resize() [1/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
void uavcan::Array< T, ArrayMode, MaxSize_ >::resize ( SizeType  new_size)
inline

Only for dynamic arrays. Range checking.

Definition at line 754 of file array.hpp.

◆ resize() [2/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
void uavcan::Array< T, ArrayMode, MaxSize_ >::resize ( SizeType  new_size,
const ValueType filler 
)
inline

Only for dynamic arrays. Range checking.

Definition at line 727 of file array.hpp.

◆ size() [1/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
template<typename R >
EnableIf<sizeof((reinterpret_cast<const R*>0))-> uavcan::Array< T, ArrayMode, MaxSize_ >::size ( ) )[0] const &&

This operator accepts any container with size() and []. Members must be comparable via operator ==.

◆ size() [2/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
template<typename R >
EnableIf<sizeof((reinterpret_cast<const R*>0))-> uavcan::Array< T, ArrayMode, MaxSize_ >::size ( ) )[0] const &&

This method compares two arrays using areClose(), which ensures proper comparison of floating point values, or DSDL data structures which contain floating point fields at any depth. Please refer to the documentation of areClose() to learn more about how it works and how to define custom fuzzy comparison behavior. Any container with size() and [] is acceptable.

◆ unpackSquareMatrix() [1/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
void uavcan::Array< T, ArrayMode, MaxSize_ >::unpackSquareMatrix ( )
inline

Reconstructs full matrix in place. Please refer to the specification to learn more about matrix packing.

Definition at line 1043 of file array.hpp.

◆ unpackSquareMatrix() [2/2]

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
template<typename ScalarType >
void uavcan::Array< T, ArrayMode, MaxSize_ >::unpackSquareMatrix ( ScalarType(&)  dst_row_major[MaxSize]) const
inline

Reconstructs full matrix, result will be saved into a static array. Please refer to the specification to learn more about matrix packing.

Definition at line 1034 of file array.hpp.

◆ unpackSquareMatrixImpl()

template<typename T , ArrayMode ArrayMode, unsigned MaxSize_>
template<typename ScalarType , typename OutputIter >
void uavcan::Array< T, ArrayMode, MaxSize_ >::unpackSquareMatrixImpl ( const OutputIter  dst_row_major) const
inlineprivate

Definition at line 602 of file array.hpp.


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


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:04