forked from alpha0010/ClangLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tokendatabase.h
43 lines (33 loc) · 1.08 KB
/
tokendatabase.h
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
#ifndef TOKENDATABASE_H
#define TOKENDATABASE_H
#include <vector>
template<typename _Tp> class TreeMap;
class wxString;
typedef int FileId;
typedef int TokenId;
struct AbstractToken
{
AbstractToken(FileId fId, int ln, int col, unsigned tknHash) :
fileId(fId), line(ln), column(col), tokenHash(tknHash) {}
FileId fileId;
int line;
int column;
unsigned tokenHash;
};
class TokenDatabase
{
public:
TokenDatabase();
~TokenDatabase();
FileId GetFilenameId(const wxString& filename);
wxString GetFilename(FileId fId) const;
TokenId InsertToken(const wxString& identifier, const AbstractToken& token); // duplicate tokens are discarded
TokenId GetTokenId(const wxString& identifier, unsigned tokenHash) const; // returns wxNOT_FOUND on failure
AbstractToken& GetToken(TokenId tId) const;
std::vector<TokenId> GetTokenMatches(const wxString& identifier) const;
void Shrink();
private:
TreeMap<AbstractToken>* m_pTokens;
TreeMap<wxString>* m_pFilenames;
};
#endif // TOKENDATABASE_H