FSTR::Object< ObjectType, ElementType > Class Template Reference

Base class template for all types. More...

#include <Object.hpp>

Inheritance diagram for FSTR::Object< ObjectType, ElementType >:
Collaboration diagram for FSTR::Object< ObjectType, ElementType >:

Public Types

using DataPtrType = const ElementType *
 
using Iterator = ObjectIterator< ObjectType, ElementType >
 

Public Member Functions

 Object ()
 Creates a null object. More...
 
 Object (const Object &obj)
 Copy constructor. More...
 
Iterator begin () const
 
Iterator end () const
 
constexpr const size_t length () const
 Get the length of the content in elements. More...
 
template<typename ValueType >
int indexOf (const ValueType &value) const
 
ElementType valueAt (unsigned index) const
 
ElementType operator[] (unsigned index) const
 Array operator[]. More...
 
size_t elementSize () const
 
DataPtrType data () const
 
size_t read (size_t index, ElementType *buffer, size_t count) const
 Read content into RAM. More...
 
size_t readFlash (size_t index, ElementType *buffer, size_t count) const
 Read content into RAM,using flashmem_read() More...
 
ElementType unsafeValueAt (const DataPtrType dataptr, unsigned index) const
 
- Public Member Functions inherited from FSTR::ObjectBase
constexpr FSTR_NOINLINE const size_t length () const
 Get the length of the object data in bytes. More...
 
constexpr const size_t size () const
 Get the object data size in bytes. More...
 
bool operator== (const ObjectBase &other) const
 
template<class ObjectType >
constexpr const ObjectType & as () const
 Cast to a different object type. More...
 
const uint8_t * data () const
 Get a pointer to the flash data. More...
 
size_t read (size_t offset, void *buffer, size_t count) const
 Read contents of a String into RAM. More...
 
size_t readFlash (size_t offset, void *buffer, size_t count) const
 Read contents of a String into RAM, using flashread() More...
 
constexpr const bool isCopy () const
 
constexpr const bool isNull () const
 Indicates an invalid String, used for return value from lookups, etc. More...
 

Static Public Member Functions

static constexpr const ObjectType & empty ()
 Return an empty object which evaluates to null. More...
 

Additional Inherited Members

- Public Attributes inherited from FSTR::ObjectBase
const uint32_t flashLength_
 
- Static Protected Attributes inherited from FSTR::ObjectBase
static const ObjectBase empty_
 
static constexpr uint32_t copyBit = 0x80000000U
 Set to indicate copy. More...
 
static constexpr uint32_t lengthInvalid = copyBit | 0
 Indicates null string in a copy. More...
 

Detailed Description

template<class ObjectType, typename ElementType>
class FSTR::Object< ObjectType, ElementType >

Base class template for all types.

Template Parameters
ObjectTypeThe object type actually being instantiated
ElementType
See also
https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern

Member Typedef Documentation

◆ DataPtrType

template<class ObjectType , typename ElementType >
using FSTR::Object< ObjectType, ElementType >::DataPtrType = const ElementType*

◆ Iterator

template<class ObjectType , typename ElementType >
using FSTR::Object< ObjectType, ElementType >::Iterator = ObjectIterator<ObjectType, ElementType>

Constructor & Destructor Documentation

◆ Object() [1/2]

template<class ObjectType , typename ElementType >
FSTR::Object< ObjectType, ElementType >::Object ( )
inline

Creates a null object.

◆ Object() [2/2]

template<class ObjectType , typename ElementType >
FSTR::Object< ObjectType, ElementType >::Object ( const Object< ObjectType, ElementType > &  obj)
inline

Copy constructor.

Note
Objects are usually passed around by reference or as a pointer, but for ease of use we need a working copy constructor. A copy contains a pointer to the real object.

Member Function Documentation

◆ begin()

template<class ObjectType , typename ElementType >
Iterator FSTR::Object< ObjectType, ElementType >::begin ( ) const
inline

◆ data()

template<class ObjectType , typename ElementType >
DataPtrType FSTR::Object< ObjectType, ElementType >::data ( ) const
inline

◆ elementSize()

template<class ObjectType , typename ElementType >
size_t FSTR::Object< ObjectType, ElementType >::elementSize ( ) const
inline

◆ empty()

template<class ObjectType , typename ElementType >
static constexpr const ObjectType& FSTR::Object< ObjectType, ElementType >::empty ( )
inlinestaticconstexpr

Return an empty object which evaluates to null.

◆ end()

template<class ObjectType , typename ElementType >
Iterator FSTR::Object< ObjectType, ElementType >::end ( ) const
inline

◆ indexOf()

template<class ObjectType , typename ElementType >
template<typename ValueType >
int FSTR::Object< ObjectType, ElementType >::indexOf ( const ValueType &  value) const
inline

◆ length()

template<class ObjectType , typename ElementType >
constexpr const size_t FSTR::Object< ObjectType, ElementType >::length ( void  ) const
inlineconstexpr

Get the length of the content in elements.

◆ operator[]()

template<class ObjectType , typename ElementType >
ElementType FSTR::Object< ObjectType, ElementType >::operator[] ( unsigned  index) const
inline

Array operator[].

◆ read()

template<class ObjectType , typename ElementType >
size_t FSTR::Object< ObjectType, ElementType >::read ( size_t  index,
ElementType *  buffer,
size_t  count 
) const
inline

Read content into RAM.

Parameters
indexFirst element to read
bufferWhere to store data
countHow many elements to read
Return values
size_tNumber of elements actually read

◆ readFlash()

template<class ObjectType , typename ElementType >
size_t FSTR::Object< ObjectType, ElementType >::readFlash ( size_t  index,
ElementType *  buffer,
size_t  count 
) const
inline

Read content into RAM,using flashmem_read()

Parameters
indexFirst element to read
bufferWhere to store data
countHow many elements to read
Return values
size_tNumber of elements actually read

◆ unsafeValueAt()

template<class ObjectType , typename ElementType >
ElementType FSTR::Object< ObjectType, ElementType >::unsafeValueAt ( const DataPtrType  dataptr,
unsigned  index 
) const
inline

◆ valueAt()

template<class ObjectType , typename ElementType >
ElementType FSTR::Object< ObjectType, ElementType >::valueAt ( unsigned  index) const
inline

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