Used when defining data structures. More...

#include <ObjectBase.hpp>

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

Public Member Functions

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

Public Attributes

const uint32_t flashLength_
 

Static Protected Attributes

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

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

◆ data()

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

Get a pointer to the flash data.

◆ isCopy()

constexpr const bool FSTR::ObjectBase::isCopy ( ) const
inlineconstexpr

◆ isNull()

constexpr const bool FSTR::ObjectBase::isNull ( ) const
inlineconstexpr

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

constexpr FSTR_NOINLINE const size_t FSTR::ObjectBase::length ( void  ) const
inlineconstexpr

Get the length of the object data in bytes.

◆ operator==()

bool FSTR::ObjectBase::operator== ( const ObjectBase other) const

◆ read()

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

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

constexpr const size_t FSTR::ObjectBase::size ( ) const
inlineconstexpr

Get the object data size in bytes.

Note
Always an integer multiple of 4 bytes

Member Data Documentation

◆ copyBit

constexpr uint32_t FSTR::ObjectBase::copyBit = 0x80000000U
staticconstexprprotected

Set to indicate copy.

◆ empty_

const ObjectBase FSTR::ObjectBase::empty_
staticprotected

◆ flashLength_

const uint32_t FSTR::ObjectBase::flashLength_

◆ lengthInvalid

constexpr uint32_t FSTR::ObjectBase::lengthInvalid = copyBit | 0
staticconstexprprotected

Indicates null string in a copy.


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