FSTR::String Class Reference

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

#include <String.hpp>

Inheritance diagram for FSTR::String:
Collaboration diagram for FSTR::String:

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, bool ignoreCase=false) const
 Check for equality with a C-string. More...
 
bool equalsIgnoreCase (const char *cstr, size_t len) const
 
bool equals (const char *cstr, bool ignoreCase=false) const
 
template<typename T >
bool equalsIgnoreCase (const T &str) const
 
bool operator== (const char *cstr) const
 
bool operator!= (const char *cstr) const
 
bool equals (const String &str, bool ignoreCase=false) const
 Check for equality with another String. More...
 
bool operator== (const String &str) const
 
bool operator!= (const String &str) const
 
 operator WString () const
 
bool equals (const WString &str, bool ignoreCase=false) 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
 
- Public Member Functions inherited from FSTR::Object< String, char >
 Object (const Object &)=delete
 
 Object (const Object &&)=delete
 
Objectoperator= (const Object &)=delete
 
Objectoperator= (const Object &&)=delete
 
Iterator begin () const
 
Iterator end () const
 
constexpr 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
 
DataPtrType data () const
 
size_t read (size_t index, char *buffer, size_t count) const
 Read content into RAM. More...
 
size_t readFlash (size_t index, char *buffer, size_t count) const
 Read content into RAM,using flashmem_read() More...
 
char unsafeValueAt (const DataPtrType dataptr, unsigned index) const
 
- Public Member Functions inherited from FSTR::ObjectBase
constexpr size_t length () const
 Get the length of the object data in bytes. More...
 
constexpr 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 bool isNull () const
 Indicates an invalid String, used for return value from lookups, etc. More...
 

Additional Inherited Members

- Public Types inherited from FSTR::Object< String, char >
using DataPtrType = const char *
 
using Iterator = ObjectIterator< String, char >
 
- Static Public Member Functions inherited from FSTR::Object< String, char >
static constexpr const Stringempty ()
 Return an empty object which evaluates to null. More...
 
- 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 lengthInvalid = 0x80000000U
 Indicates null string. More...
 

Detailed Description

describes a counted string stored in flash memory

Member Function Documentation

◆ data()

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

Get a WString-compatible pointer to the flash data.

◆ equals() [1/4]

bool FSTR::String::equals ( const char *  cstr,
bool  ignoreCase = false 
) const

◆ equals() [2/4]

bool FSTR::String::equals ( const char *  cstr,
size_t  len,
bool  ignoreCase = false 
) 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() [3/4]

bool FSTR::String::equals ( const String str,
bool  ignoreCase = false 
) const

Check for equality with another String.

Parameters
str
Return values
booltrue if strings are identical

◆ equals() [4/4]

bool FSTR::String::equals ( const WString str,
bool  ignoreCase = false 
) const

◆ equalsIgnoreCase() [1/2]

bool FSTR::String::equalsIgnoreCase ( const char *  cstr,
size_t  len 
) const
inline

◆ equalsIgnoreCase() [2/2]

template<typename T >
bool FSTR::String::equalsIgnoreCase ( const T &  str) const
inline

◆ operator WString()

FSTR::String::operator WString ( ) const

◆ operator!=() [1/3]

bool FSTR::String::operator!= ( const char *  cstr) 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 *  cstr) 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

◆ 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

◆ 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

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