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.8 by root, Sun Sep 3 23:33:01 2006 UTC vs.
Revision 1.11 by root, Thu Sep 14 21:16:12 2006 UTC

74 74
75 const shstr &operator =(const char *str) 75 const shstr &operator =(const char *str)
76 { 76 {
77 --refcnt (); 77 --refcnt ();
78 78
79#if 0
80 // this optimises the important case of str == constant 0 79 // this optimises the important case of str == constant 0
81 if (is_constant (str)) 80 if (is_constant (str))
82 s = str ? intern (str) : null; 81 s = str ? intern (str) : null;
83 else 82 else
84#endif
85 s = intern (str); 83 s = intern (str);
86 84
87 return *this; 85 return *this;
86 }
87
88 bool operator ==(const shstr &b)
89 {
90 return s == b.s;
91 }
92
93 bool operator !=(const shstr &b)
94 {
95 return !(*this == b);
88 } 96 }
89}; 97};
90 98
91inline int strlen (const shstr &sh) 99inline int strlen (const shstr &sh)
92{ 100{
93 return sh.length (); 101 return sh.length ();
94} 102}
95 103
104// only good for mass comparisons to shstr objects
105struct shstr_cmp
106{
107 const char *s;
108
109 explicit shstr_cmp (const char *s)
110 : s (shstr::find (s))
111 {
112 }
113
114 shstr_cmp (const shstr_cmp &sh)
115 : s (sh.s)
116 {
117 }
118
119 shstr_cmp &operator =(const shstr_cmp sh) { s = sh.s; return *this; }
120 operator const char *() const { return s; }
121};
122
96inline bool operator ==(const shstr &a, const shstr &b) 123inline bool operator ==(const shstr_cmp &a, const shstr &b)
97{ 124{
98 return a.s == b.s; 125 return a.s == b.s;
99} 126}
100 127
101inline bool operator !=(const shstr &a, const shstr &b) 128inline bool operator ==(const shstr &a, const shstr_cmp &b)
102{ 129{
103 return !(a == b); 130 return b == a;
104} 131}
132
133extern const shstr undead_name; /* Used in hit_player() in main.c */
105 134
106#endif 135#endif
107 136

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines