From 1eaa2d52c218936054c0bd4a15550202538bd9f1 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 24 Jan 2018 19:37:25 +0100 Subject: [PATCH] Update README and TODOs to current state --- README.md | 25 +++++++++++++------------ TODOs.md | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 474f77e..2774e47 100644 --- a/README.md +++ b/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 +#include // define structures, eg. -struct TestObject : public JsonSerializable { +struct TestObject : public ReflectiveRapidJSON::JsonSerializable { int number; double number2; vector numbers; string text; bool boolean; }; -struct NestingObject : public JsonSerializable { +struct NestingObject : public ReflectiveRapidJSON::JsonSerializable { string name; TestObject testObj; }; -struct NestingArray : public JsonSerializable { +struct NestingArray : public ReflectiveRapidJSON::JsonSerializable { string name; vector 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 " +#include " // define structures using BOOST_HANA_DEFINE_STRUCT, eg. struct TestObject : public JsonSerializable { @@ -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 diff --git a/TODOs.md b/TODOs.md index a6bf735..352a1ea 100644 --- a/TODOs.md +++ b/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?)