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.10 by root, Tue Sep 12 18:15:34 2006 UTC vs.
Revision 1.12 by root, Mon Feb 5 02:07:40 2007 UTC

99inline int strlen (const shstr &sh) 99inline int strlen (const shstr &sh)
100{ 100{
101 return sh.length (); 101 return sh.length ();
102} 102}
103 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
104// only good for mass comparisons to shstr objects 116// only good for mass comparisons to shstr objects
105struct shstr_cmp 117struct shstr_cmp
106{ 118{
107 const char *s; 119 const char *s;
108 120
109 explicit shstr_cmp (const char *s) 121 explicit shstr_cmp (const char *s)
110 : s (shstr::find (s)) 122 : s (shstr::find (s))
111 { 123 {
112 } 124 }
113 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; }
114 operator const char *() const { return s; } 132 operator const char *() const { return s; }
115}; 133};
116 134
117inline bool operator ==(const shstr_cmp &a, const shstr &b) 135inline bool operator ==(const shstr_cmp &a, const shstr &b)
118{ 136{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines