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.9 by root, Mon Sep 4 11:07:59 2006 UTC vs.
Revision 1.10 by root, Tue Sep 12 18:15:34 2006 UTC

82 else 82 else
83 s = intern (str); 83 s = intern (str);
84 84
85 return *this; 85 return *this;
86 } 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);
96 }
87}; 97};
88 98
89inline int strlen (const shstr &sh) 99inline int strlen (const shstr &sh)
90{ 100{
91 return sh.length (); 101 return sh.length ();
92} 102}
93 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 operator const char *() const { return s; }
115};
116
94inline bool operator ==(const shstr &a, const shstr &b) 117inline bool operator ==(const shstr_cmp &a, const shstr &b)
95{ 118{
96 return a.s == b.s; 119 return a.s == b.s;
97} 120}
98 121
99inline bool operator !=(const shstr &a, const shstr &b) 122inline bool operator ==(const shstr &a, const shstr_cmp &b)
100{ 123{
101 return !(a == b); 124 return b == a;
102} 125}
103 126
104extern const shstr undead_name; /* Used in hit_player() in main.c */ 127extern const shstr undead_name; /* Used in hit_player() in main.c */
105 128
106#endif 129#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines