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.12 by root, Mon Feb 5 02:07:40 2007 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
104inline int strcmp (const shstr &a, const shstr &b)
105{
106 // TODO: use this to find all the occurences of people using strcmp
107 // all uses should be bogus, as we should be never interested in
108 // comparing shstr's alphabetically
109#if 0
110 extern void do_not_use_strcmp_to_compare_shstr_values ();
111 do_not_use_strcmp_to_compare_shstr_values ();
112#endif
113 return a != b;
114}
115
116// only good for mass comparisons to shstr objects
117struct shstr_cmp
118{
119 const char *s;
120
121 explicit shstr_cmp (const char *s)
122 : s (shstr::find (s))
123 {
124 }
125
126 shstr_cmp (const shstr_cmp &sh)
127 : s (sh.s)
128 {
129 }
130
131 shstr_cmp &operator =(const shstr_cmp sh) { s = sh.s; return *this; }
132 operator const char *() const { return s; }
133};
134
94inline bool operator ==(const shstr &a, const shstr &b) 135inline bool operator ==(const shstr_cmp &a, const shstr &b)
95{ 136{
96 return a.s == b.s; 137 return a.s == b.s;
97} 138}
98 139
99inline bool operator !=(const shstr &a, const shstr &b) 140inline bool operator ==(const shstr &a, const shstr_cmp &b)
100{ 141{
101 return !(a == b); 142 return b == a;
102} 143}
103 144
104extern const shstr undead_name; /* Used in hit_player() in main.c */ 145extern const shstr undead_name; /* Used in hit_player() in main.c */
105 146
106#endif 147#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines