25 #ifndef ACE_COMMON_KSTRING_H
26 #define ACE_COMMON_KSTRING_H
29 class __FlashStringHelper;
32 namespace ace_common {
34 class KStringIterator;
69 const char*
const* keywords,
73 keywords_((const void* const*) keywords),
75 numKeywords_(numKeywords > 0x20 ? 0x20 : numKeywords)
87 const __FlashStringHelper* fs,
88 const __FlashStringHelper*
const* keywords,
92 keywords_((const void* const*) keywords),
94 numKeywords_(numKeywords > 0x20 ? 0x20 : numKeywords)
116 static const uint8_t kTypeCstring = 0;
117 static const uint8_t kTypeFstring = 1;
121 const void*
const string_;
122 const void*
const*
const keywords_;
124 uint8_t
const numKeywords_;
140 firstPtr_((const char*) ks.string_),
159 static char getInternal(uint8_t type,
const char* p) {
160 return (type == KString::kTypeCstring) ? *p : pgm_read_byte(p);
166 const char* firstPtr_;
167 const char* secondPtr_;
193 const char*
get(uint8_t i)
const {
194 if (type_ == KString::kTypeCstring) {
195 auto words = (
const char*
const*) keywords_;
198 auto words = (
const __FlashStringHelper*
const*) keywords_;
199 return (
const char*) pgm_read_ptr(words + i);
205 const void*
const* keywords_;
An interator that points to a character inside a KString.
KStringIterator(const KString &ks)
Constructor.
void next()
Advance the iterator one character,.
char get()
Return the current character referenced by the iterator.
A thin helper object around an array of const char* in regular memory, or an array of const __FlashSt...
KStringKeywords(uint8_t type, const void *const *keywords)
const char * get(uint8_t i) const
Return the string pointer of index i.
A wrapper class around a normal c-string or Arduino f-string which is encoded and compressed using ke...
void printTo(Print &printer)
Expand and print the current string to the given printer.
int compareTo(const char *s)
Compare this string against a c-string s and return <0, 0 or >0 if this string is <,...
KString(const char *s, const char *const *keywords, uint8_t numKeywords)
Constructor around a simple c-string.
KString(const __FlashStringHelper *fs, const __FlashStringHelper *const *keywords, uint8_t numKeywords)
Constructor around an Arduino Flash string.