1
- #include <string.h>
1
+ #ifndef _GHLIBCPP_STRING
2
+ #define _GHLIBCPP_STRING
3
+ #include "initializer_list"
4
+ #include "iosfwd.h"
5
+ #include "iterator.h"
6
+ #include "stddef.h"
7
+
8
+ namespace std {
9
+ template <class charT> struct char_traits;
10
+
11
+ template <class T> class allocator {
12
+ public:
13
+ allocator() throw();
14
+ typedef size_t size_type;
15
+ };
16
+
17
+ template <class charT, class traits = char_traits<charT>,
18
+ class Allocator = allocator<charT>>
19
+ class basic_string {
20
+ public:
21
+ using value_type = charT;
22
+ using reference = value_type &;
23
+ using const_reference = const value_type &;
24
+ typedef typename Allocator::size_type size_type;
25
+ static const size_type npos = -1;
26
+
27
+ basic_string() : basic_string(Allocator()) {}
28
+ explicit basic_string(const Allocator &a);
29
+ basic_string(const basic_string &str);
30
+ basic_string(basic_string &&str) noexcept;
31
+ basic_string(const charT *s, size_type n, const Allocator &a = Allocator());
32
+ basic_string(const charT *s, const Allocator &a = Allocator());
33
+ basic_string(size_type n, charT c, const Allocator &a = Allocator());
34
+ template <class InputIterator>
35
+ basic_string(InputIterator begin, InputIterator end,
36
+ const Allocator &a = Allocator());
37
+
38
+ ~basic_string();
39
+ basic_string &operator=(const basic_string &str);
40
+ basic_string &operator=(basic_string &&str) noexcept;
41
+ basic_string &operator=(const charT *s);
42
+ basic_string &operator=(charT c);
43
+ basic_string &operator=(initializer_list<charT>);
44
+
45
+ const charT *c_str() const;
46
+ charT *data() noexcept;
47
+ size_type size() const noexcept;
48
+ size_type length() const noexcept;
49
+
50
+ typedef __iterator<charT> iterator;
51
+ typedef __iterator<const charT> const_iterator;
52
+
53
+ iterator begin();
54
+ iterator end();
55
+ const_iterator begin() const;
56
+ const_iterator end() const;
57
+ const_iterator cbegin() const;
58
+ const_iterator cend() const;
59
+
60
+ const charT &front() const;
61
+ charT &front();
62
+ const charT &back() const;
63
+ charT &back();
64
+
65
+ const_reference operator[](size_type pos) const;
66
+ reference operator[](size_type pos);
67
+ const_reference at(size_type n) const;
68
+ reference at(size_type n);
69
+ basic_string &operator+=(const basic_string &str);
70
+ basic_string &operator+=(const charT *s);
71
+ basic_string &operator+=(charT c);
72
+ basic_string &operator+=(initializer_list<charT>);
73
+ basic_string &append(const basic_string &str);
74
+ basic_string &append(const basic_string &str, size_type pos,
75
+ size_type n = npos);
76
+ basic_string &append(const charT *s, size_type n);
77
+ basic_string &append(const charT *s);
78
+ basic_string &append(size_type n, charT c);
79
+ template <class InputIterator>
80
+ basic_string &append(InputIterator first, InputIterator last);
81
+ basic_string &append(initializer_list<charT>);
82
+ void push_back(charT c);
83
+ basic_string &assign(const basic_string &str);
84
+ basic_string &assign(basic_string &&str) noexcept;
85
+ basic_string &assign(const basic_string &str, size_type pos,
86
+ size_type n = npos);
87
+ basic_string &assign(const charT *s, size_type n);
88
+ basic_string &assign(const charT *s);
89
+ basic_string &assign(size_type n, charT c);
90
+ template <class InputIterator>
91
+ basic_string &assign(InputIterator first, InputIterator last);
92
+ basic_string &assign(initializer_list<charT>);
93
+ basic_string &insert(size_type pos1, const basic_string &str);
94
+ basic_string &insert(size_type pos1, const basic_string &str, size_type pos2,
95
+ size_type n = npos);
96
+ basic_string &insert(size_type pos, const charT *s, size_type n);
97
+ basic_string &insert(size_type pos, const charT *s);
98
+ basic_string &insert(size_type pos, size_type n, charT c);
99
+ iterator insert(const_iterator p, charT c);
100
+ iterator insert(const_iterator p, size_type n, charT c);
101
+ template <class InputIterator>
102
+ iterator insert(const_iterator p, InputIterator first, InputIterator last);
103
+ iterator insert(const_iterator p, initializer_list<charT>);
104
+ basic_string &erase(size_type pos = 0, size_type n = npos);
105
+ iterator erase(const_iterator p);
106
+ iterator erase(const_iterator first, const_iterator last);
107
+ basic_string &replace(size_type pos1, size_type n1, const basic_string &str);
108
+ basic_string &replace(size_type pos1, size_type n1, const basic_string &str,
109
+ size_type pos2, size_type n2 = npos);
110
+ basic_string &replace(size_type pos, size_type n1, const charT *s,
111
+ size_type n2);
112
+ basic_string &replace(size_type pos, size_type n1, const charT *s);
113
+ basic_string &replace(size_type pos, size_type n1, size_type n2, charT c);
114
+ basic_string &replace(const_iterator i1, const_iterator i2,
115
+ const basic_string &str);
116
+ basic_string &replace(const_iterator i1, const_iterator i2, const charT *s,
117
+ size_type n);
118
+ basic_string &replace(const_iterator i1, const_iterator i2, const charT *s);
119
+ basic_string &replace(const_iterator i1, const_iterator i2, size_type n,
120
+ charT c);
121
+ template <class InputIterator>
122
+ basic_string &replace(const_iterator i1, const_iterator i2, InputIterator j1,
123
+ InputIterator j2);
124
+ basic_string &replace(const_iterator, const_iterator,
125
+ initializer_list<charT>);
126
+
127
+ size_type copy(charT *s, size_type n, size_type pos = 0) const;
128
+ void clear() noexcept;
129
+ void swap(basic_string &s) noexcept;
130
+
131
+ size_type find(const basic_string &str, size_type pos = 0) const noexcept;
132
+ size_type find(const charT *s, size_type pos, size_type n) const;
133
+ size_type find(const charT *s, size_type pos = 0) const;
134
+ size_type find(charT c, size_type pos = 0) const;
135
+ size_type rfind(const basic_string &str, size_type pos = npos) const noexcept;
136
+ size_type rfind(const charT *s, size_type pos, size_type n) const;
137
+ size_type rfind(const charT *s, size_type pos = npos) const;
138
+ size_type rfind(charT c, size_type pos = npos) const;
139
+ size_type find_first_of(const basic_string &str,
140
+ size_type pos = 0) const noexcept;
141
+ size_type find_first_of(const charT *s, size_type pos, size_type n) const;
142
+ size_type find_first_of(const charT *s, size_type pos = 0) const;
143
+ size_type find_first_of(charT c, size_type pos = 0) const;
144
+ size_type find_last_of(const basic_string &str,
145
+ size_type pos = npos) const noexcept;
146
+ size_type find_last_of(const charT *s, size_type pos, size_type n) const;
147
+ size_type find_last_of(const charT *s, size_type pos = npos) const;
148
+ size_type find_last_of(charT c, size_type pos = npos) const;
149
+ size_type find_first_not_of(const basic_string &str,
150
+ size_type pos = 0) const noexcept;
151
+ size_type find_first_not_of(const charT *s, size_type pos, size_type n) const;
152
+ size_type find_first_not_of(const charT *s, size_type pos = 0) const;
153
+ size_type find_first_not_of(charT c, size_type pos = 0) const;
154
+ size_type find_last_not_of(const basic_string &str,
155
+
156
+ size_type pos = npos) const noexcept;
157
+ size_type find_last_not_of(const charT *s, size_type pos, size_type n) const;
158
+ size_type find_last_not_of(const charT *s, size_type pos = npos) const;
159
+ size_type find_last_not_of(charT c, size_type pos = npos) const;
160
+ basic_string substr(size_type pos = 0, size_type n = npos) const;
161
+ int compare(const basic_string &str) const noexcept;
162
+ int compare(size_type pos1, size_type n1, const basic_string &str) const;
163
+ int compare(size_type pos1, size_type n1, const basic_string &str,
164
+ size_type pos2, size_type n2 = npos) const;
165
+ int compare(const charT *s) const;
166
+ int compare(size_type pos1, size_type n1, const charT *s) const;
167
+ int compare(size_type pos1, size_type n1, const charT *s, size_type n2) const;
168
+ };
169
+
170
+ template <class charT, class traits, class Allocator>
171
+ basic_string<charT, traits, Allocator>
172
+ operator+(const basic_string<charT, traits, Allocator> &lhs,
173
+ const basic_string<charT, traits, Allocator> &rhs);
174
+ template <class charT, class traits, class Allocator>
175
+ basic_string<charT, traits, Allocator>
176
+ operator+(const basic_string<charT, traits, Allocator> &lhs, const charT *rhs);
177
+ template <class charT, class traits, class Allocator>
178
+ basic_string<charT, traits, Allocator>
179
+ operator+(const charT *lhs, const basic_string<charT, traits, Allocator> &rhs);
180
+
181
+ template <class charT, class traits, class Allocator>
182
+ bool operator==(const basic_string<charT, traits, Allocator> &lhs,
183
+ const basic_string<charT, traits, Allocator> &rhs) noexcept;
184
+ template <class charT, class traits, class Allocator>
185
+ bool operator==(const charT *lhs,
186
+ const basic_string<charT, traits, Allocator> &rhs);
187
+ template <class charT, class traits, class Allocator>
188
+ bool operator==(const basic_string<charT, traits, Allocator> &lhs,
189
+ const charT *rhs);
190
+ template <class charT, class traits, class Allocator>
191
+ bool operator!=(const basic_string<charT, traits, Allocator> &lhs,
192
+ const basic_string<charT, traits, Allocator> &rhs) noexcept;
193
+ template <class charT, class traits, class Allocator>
194
+ bool operator!=(const charT *lhs,
195
+ const basic_string<charT, traits, Allocator> &rhs);
196
+ template <class charT, class traits, class Allocator>
197
+ bool operator!=(const basic_string<charT, traits, Allocator> &lhs,
198
+ const charT *rhs);
199
+ template <class charT, class traits, class Allocator>
200
+ bool operator<(const basic_string<charT, traits, Allocator> &lhs,
201
+ const basic_string<charT, traits, Allocator> &rhs) noexcept;
202
+ template <class charT, class traits, class Allocator>
203
+ bool operator<(const basic_string<charT, traits, Allocator> &lhs,
204
+ const charT *rhs);
205
+ template <class charT, class traits, class Allocator>
206
+ bool operator<(const charT *lhs,
207
+ const basic_string<charT, traits, Allocator> &rhs);
208
+ template <class charT, class traits, class Allocator>
209
+ bool operator>(const basic_string<charT, traits, Allocator> &lhs,
210
+ const basic_string<charT, traits, Allocator> &rhs) noexcept;
211
+ template <class charT, class traits, class Allocator>
212
+ bool operator>(const basic_string<charT, traits, Allocator> &lhs,
213
+ const charT *rhs);
214
+ template <class charT, class traits, class Allocator>
215
+ bool operator>(const charT *lhs,
216
+ const basic_string<charT, traits, Allocator> &rhs);
217
+ template <class charT, class traits, class Allocator>
218
+ bool operator<=(const basic_string<charT, traits, Allocator> &lhs,
219
+ const basic_string<charT, traits, Allocator> &rhs) noexcept;
220
+ template <class charT, class traits, class Allocator>
221
+ bool operator<=(const basic_string<charT, traits, Allocator> &lhs,
222
+ const charT *rhs);
223
+ template <class charT, class traits, class Allocator>
224
+ bool operator<=(const charT *lhs,
225
+ const basic_string<charT, traits, Allocator> &rhs);
226
+ template <class charT, class traits, class Allocator>
227
+ bool operator>=(const basic_string<charT, traits, Allocator> &lhs,
228
+ const basic_string<charT, traits, Allocator> &rhs) noexcept;
229
+ template <class charT, class traits, class Allocator>
230
+ bool operator>=(const basic_string<charT, traits, Allocator> &lhs,
231
+ const charT *rhs);
232
+ template <class charT, class traits, class Allocator>
233
+ bool operator>=(const charT *lhs,
234
+ const basic_string<charT, traits, Allocator> &rhs);
235
+
236
+ typedef basic_string<char> string;
237
+
238
+ int stoi(const string &str, size_t *idx = 0, int base = 10);
239
+ long stol(const string &str, size_t *idx = 0, int base = 10);
240
+ unsigned long stoul(const string &str, size_t *idx = 0, int base = 10);
241
+ long long stoll(const string &str, size_t *idx = 0, int base = 10);
242
+ unsigned long long stoull(const string &str, size_t *idx = 0, int base = 10);
243
+ float stof(const string &str, size_t *idx = 0);
244
+ double stod(const string &str, size_t *idx = 0);
245
+ long double stold(const string &str, size_t *idx = 0);
246
+
247
+ std::string to_string(int value);
248
+ } // namespace std
249
+
250
+ #endif // _GHLIBCPP_STRING
0 commit comments