-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmst.h
More file actions
70 lines (55 loc) · 1.73 KB
/
mst.h
File metadata and controls
70 lines (55 loc) · 1.73 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//-----------------------------------------------------
// Name: mst.h
// Author: brianuuu
// Date: 29/7/2019
//-----------------------------------------------------
#pragma once
#include <string>
#include <vector>
#include <map>
using namespace std;
class mst
{
public:
struct TextEntry
{
string m_name;
vector<wstring> m_subtitles;
vector<string> m_tags;
};
public:
mst();
~mst();
bool IsLoaded() { return m_loaded; }
// Load & Save
bool Load(string const& _fileName, string& _errorMsg);
bool Save(string const& _fileName, string& _errorMsg);
// Export plain text
void Export(string const& _fileName, bool _russian = false);
// Helpers
int Search(string const& _str, unsigned int _start = 0);
int Search(wstring const& _str, unsigned int _start = 0);
void GetAllEntries(vector<TextEntry>& _textEntries);
TextEntry GetEntry(unsigned int _id);
// Modifiers
int AddNewEntry();
void RemoveEntry(unsigned int _id);
void ModifyEntry(unsigned int _id, TextEntry const& _entry);
void MoveEntry(unsigned int _from, unsigned int _to);
private:
// Reading from bytes
unsigned int ReadInt(FILE* _file);
string ReadAscii(FILE* _file, unsigned int _length = 0);
wstring ReadUTF16(FILE* _file);
// Writing bytes
void WriteInt(FILE* _file, unsigned int _writeInt);
void WriteAscii(FILE* _file, string _writeString, bool _termination = true);
void WriteUTF16(FILE* _file, wstring _writeString, bool _termination = true);
private:
bool m_loaded;
unsigned int m_fileSize;
string m_tableName;
vector<TextEntry> m_entries;
map<wchar_t, wchar_t> m_unicodeToRussian;
map<wchar_t, wchar_t> m_russianToUnicode;
};