Instantiator
Generate c++ template instantiations
Loading...
Searching...
No Matches
Injection.hpp
Go to the documentation of this file.
1#ifndef INJECTION_HPP_
2#define INJECTION_HPP_
3
4#include <string>
5#include <vector>
6
7#include "fmt/color.h"
8#include "fmt/core.h"
9#include "fmt/ranges.h"
10
11#include "clang/AST/DeclCXX.h"
12#include "clang/AST/Type.h"
13
14#include "Param.hpp"
15#include "TemplateArgument.hpp"
16
21{
22 typedef std::string StringType;
28
35
41
45 std::string return_type = "";
46
51 std::vector<std::string> func_Ttypes;
52
57 std::vector<Instantiator::TemplateArgument> class_Targs;
58
63 std::vector<Param> params;
64
70 std::vector<Param> nonresolved_params;
71
73 bool is_const = false;
74
76 bool is_member = false;
77
82 bool is_constructor = false;
83
86
90 std::string getInstantiation() const;
91
102 bool match(const Injection& other) const;
103
120 static Injection createFromMFS(const clang::CXXMethodDecl* MFS, clang::PrintingPolicy pp);
121
137 static Injection createFromFS(const clang::FunctionDecl* FS, clang::PrintingPolicy pp);
138};
139
141std::ostream& operator<<(std::ostream& stream, const Injection& toDo);
142
143template <>
144class fmt::formatter<Injection>
145{
146public:
147 constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
148 template <typename Context>
149 constexpr auto format(Injection const& toDo, Context& ctx) const
150 {
151 return fmt::format_to(ctx.out(),
152 "{} {}{}<{}>::{}<{}>({}){}",
153 toDo.return_type,
154 toDo.nested_namespace,
155 toDo.class_name,
156 toDo.class_Targs,
157 toDo.func_name,
158 toDo.func_Ttypes,
159 toDo.params,
160 toDo.is_const ? "const" : "");
161 }
162};
163
164#endif
std::ostream & operator<<(std::ostream &stream, const Injection &toDo)
constexpr auto parse(format_parse_context &ctx)
constexpr auto format(Injection const &toDo, Context &ctx) const
Struct for the collection of all relevant data for a template instantiation which needs to be inserte...
Definition Injection.hpp:21
static Injection createFromFS(const clang::FunctionDecl *FS, clang::PrintingPolicy pp)
Definition Injection.cpp:30
bool match(const Injection &other) const
Definition Injection.cpp:15
std::string getInstantiation() const
Definition Injection.cpp:95
StringType nested_namespace
Definition Injection.hpp:34
std::vector< std::string > func_Ttypes
Definition Injection.hpp:51
std::string StringType
Definition Injection.hpp:22
static Injection createFromMFS(const clang::CXXMethodDecl *MFS, clang::PrintingPolicy pp)
Definition Injection.cpp:52
StringType func_name
Definition Injection.hpp:27
std::string return_type
Definition Injection.hpp:45
StringType class_name
Definition Injection.hpp:40
StringType guess_injection_place
Definition Injection.hpp:85
bool is_const
Definition Injection.hpp:73
std::vector< Instantiator::TemplateArgument > class_Targs
Definition Injection.hpp:57
bool is_constructor
Definition Injection.hpp:82
std::vector< Param > nonresolved_params
Definition Injection.hpp:70
bool is_member
Definition Injection.hpp:76
std::vector< Param > params
Definition Injection.hpp:63