clang 17.0.0git
SerializerBase.h
Go to the documentation of this file.
1//===- ExtractAPI/Serialization/SerializerBase.h ----------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file defines the ExtractAPI APISetVisitor interface.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SERIALIZERBASE_H
15#define LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SERIALIZERBASE_H
16
18
19namespace clang {
20namespace extractapi {
21
22/// The base interface of visitors for API information.
23template <typename Derived> class APISetVisitor {
24public:
26 getDerived()->traverseGlobalVariableRecords();
27
28 getDerived()->traverseGlobalFunctionRecords();
29
30 getDerived()->traverseEnumRecords();
31
32 getDerived()->traverseStructRecords();
33
34 getDerived()->traverseObjCInterfaces();
35
36 getDerived()->traverseObjCProtocols();
37
38 getDerived()->traverseMacroDefinitionRecords();
39
40 getDerived()->traverseTypedefRecords();
41 }
42
44 for (const auto &GlobalFunction : API.getGlobalFunctions())
45 getDerived()->visitGlobalFunctionRecord(*GlobalFunction.second);
46 }
47
49 for (const auto &GlobalVariable : API.getGlobalVariables())
50 getDerived()->visitGlobalVariableRecord(*GlobalVariable.second);
51 }
52
54 for (const auto &Enum : API.getEnums())
55 getDerived()->visitEnumRecord(*Enum.second);
56 }
57
59 for (const auto &Struct : API.getStructs())
60 getDerived()->visitStructRecord(*Struct.second);
61 }
62
64 for (const auto &Interface : API.getObjCInterfaces())
65 getDerived()->visitObjCContainerRecord(*Interface.second);
66 }
67
69 for (const auto &Protocol : API.getObjCProtocols())
70 getDerived()->visitObjCContainerRecord(*Protocol.second);
71 }
72
74 for (const auto &Macro : API.getMacros())
75 getDerived()->visitMacroDefinitionRecord(*Macro.second);
76 }
77
79 for (const auto &Typedef : API.getTypedefs())
80 getDerived()->visitTypedefRecord(*Typedef.second);
81 }
82
83 /// Visit a global function record.
85
86 /// Visit a global variable record.
88
89 /// Visit an enum record.
90 void visitEnumRecord(const EnumRecord &Record){};
91
92 /// Visit a struct record.
93 void visitStructRecord(const StructRecord &Record){};
94
95 /// Visit an Objective-C container record.
97
98 /// Visit a macro definition record.
100
101 /// Visit a typedef record.
102 void visitTypedefRecord(const TypedefRecord &Record){};
103
104protected:
105 const APISet &API;
106
107public:
108 APISetVisitor() = delete;
109 APISetVisitor(const APISetVisitor &) = delete;
113
114protected:
116 ~APISetVisitor() = default;
117
118 Derived *getDerived() { return static_cast<Derived *>(this); };
119};
120
121} // namespace extractapi
122} // namespace clang
123
124#endif // LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SERIALIZERBASE_H
This file defines the APIRecord-based structs and the APISet class.
The base interface of visitors for API information.
void visitTypedefRecord(const TypedefRecord &Record)
Visit a typedef record.
void visitGlobalVariableRecord(const GlobalVariableRecord &Record)
Visit a global variable record.
void visitObjCContainerRecord(const ObjCContainerRecord &Record)
Visit an Objective-C container record.
void visitMacroDefinitionRecord(const MacroDefinitionRecord &Record)
Visit a macro definition record.
void visitEnumRecord(const EnumRecord &Record)
Visit an enum record.
APISetVisitor & operator=(APISetVisitor &&)=delete
void visitGlobalFunctionRecord(const GlobalFunctionRecord &Record)
Visit a global function record.
APISetVisitor(const APISetVisitor &)=delete
void visitStructRecord(const StructRecord &Record)
Visit a struct record.
APISetVisitor & operator=(const APISetVisitor &)=delete
APISetVisitor(APISetVisitor &&)=delete
APISet holds the set of API records collected from given inputs.
Definition: API.h:596
const RecordMap< EnumRecord > & getEnums() const
Definition: API.h:793
const RecordMap< TypedefRecord > & getTypedefs() const
Definition: API.h:805
const RecordMap< GlobalVariableRecord > & getGlobalVariables() const
Definition: API.h:790
const RecordMap< MacroDefinitionRecord > & getMacros() const
Definition: API.h:804
const RecordMap< ObjCProtocolRecord > & getObjCProtocols() const
Definition: API.h:801
const RecordMap< ObjCInterfaceRecord > & getObjCInterfaces() const
Definition: API.h:798
const RecordMap< GlobalFunctionRecord > & getGlobalFunctions() const
Definition: API.h:787
const RecordMap< StructRecord > & getStructs() const
Definition: API.h:794
This holds information associated with enums.
Definition: API.h:212
This holds information associated with global functions.
Definition: API.h:152
This holds information associated with global functions.
Definition: API.h:175
This holds information associated with macro definitions.
Definition: API.h:536
The base representation of an Objective-C container record.
Definition: API.h:449
This holds information associated with structs.
Definition: API.h:250
This holds information associated with typedefs.
Definition: API.h:558