Reflection for RapidJSON 0.0.17
Reflection for serializing/deserializing with RapidJSON
Loading...
Searching...
No Matches
codegenerator.cpp
Go to the documentation of this file.
1#include "./codegenerator.h"
2#include "./codefactory.h"
3
4#include <c++utilities/application/global.h>
5
6#include <clang/AST/DeclCXX.h>
7#include <clang/Frontend/CompilerInstance.h>
8
9using namespace std;
10
11namespace ReflectiveRapidJSON {
12
16
20void CodeGenerator::addDeclaration(clang::Decl *decl)
21{
22 CPP_UTILITIES_UNUSED(decl)
23}
24
30{
31 if (factory().compilerInstance()) {
32 m_sourceManager = &factory().compilerInstance()->getSourceManager();
33 }
34}
35
39bool CodeGenerator::isOnlyIncluded(const clang::Decl *declaration) const
40{
41 return m_sourceManager
42 && m_sourceManager->getFileID(m_sourceManager->getExpansionLoc(declaration->getSourceRange().getBegin())) != m_sourceManager->getMainFileID();
43}
44
50clang::CXXBaseSpecifier *CodeGenerator::inheritsFromInstantiationOf(clang::CXXRecordDecl *const record, const char *const templateClass)
51{
52 for (clang::CXXBaseSpecifier &base : record->bases()) {
53 clang::CXXRecordDecl *const baseDecl = base.getType()->getAsCXXRecordDecl();
54 if (baseDecl && baseDecl->getQualifiedNameAsString() == templateClass) {
55 return &base;
56 }
57 }
58 return nullptr;
59}
60
61} // namespace ReflectiveRapidJSON
clang::CompilerInstance * compilerInstance()
Returns the compiler instance.
static clang::CXXBaseSpecifier * inheritsFromInstantiationOf(clang::CXXRecordDecl *record, const char *templateClass)
Returns whether the specified record inherits from an instantiation of the specified templateClass.
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.