… | |
… | |
29 | } |
29 | } |
30 | |
30 | |
31 | int length () const |
31 | int length () const |
32 | { |
32 | { |
33 | return length (s); |
33 | return length (s); |
|
|
34 | } |
|
|
35 | |
|
|
36 | // returns wether this shared string begins with the given prefix, |
|
|
37 | // used mainly for searched when users give only the start of a name. |
|
|
38 | bool begins_with (const char *prefix) const |
|
|
39 | { |
|
|
40 | int plen = strlen (prefix); |
|
|
41 | return !strncasecmp (s, prefix, plen) && length () >= plen; |
34 | } |
42 | } |
35 | |
43 | |
36 | static const char *find (const char *s); |
44 | static const char *find (const char *s); |
37 | static const char *intern (const char *s); |
45 | static const char *intern (const char *s); |
38 | |
46 | |
… | |
… | |
113 | do_not_use_strcmp_to_compare_shstr_values (); |
121 | do_not_use_strcmp_to_compare_shstr_values (); |
114 | #endif |
122 | #endif |
115 | return a != b; |
123 | return a != b; |
116 | } |
124 | } |
117 | |
125 | |
118 | std::ostream &operator <<(std::ostream &o, const shstr &sh) |
126 | static std::ostream &operator <<(std::ostream &o, const shstr &sh) |
119 | { |
127 | { |
120 | o.write (sh.s, sh.length ()); |
128 | o.write (sh.s, sh.length ()); |
121 | return o; |
129 | return o; |
122 | } |
130 | } |
123 | |
131 | |