-
Notifications
You must be signed in to change notification settings - Fork 0
/
mint_utils.h
124 lines (105 loc) · 5.35 KB
/
mint_utils.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
115
116
117
118
119
120
121
122
123
124
#ifndef OOPFINAL_MINT_UTILS_H
#define OOPFINAL_MINT_UTILS_H
#include <string>
#include <vector>
#include <concepts>
#include <algorithm>
namespace mints {
std::string make_lowercase(std::string str);
std::vector<std::string> split(const std::string& str);
std::string identity_str(std::string str);
std::string reversed_str(std::string str);
/**
* 예외 사유를 지정하는 예외 객체 : std::exception 상속 중
*/
struct named_exception : std::exception {
std::string err_msg;
explicit named_exception(const std::string& s);
explicit named_exception(std::string&& s);
[[nodiscard]] const char* what() const noexcept override;
};
struct double_alloc : named_exception {
explicit double_alloc(std::string s) : named_exception(std::move(s)) {}
};
struct double_free : named_exception {
explicit double_free(std::string s) : named_exception(std::move(s)) {}
};
struct input_out_of_range : named_exception {
explicit input_out_of_range(std::string s) : named_exception(std::move(s)) {}
};
struct too_large_argument : named_exception {
explicit too_large_argument(std::string s) : named_exception(std::move(s)) {}
};
struct unpoppable : named_exception {
explicit unpoppable(std::string s) : named_exception(std::move(s)) {}
};
struct unable_to_open_file : named_exception {
explicit unable_to_open_file(std::string s) : named_exception(std::move(s)) {}
};
// TODO : move this function to Trie class
unsigned int closeness(const std::string& s1, const std::string& s2,
const auto& init = identity_str) {
std::string str1 = init(s1);
std::string str2 = init(s2);
auto size = static_cast<unsigned int>(s1.size() < s2.size() ? s1.size() : s2.size());
for (int ret = 0, i = 0; i < size; ++i) {
if (str1[i] == str2[i]) {
++ret;
} else {
return ret;
}
}
return size;
}
}
/**
* 프로그램 내에서 출력될 default manuals를 저장하는 네임스페이스
*/
namespace mint_manuals {
using namespace std::string_literals;
const std::string general_manual{"Put 1 to print all CONTENTS in the document.\n"
"Put 2 to print all TYPES and TITLES of holders in the document.\n"
"\n"
"Put 10 to print an individual holder.\n"
"Put 11 to access and modify an individual holder.\n"
"\n"
"Put 20 to make a new holder at the END of the document.\n"
"Put 21 to add a new holder BETWEEN holders and holders.\n"
"Put 22 to pop a holder at the END of the document.\n"
"Put 23 to delete a holder in any place.\n"
"\n"
"Put -1 to exit the program.\n\n"s};
const std::string str_manual = "Put 1 to print all CONTENTS of the holder.\n"
"Put 3 to change the title of holder.\n"
"\n"
"Put 10 to push your text at the back of the string.\n"
"Put 11 to insert your text between the data.\n"
"Put 20 to delete some elements between strings.\n"
"Put 21 to replace some elements between string into other.\n"
"Put 50 to print title.\n"
"Put 51 to hide title.\n"
"\n"
"Put 99 to operate the spell-check function.\n"
"Put -1 to break.\n\n"s;
const std::string tab_manual = "Put 1 to print all CONTENTS of the holder.\n"
"Put 3 to change the title of holder.\n"
"\n"
"Put 10 to change an element in the table.\n"
"Put 50 to print title.\n"
"Put 51 to hide title.\n"
"\n"
"Put -1 to break.\n\n"s;
const std::string cha_manual = "Put 1 to print all CONTENTS of the holder.\n"
"Put 3 to change the title of holder.\n"
"\n"
"Put 10 to push a data.\n"
"Put 11 to pop a data.\n"
"Put 20 to modify the vertical size of the graph.\n"
"Put 21 to modify the data name.\n"
"Put 22 to modify the height.\n"
"Put 50 to print title.\n"
"Put 51 to hide title.\n"
"\n"
"Put -1 to break.\n\n"s;
}
#endif //OOPFINAL_MINT_UTILS_H