-
Notifications
You must be signed in to change notification settings - Fork 2
/
Parser.hpp
58 lines (48 loc) · 1.29 KB
/
Parser.hpp
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
#include <utility>
//
// Created by koncord on 20.01.19.
//
#pragma once
#include <clang-c/Index.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <memory>
struct TArg
{
TArg() = default;
TArg(CXType &type, std::string name): type(type), name(std::move(name)) {}
CXType type{};
std::string name;
};
struct CDeclTokens
{
CXType retType;
std::string declName;
std::vector<TArg> args;
};
class Parser
{
private:
friend class IConverter;
public:
explicit Parser(const char *inputFile, const char *ns, const char *module, const std::vector<const char *> &clangArgs);
~Parser();
CXType GetTypeDef(const std::string &typeName) const;
std::string GetModule() const { return module; }
std::string GetFullFilePath() const { return file; }
std::string GetNamespace() const { return ns; }
const std::vector<CDeclTokens> &GetTokens() const { return tokens; }
const std::set<std::string> &GetDefinesInUse() const { return defsInUse; }
private:
CXIndex index;
CXTranslationUnit unit;
std::vector<CDeclTokens> tokens;
std::map<std::string, CXType> typedefs;
std::set<std::string> defsInUse;
std::map<std::string, std::string> docstrings;
std::string module;
std::string file;
std::string ns;
};