ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/shstr.h
(Generate patch)

Comparing deliantra/server/include/shstr.h (file contents):
Revision 1.25 by root, Wed Dec 31 18:07:41 2008 UTC vs.
Revision 1.26 by root, Wed Dec 31 18:25:12 2008 UTC

94 94
95 // this is used for informational messages and the like 95 // this is used for informational messages and the like
96 const char *operator &() const { return s; } 96 const char *operator &() const { return s; }
97 97
98 operator const char *() const { return s == null () ? 0 : s; } 98 operator const char *() const { return s == null () ? 0 : s; }
99
100protected:
101 // dummy is there so it isn't used as type converter accidentally
102 shstr_tmp (int dummy, const char *s)
103 : s(s)
104 {
105 }
99}; 106};
100 107
101inline bool operator ==(const shstr_tmp &a, const shstr_tmp &b) 108inline bool operator ==(const shstr_tmp &a, const shstr_tmp &b)
102{ 109{
103 return a.s == b.s; 110 return a.s == b.s;
155 { 162 {
156 ++refcnt (); 163 ++refcnt ();
157 } 164 }
158 165
159 explicit shstr (const char *str) 166 explicit shstr (const char *str)
160 {
161 s = is_constant (str) && !str ? null () : intern (str); 167 : shstr_tmp (0, is_constant (str) && !str ? null () : intern (str))
168 {
162 } 169 }
163 170
164 ~shstr () 171 ~shstr ()
165 { 172 {
166 --refcnt (); 173 --refcnt ();
225inline bool operator ==(const shstr_tmp &a, const shstr_cmp &b) 232inline bool operator ==(const shstr_tmp &a, const shstr_cmp &b)
226{ 233{
227 return a.s == b.s; 234 return a.s == b.s;
228} 235}
229 236
237struct shstr_const : shstr_tmp
238{
239 shstr_const (const char *s)
240 : shstr_tmp (0, s)
241 {
242 }
243};
244
230#define def(str) extern const shstr shstr_ ## str; 245#define def(str) extern const shstr_const shstr_ ## str;
231# include "shstrinc.h" 246# include "shstrinc.h"
232#undef def 247#undef def
233 248
234#endif 249#endif
235 250

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines