This tutorial provides the framework to compile a library and GTest -based application showing the steps necessary for using the lldc-reflection (and RTTR) libraries. The goals of this document are to inform how to:
- Define a structure with value types that can be handled by the reflection library.
- Register your base structure with RTTR.
- Define a GTest that can serialize and deserialize the structure (verify success).
- Extend the design to include setters and getters for properties.
- Extend the design further with an object member (by value).
- Change the storage of the object member to a raw pointer.
- Change the storage of the object member to a shared pointer.
- Subclass a base message structure and register that subclass.
- Leveraging enumerations to strings, values, etc.
- Metadata: what does
optional
mean? - Metadata: what about optionally serializing a member if the value matches a reference?
- Metadata: what does it mean to leave it as a
blob
? What is a use case?
For the sake of simplifying debugging, this design will serialize to/from JsonGlib for now, as it has a to string API for easier printing of the intermediate object as well as testing from string direct serialization in a human-readable way. Therefore enable both the example and use of JsonGlib by at the root directory of this library:
rm -rf builddir
meson setup -Djsonglib=true -Dtutorial=enabled builddir
Later compilation and tests are the usual:
meson compile -C builddir
meson test -C builddir
# etc.
The layout of this directory includes:
Path | Description |
---|---|
lib |
The library where you will be adding your structures and handling the RTTR Registration definitions. |
tests |
The GTest main() and related test cases. |