Reflection for RapidJSON 0.0.17
Reflection for serializing/deserializing with RapidJSON
Loading...
Searching...
No Matches
codegenerator.h
Go to the documentation of this file.
1#ifndef REFLECTIVE_RAPIDJSON_CODE_GENERATOR_H
2#define REFLECTIVE_RAPIDJSON_CODE_GENERATOR_H
3
4#include <iosfwd>
5#include <string>
6#include <vector>
7
8namespace clang {
9class Decl;
10class CXXRecordDecl;
11class CXXBaseSpecifier;
12class SourceManager;
13} // namespace clang
14
16
17class CodeFactory;
18
23public:
25 virtual ~CodeGenerator();
26
27 virtual void addDeclaration(clang::Decl *decl);
28
30 virtual void generate(std::ostream &os) const = 0;
31
32protected:
33 CodeFactory &factory() const;
34 void lazyInitializeSourceManager() const;
35 bool isOnlyIncluded(const clang::Decl *declaration) const;
36 static clang::CXXBaseSpecifier *inheritsFromInstantiationOf(clang::CXXRecordDecl *record, const char *templateClass);
37
38private:
39 CodeFactory &m_factory;
40 mutable const clang::SourceManager *m_sourceManager;
41};
42
44 : m_factory(factory)
45 , m_sourceManager(nullptr)
46{
47}
48
50{
51 return m_factory;
52}
53
54} // namespace ReflectiveRapidJSON
55
56#endif // REFLECTIVE_RAPIDJSON_CODE_GENERATOR_H
The CodeFactory class produces additional (reflection) code for a specified list of C++ source files.
Definition codefactory.h:27
static clang::CXXBaseSpecifier * inheritsFromInstantiationOf(clang::CXXRecordDecl *record, const char *templateClass)
Returns whether the specified record inherits from an instantiation of the specified templateClass.
CodeGenerator(CodeFactory &factory)
void lazyInitializeSourceManager() const
Lazy initializes the source manager.
virtual void addDeclaration(clang::Decl *decl)
Adds the specified decl to the code generator.
bool isOnlyIncluded(const clang::Decl *declaration) const
Returns whether the specified declaration is only included and not part of the actual file.
virtual void generate(std::ostream &os) const =0
Generates code based on the previously added declarations. The code is written to os.