ScummVM API documentation
string.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ULTIMA_STD_STRING_H
23 #define ULTIMA_STD_STRING_H
24 
25 #include "common/str.h"
26 
27 namespace Ultima {
28 namespace Std {
29 
30 class string final : public Common::String {
31 public:
33  private:
34  string *_owner;
35  int _index;
36  public:
37  reverse_iterator(string *owner, int index) : _owner(owner), _index(index) {}
38  reverse_iterator() : _owner(0), _index(-1) {}
39 
40  char &operator*() const { return (*_owner)[_index]; }
41 
42  reverse_iterator &operator++() {
43  --_index;
44  return *this;
45  }
46  reverse_iterator operator++(int) {
47  reverse_iterator tmp(_owner, _index);
48  ++(*this);
49  return tmp;
50  }
51 
52  bool operator==(const reverse_iterator &rhs) {
53  return _owner == rhs._owner && _index == rhs._index;
54  }
55  bool operator!=(const reverse_iterator &rhs) {
56  return !operator==(rhs);
57  }
58  };
59 public:
60  constexpr string() : Common::String() {}
61  string(const char *str) : Common::String(str) {}
62  string(const char *str, uint32 len) : Common::String(str, len) {}
63  string(const char *beginP, const char *endP) : Common::String(beginP, endP) {}
64  string(const String &str) : Common::String(str) {}
65  explicit constexpr string(char c) : Common::String(c) {}
66  string(size_t n, char c) : Common::String(n, c) {}
67 
68  reverse_iterator rbegin() {
69  return reverse_iterator(this, (int)size() - 1);
70  }
71  reverse_iterator rend() {
72  return reverse_iterator(this, -1);
73  }
74 };
75 
76 } // End of namespace Std
77 } // End of namespace Ultima
78 
79 #endif
Definition: str.h:59
Definition: str.h:38
Definition: detection.h:27
Definition: string.h:30
Definition: algorithm.h:37