-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLZString.h
More file actions
50 lines (36 loc) · 1.51 KB
/
Copy pathLZString.h
File metadata and controls
50 lines (36 loc) · 1.51 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
#ifndef LZ_STRING_LZ_STRING_H_
#define LZ_STRING_LZ_STRING_H_
#include <string>
#include <unordered_map>
#include <functional>
namespace lzstring
{
class LZString
{
typedef std::unordered_map<char, char> CharDict;
typedef std::unordered_map<std::wstring, int> StringDict;
typedef std::unordered_map<std::wstring, bool> StringFlagDict;
typedef std::function<wchar_t(int)> GetCharFromIntFunc;
typedef std::function<wchar_t(int)> GetNextCharFunc;
public:
LZString();
~LZString();
std::string CompressToBase64(const std::wstring &input);
std::wstring DeCompressFromBase64(const std::string &input);
std::wstring CompressToUTF16(const std::wstring &input);
std::wstring DeCompressFromUTF16(const std::wstring &input);
std::string CompressToEncodedURIComponent(const std::wstring &input);
std::wstring DeCompressFromEncodedURIComponent(const std::string &input);
void CompressToUint8Array(const std::wstring &input, std::vector<uint8_t> &res);
std::wstring DeCompressFromUint8Array(const std::vector<uint8_t> &input);
std::wstring Compress(const std::wstring &input);
std::wstring DeCompress(const std::wstring &input);
private:
void CreateBaseDict(const std::string &alphabet, CharDict &dict);
std::wstring Compress(const std::wstring &input, const int bitsPerChar, GetCharFromIntFunc func);
std::wstring DeCompress(const int length, const int resetValue, GetNextCharFunc func);
CharDict m_keyStrBase64Dict;
CharDict m_keyStrUrisafeDict;
};
} // namespace lzstring
#endif