-
Notifications
You must be signed in to change notification settings - Fork 0
/
formatting_script.h
61 lines (50 loc) · 1.19 KB
/
formatting_script.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
#pragma once
class formatting_script
{
private:
pfc::string8 string;
mutable service_ptr_t<titleformat_object> script;
mutable bool compiled = false;
public:
formatting_script() {}
formatting_script(const char * s) {
string = s;
}
formatting_script & operator=(const char * s) {
string = s;
compiled = false;
return *this;
}
formatting_script & operator=(pfc::string8 s) {
string = s;
compiled = false;
return *this;
}
inline operator const pfc::string8 & () const {
return string;
}
inline operator const char * () const {
return string.get_ptr();
}
inline const char * get_ptr() {
return string.get_ptr();
}
const service_ptr_t<titleformat_object> & operator->() const {
if (script == NULL || !compiled) {
static_api_ptr_t<titleformat_compiler>()->compile_safe_ex(script, string);
compiled = true;
}
return script;
}
const service_ptr_t<titleformat_object> & get_script() const {
if (script == NULL || !compiled) {
static_api_ptr_t<titleformat_compiler>()->compile_safe_ex(script, string);
compiled = true;
}
return script;
}
formatting_script(const formatting_script &other) {
string = other.string;
compiled = other.compiled;
}
};