81 #ifndef __FLASH_STRING_H_ 82 #define __FLASH_STRING_H_ 93 #define DEFINE_FSTR(_name, _str) \ 94 DEFINE_FSTR_STRUCT(_##_name, _str) \ 95 const FlashString& _name = _##_name.fstr; 97 #define DEFINE_FSTR_STRUCT(_name, _str) \ 100 char data[ALIGNUP(sizeof(_str))]; \ 101 } _name PROGMEM = {{sizeof(_str) - 1}, _str}; 104 #define DECLARE_FSTR(_name) extern const FlashString& _name; 107 #define FSTR_PTR(_struct) &_##_struct.fstr 126 #define FSTR_TABLE(_name) const FlashString* const _name[] PROGMEM 138 #define LOAD_FSTR(_name, _fstr) \ 139 char _name[(_fstr).size()] __attribute__((aligned(4))); \ 140 memcpy_aligned(_name, (_fstr).data(), sizeof(_name)); 148 #define FSTR_ARRAY(_name, _str) \ 149 static DEFINE_FSTR(_##_name, _str); \ 150 LOAD_FSTR(_name, _##_name) 157 #define IMPORT_FSTR(name, file) \ 158 __asm__(".section .irom.text\n" \ 159 ".global " #name "\n" \ 160 ".type " #name ", @object\n" \ 161 ".align 4\n" #name ":\n" \ 162 ".word _" #name "_end - " #name " - 4\n" \ 163 ".incbin \"" file "\"\n" \ 164 "_" #name "_end:\n"); \ 165 extern const __attribute__((aligned(4))) FlashString name; 176 uint32_t length()
const 181 uint32_t size()
const 183 return ALIGNUP(flashLength + 1);
186 flash_string_t data()
const 188 return FPSTR(flashData);
200 return flashLength == 0;
202 size_t cstrlen = strlen(cstr);
203 if(cstrlen != flashLength)
205 LOAD_FSTR(buf, *
this);
206 return memcmp(buf, cstr, cstrlen) == 0;
217 if(flashData == str.flashData)
219 return memcmp_aligned(flashData, str.flashData, ALIGNUP(flashLength)) == 0;
224 return str.equals(*
this);
227 bool operator==(
const char* str)
const 237 bool operator==(
const String& str)
const 242 bool operator!=(
const char* str)
const 252 bool operator!=(
const String& str)
const bool isEqual(const char *cstr) const
Check for equality with a C-string.
Definition: FlashString.h:196
uint32_t flashLength
Only needs to be uint16_t but ensures data is aligned.
Definition: FlashString.h:173
describes a counted string stored in flash memory
Definition: FlashString.h:171
The string class.
Definition: WString.h:104
bool isEqual(const FlashString &str) const
Check for equality with another FlashString.
Definition: FlashString.h:213