1 | #ifndef SHSTR_H__ |
1 | #ifndef SHSTR_H__ |
2 | #define SHSTR_H__ |
2 | #define SHSTR_H__ |
|
|
3 | |
|
|
4 | #include <sstream> |
3 | |
5 | |
4 | #include "util.h" |
6 | #include "util.h" |
5 | |
7 | |
6 | extern int buf_overflow (const char *buf1, const char *buf2, int bufsize); |
8 | extern int buf_overflow (const char *buf1, const char *buf2, int bufsize); |
7 | |
9 | |
… | |
… | |
99 | inline int strlen (const shstr &sh) |
101 | inline int strlen (const shstr &sh) |
100 | { |
102 | { |
101 | return sh.length (); |
103 | return sh.length (); |
102 | } |
104 | } |
103 | |
105 | |
|
|
106 | inline int strcmp (const shstr &a, const shstr &b) |
|
|
107 | { |
|
|
108 | // TODO: use this to find all the occurences of people using strcmp |
|
|
109 | // all uses should be bogus, as we should be never interested in |
|
|
110 | // comparing shstr's alphabetically |
|
|
111 | #if 0 |
|
|
112 | extern void do_not_use_strcmp_to_compare_shstr_values (); |
|
|
113 | do_not_use_strcmp_to_compare_shstr_values (); |
|
|
114 | #endif |
|
|
115 | return a != b; |
|
|
116 | } |
|
|
117 | |
|
|
118 | static std::ostream &operator <<(std::ostream &o, const shstr &sh) |
|
|
119 | { |
|
|
120 | o.write (sh.s, sh.length ()); |
|
|
121 | return o; |
|
|
122 | } |
|
|
123 | |
104 | // only good for mass comparisons to shstr objects |
124 | // only good for mass comparisons to shstr objects |
105 | struct shstr_cmp |
125 | struct shstr_cmp |
106 | { |
126 | { |
107 | const char *s; |
127 | const char *s; |
108 | |
128 | |