-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring.hpp
39 lines (27 loc) · 819 Bytes
/
string.hpp
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
#ifndef TL_STRING_HPP
#define TL_STRING_HPP
#include "std.h"
#include "vec.hpp"
namespace tl {
typedef Vec<u8> String;
typedef VecSlice<u8 const> StringSlice;
struct StringSliceTerminated : StringSlice {
using StringSlice::StringSlice;
char const* c_str() const { return (char const *)this->begin(); }
};
struct StringSliceLiteral : StringSliceTerminated {
using StringSliceTerminated::StringSliceTerminated;
};
struct StringTerminated : Vec<char> {
using Vec::Vec;
operator char const*() const {
return (char const *)this->begin();
}
};
StringTerminated c_str(StringSlice str);
StringSliceTerminated from_c_str(char const* str);
}
inline tl::StringSliceLiteral operator"" _S(char const* p, usize len) {
return tl::StringSliceLiteral((u8 const *)p, (u8 const *)p + len);
}
#endif // TL_STRING_HPP