-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyString.h
51 lines (39 loc) · 1.52 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
47
48
49
50
51
#pragma once
#include <iostream>
class MyString
{
char* _data;
size_t _length;
void copyFrom(const MyString& data);
void free();
void move(MyString&& other)noexcept;
explicit MyString(size_t capacity);
public:
MyString();
MyString(const char* data);
MyString(const MyString& other);
MyString& operator=(const MyString& other);
~MyString();
MyString(MyString&& other)noexcept;
MyString& operator=(MyString&& other)noexcept;
size_t length() const;
MyString& operator+=(const MyString& other);
bool isWordPresent(const char* word)const;
MyString substr(size_t begin, size_t howMany) const;
char& operator[](size_t index);
char operator[](size_t index) const;
const char* c_str() const;
friend MyString operator+(const MyString& lhs, const MyString& rhs);
friend std::istream& operator>>(std::istream&, MyString& str);
friend std::istream& getline(std::istream& is, MyString& str);
};
std::istream& getline(std::istream& is, MyString& str);
std::ostream& operator<<(std::ostream& os, const MyString& str);
void writeMyStringToFile(const MyString& str, std::ofstream& out);
MyString readMyStringFromFile(std::ifstream& in);
bool operator<(const MyString& lhs, const MyString& rhs);
bool operator<=(const MyString& lhs, const MyString& rhs);
bool operator>=(const MyString& lhs, const MyString& rhs);
bool operator>(const MyString& lhs, const MyString& rhs);
bool operator==(const MyString& lhs, const MyString& rhs);
bool operator!=(const MyString& lhs, const MyString& rhs);