-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeSnippetManager.h
More file actions
37 lines (32 loc) · 1.05 KB
/
CodeSnippetManager.h
File metadata and controls
37 lines (32 loc) · 1.05 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
#ifndef CODE_SNIPPET_MANAGER_H
#define CODE_SNIPPET_MANAGER_H
#include <string>
#include <map>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <sstream>
using namespace std;
class CodeSnippetManager
{
private:
map<string,string> snippets;
string filePrefix;
unordered_map<string, unordered_set<string>> invertedIndex;
public:
CodeSnippetManager(const string &prefix = "./snippets/");
~CodeSnippetManager();
bool AddSnippet(const string &tag, const string &code);
bool RetrieveSnippet(const string &tag);
bool DeleteSnippet(const string &tag);
bool UpdateSnippet(const string &tag, const string &code);
vector<string> SearchSnippetsByTag(const string &tagPrefix);
vector<string> SearchSnippetsByContent(const vector<string> &keywords);
bool SaveToFile();
bool LoadFromFile();
void LoadInvertedIndex();
void SaveInvertedIndex();
void UpdateInvertedIndex(const string &tag, const string &code);
void RemoveFromInvertedIndex(const string &tag, const string &code);
};
#endif