Repository navigation
Expand file tree
/
Copy pathmodule_cmdgen.h
More file actions
60 lines (47 loc) · 1.55 KB
/
Copy pathmodule_cmdgen.h
File metadata and controls
60 lines (47 loc) · 1.55 KB
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
#pragma once
#include "scanner.h"
#include <string>
#include <functional>
#pragma warning(disable:4275) // non dll-interface class 'std::runtime_error' used as base for dll-interface class 'fmt::v6::format_error'
#include "fmt/format.h"
namespace cppm {
struct ModuleCommandGenerator
{
fmt::memory_buffer cmd_buf;
ScanItemSetView item_set;
ModuleVisitor& module_visitor;
std::size_t references_end = 0;
enum FormatEnum {
Unknown,
MSVC,
ClangCl,
Clang,
GCC
};
struct Format {
FormatEnum format = Unknown;
operator bool() { return format != Unknown; }
bool isClangCl() { return format == ClangCl; }
bool isClang() { return format == Clang; };
bool isMSVC() { return format == MSVC; }
bool isGCC() { return format == GCC; }
static Format from_string(std::string_view f) {
if (f == "msvc") return { MSVC };
else if (f == "clang") return { Clang };
else if (f == "clangcl") return { ClangCl };
else if (f == "gcc") return { GCC };
throw std::invalid_argument("unsupported command format " + std::string(f));
}
};
static Format detect_format(std::string_view cmd);
ModuleCommandGenerator(ScanItemSetView item_set, ModuleVisitor& module_visitor);
std::string get_bmi_file(std::string_view output_file);
// todo: use function_ref
void generate(scan_item_idx_t idx, Format format,
std::function<std::string_view(scan_item_idx_t)> bmi_file_func);
void full_cmd_to_string(std::string& str);
std::string full_cmd_to_string();
void references_to_string(std::string& str);
std::string references_to_string();
};
} // namespace cppm