Reflection for RapidJSON 0.0.17
Reflection for serializing/deserializing with RapidJSON
Loading...
Searching...
No Matches
ReflectiveRapidJSON::CodeGenerator Class Referenceabstract

The CodeGenerator class is the base for generators used by the CodeFactory class. More...

#include <codegenerator.h>

Inheritance diagram for ReflectiveRapidJSON::CodeGenerator:
[legend]

Public Member Functions

 CodeGenerator (CodeFactory &factory)
virtual ~CodeGenerator ()
virtual void addDeclaration (clang::Decl *decl)
 Adds the specified decl to the code generator.
virtual void generate (std::ostream &os) const =0
 Generates code based on the previously added declarations. The code is written to os.

Protected Member Functions

CodeFactory & factory () const
void lazyInitializeSourceManager () const
 Lazy initializes the source manager.
bool isOnlyIncluded (const clang::Decl *declaration) const
 Returns whether the specified declaration is only included and not part of the actual file.

Static Protected Member Functions

static clang::CXXBaseSpecifier * inheritsFromInstantiationOf (clang::CXXRecordDecl *record, const char *templateClass)
 Returns whether the specified record inherits from an instantiation of the specified templateClass.

Detailed Description

The CodeGenerator class is the base for generators used by the CodeFactory class.

Definition at line 22 of file codegenerator.h.

Constructor & Destructor Documentation

◆ CodeGenerator()

ReflectiveRapidJSON::CodeGenerator::CodeGenerator ( CodeFactory & factory)
inline

Definition at line 43 of file codegenerator.h.

◆ ~CodeGenerator()

ReflectiveRapidJSON::CodeGenerator::~CodeGenerator ( )
virtual

Definition at line 13 of file codegenerator.cpp.

Member Function Documentation

◆ addDeclaration()

void ReflectiveRapidJSON::CodeGenerator::addDeclaration ( clang::Decl * decl)
virtual

Adds the specified decl to the code generator.

The generator might ignore irrelevant declarations.

Reimplemented in ReflectiveRapidJSON::SerializationCodeGenerator.

Definition at line 20 of file codegenerator.cpp.

◆ factory()

CodeFactory & ReflectiveRapidJSON::CodeGenerator::factory ( ) const
inlineprotected

Definition at line 49 of file codegenerator.h.

◆ generate()

virtual void ReflectiveRapidJSON::CodeGenerator::generate ( std::ostream & os) const
pure virtual

Generates code based on the previously added declarations. The code is written to os.

Implemented in ReflectiveRapidJSON::BinarySerializationCodeGenerator, and ReflectiveRapidJSON::JsonSerializationCodeGenerator.

◆ inheritsFromInstantiationOf()

clang::CXXBaseSpecifier * ReflectiveRapidJSON::CodeGenerator::inheritsFromInstantiationOf ( clang::CXXRecordDecl * record,
const char * templateClass )
staticprotected

Returns whether the specified record inherits from an instantiation of the specified templateClass.

Returns
Returns the relevant base class if that's the case and otherwise nullptr.
Remarks
The specified record must be defined (not only forward-declared).

Definition at line 50 of file codegenerator.cpp.

◆ isOnlyIncluded()

bool ReflectiveRapidJSON::CodeGenerator::isOnlyIncluded ( const clang::Decl * declaration) const
protected

Returns whether the specified declaration is only included and not part of the actual file.

Definition at line 39 of file codegenerator.cpp.

◆ lazyInitializeSourceManager()

void ReflectiveRapidJSON::CodeGenerator::lazyInitializeSourceManager ( ) const
protected

Lazy initializes the source manager.

Remarks
This method must be called in generate() when subclassing to make use of isOnlyIncluded().

Definition at line 29 of file codegenerator.cpp.


The documentation for this class was generated from the following files: