Base class template for all types. More...

#include <Object.hpp>

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

Public Types

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
 
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
 
const ElementType * 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...
 
size_t size () const
 Get the object data size in bytes. More...
 
template<class ObjectType >
constexpr const ObjectType & as () const
 Cast to a different object type. 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...
 
bool isCopy () const
 
bool isNull () const
 Indicates an invalid String, used for return value from lookups, etc. More...
 

Static Public Member Functions

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

Public Attributes

uint32_t flashLength_
 

Protected Member Functions

void invalidate ()
 
void copy (const ObjectBase &obj)
 

Static Protected Attributes

static const ObjectBase empty_
 

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

◆ 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.

Member Function Documentation

◆ as()

template<class ObjectType >
constexpr const ObjectType& FSTR::ObjectBase::as ( ) const
inlineinherited

Cast to a different object type.

Note
example:
    fstr.as<Array<int>>();

◆ begin()

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

◆ copy()

void FSTR::ObjectBase::copy ( const ObjectBase obj)
inlineprotectedinherited

◆ data()

template<class ObjectType, typename ElementType>
const ElementType* 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 const ObjectType& FSTR::Object< ObjectType, ElementType >::empty ( )
inlinestatic

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

◆ invalidate()

void FSTR::ObjectBase::invalidate ( )
protectedinherited

◆ isCopy()

bool FSTR::ObjectBase::isCopy ( ) const
inlineinherited

◆ isNull()

bool FSTR::ObjectBase::isNull ( ) const
inlineinherited

Indicates an invalid String, used for return value from lookups, etc.

Note
A real String can be zero-length, but it cannot be null

◆ length()

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

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() [1/2]

size_t FSTR::ObjectBase::read ( size_t  offset,
void *  buffer,
size_t  count 
) const
inlineinherited

Read contents of a String into RAM.

Parameters
offsetZero-based offset from start of flash data to start reading
bufferWhere to store data
countHow many bytes to read
Return values
size_tNumber of bytes actually read

◆ read() [2/2]

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() [1/2]

size_t FSTR::ObjectBase::readFlash ( size_t  offset,
void *  buffer,
size_t  count 
) const
inherited

Read contents of a String into RAM, using flashread()

Parameters
offsetZero-based offset from start of flash data to start reading
bufferWhere to store data
countHow many bytes to read
Return values
size_tNumber of bytes actually read
See also
See also FlashMemoryStream class.

PROGMEM data is accessed via the CPU data cache, so to avoid degrading performance you can use this method to read data directly from flash memory. This is appropriate for infrequently accessed data, especially if it is large. For example, if storing content using IMPORT_FSTR instead of SPIFFS then it is generally better to avoid contaminating the cache.

◆ readFlash() [2/2]

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

◆ size()

size_t FSTR::ObjectBase::size ( ) const
inlineinherited

Get the object data size in bytes.

Note
Always an integer multiple of 4 bytes

◆ valueAt()

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

Member Data Documentation

◆ empty_

const ObjectBase FSTR::ObjectBase::empty_
staticprotectedinherited

◆ flashLength_

uint32_t FSTR::ObjectBase::flashLength_
inherited

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