AJSON_FIELDS#
Json fields definition.
| Header: | #include <AUI/Json/Conversion.h> |
| CMake: | aui_link(my_target PUBLIC aui::json) |
Definition#
#define AJSON_FIELDS(N, ...) \
template<> struct AJsonConvFieldDescriptor<N>: N { \
auto operator()() { \
return aui::impl::json::empty_tuple() \
__VA_ARGS__ \
; \
} \
};
Detailed Description#
struct SomeModel {
type1 field1;
type2 field2;
...
};
AJSON_FIELDS(SomeModel,
(field1, "name1")
(field2, "name2")
...
)
Also, flags can be set:
See also AJsonFieldFlags.
struct SomeModel {
int value1;
AString value2;
};
AJSON_FIELDS(SomeModel,
(value1, "value1")
(value2, "value2")
)
// or
AJSON_FIELDS(SomeModel,
AJSON_FIELDS_ENTRY(value1)
AJSON_FIELDS_ENTRY(value2)
)
Examples#
examples/app/notes/src/main.cpp
Notes App — Note taking app that demonstrates usage of AListModel, AProperty, user data saving and loading.
AProperty<AString> title;
AProperty<AString> content;
};
AJSON_FIELDS(Note, AJSON_FIELDS_ENTRY(title) AJSON_FIELDS_ENTRY(content))
class TitleTextArea : public ATextArea {
public:
using ATextArea::ATextArea;
void onCharEntered(AChar c) override {