Arrays
Introduction
Supports arrays of simple types, such as char, int, double, or POD structures (i.e. basic C structures).
FSTR::Array
is a class template, so requires an additional ElementType
parameter:
#include <FlashString/Array.hpp>
DEFINE_FSTR_ARRAY(myDoubleArray, double,
PI, 53.0, 100, 1e8, 47
);
Serial << "My double array: " << myDoubleArray << endl;
You can share Arrays between translation units by declaring it in a header:
DECLARE_FSTR_ARRAY(table);
Macros
-
DECLARE_FSTR_ARRAY(name, ElementType)
Declare a global Array& reference.
Note
Use
DEFINE_FSTR_ARRAY
to instantiate the global Object- Parameters:
name
ElementType
-
DEFINE_FSTR_ARRAY(name, ElementType, ...)
Define an Array Object with global reference.
Note
Unlike String, array is not NUL-terminated
- Parameters:
name – Name of Array& reference to define
ElementType
... – List of ElementType items
-
DEFINE_FSTR_ARRAY_LOCAL(name, ElementType, ...)
Like DEFINE_FSTR_ARRAY except reference is declared static constexpr.
-
DEFINE_FSTR_ARRAY_DATA(name, ElementType, ...)
Define an Array data structure.
- Parameters:
name – Name of data structure
ElementType
... – List of ElementType items
-
DEFINE_FSTR_ARRAY_DATA_SIZED(name, ElementType, size, ...)
Define an Array data structure, specifying the number of elements.
- Parameters:
name – Name of data structure
ElementType
size – Number of elements
... – List of ElementType items
-
LOAD_FSTR_ARRAY(name, array)
Load an Array object into a named local (stack) buffer.
Note
Example:
DEFINE_FSTR_ARRAY(fsArray, double, 5.33, PI) ... LOAD_FSTR_ARRAY(arr, fsArray) printf("arr[0] = %f, %u elements, buffer is %u bytes\n", arr[0], fsArray.length(), sizeof(arr));
-
FSTR_ARRAY_ARRAY(name, ElementType, ...)
Define an Array and load it into a named buffer on the stack.
Note
Equivalent to
ElementType name[] = {a, b, c}
except the buffer is word-aligned
-
IMPORT_FSTR_ARRAY(name, ElementType, file)
Define an Array containing data from an external file.
See also
See also
IMPORT_FSTR_DATA
- Parameters:
name – Name for the Array object
ElementType – Array element type
file – Absolute path to the file containing the content
-
IMPORT_FSTR_ARRAY_LOCAL(name, ElementType, file)
Like IMPORT_FSTR_ARRAY except reference is declared static constexpr.
Classes
-
template<typename ElementType>
class Array : public FSTR::Object<Array<ElementType>, ElementType> Class to access an array of integral values stored in flash.
- Template Parameters:
ElementType –