Used when defining data structures. More...

#include <ObjectBase.hpp>

Inheritance diagram for FSTR::ObjectBase:
Collaboration diagram for FSTR::ObjectBase:

Public Member Functions

size_t length () const
 Get the length of the object data in bytes. 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...
 
const uint8_tdata () 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...
 
bool isCopy () const
 
bool isNull () const
 Indicates an invalid String, used for return value from lookups, etc. 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

Used when defining data structures.

Note
Should not be used directly, use appropriate Object methods instead

Member Function Documentation

◆ as()

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

Cast to a different object type.

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

◆ copy()

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

◆ data()

const uint8_t* FSTR::ObjectBase::data ( ) const

Get a pointer to the flash data.

◆ invalidate()

void FSTR::ObjectBase::invalidate ( )
protected

◆ isCopy()

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

◆ isNull()

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

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()

size_t FSTR::ObjectBase::length ( ) const

Get the length of the object data in bytes.

◆ read()

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

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

◆ readFlash()

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

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.

◆ size()

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

Get the object data size in bytes.

Note
Always an integer multiple of 4 bytes

Member Data Documentation

◆ empty_

const ObjectBase FSTR::ObjectBase::empty_
staticprotected

◆ flashLength_

uint32_t FSTR::ObjectBase::flashLength_

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