describes a counted string stored in flash memory More...

#include <String.hpp>

Inheritance diagram for FSTR::String:
[legend]
Collaboration diagram for FSTR::String:
[legend]

Public Types

using Iterator = ObjectIterator< String, char >
 

Public Member Functions

size_t size () const
 Get the number of bytes used to store the String. More...
 
flash_string_t data () const
 Get a WString-compatible pointer to the flash data. More...
 
bool equals (const char *cstr, size_t len=0) const
 Check for equality with a C-string. More...
 
bool equals (const String &str) const
 Check for equality with another String. More...
 
bool operator== (const char *str) const
 
bool operator== (const String &str) const
 
bool operator!= (const char *str) const
 
bool operator!= (const String &str) const
 
 operator WString () const
 
bool equals (const WString &str) const
 
bool equalsIgnoreCase (const WString &str) const
 
bool operator== (const WString &str) const
 
bool operator!= (const WString &str) const
 
StringPrinter printer () const
 Supports printing of large String objects. More...
 
size_t printTo (Print &p) const
 
Iterator begin () const
 
Iterator end () const
 
size_t length () const
 Get the length of the content in elements. More...
 
int indexOf (const ValueType &value) const
 
char valueAt (unsigned index) const
 
char operator[] (unsigned index) const
 Array operator[]. More...
 
size_t elementSize () const
 
size_t read (size_t index, char *buffer, size_t count) const
 Read content into RAM. 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 index, char *buffer, size_t count) const
 Read content into RAM,using flashmem_read() More...
 
size_t readFlash (size_t offset, void *buffer, size_t count) const
 Read contents of a String into RAM, using flashread() More...
 
template<class ObjectType >
constexpr const ObjectType & as () const
 Cast to a different object type. 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 Stringempty ()
 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

describes a counted string stored in flash memory

Member Typedef Documentation

◆ Iterator

using FSTR::Object< String , char >::Iterator = ObjectIterator<String , char >
inherited

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

Iterator FSTR::Object< String , char >::begin ( ) const
inlineinherited

◆ copy()

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

◆ data()

flash_string_t FSTR::String::data ( ) const
inline

Get a WString-compatible pointer to the flash data.

◆ elementSize()

size_t FSTR::Object< String , char >::elementSize ( ) const
inlineinherited

◆ empty()

static const String & FSTR::Object< String , char >::empty ( )
inlinestaticinherited

Return an empty object which evaluates to null.

◆ end()

Iterator FSTR::Object< String , char >::end ( ) const
inlineinherited

◆ equals() [1/3]

bool FSTR::String::equals ( const char *  cstr,
size_t  len = 0 
) const

Check for equality with a C-string.

Parameters
cstr
lenLength of cstr (optional)
Return values
booltrue if strings are identical
Note
loads string into a stack buffer for the comparison, no heap required

◆ equals() [2/3]

bool FSTR::String::equals ( const String str) const

Check for equality with another String.

Parameters
str
Return values
booltrue if strings are identical

◆ equals() [3/3]

bool FSTR::String::equals ( const WString str) const

◆ equalsIgnoreCase()

bool FSTR::String::equalsIgnoreCase ( const WString str) const

◆ indexOf()

int FSTR::Object< String , char >::indexOf ( const ValueType &  value) const
inlineinherited

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

size_t FSTR::Object< String , char >::length ( void  ) const
inlineinherited

Get the length of the content in elements.

◆ operator WString()

FSTR::String::operator WString ( ) const

◆ operator!=() [1/3]

bool FSTR::String::operator!= ( const char *  str) const
inline

◆ operator!=() [2/3]

bool FSTR::String::operator!= ( const String str) const
inline

◆ operator!=() [3/3]

bool FSTR::String::operator!= ( const WString str) const
inline

◆ operator==() [1/3]

bool FSTR::String::operator== ( const char *  str) const
inline

◆ operator==() [2/3]

bool FSTR::String::operator== ( const String str) const
inline

◆ operator==() [3/3]

bool FSTR::String::operator== ( const WString str) const
inline

◆ operator[]()

char FSTR::Object< String , char >::operator[] ( unsigned  index) const
inlineinherited

Array operator[].

◆ printer()

StringPrinter FSTR::String::printer ( ) const
inline

Supports printing of large String objects.

Avoids implicit String() cast when working with large FlashStrings:

IMPORT_FSTR(largeString, PROJECT_DIR "/files/large-text.txt");
    Serial.println(largeString.printer());

◆ printTo()

size_t FSTR::String::printTo ( Print p) const
inline

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

size_t FSTR::Object< String , char >::read ( size_t  index,
char *  buffer,
size_t  count 
) const
inlineinherited

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]

size_t FSTR::Object< String , char >::readFlash ( size_t  index,
char *  buffer,
size_t  count 
) const
inlineinherited

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::String::size ( ) const
inline

Get the number of bytes used to store the String.

Note
Always an integer multiple of 4 bytes

◆ valueAt()

char FSTR::Object< String , char >::valueAt ( unsigned  index) const
inlineinherited

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: