-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathcpp_classes_h.mustache
68 lines (56 loc) · 1.39 KB
/
cpp_classes_h.mustache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// generated by {{generator}} from {{source}}
// clang-format off
#pragma once
#include <iostream>
#include <optional>
#include <vector>
#include <binlog/binlog.hpp>
#include <binlog/adapt_stdoptional.hpp>
#include "{{trap_library}}/TrapLabel.h"
#include "{{trap_library}}/TrapTagTraits.h"
#include "./TrapEntries.h"
{{#include_parent}}
#include "../TrapClasses.h"
{{/include_parent}}
namespace codeql {
{{#classes}}
struct {{name}}{{#has_bases}} : {{#bases}}{{^first}}, {{/first}}{{ref.name}}{{/bases}}{{/has_bases}} {
static constexpr const char* NAME = "{{name}}";
{{#final}}
explicit {{name}}(TrapLabel<{{name}}Tag> id) : id{id} {}
TrapLabel<{{name}}Tag> id{};
{{/final}}
{{#fields}}
{{type}} {{field_name}}{};
{{/fields}}
{{#final}}
friend std::ostream& operator<<(std::ostream& out, const {{name}}& x) {
x.emit(out);
return out;
}
{{/final}}
{{^final}}
protected:
{{/final}}
template <typename F>
void forEachLabel(F f) {
{{>cpp_for_each_label_body}}
}
template <typename F>
void forEachLabel(F f) const {
{{>cpp_for_each_label_body}}
}
protected:
void emit({{^final}}TrapLabel<{{name}}Tag> id, {{/final}}std::ostream& out) const;
};
template <>
struct detail::ToTrapClassFunctor<{{name}}Tag> {
using type = {{name}};
};
{{/classes}}
}
{{#classes}}
{{#final}}
BINLOG_ADAPT_STRUCT(codeql::{{name}}, id{{> cpp_list_fields}});
{{/final}}
{{/classes}}