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.13 by root, Mon Apr 23 15:27:46 2007 UTC vs.
Revision 1.16 by root, Mon May 28 21:15:56 2007 UTC

1/*
2 * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game.
3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 *
6 * Crossfire TRT is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
18 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 * The authors can be reached via e-mail to <crossfire@schmorp.de>
21 */
22
1#ifndef SHSTR_H__ 23#ifndef SHSTR_H__
2#define SHSTR_H__ 24#define SHSTR_H__
3 25
4#include <sstream> 26#include <sstream>
5 27
29 } 51 }
30 52
31 int length () const 53 int length () const
32 { 54 {
33 return length (s); 55 return length (s);
56 }
57
58 // returns wether this shared string begins with the given prefix,
59 // used mainly for searched when users give only the start of a name.
60 bool begins_with (const char *prefix) const
61 {
62 int plen = strlen (prefix);
63 return !strncasecmp (s, prefix, plen) && length () >= plen;
34 } 64 }
35 65
36 static const char *find (const char *s); 66 static const char *find (const char *s);
37 static const char *intern (const char *s); 67 static const char *intern (const char *s);
38 68
113 do_not_use_strcmp_to_compare_shstr_values (); 143 do_not_use_strcmp_to_compare_shstr_values ();
114#endif 144#endif
115 return a != b; 145 return a != b;
116} 146}
117 147
118std::ostream &operator <<(std::ostream &o, const shstr &sh) 148static std::ostream &operator <<(std::ostream &o, const shstr &sh)
119{ 149{
120 o.write (sh.s, sh.length ()); 150 o.write (sh.s, sh.length ());
121 return o; 151 return o;
122} 152}
123 153

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines