Namespaces | |
| FSTR | |
Macros | |
| #define | DECLARE_FSTR_OBJECT(name, ObjectType) extern const ObjectType& name; |
| Declare a global Object reference. More... | |
| #define | DEFINE_FSTR_REF(name, ObjectType, object) const ObjectType& name PROGMEM = object.template as<ObjectType>(); |
| Define a reference to an object. More... | |
| #define | DEFINE_FSTR_REF_NAMED(name, ObjectType) DEFINE_FSTR_REF(name, ObjectType, FSTR_DATA_NAME(name).object); |
| #define | FSTR_DATA_NAME(name) __fstr__##name |
| Provide internal name for generated flash string structures. More... | |
| #define | FSTR_PTR(objref) static_cast<std::remove_reference<decltype(objref)>::type*>(&FSTR_DATA_NAME(objref).object) |
| Given an Object& reference, return a pointer to the actual object. More... | |
| #define | FSTR_CHECK_STRUCT(name) |
| Check structure is POD-compliant and correctly aligned. More... | |
| #define | IMPORT_FSTR_OBJECT(name, ObjectType, file) |
| Import an object from an external file with reference. More... | |
| #define | IMPORT_FSTR_OBJECT_LOCAL(name, ObjectType, file) |
| Like IMPORT_FSTR_OBJECT except reference is declared static constexpr. More... | |
Detailed Description
Macro Definition Documentation
◆ DECLARE_FSTR_OBJECT
| #define DECLARE_FSTR_OBJECT | ( | name, | |
| ObjectType | |||
| ) | extern const ObjectType& name; |
Declare a global Object reference.
- Parameters
-
name ObjectType
◆ DEFINE_FSTR_REF
| #define DEFINE_FSTR_REF | ( | name, | |
| ObjectType, | |||
| object | |||
| ) | const ObjectType& name PROGMEM = object.template as<ObjectType>(); |
Define a reference to an object.
- Parameters
-
name Name for reference ObjectType Fully qualified typename of object required, e.g. FSTR::String, FlashString, FSTR::Vector<int>, etc. object Object instance to cast
◆ DEFINE_FSTR_REF_NAMED
| #define DEFINE_FSTR_REF_NAMED | ( | name, | |
| ObjectType | |||
| ) | DEFINE_FSTR_REF(name, ObjectType, FSTR_DATA_NAME(name).object); |
◆ FSTR_CHECK_STRUCT
| #define FSTR_CHECK_STRUCT | ( | name | ) |
Check structure is POD-compliant and correctly aligned.
◆ FSTR_DATA_NAME
| #define FSTR_DATA_NAME | ( | name | ) | __fstr__##name |
Provide internal name for generated flash string structures.
◆ FSTR_PTR
| #define FSTR_PTR | ( | objref | ) | static_cast<std::remove_reference<decltype(objref)>::type*>(&FSTR_DATA_NAME(objref).object) |
Given an Object& reference, return a pointer to the actual object.
- Parameters
-
objref When an Object pointer is required, such when defining entries for a Vector or Map, it is usually sufficient to use &objref.
However, some older compilers such as GCC 4.8.5 requires such references to be declared constexpr. For example, this fails with FSTR structure not POD:
DEFINE_FSTR(globalStringRef, "This creates a global reference");
DEFINE_VECTOR(myVector, FSTR::String, &globalStringRef);
^^^
Global references cannot be declared constexpr, so changing DEFINE_FSTR to DEFINE_FSTR_LOCAL will fix the problem.
Another solution is to get a direct pointer to the actual data structure:
DEFINE_VECTOR(myVector, FSTR::String, FSTR_PTR(globalStringRef));
We can only do this of course if the data structure is in scope.
◆ IMPORT_FSTR_OBJECT
| #define IMPORT_FSTR_OBJECT | ( | name, | |
| ObjectType, | |||
| file | |||
| ) |
Import an object from an external file with reference.
- Parameters
-
name Name for the object ObjectType Object type for reference file Absolute path to the file containing the content
- See also
- See also
IMPORT_FSTR_DATA
- Note
- Can only be used at file scope
◆ IMPORT_FSTR_OBJECT_LOCAL
| #define IMPORT_FSTR_OBJECT_LOCAL | ( | name, | |
| ObjectType, | |||
| file | |||
| ) |
Like IMPORT_FSTR_OBJECT except reference is declared static constexpr.
1.8.17