2017-10-28 16:31:07 +02:00
|
|
|
#ifndef REFLECTIVE_RAPIDJSON_CODE_JSON_SERIALIZATION_GENERATOR_H
|
|
|
|
#define REFLECTIVE_RAPIDJSON_CODE_JSON_SERIALIZATION_GENERATOR_H
|
|
|
|
|
2018-06-23 18:04:30 +02:00
|
|
|
#include "./serializationcodegenerator.h"
|
2017-10-28 16:31:07 +02:00
|
|
|
|
2017-11-06 15:31:21 +01:00
|
|
|
#include <c++utilities/application/argumentparser.h>
|
|
|
|
|
2017-10-28 16:31:07 +02:00
|
|
|
namespace ReflectiveRapidJSON {
|
|
|
|
|
|
|
|
/*!
|
2018-06-23 17:25:30 +02:00
|
|
|
* \brief The JsonSerializationCodeGenerator class generates code for JSON (de)serialization
|
2017-10-28 16:31:07 +02:00
|
|
|
* of objects inheriting from an instantiation of JsonSerializable.
|
|
|
|
*/
|
2018-06-23 18:04:30 +02:00
|
|
|
class JsonSerializationCodeGenerator : public SerializationCodeGenerator {
|
2017-10-28 16:31:07 +02:00
|
|
|
public:
|
2017-11-06 15:31:21 +01:00
|
|
|
struct Options {
|
|
|
|
Options();
|
2018-02-02 18:21:04 +01:00
|
|
|
Options(const Options &other) = delete;
|
2019-06-10 22:46:06 +02:00
|
|
|
void appendTo(CppUtilities::Argument *arg);
|
2017-10-28 16:31:07 +02:00
|
|
|
|
2019-06-10 22:46:06 +02:00
|
|
|
CppUtilities::ConfigValueArgument additionalClassesArg;
|
|
|
|
CppUtilities::ConfigValueArgument visibilityArg;
|
2017-11-06 15:31:21 +01:00
|
|
|
};
|
2017-10-28 16:31:07 +02:00
|
|
|
|
2017-11-06 15:31:21 +01:00
|
|
|
JsonSerializationCodeGenerator(CodeFactory &factory, const Options &options);
|
|
|
|
|
|
|
|
void generate(std::ostream &os) const override;
|
|
|
|
|
2018-06-23 18:04:30 +02:00
|
|
|
protected:
|
|
|
|
std::string qualifiedNameIfRelevant(clang::CXXRecordDecl *record) const override;
|
2017-10-28 16:31:07 +02:00
|
|
|
|
2017-11-06 15:31:21 +01:00
|
|
|
const Options &m_options;
|
2017-10-28 16:31:07 +02:00
|
|
|
};
|
|
|
|
|
2019-06-10 22:46:06 +02:00
|
|
|
inline void JsonSerializationCodeGenerator::Options::appendTo(CppUtilities::Argument *arg)
|
2017-12-24 02:02:40 +01:00
|
|
|
{
|
|
|
|
arg->addSubArgument(&additionalClassesArg);
|
|
|
|
arg->addSubArgument(&visibilityArg);
|
|
|
|
}
|
|
|
|
|
2017-10-28 16:31:07 +02:00
|
|
|
} // namespace ReflectiveRapidJSON
|
|
|
|
|
|
|
|
#endif // REFLECTIVE_RAPIDJSON_CODE_JSON_SERIALIZATION_GENERATOR_H
|