AceCommon
1.1.2
Arduino library for low-level common functions and features with no external dependencies
|
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. | |
FCString (const char *s) | |
Construct with a c-string. | |
FCString (const __FlashStringHelper *s) | |
Construct with a flash string. | |
bool | isNull () const |
Return if this is a null string. | |
uint8_t | getType () const |
Get the internal type of string. | |
const char * | getCString () const |
Get the c-string pointer. | |
const __FlashStringHelper * | getFString () const |
Get the flash string pointer. | |
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. | |
Static Public Attributes | |
static const uint8_t | kCStringType = 0 |
Identifies the object as holding a c-string. More... | |
static const uint8_t | kFStringType = 1 |
Identifies the object as holding an f-string. More... | |
A union of (const char*) and (const __FlashStringHelper*) with a discriminator.
This allows us to treat these 2 strings like a single object.
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. Instead, use the printTo(Print&)
method.
Definition at line 47 of file FCString.h.
size_t ace_common::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 35 of file FCString.cpp.
|
static |
Identifies the object as holding a c-string.
getCString() is valid.
Definition at line 50 of file FCString.h.
|
static |
Identifies the object as holding an f-string.
getFString() is valid.
Definition at line 53 of file FCString.h.