-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmystring.h
47 lines (41 loc) · 1.05 KB
/
mystring.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
#include <iostream>
#include <stdio.h>
class StringValue {
private:
char* data_;
int refcnt;
public:
StringValue();
StringValue(char const *);
~StringValue();
StringValue* copied();
char* getData();
int getRefcnt();
void deincRefcnt();
size_t length();
};
class MyString {
private:
StringValue *sv_;
public:
MyString();
MyString(char const *);
MyString(StringValue &&sv);
~MyString();
MyString(MyString const &);
MyString(MyString &&);
MyString& operator=(MyString const &);
MyString& operator=(MyString &&);
char* getStringValue();
void setStringValue(char const *);
MyString& operator+=(MyString const &);
MyString& operator+(char const *);
MyString& operator+=(char const *);
char& operator[](int);
size_t length();
bool isEmpty();
friend std::ostream& operator<<(std::ostream &, MyString &);
friend std::istream& operator>>(std::istream &, MyString &);
};
MyString&& operator+(MyString &, MyString &);
MyString&& operator+(MyString &&, MyString &);