FSTR::String Class Reference

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 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
 
- 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
 
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
 
const char * 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...
 
- Public Member Functions inherited from FSTR::ObjectBase
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_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...
 
bool isCopy () 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 Iterator = ObjectIterator< String, char >
 
- Static Public Member Functions inherited from FSTR::Object< String, char >
static const Stringempty ()
 Return an empty object which evaluates to null. More...
 
- Public Attributes inherited from FSTR::ObjectBase
uint32_t flashLength_
 
- Protected Member Functions inherited from FSTR::ObjectBase
void invalidate ()
 
void copy (const ObjectBase &obj)
 
- Static Protected Attributes inherited from FSTR::ObjectBase
static const ObjectBase empty_
 

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

◆ 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

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