Reflection for RapidJSON
0.0.17
Reflection for serializing/deserializing with RapidJSON
Toggle main menu visibility
Loading...
Searching...
No Matches
consumer.h
Go to the documentation of this file.
1
#ifndef REFLECTIVE_RAPIDJSON_CONSUMER_H
2
#define REFLECTIVE_RAPIDJSON_CONSUMER_H
3
4
#include "
./visitor.h
"
5
6
#include <clang/AST/ASTConsumer.h>
7
#include <clang/AST/Decl.h>
8
#include <clang/Basic/DiagnosticIDs.h>
9
#include <clang/Basic/Version.h>
10
#include <clang/Frontend/CompilerInstance.h>
11
#include <clang/Lex/LexDiagnostic.h>
12
13
namespace
ReflectiveRapidJSON
{
14
15
class
CodeFactory
;
16
24
class
Consumer
:
public
clang::ASTConsumer {
25
public
:
26
Consumer
(
CodeFactory
&factory, clang::CompilerInstance &compilerInstance);
27
28
bool
HandleTopLevelDecl
(clang::DeclGroupRef groupRefDecl)
override
;
29
void
HandleTranslationUnit
(clang::ASTContext &context)
override
;
30
31
bool
shouldParseDecl
(clang::Decl *declaration);
32
33
private
:
34
void
handleNamespaceDefinition(clang::NamespaceDecl *nsDecl);
35
36
CodeFactory
&m_factory;
37
clang::CompilerInstance &m_compilerInstance;
38
Visitor
m_visitor;
39
};
40
41
inline
Consumer::Consumer
(
CodeFactory
&factory, clang::CompilerInstance &compilerInstance)
42
: m_factory(factory)
43
, m_compilerInstance(compilerInstance)
44
, m_visitor(factory)
45
{
46
}
47
52
class
DiagConsumer
:
public
clang::DiagnosticConsumer {
53
public
:
54
DiagConsumer
(std::unique_ptr<DiagnosticConsumer> previous,
bool
errorResilient);
55
unsigned
int
realErrorCount
()
const
;
56
57
void
BeginSourceFile
(
const
clang::LangOptions &langOpts,
const
clang::Preprocessor *pp =
nullptr
)
override
;
58
void
clear
()
override
;
59
void
EndSourceFile
()
override
;
60
#if CLANG_VERSION_MAJOR <= 22
61
void
finish
()
override
;
62
#endif
63
void
HandleDiagnostic
(clang::DiagnosticsEngine::Level diagLevel,
const
clang::Diagnostic &info)
override
;
64
65
private
:
66
std::unique_ptr<DiagnosticConsumer> m_proxy;
67
unsigned
int
m_realErrorCount;
68
bool
m_errorResilient;
69
};
70
71
inline
DiagConsumer::DiagConsumer
(std::unique_ptr<clang::DiagnosticConsumer> previous,
bool
errorResilient)
72
: m_proxy(std::move(previous))
73
, m_realErrorCount(0)
74
, m_errorResilient(errorResilient)
75
{
76
}
77
81
inline
unsigned
int
DiagConsumer::realErrorCount
()
const
82
{
83
return
m_realErrorCount;
84
}
85
86
}
// namespace ReflectiveRapidJSON
87
88
#endif
// REFLECTIVE_RAPIDJSON_CONSUMER_H
ReflectiveRapidJSON::CodeFactory
The CodeFactory class produces additional (reflection) code for a specified list of C++ source files.
Definition
codefactory.h:27
ReflectiveRapidJSON::Consumer::HandleTranslationUnit
void HandleTranslationUnit(clang::ASTContext &context) override
Definition
consumer.cpp:33
ReflectiveRapidJSON::Consumer::shouldParseDecl
bool shouldParseDecl(clang::Decl *declaration)
Definition
consumer.cpp:15
ReflectiveRapidJSON::Consumer::Consumer
Consumer(CodeFactory &factory, clang::CompilerInstance &compilerInstance)
Definition
consumer.h:41
ReflectiveRapidJSON::Consumer::HandleTopLevelDecl
bool HandleTopLevelDecl(clang::DeclGroupRef groupRefDecl) override
Definition
consumer.cpp:21
ReflectiveRapidJSON::DiagConsumer::realErrorCount
unsigned int realErrorCount() const
Returns the number of errors which actually would have been occurred if we would not turn most errors...
Definition
consumer.h:81
ReflectiveRapidJSON::DiagConsumer::EndSourceFile
void EndSourceFile() override
Definition
consumer.cpp:49
ReflectiveRapidJSON::DiagConsumer::clear
void clear() override
Definition
consumer.cpp:44
ReflectiveRapidJSON::DiagConsumer::BeginSourceFile
void BeginSourceFile(const clang::LangOptions &langOpts, const clang::Preprocessor *pp=nullptr) override
Definition
consumer.cpp:39
ReflectiveRapidJSON::DiagConsumer::HandleDiagnostic
void HandleDiagnostic(clang::DiagnosticsEngine::Level diagLevel, const clang::Diagnostic &info) override
Turns most errors into warnings so the code generator can even work when parsing incomplete headers.
Definition
consumer.cpp:64
ReflectiveRapidJSON::DiagConsumer::DiagConsumer
DiagConsumer(std::unique_ptr< DiagnosticConsumer > previous, bool errorResilient)
Definition
consumer.h:71
ReflectiveRapidJSON::DiagConsumer::finish
void finish() override
Definition
consumer.cpp:55
ReflectiveRapidJSON::Visitor
The Visitor class is used to traverse the elements of a translation unit.
Definition
visitor.h:15
ReflectiveRapidJSON
Definition
codegenerator.h:15
visitor.h
Generated on
for Reflection for RapidJSON by
1.18.0