mirror of
https://github.com/github/codeql.git
synced 2026-01-29 22:32:58 +01:00
Properties marked with `predicate` in the schema are now accepted. * in the dbscheme, they will translate to a table with a single `id` column (and the table name will not be pluralized) * in C++ classes, they will translate to `bool` fields * in QL classes, they will translate to predicates Closes https://github.com/github/codeql-c-team/issues/1016
59 lines
1.6 KiB
Plaintext
59 lines
1.6 KiB
Plaintext
// generated by {{generator}}
|
|
// clang-format off
|
|
#pragma once
|
|
|
|
#include <iostream>
|
|
#include <optional>
|
|
#include <vector>
|
|
|
|
#include "{{include_dir}}/{{trap_affix}}Label.h"
|
|
#include "./{{trap_affix}}Entries.h"
|
|
|
|
namespace {{namespace}} {
|
|
{{#classes}}
|
|
|
|
struct {{name}}{{#final}} : Binding<{{name}}Tag>{{#bases}}, {{ref.name}}{{/bases}}{{/final}}{{^final}}{{#has_bases}}: {{#bases}}{{^first}}, {{/first}}{{ref.name}}{{/bases}}{{/has_bases}}{{/final}} {
|
|
{{#fields}}
|
|
{{type}} {{name}}{};
|
|
{{/fields}}
|
|
{{#final}}
|
|
|
|
friend std::ostream& operator<<(std::ostream& out, const {{name}}& x) {
|
|
x.emit(out);
|
|
return out;
|
|
}
|
|
{{/final}}
|
|
|
|
protected:
|
|
void emit({{^final}}{{trap_affix}}Label<{{name}}Tag> id, {{/final}}std::ostream& out) const {
|
|
{{#trap_name}}
|
|
out << {{.}}{{trap_affix}}{id{{#single_fields}}, {{name}}{{/single_fields}}} << '\n';
|
|
{{/trap_name}}
|
|
{{#bases}}
|
|
{{ref.name}}::emit(id, out);
|
|
{{/bases}}
|
|
{{#fields}}
|
|
{{#is_predicate}}
|
|
if ({{name}}) out << {{trap_name}}{{trap_affix}}{id} << '\n';
|
|
{{/is_predicate}}
|
|
{{#is_optional}}
|
|
{{^is_repeated}}
|
|
if ({{name}}) out << {{trap_name}}{{trap_affix}}{id, *{{name}}} << '\n';
|
|
{{/is_repeated}}
|
|
{{/is_optional}}
|
|
{{#is_repeated}}
|
|
for (auto i = 0u; i < {{name}}.size(); ++i) {
|
|
{{^is_optional}}
|
|
out << {{trap_name}}{{trap_affix}}{id, i, {{name}}[i]};
|
|
{{/is_optional}}
|
|
{{#is_optional}}
|
|
if ({{name}}[i]) out << {{trap_name}}{{trap_affix}}{id, i, *{{name}}[i]};
|
|
{{/is_optional}}
|
|
}
|
|
{{/is_repeated}}
|
|
{{/fields}}
|
|
}
|
|
};
|
|
{{/classes}}
|
|
}
|