summaryrefslogtreecommitdiff
path: root/Source/Kernel/Library/String.class.h
blob: 6a9de640730d0f18225dd04ba78fed61169800aa (plain) (blame)
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
#ifndef DEF_STRING_CLASS
#define DEF_STRING_CLASS

#include <Core/common.wtf.h>
#include <Library/WChar.class.h>

template <typename T> class Vector;

class String {
	private:
	WChar *m_string;
	u32int m_length;

	public:
	static String hex(u32int number);
	static String number(s32int number);

	String(const char* string, u8int encoding = UE_UTF8);
	String();
	String(const String &other);
	~String();

	void affect(const String &other);
	void affect(const char* string, u8int encoding = UE_UTF8);
	void operator= (const String &other) { affect(other); }
	void operator= (const char* other) { affect(other); }

	bool compare(const String &other) const;
	bool compare(const char* string, u8int encoding = UE_UTF8) const;
	bool operator== (const String &other) const { return compare(other); }
	bool operator== (const char* other) const { return compare(other); }
	bool operator!= (const String &other) { return !compare(other); }
	bool operator!= (const char* other) { return !compare(other); }

	String& append(const String &other);
	String& append(const char* other, u8int encoding = UE_UTF8);
	String& append(WChar other);
	String &operator+= (const String &other) { return append(other); }
	String &operator+= (const char* other) { return append(other); }
	String &operator+= (WChar other) { return append(other); }

	String concat(const String &other) const;
	String concat(const char* other, u8int encoding = UE_UTF8) const;
	String concat(WChar other) const;
	String operator+ (const String &other) const { return concat(other); }
	String operator+ (const char* other) const { return concat(other); }
	String operator+ (WChar other) const { return concat(other); }

	s32int toInt() const; 	//Convert from DEC
	u32int toInt16() const;	//Convert from HEX

	WChar& operator[] (int index) const;

	u32int size() const;
	void clear();
	bool empty() const;

	Vector<String> split(WChar c) const;

	String substr(s32int start, s32int size);
};

#endif