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 equals (const String &str, bool ignoreCase=false) const
 Check for equality with another String. More...
 
template<typename T >
bool operator== (const T &str) const
 
template<typename T >
bool operator!= (const T &str) const
 
 operator WString () const
 
bool equals (const WString &str, bool ignoreCase=false) 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 ()
 Creates a null object. More...
 
 Object (const Object &obj)
 Copy constructor. More...
 
Iterator begin () const
 
Iterator end () const
 
constexpr 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
 
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 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...
 

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 copyBit = 0x80000000U
 Set to indicate copy. More...
 
static constexpr uint32_t lengthInvalid = copyBit | 0
 Indicates null string in a copy. 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!=()

template<typename T >
bool FSTR::String::operator!= ( const T &  str) const
inline

◆ operator==()

template<typename T >
bool FSTR::String::operator== ( const T &  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: