aboutsummaryrefslogtreecommitdiff
path: root/backend/String.h
blob: 4fade62d50f92f2a76f16bbd9cc53223b8d0b0e8 (plain)
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
#pragma once

#include <stddef.h>
#include <stdarg.h>

class String {
public:
	String();
	String(const char * c_str);
	String(const char * data, size_t size);
	String(const String &);
	String(String &&);
	String & operator = (const String &);
	String & operator = (String &&);
	~String();
public:
	static String va_fmt(va_list args, const char * fmt);
	static String fmt(const char * fmt, ...);

public:
	const char * c_str() const;
	char * data() const;
	size_t size() const;
	bool empty() const;

public:
	friend bool operator == (const String &, const String &);
	friend bool operator != (const String &, const String &);

private:
	void set(const char * data);
	void set(const char * data, size_t data_len);
private:
	char * _data = nullptr;
	size_t _data_len = 0;

};