AceRoutine  1.0
A low-memory, fast-switching, cooperative multitasking library using stackless coroutines on Arduino platforms.
Public Member Functions | Static Public Attributes | List of all members
ace_routine::FCString Class Reference

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
 

Detailed Description

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.

Definition at line 46 of file FCString.h.

Constructor & Destructor Documentation

◆ FCString() [1/3]

ace_routine::FCString::FCString ( )
inline

Default constructor initializes to a nullptr of kCStringType.

Definition at line 52 of file FCString.h.

◆ FCString() [2/3]

ace_routine::FCString::FCString ( const char *  s)
inlineexplicit

Construct with a c-string.

Definition at line 55 of file FCString.h.

◆ FCString() [3/3]

ace_routine::FCString::FCString ( const __FlashStringHelper *  s)
inlineexplicit

Construct with a flash string.

Definition at line 61 of file FCString.h.

Member Function Documentation

◆ compareTo()

int ace_routine::FCString::compareTo ( const FCString that) const

Compare to another FCString.

Definition at line 86 of file FCString.cpp.

◆ getCString()

const char* ace_routine::FCString::getCString ( ) const
inline

Get the c-string pointer.

Definition at line 73 of file FCString.h.

◆ getFString()

const __FlashStringHelper* ace_routine::FCString::getFString ( ) const
inline

Get the flash string pointer.

Definition at line 76 of file FCString.h.

◆ getType()

uint8_t ace_routine::FCString::getType ( ) const
inline

Get the internal type of string.

Definition at line 70 of file FCString.h.

◆ isNull()

bool ace_routine::FCString::isNull ( ) const
inline

Return if this is a null string.

Definition at line 67 of file FCString.h.

◆ printTo()

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 35 of file FCString.cpp.


The documentation for this class was generated from the following files: