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.
},
/// [scrollarea]
AScrollArea::Builder()
.withContents(
AUI_DECLARATIVE_FOR(note, *mNotes, AVerticalLayout) {
observeChangesForDirty(note);
return notePreview(note) AUI_LET {
connect(it->clicked, [this, note] { mCurrentNote = note; });
it& mCurrentNote > [note](AView& view, const _<Note>& currentNote) {
ALOG_DEBUG(LOG_TAG) << "currentNote == note " << currentNote << " == " << note;