-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary.h
114 lines (86 loc) · 2.75 KB
/
library.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#pragma once
#include <string>
#include <list>
#include <vector>
#include <map>
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
std::vector<std::wstring> tokenSplit(const std::wstring& str, const std::wstring& delim = L", \t");
std::wstring tokenMerge(const std::vector<std::wstring>& tokens, const std::wstring& delim = L", ");
std::wstring toLower(const std::wstring& str);
//---------------------------------------------------------------------------------------------------
// struct Document
//---------------------------------------------------------------------------------------------------
struct Document
{
std::wstring m_path;
std::wstring m_pathLower;
std::wstring m_keywords;
std::wstring m_authors;
std::wstring m_company;
unsigned int m_hash;
std::wstring m_timestamp;
void SetKeywords(const std::wstring& keywordString);
};
typedef std::list<Document*> DocumentList;
//---------------------------------------------------------------------------------------------------
// class Documents
//---------------------------------------------------------------------------------------------------
class Documents
{
public:
Documents()
{}
Documents(const DocumentList& list)
: m_Documents(list)
{}
void Clear();
bool Empty() const
{
return m_Documents.size() == 0;
}
Documents Filter(const std::wstring& filterString) const;
bool AddDocument(Document& doc, Document** existingDoc = NULL);
Document* RemoveDocument(const std::wstring& path);
const DocumentList& GetDocuments() const
{
return m_Documents;
}
private:
DocumentList m_Documents;
};
//---------------------------------------------------------------------------------------------------
// class Library
//---------------------------------------------------------------------------------------------------
class Library
{
public:
Library(const std::wstring& savePath);
const std::wstring& GetSaveFilename() const
{
return m_SavePath;
}
void AddScanPath(const std::wstring& rootPath, bool runScan);
void Scan();
void Clear();
void LoadMeta();
void SaveMeta() const;
bool AddDocument(Document& doc);
Document* AddDocument(const std::wstring& path, const std::wstring& keywords, bool runScanOnFolders);
void RemoveDocument(const std::wstring& path);
const DocumentList& GetDocuments() const
{
return m_Documents.GetDocuments();
}
Documents Filter(const std::wstring& filterString) const
{
return m_Documents.Filter(filterString);
}
private:
void ScanFolder(const std::wstring& path);
private:
typedef std::vector<std::wstring> PathArray;
std::wstring m_SavePath;
PathArray m_ScanPaths;
Documents m_Documents;
};