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

The CodeFactory class produces additional (reflection) code for a specified list of C++ source files. More...

#include <codefactory.h>

Classes

struct  ToolInvocation

Public Member Functions

 CodeFactory (std::string_view applicationPath, const std::vector< const char * > &sourceFiles, const std::vector< std::string_view > &clangOptions, std::ostream &os)
 Constructs a new instance.
 ~CodeFactory ()
const std::vector< std::unique_ptr< CodeGenerator > > & generators () const
 Returns the added generators.
template<typename GeneratorType, typename... Args>
void addGenerator (Args &&...args)
 Instantiates a code generator of the specified type and adds it to the current instance.
template<typename GeneratorType, typename... Args>
auto bindGenerator (Args &&...args)
 Returns a function which instantiates a code generator of the specified type and adds it to the current instance.
bool run ()
 Reads (relevant) AST elements using Clang and generates code.
clang::CompilerInstance * compilerInstance ()
 Returns the compiler instance.
void setCompilerInstance (clang::CompilerInstance *compilerInstance)
 Assigns the compiler instance.
bool isErrorResilient () const
 Returns whether most errors will be turned into warnings (by default false).
void setErrorResilient (bool errorResilient)
 Sets whether most errors will be turned into warnings (by default false).

Friends

class Consumer
class Visitor

Detailed Description

The CodeFactory class produces additional (reflection) code for a specified list of C++ source files.

Remarks
  • The code is written to a specified std::ostream instance.
  • The CodeFactory class is constituted by its underlying CodeGenerator instances.

Definition at line 27 of file codefactory.h.

Constructor & Destructor Documentation

◆ CodeFactory()

ReflectiveRapidJSON::CodeFactory::CodeFactory ( std::string_view applicationPath,
const std::vector< const char * > & sourceFiles,
const std::vector< std::string_view > & clangOptions,
std::ostream & os )

Constructs a new instance.

Remarks
The specified arguments are not copied and must remain valid for the live-time of the code factory.

Definition at line 35 of file codefactory.cpp.

◆ ~CodeFactory()

ReflectiveRapidJSON::CodeFactory::~CodeFactory ( )

Definition at line 46 of file codefactory.cpp.

Member Function Documentation

◆ addGenerator()

template<typename GeneratorType, typename... Args>
void ReflectiveRapidJSON::CodeFactory::addGenerator ( Args &&... args)

Instantiates a code generator of the specified type and adds it to the current instance.

Remarks
The specified args are forwarded to the generator's constructor.

Definition at line 67 of file codefactory.h.

◆ bindGenerator()

template<typename GeneratorType, typename... Args>
auto ReflectiveRapidJSON::CodeFactory::bindGenerator ( Args &&... args)

Returns a function which instantiates a code generator of the specified type and adds it to the current instance.

Remarks
  • The specified args are forwarded to the generator's constructor.
  • No copy of args passed by reference is made.

Definition at line 104 of file codefactory.h.

◆ compilerInstance()

clang::CompilerInstance * ReflectiveRapidJSON::CodeFactory::compilerInstance ( )
inline

Returns the compiler instance.

Remarks
The is nullptr for a newly constructed factory and should be assigned by the frontend action.

Definition at line 121 of file codefactory.h.

◆ generators()

const std::vector< std::unique_ptr< CodeGenerator > > & ReflectiveRapidJSON::CodeFactory::generators ( ) const
inline

Returns the added generators.

Definition at line 112 of file codefactory.h.

◆ isErrorResilient()

bool ReflectiveRapidJSON::CodeFactory::isErrorResilient ( ) const
inline

Returns whether most errors will be turned into warnings (by default false).

Definition at line 138 of file codefactory.h.

◆ run()

bool ReflectiveRapidJSON::CodeFactory::run ( )

Reads (relevant) AST elements using Clang and generates code.

Definition at line 90 of file codefactory.cpp.

◆ setCompilerInstance()

void ReflectiveRapidJSON::CodeFactory::setCompilerInstance ( clang::CompilerInstance * compilerInstance)
inline

Assigns the compiler instance.

Remarks
The factory does not take ownership.

Definition at line 130 of file codefactory.h.

◆ setErrorResilient()

void ReflectiveRapidJSON::CodeFactory::setErrorResilient ( bool errorResilient)
inline

Sets whether most errors will be turned into warnings (by default false).

Definition at line 146 of file codefactory.h.

◆ Consumer

friend class Consumer
friend

Definition at line 28 of file codefactory.h.

◆ Visitor

friend class Visitor
friend

Definition at line 29 of file codefactory.h.


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