1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
5 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
7 | * the terms of the Affero GNU General Public License as published by the |
7 | * the terms of the Affero GNU General Public License as published by the |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * option) any later version. |
9 | * option) any later version. |
10 | * |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
14 | * GNU General Public License for more details. |
15 | * |
15 | * |
16 | * You should have received a copy of the Affero GNU General Public License |
16 | * You should have received a copy of the Affero GNU General Public License |
17 | * and the GNU General Public License along with this program. If not, see |
17 | * and the GNU General Public License along with this program. If not, see |
18 | * <http://www.gnu.org/licenses/>. |
18 | * <http://www.gnu.org/licenses/>. |
19 | * |
19 | * |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | */ |
21 | */ |
22 | |
22 | |
23 | #ifndef SHSTR_H__ |
23 | #ifndef SHSTR_H__ |
24 | #define SHSTR_H__ |
24 | #define SHSTR_H__ |
… | |
… | |
84 | } |
84 | } |
85 | |
85 | |
86 | // returns true if the substring is contained in the shstr |
86 | // returns true if the substring is contained in the shstr |
87 | // if the shstr is 0, then this always returns false. |
87 | // if the shstr is 0, then this always returns false. |
88 | // the shstr is (theoretically) treated as a comma/colon/space etc. separated list. |
88 | // the shstr is (theoretically) treated as a comma/colon/space etc. separated list. |
89 | bool contains (const char *substring) const |
89 | bool contains (const char *substring) const; |
90 | { |
|
|
91 | return s != null () && strstr (s, substring); |
|
|
92 | } |
|
|
93 | |
90 | |
94 | //TODO: case sensitive should be eradicated |
91 | //TODO: case sensitive should be eradicated |
95 | bool eq_nc (const char *otherstring) const |
92 | bool eq_nc (const char *otherstring) const |
96 | { |
93 | { |
97 | return !strcasecmp (s, otherstring); |
94 | return !strcasecmp (s, otherstring); |
… | |
… | |
181 | { |
178 | { |
182 | ++refcnt (); |
179 | ++refcnt (); |
183 | } |
180 | } |
184 | |
181 | |
185 | explicit shstr (const char *str) |
182 | explicit shstr (const char *str) |
186 | : shstr_tmp (0, is_constant (str) && !str ? null () : intern (str)) |
183 | : shstr_tmp (0, ecb_is_constant (str) && !str ? null () : intern (str)) |
187 | { |
184 | { |
188 | } |
185 | } |
189 | |
186 | |
190 | ~shstr () |
187 | ~shstr () |
191 | { |
188 | { |
… | |
… | |
213 | |
210 | |
214 | // shstr_tmp doesn't have this one |
211 | // shstr_tmp doesn't have this one |
215 | shstr &operator =(const char *str) |
212 | shstr &operator =(const char *str) |
216 | { |
213 | { |
217 | --refcnt (); |
214 | --refcnt (); |
218 | s = is_constant (str) && !str ? null () : intern (str); |
215 | s = ecb_is_constant (str) && !str ? null () : intern (str); |
219 | |
216 | |
220 | return *this; |
217 | return *this; |
221 | } |
218 | } |
222 | }; |
219 | }; |
223 | |
220 | |