1
2
3
4
5
6 #include <cmajor/symbols/SymbolCollector.hpp>
7 #include <algorithm>
8
9 namespace cmajor { namespace symbols {
10
11 SymbolCollector::SymbolCollector()
12 {
13 }
14
15 void SymbolCollector::AddBasicType(BasicTypeSymbol* basicType)
16 {
17 basicTypes.push_back(basicType);
18 }
19
20 void SymbolCollector::AddClass(ClassTypeSymbol* class_)
21 {
22 classes.push_back(class_);
23 }
24
25 void SymbolCollector::AddConcept(ConceptSymbol* conceptSymbol)
26 {
27 concepts.push_back(conceptSymbol);
28 }
29
30 void SymbolCollector::AddConstant(ConstantSymbol* constant)
31 {
32 constants.push_back(constant);
33 }
34
35 void SymbolCollector::AddDelegate(DelegateTypeSymbol* delegate)
36 {
37 delegates.push_back(delegate);
38 }
39
40 void SymbolCollector::AddClassDelegate(ClassDelegateTypeSymbol* classDelegate)
41 {
42 classDelegates.push_back(classDelegate);
43 }
44
45 void SymbolCollector::AddEnumeratedType(EnumTypeSymbol* enumType)
46 {
47 enumeratedTypes.push_back(enumType);
48 }
49
50 void SymbolCollector::AddEnumerationConstant(EnumConstantSymbol* enumConstant)
51 {
52 enumerationConstants.push_back(enumConstant);
53 }
54
55 void SymbolCollector::AddFunction(FunctionSymbol* function)
56 {
57 functions.push_back(function);
58 }
59
60 void SymbolCollector::AddInterface(InterfaceTypeSymbol* interface_)
61 {
62 interfaces.push_back(interface_);
63 }
64
65 void SymbolCollector::AddTypedef(TypedefSymbol* typedef_)
66 {
67 typedefs.push_back(typedef_);
68 }
69
70 void SymbolCollector::AddMemberVariable(MemberVariableSymbol* memberVariable)
71 {
72 memberVariables.push_back(memberVariable);
73 }
74
75 void SymbolCollector::AddGlobalVariable(GlobalVariableSymbol* globalVariable)
76 {
77 globalVariables.push_back(globalVariable);
78 }
79
80 bool ByFullName::operator()(Symbol* left, Symbol* right) const
81 {
82 return left->FullName() < right->FullName();
83 }
84
85 void SymbolCollector::SortByFullName()
86 {
87 std::sort(basicTypes.begin(), basicTypes.end(), ByFullName());
88 std::sort(classes.begin(), classes.end(), ByFullName());
89 std::sort(interfaces.begin(), interfaces.end(), ByFullName());
90 std::sort(functions.begin(), functions.end(), ByFullName());
91 std::sort(typedefs.begin(), typedefs.end(), ByFullName());
92 std::sort(concepts.begin(), concepts.end(), ByFullName());
93 std::sort(delegates.begin(), delegates.end(), ByFullName());
94 std::sort(classDelegates.begin(), classDelegates.end(), ByFullName());
95 std::sort(constants.begin(), constants.end(), ByFullName());
96 std::sort(enumeratedTypes.begin(), enumeratedTypes.end(), ByFullName());
97 std::sort(memberVariables.begin(), memberVariables.end(), ByFullName());
98 std::sort(globalVariables.begin(), globalVariables.end(), ByFullName());
99 }
100
101 bool ByDocName::operator()(Symbol* left, Symbol* right) const
102 {
103 return left->DocName() < right->DocName();
104 }
105
106 void SymbolCollector::SortByDocName()
107 {
108 std::sort(basicTypes.begin(), basicTypes.end(), ByDocName());
109 std::sort(classes.begin(), classes.end(), ByDocName());
110 std::sort(interfaces.begin(), interfaces.end(), ByDocName());
111 std::sort(functions.begin(), functions.end(), ByDocName());
112 std::sort(typedefs.begin(), typedefs.end(), ByDocName());
113 std::sort(concepts.begin(), concepts.end(), ByDocName());
114 std::sort(delegates.begin(), delegates.end(), ByDocName());
115 std::sort(classDelegates.begin(), classDelegates.end(), ByDocName());
116 std::sort(constants.begin(), constants.end(), ByDocName());
117 std::sort(enumeratedTypes.begin(), enumeratedTypes.end(), ByDocName());
118 std::sort(memberVariables.begin(), memberVariables.end(), ByDocName());
119 std::sort(globalVariables.begin(), globalVariables.end(), ByDocName());
120 }
121
122 bool SymbolCollector::IsEmpty() const
123 {
124 if (!basicTypes.empty()) return false;
125 if (!classes.empty()) return false;
126 if (!interfaces.empty()) return false;
127 if (!functions.empty()) return false;
128 if (!typedefs.empty()) return false;
129 if (!concepts.empty()) return false;
130 if (!delegates.empty()) return false;
131 if (!classDelegates.empty()) return false;
132 if (!constants.empty()) return false;
133 if (!enumeratedTypes.empty()) return false;
134 if (!memberVariables.empty()) return false;
135 if (!globalVariables.empty()) return false;
136 return true;
137 }
138
139 } }