AceRoutine
0.2
A low-memory, fast-switching, cooperative multitasking library using stackless coroutines on Arduino platforms.
|
A union of (const char*) and (const __FlashStringHelper*) with a discriminator. More...
#include <FCString.h>
Public Member Functions | |
FCString () | |
Default constructor initializes to a nullptr of kCStringType. More... | |
FCString (const char *s) | |
Construct with a c-string. More... | |
FCString (const __FlashStringHelper *s) | |
Construct with a flash string. More... | |
bool | isNull () const |
Return if this is a null string. More... | |
uint8_t | getType () const |
Get the internal type of string. More... | |
const char * | getCString () const |
Get the c-string pointer. More... | |
const __FlashStringHelper * | getFString () const |
Get the flash string pointer. More... | |
size_t | printTo (Print &printer) const |
Convenience method for printing an FCString to printer. More... | |
int | compareTo (const FCString &that) const |
Compare to another FCString. More... | |
Static Public Attributes | |
static const uint8_t | kCStringType = 0 |
static const uint8_t | kFStringType = 1 |
A union of (const char*) and (const __FlashStringHelper*) with a discriminator.
This allows us to treat these 2 strings like a single object. The major reason this class is needed is because the F() cannot be used outside a function, it can only be used inside a function, so we are forced to use normal c-strings instead of F() strings when manually creating Test or TestOnce instances.
I deliberately decided not to inherit from Printable. While it is convenient to be able to call Print::print() with an instance of this class, the cost is 2 (AVR) or 4 (Teensy-ARM or ESP8266) extra bytes of static memory for the v-table pointer for each instance. But each instance is only 3 (AVR) or 5 (Teensy-ARM or ESP8266) bytes big, so the cost of 50-100 bytes of static memory for a large suite of 25 unit tests does not seem worth the minor convenience.
Definition at line 53 of file FCString.h.
|
inline |
Default constructor initializes to a nullptr of kCStringType.
Definition at line 59 of file FCString.h.
|
inlineexplicit |
Construct with a c-string.
Definition at line 62 of file FCString.h.
|
inlineexplicit |
Construct with a flash string.
Definition at line 68 of file FCString.h.
int ace_routine::FCString::compareTo | ( | const FCString & | that | ) | const |
Compare to another FCString.
Definition at line 87 of file FCString.cpp.
|
inline |
Get the c-string pointer.
Definition at line 80 of file FCString.h.
|
inline |
Get the flash string pointer.
Definition at line 83 of file FCString.h.
|
inline |
Get the internal type of string.
Definition at line 77 of file FCString.h.
|
inline |
Return if this is a null string.
Definition at line 74 of file FCString.h.
size_t ace_routine::FCString::printTo | ( | Print & | printer | ) | const |
Convenience method for printing an FCString to printer.
This is identical to the method in Printable but we don't derive from Printable because we don't want to want to pay the memory cost of the vtable pointer for such a small class.
Definition at line 36 of file FCString.cpp.