… | |
… | |
70 | return length () >= plen && !strncasecmp (s, prefix, plen); |
70 | return length () >= plen && !strncasecmp (s, prefix, plen); |
71 | } |
71 | } |
72 | |
72 | |
73 | bool contains (const char *substring) const |
73 | bool contains (const char *substring) const |
74 | { |
74 | { |
75 | return strstr (s, substring); |
75 | return s != null () && strstr (s, substring); |
76 | } |
76 | } |
77 | |
77 | |
78 | //TODO: case sensitive should be eradicated |
78 | //TODO: case sensitive should be eradicated |
79 | bool eq_nc (const char *otherstring) const |
79 | bool eq_nc (const char *otherstring) const |
80 | { |
80 | { |
… | |
… | |
119 | inline bool operator !=(const shstr_tmp &a, const shstr_tmp &b) |
119 | inline bool operator !=(const shstr_tmp &a, const shstr_tmp &b) |
120 | { |
120 | { |
121 | return a.s != b.s; |
121 | return a.s != b.s; |
122 | } |
122 | } |
123 | |
123 | |
124 | inline int strlen (const shstr_tmp &sh) |
124 | inline int strlen (shstr_tmp sh) |
125 | { |
125 | { |
126 | return sh.length (); |
126 | return sh.length (); |
127 | } |
127 | } |
128 | |
128 | |
129 | static std::ostream &operator <<(std::ostream &o, shstr_tmp sh) |
129 | static std::ostream &operator <<(std::ostream &o, shstr_tmp sh) |
… | |
… | |
241 | inline bool operator ==(const shstr_tmp &a, const shstr_cmp &b) |
241 | inline bool operator ==(const shstr_tmp &a, const shstr_cmp &b) |
242 | { |
242 | { |
243 | return a.s == b.s; |
243 | return a.s == b.s; |
244 | } |
244 | } |
245 | |
245 | |
246 | #define def2(id,str) extern const shstr shstr_ ## id; |
246 | #define def2(id,str) extern const shstr id; |
247 | #define def(id) def2(id, # id) |
247 | #define def(id) def2(shstr_ ## id, # id) |
248 | # include "shstrinc.h" |
248 | # include "shstrinc.h" |
249 | #undef def |
249 | #undef def |
250 | #undef def2 |
250 | #undef def2 |
251 | |
251 | |
252 | // undefined external reference to catch people using str* functions when they shouldn't |
252 | // undefined external reference to catch people using str* functions when they shouldn't |
253 | //template<class any> void strcmp (const shstr_tmp &a, any b); |
253 | //template<class any> void strcmp (const shstr_tmp &a, any b); |
254 | //template<class any> void strstr (const shstr_tmp &a, any b); |
254 | template<class any> void strstr (const shstr_tmp &a, any b); |
255 | |
255 | |
256 | #endif |
256 | #endif |
257 | |
257 | |