ScummVM API documentation
afxstr.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 BAGEL_MFC_AFXSTR_H
23 #define BAGEL_MFC_AFXSTR_H
24 
25 #include "bagel/mfc/minwindef.h"
26 #include "common/str.h"
27 
28 namespace Bagel {
29 namespace MFC {
30 
31 class CString : public Common::String {
32 public:
33  CString() : Common::String() {
34  }
35  CString(const char *s) : Common::String(s) {
36  }
37  CString(char c) : Common::String(c) {
38  }
39  CString(const char *s, int nCount) :
40  Common::String(s, s + (nCount == -1 ? strlen(s) : nCount)) {
41  }
42 
43  char *GetBufferSetLength(size_t nNewLength) {
44  ensureCapacity(nNewLength + 1, false);
45  return const_cast<char *>(c_str());
46  }
47  void ReleaseBuffer(int nNewLength = -1) {
48  assert(nNewLength == -1);
49  *this = CString(c_str());
50  }
51  size_t GetLength() const {
52  return size();
53  }
54  bool IsEmpty() const {
55  return empty();
56  }
57  void Empty() {
58  clear();
59  }
60 
61  operator const char *() const {
62  return c_str();
63  }
64 
65  CString &operator+=(const char *str) {
66  Common::String::operator+=(str);
67  return *this;
68  }
69  CString &operator+=(const Common::String &str) {
70  Common::String::operator+=(str);
71  return *this;
72  }
73  CString &operator+=(char c) {
74  Common::String::operator+=(c);
75  return *this;
76  }
77 
78  bool LoadString(unsigned int nID);
79 };
80 
81 
82 inline CString operator+(const CString &x, const CString &y) {
83  CString tmp = x;
84  tmp += y;
85  return tmp;
86 }
87 
88 inline CString operator+(const char *x, const CString &y) {
89  CString tmp(x);
90  tmp += y;
91  return tmp;
92 }
93 
94 inline CString operator+(const CString &x, const char *y) {
95  CString tmp = x;
96  tmp += y;
97  return tmp;
98 }
99 
100 inline CString operator+(const CString &x, char y) {
101  CString tmp = x;
102  tmp += y;
103  return tmp;
104 }
105 
106 inline CString operator+(char x, const CString &y) {
107  CString tmp;
108  tmp += x;
109  tmp += y;
110  return tmp;
111 }
112 
113 } // namespace MFC
114 } // namespace Bagel
115 
116 #endif
Definition: str.h:59
Definition: afxstr.h:31
Definition: afxwin.h:27