39 #define DECLARE_FSTR_VECTOR(name, ObjectType) DECLARE_FSTR_OBJECT(name, FSTR::Vector<ObjectType>)
48 #define DEFINE_FSTR_VECTOR(name, ObjectType, ...) \
49 static DEFINE_FSTR_VECTOR_DATA(FSTR_DATA_NAME(name), ObjectType, __VA_ARGS__); \
50 DEFINE_FSTR_REF_NAMED(name, FSTR::Vector<ObjectType>);
55 #define DEFINE_FSTR_VECTOR_LOCAL(name, ObjectType, ...) \
56 static DEFINE_FSTR_VECTOR_DATA(FSTR_DATA_NAME(name), ObjectType, __VA_ARGS__); \
57 static constexpr DEFINE_FSTR_REF_NAMED(name, FSTR::Vector<ObjectType>);
67 #define DEFINE_FSTR_VECTOR_SIZED(name, ObjectType, size, ...) \
68 static DEFINE_FSTR_VECTOR_DATA_SIZED(FSTR_DATA_NAME(name), ObjectType, size, __VA_ARGS__); \
69 DEFINE_FSTR_REF_NAMED(name, FSTR::Vector<ObjectType>);
74 #define DEFINE_FSTR_VECTOR_SIZED_LOCAL(name, ObjectType, size, ...) \
75 static DEFINE_FSTR_VECTOR_DATA_SIZED(FSTR_DATA_NAME(name), ObjectType, size, __VA_ARGS__); \
76 static constexpr DEFINE_FSTR_REF_NAMED(name, FSTR::Vector<ObjectType>);
85 #define DEFINE_FSTR_VECTOR_DATA(name, ObjectType, ...) \
86 DEFINE_FSTR_VECTOR_DATA_SIZED(name, ObjectType, sizeof((const void*[]){__VA_ARGS__}) / sizeof(void*), __VA_ARGS__)
96 #define DEFINE_FSTR_VECTOR_DATA_SIZED(name, ObjectType, size, ...) \
97 constexpr const struct { \
98 FSTR::ObjectBase object; \
99 const ObjectType* data[size]; \
100 } name PROGMEM = {{sizeof(name.data)}, __VA_ARGS__}; \
101 FSTR_CHECK_STRUCT(name);
109 template <
class ObjectType>
class Vector :
public Object<Vector<ObjectType>, const ObjectType*>
116 template <
typename T = ObjectType>
117 typename std::enable_if<std::is_same<T, String>::value,
int>::type
indexOf(
const char* value,
118 bool ignoreCase =
true)
const
120 auto dataptr = this->
data();
121 auto len = this->
length();
122 auto clen = strlen(value);
123 for(
unsigned i = 0; i < len; ++i) {
124 if(
unsafeValueAt(dataptr, i).equals(value, clen, ignoreCase)) {
132 template <
typename ValueType,
typename T = ObjectType>
133 typename std::enable_if<std::is_same<T, String>::value,
int>::type
indexOf(
const ValueType& value,
134 bool ignoreCase =
true)
const
136 auto dataptr = this->
data();
137 auto len = this->
length();
138 for(
unsigned i = 0; i < len; ++i) {
171 auto ptr = dataptr[index];
172 return ptr ? *ptr : ObjectType::empty();
Class template to provide a simple way to print the contents of an array.
Definition: ArrayPrinter.hpp:40
Base class template for all types.
Definition: Object.hpp:121
constexpr const size_t length() const
Get the length of the content in elements.
Definition: Object.hpp:168
DataPtrType data() const
Definition: Object.hpp:205
Class to access a Vector of objects stored in flash.
Definition: Vector.hpp:110
std::enable_if< std::is_same< T, String >::value, int >::type indexOf(const ValueType &value, bool ignoreCase=true) const
Definition: Vector.hpp:133
size_t printTo(Print &p) const
Definition: Vector.hpp:164
const ObjectType & operator[](unsigned index) const
Definition: Vector.hpp:152
std::enable_if< std::is_same< T, String >::value, int >::type indexOf(const char *value, bool ignoreCase=true) const
Definition: Vector.hpp:117
const ObjectType *const * DataPtrType
Definition: Vector.hpp:112
ArrayPrinter< Vector > printer() const
Definition: Vector.hpp:159
const ObjectType & valueAt(unsigned index) const
Definition: Vector.hpp:147
static const ObjectType & unsafeValueAt(const DataPtrType dataptr, unsigned index)
Definition: Vector.hpp:169
Provides formatted output to stream.
Definition: Print.h:37
#define FSTR_INLINE
Definition: config.hpp:28
Definition: Array.hpp:108
ObjectType
Definition: Libraries/jerryscript/src/include/Jerryscript/Types.h:34