Collaboration diagram for Strings:

Namespaces

 FSTR
 

Macros

#define FS_PTR(str)
 Define an inline String and return a pointer to it. More...
 
#define FS(str)   (*FS_PTR(str))
 Define an inline FSTR::String and return it as a copy. More...
 
#define DECLARE_FSTR(name)   DECLARE_FSTR_OBJECT(name, FSTR::String)
 Declare a global FSTR::String& reference. More...
 
#define DEFINE_FSTR(name, str)
 Define a FSTR::String object with global reference. More...
 
#define DEFINE_FSTR_LOCAL(name, str)
 Like DEFINE_FSTR except reference is declared static constexpr. More...
 
#define DEFINE_FSTR_DATA(name, str)
 Define a FSTR::String data structure. More...
 
#define LOAD_FSTR(name, fstr)
 Load a FSTR::String object into a named local (stack) buffer. More...
 
#define FSTR_ARRAY(name, str)
 Define a flash FSTR::String and load it into a named char[] buffer on the stack. More...
 
#define IMPORT_FSTR(name, file)   IMPORT_FSTR_OBJECT(name, FSTR::String, file)
 Define a FSTR::String containing data from an external file. More...
 
#define IMPORT_FSTR_LOCAL(name, file)   IMPORT_FSTR_OBJECT_LOCAL(name, FSTR::String, file)
 Like IMPORT_FSTR except reference is declared static constexpr. More...
 
#define FSTR_TABLE(name)   const FSTR::String* const name[] PROGMEM
 declare a table of FlashStrings More...
 

Detailed Description

Macro Definition Documentation

◆ DECLARE_FSTR

#define DECLARE_FSTR (   name)    DECLARE_FSTR_OBJECT(name, FSTR::String)

Declare a global FSTR::String& reference.

Parameters
name
Note
Define the FSTR::String object using DEFINE_STR()

◆ DEFINE_FSTR

#define DEFINE_FSTR (   name,
  str 
)
Value:
DEFINE_FSTR_REF_NAMED(name, FSTR::String);
#define str(s)
Definition: testrunner.h:124
#define DEFINE_FSTR_DATA(name, str)
Define a FSTR::String data structure.
Definition: String.hpp:93
#define FSTR_DATA_NAME(name)
Provide internal name for generated flash string structures.
Definition: Object.hpp:56
describes a counted string stored in flash memory
Definition: String.hpp:173

Define a FSTR::String object with global reference.

Parameters
nameName of FSTR::String& reference to define
strContent of the FSTR::String

Example:

DEFINE_FSTR(test, "This is a test\0Another test\0hello")

The data includes the nul terminator but the length does not.

◆ DEFINE_FSTR_DATA

#define DEFINE_FSTR_DATA (   name,
  str 
)
Value:
constexpr const struct { \
FSTR::ObjectBase object; \
char data[ALIGNUP4(sizeof(str))]; \
} name PROGMEM = {{sizeof(str) - 1}, str}; \
FSTR_CHECK_STRUCT(name);
#define str(s)
Definition: testrunner.h:124
#define PROGMEM
Place entity into flash memory.
Definition: Arch/Esp8266/Components/libc/include/sys/pgmspace.h:36
#define ALIGNUP4(n)
Align a size up to the nearest word boundary.
Definition: FakePgmSpace.h:39

Define a FSTR::String data structure.

Parameters
nameName of data structure
strQuoted string content

◆ DEFINE_FSTR_LOCAL

#define DEFINE_FSTR_LOCAL (   name,
  str 
)
Value:
static constexpr DEFINE_FSTR_REF_NAMED(name, FSTR::String);
#define str(s)
Definition: testrunner.h:124
#define DEFINE_FSTR_REF_NAMED(name, ObjectType)
Definition: Object.hpp:51
#define DEFINE_FSTR_DATA(name, str)
Define a FSTR::String data structure.
Definition: String.hpp:93
#define FSTR_DATA_NAME(name)
Provide internal name for generated flash string structures.
Definition: Object.hpp:56
describes a counted string stored in flash memory
Definition: String.hpp:173

Like DEFINE_FSTR except reference is declared static constexpr.

◆ FS

#define FS (   str)    (*FS_PTR(str))

Define an inline FSTR::String and return it as a copy.

Example:

    Serial.println(FS("This is a Flash String"));

◆ FS_PTR

#define FS_PTR (   str)
Value:
(__extension__({ \
static DEFINE_FSTR_DATA(__fstr__, str); \
static_cast<const FSTR::String*>(&__fstr__.object); \
}))
#define str(s)
Definition: testrunner.h:124
#define DEFINE_FSTR_DATA(name, str)
Define a FSTR::String data structure.
Definition: String.hpp:93
describes a counted string stored in flash memory
Definition: String.hpp:173

Define an inline String and return a pointer to it.

Note
The rather obscure asm statement is required to prevent the compiler from discarding the symbol at link time, which leads to an 'undefined reference' error

◆ FSTR_ARRAY

#define FSTR_ARRAY (   name,
  str 
)
Value:
LOAD_FSTR(name, FSTR_DATA_NAME(name).object.template as<FSTR::String>())
#define str(s)
Definition: testrunner.h:124
#define DEFINE_FSTR_DATA(name, str)
Define a FSTR::String data structure.
Definition: String.hpp:93
#define FSTR_DATA_NAME(name)
Provide internal name for generated flash string structures.
Definition: Object.hpp:56

Define a flash FSTR::String and load it into a named char[] buffer on the stack.

Parameters
nameName of char[] buffer
strContent of FSTR::String
Note
Equivalent to char name[] = "text" except the buffer is word aligned. Faster than using a temporary Wiring String and avoids using the heap.

◆ FSTR_TABLE

#define FSTR_TABLE (   name)    const FSTR::String* const name[] PROGMEM

declare a table of FlashStrings

Parameters
namename of the table
Deprecated:
Use a Vector or Map

Declares a simple table. Example:

DEFINE_FSTR(fstr1, "Test string #1");
DEFINE_FSTR(fstr2, "Test string #2");

FSTR_TABLE(table) = {
    &fstr1,
    &fstr2,
};

Table entries may be accessed directly as they are word-aligned. Examples:

debugf("fstr1 = '%s'", FSTR::String(*table[0]).c_str());
debugf("fstr2.length() = %u", table[1]->length());

◆ IMPORT_FSTR

#define IMPORT_FSTR (   name,
  file 
)    IMPORT_FSTR_OBJECT(name, FSTR::String, file)

Define a FSTR::String containing data from an external file.

Parameters
nameName for the FSTR::String object
fileAbsolute path to the file containing the content
See also
See also IMPORT_FSTR_DATA

◆ IMPORT_FSTR_LOCAL

#define IMPORT_FSTR_LOCAL (   name,
  file 
)    IMPORT_FSTR_OBJECT_LOCAL(name, FSTR::String, file)

Like IMPORT_FSTR except reference is declared static constexpr.

◆ LOAD_FSTR

#define LOAD_FSTR (   name,
  fstr 
)
Value:
char name[(fstr).size()] FSTR_ALIGNED; \
memcpy_aligned(name, (fstr).data(), (fstr).length()); \
name[(fstr).length()] = '\0';
#define FSTR_ALIGNED
Definition: config.hpp:29

Load a FSTR::String object into a named local (stack) buffer.

Example:

DEFINE_FSTR(globalTest, "This is a testing string")
...
LOAD_FSTR(local, globalTest)
printf("%s, %u characters, buffer is %u bytes\n", local, globalTest.length(), sizeof(local));