Update README and TODOs to current state
This commit is contained in:
parent
ce14bd12c4
commit
1eaa2d52c2
25
README.md
25
README.md
|
@ -28,6 +28,7 @@ The basic functionality is implemented, tested and documented:
|
|||
### TODOs
|
||||
There are still things missing which would likely be very useful in practise. The following list contains the open TODOs which are supposed to be most relevant in practise:
|
||||
|
||||
* [ ] Fix the massive number of warnings which are currently being created by the code generator
|
||||
* [ ] Allow to specify which member variables should be considered
|
||||
* This could work similar to Qt's Signals & Slots macros.
|
||||
* but there should also be a way to do this for 3rdparty types.
|
||||
|
@ -60,7 +61,7 @@ The following table shows the mapping of supported C++ types to supported JSON t
|
|||
|
||||
### Remarks
|
||||
* Raw pointer are not supported. This prevents
|
||||
forgetting to free memoery which would have to be allocated when deserializing.
|
||||
forgetting to free memory which would have to be allocated when deserializing.
|
||||
* For the same reason `const char *` strings are only supported for serialization.
|
||||
* Enums are (de)serialized as their underlying integer value. When deserializing, it is currently *not* checked
|
||||
whether the present integer value is a valid enumeration item.
|
||||
|
@ -75,21 +76,21 @@ The following table shows the mapping of supported C++ types to supported JSON t
|
|||
## Usage
|
||||
This example shows how the library can be used to make a `struct` serializable:
|
||||
```
|
||||
#include <reflective-rapidjson/json/serializable.h>
|
||||
#include <reflective_rapidjson/json/serializable.h>
|
||||
|
||||
// define structures, eg.
|
||||
struct TestObject : public JsonSerializable<TestObject> {
|
||||
struct TestObject : public ReflectiveRapidJSON::JsonSerializable<TestObject> {
|
||||
int number;
|
||||
double number2;
|
||||
vector<int> numbers;
|
||||
string text;
|
||||
bool boolean;
|
||||
};
|
||||
struct NestingObject : public JsonSerializable<NestingObject> {
|
||||
struct NestingObject : public ReflectiveRapidJSON::JsonSerializable<NestingObject> {
|
||||
string name;
|
||||
TestObject testObj;
|
||||
};
|
||||
struct NestingArray : public JsonSerializable<NestingArray> {
|
||||
struct NestingArray : public ReflectiveRapidJSON::JsonSerializable<NestingArray> {
|
||||
string name;
|
||||
vector<TestObject> testObjects;
|
||||
};
|
||||
|
@ -107,11 +108,11 @@ const auto obj = NestingArray::fromJson(...);
|
|||
|
||||
Note that the header included at the bottom must be generated by invoking the code generator appropriately, eg.:
|
||||
```
|
||||
reflective_rapidjson_generator -i "$srcdir/code-defining-structs.cpp" -o "$builddir/reflection/code-defining-structs.h"
|
||||
reflective_rapidjson_generator --input-file "$srcdir/code-defining-structs.cpp" --output-file "$builddir/reflection/code-defining-structs.h"
|
||||
```
|
||||
|
||||
#### Invoking code generator with CMake macro
|
||||
It is possible to use the provided CMake macro to automate this task:
|
||||
It is possible to use the provided CMake macro to automate the code generator invocation:
|
||||
```
|
||||
# find the package and make macro available
|
||||
find_package(reflective-rapidjson REQUIRED)
|
||||
|
@ -155,14 +156,14 @@ from certain targets to the code generator. The targets can be specified using t
|
|||
* For cross compilation, it is required to build the code generator for the platform you're building on.
|
||||
* Since the code generator is likely not required under the target platform, you should add `-DNO_GENERATOR:BOOL=ON` to the CMake
|
||||
arguments when building Reflective RapidJSON for the target platform.
|
||||
* When using the `add_reflection_generator_invocation` macro, you need to set the following CMake variables:
|
||||
* `REFLECTION_GENERATOR_EXECUTABLE:FILEPATH=/path/to/executable`: path of the code generator executable to run under the platform
|
||||
* When using the `add_reflection_generator_invocation` macro, you need to set the following CMake cache variables:
|
||||
* `REFLECTION_GENERATOR_EXECUTABLE:FILEPATH=/path/to/executable`: path of the code generator executable built for the platform
|
||||
you're building on
|
||||
* `REFLECTION_GENERATOR_INCLUDE_DIRECTORIES:STRING=/custom/prefix/include`: directories containing header files for target
|
||||
platform (not required if you set `CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES` anyways since it defaults to that variable)
|
||||
* It is likely required to pass additional options for the target platform. For example, to cross compile with MingGW, is is
|
||||
required to add `-fdeclspec`, `-D_WIN32` and some more options (see `lib/cmake/modules/ReflectionGenerator.cmake`). The
|
||||
`add_reflection_generator_invocation` macro is supposed to take care of this, but currently only MingGW is supported.
|
||||
`add_reflection_generator_invocation` macro is supposed to take care of this, but currently only MingGW under GNU/Linux is supported.
|
||||
* The Arch Linux packages mentioned at the end of the README file also include `mingw-w64` variants which give a concrete example how
|
||||
cross-compilation can be done.
|
||||
|
||||
|
@ -170,7 +171,7 @@ from certain targets to the code generator. The targets can be specified using t
|
|||
The same example as above. However, this time Boost.Hana is used - so it doesn't require invoking the generator.
|
||||
|
||||
```
|
||||
#include "<reflective-rapidjson/json/serializable-boosthana.h>
|
||||
#include "<reflective_rapidjson/json/serializable-boosthana.h>
|
||||
|
||||
// define structures using BOOST_HANA_DEFINE_STRUCT, eg.
|
||||
struct TestObject : public JsonSerializable<TestObject> {
|
||||
|
@ -209,7 +210,7 @@ So beside the `BOOST_HANA_DEFINE_STRUCT` macro, the usage remains the same.
|
|||
* Use of ugly macro required
|
||||
* No context information for errors like type-mismatch available
|
||||
* Inherited members not considered
|
||||
* Support for enums is unlikely
|
||||
* Proper support for enums is unlikely
|
||||
* Attempt to access private members can not be prevented
|
||||
|
||||
### Enable reflection for 3rd party classes/structs
|
||||
|
|
2
TODOs.md
2
TODOs.md
|
@ -10,7 +10,7 @@
|
|||
explicitely
|
||||
- [x] Fix traits currently relying on `JsonSerializable` being base class
|
||||
- [x] Allow exporting symbols
|
||||
- [ ] Fix the massive number of warnings which are currently being created
|
||||
- [ ] Fix the massive number of warnings which are currently being created by the code generator
|
||||
- [ ] Test with libc++ (currently only tested with libstdc++)
|
||||
- [ ] Support templated classes
|
||||
- [ ] Allow (de)serialization of static members (if that makes sense?)
|
||||
|
|
Loading…
Reference in New Issue