]>
Commit | Line | Data |
---|---|---|
0f15e632 | 1 | |
2 | /* | |
d968c095 | 3 | * $Id: SquidString.h,v 1.12 2007/11/04 23:59:51 amosjeffries Exp $ |
0f15e632 | 4 | * |
5 | * DEBUG: section 67 String | |
30abd221 | 6 | * AUTHOR: Duane Wessels |
0f15e632 | 7 | * |
8 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
9 | * ---------------------------------------------------------- | |
10 | * | |
11 | * Squid is the result of efforts by numerous individuals from | |
12 | * the Internet community; see the CONTRIBUTORS file for full | |
13 | * details. Many organizations have provided support for Squid's | |
14 | * development; see the SPONSORS file for full details. Squid is | |
15 | * Copyrighted (C) 2001 by the Regents of the University of | |
16 | * California; see the COPYRIGHT file for full details. Squid | |
17 | * incorporates software developed and/or copyrighted by other | |
18 | * sources; see the CREDITS file for full details. | |
19 | * | |
20 | * This program is free software; you can redistribute it and/or modify | |
21 | * it under the terms of the GNU General Public License as published by | |
22 | * the Free Software Foundation; either version 2 of the License, or | |
23 | * (at your option) any later version. | |
24 | * | |
25 | * This program is distributed in the hope that it will be useful, | |
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
28 | * GNU General Public License for more details. | |
29 | * | |
30 | * You should have received a copy of the GNU General Public License | |
31 | * along with this program; if not, write to the Free Software | |
32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
33 | * | |
34 | */ | |
35 | ||
36 | #ifndef SQUID_STRING_H | |
37 | #define SQUID_STRING_H | |
38 | ||
30abd221 | 39 | /* forward decls */ |
40 | ||
41 | class CacheManager; | |
42 | ||
43 | #define DEBUGSTRINGS 0 | |
44 | #if DEBUGSTRINGS | |
45 | #include "splay.h" | |
46 | ||
47 | class String; | |
48 | ||
49 | class StringRegistry | |
50 | { | |
51 | ||
52 | public: | |
53 | static StringRegistry &Instance(); | |
54 | ||
55 | void add | |
56 | (String const *); | |
57 | ||
58 | void registerWithCacheManager(CacheManager & manager); | |
59 | ||
60 | void remove | |
61 | (String const *); | |
62 | ||
63 | private: | |
64 | static OBJH Stat; | |
0353e724 | 65 | |
30abd221 | 66 | static StringRegistry Instance_; |
0353e724 | 67 | |
30abd221 | 68 | static SplayNode<String const *>::SPLAYWALKEE Stater; |
0353e724 | 69 | |
30abd221 | 70 | Splay<String const *> entries; |
0353e724 | 71 | |
30abd221 | 72 | bool registered; |
0353e724 | 73 | |
30abd221 | 74 | }; |
0353e724 | 75 | |
30abd221 | 76 | class StoreEntry; |
77 | #endif | |
0353e724 | 78 | |
30abd221 | 79 | class String |
80 | { | |
0353e724 | 81 | |
30abd221 | 82 | public: |
83 | _SQUID_INLINE_ String(); | |
84 | String (char const *); | |
85 | String (String const &); | |
86 | ~String(); | |
87 | ||
88 | String &operator =(char const *); | |
89 | String &operator =(String const &); | |
90 | bool operator ==(String const &) const; | |
91 | bool operator !=(String const &) const; | |
92 | ||
93 | _SQUID_INLINE_ int size() const; | |
94 | _SQUID_INLINE_ char const * buf() const; | |
95 | void buf(char *); | |
96 | void init (char const *); | |
97 | void initBuf(size_t sz); | |
98 | void limitInit(const char *str, int len); | |
99 | void clean(); | |
100 | void reset(char const *str); | |
101 | void append(char const *buf, int len); | |
102 | void append(char const *buf); | |
103 | void append(char const); | |
104 | void append (String const &); | |
105 | void absorb(String &old); | |
106 | _SQUID_INLINE_ const char * pos(char const *) const; | |
107 | _SQUID_INLINE_ const char * pos(char const ch) const; | |
108 | _SQUID_INLINE_ const char * rpos(char const ch) const; | |
109 | _SQUID_INLINE_ int cmp (char const *) const; | |
110 | _SQUID_INLINE_ int cmp (char const *, size_t count) const; | |
111 | _SQUID_INLINE_ int cmp (String const &) const; | |
112 | _SQUID_INLINE_ int caseCmp (char const *) const; | |
113 | _SQUID_INLINE_ int caseCmp (char const *, size_t count) const; | |
114 | ||
d968c095 | 115 | _SQUID_INLINE_ void set(char const *loc, char const ch); |
30abd221 | 116 | |
d968c095 | 117 | _SQUID_INLINE_ void cut(size_t newLength); |
30abd221 | 118 | |
d968c095 | 119 | _SQUID_INLINE_ void cutPointer(char const *loc); |
30abd221 | 120 | |
121 | #if DEBUGSTRINGS | |
122 | ||
123 | void stat (StoreEntry *) const; | |
124 | ||
125 | #endif | |
126 | ||
127 | private: | |
128 | /* never reference these directly! */ | |
129 | unsigned short int size_; /* buffer size; 64K limit */ | |
130 | ||
131 | unsigned short int len_; /* current length */ | |
132 | ||
133 | char *buf_; | |
134 | }; | |
135 | ||
136 | _SQUID_INLINE_ std::ostream & operator<<(std::ostream& os, String const &aString); | |
137 | ||
138 | #ifdef _USE_INLINE_ | |
139 | #include "String.cci" | |
140 | #endif | |
0f15e632 | 141 | |
142 | #endif /* SQUID_STRING_H */ |