25 #ifndef AUNIT_FSTRING_H 26 #define AUNIT_FSTRING_H 31 class __FlashStringHelper;
57 static const uint8_t kCStringType = 0;
58 static const uint8_t kFStringType = 1;
65 mStringType(kCStringType) {
70 explicit FCString(
const __FlashStringHelper* s):
71 mStringType(kFStringType) {
76 uint8_t
getType()
const {
return mStringType; }
79 const char*
getCString()
const {
return mString.cstring; }
82 const __FlashStringHelper*
getFString()
const {
return mString.fstring; }
85 void print(Print* printer)
const;
88 void println(Print* printer)
const;
98 int compareToN(
const char* that,
size_t n)
const;
105 int compareToN(
const __FlashStringHelper* that,
size_t n)
const;
111 const __FlashStringHelper* fstring;
112 } mString = {
nullptr };
114 uint8_t mStringType = kCStringType;
void println(Print *printer) const
Convenience method for printing an FCString.
FCString(const char *s)
Construct with a c-string.
int compareToN(const char *that, size_t n) const
Compare to C-string using the first n characters.
A union of (const char*) and (const __FlashStringHelper*) with a discriminator.
const __FlashStringHelper * getFString() const
Get the flash string pointer.
const char * getCString() const
Get the c-string pointer.
int compareTo(const FCString &that) const
Compare to another FCString.
FCString(const __FlashStringHelper *s)
Construct with a flash string.
FCString()
Default constructor initializes to a nullptr of kCStringType.
uint8_t getType() const
Get the internal type of string.
void print(Print *printer) const
Convenience method for printing an FCString.