]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/SquidString.h
2 * DEBUG: section 67 String
3 * AUTHOR: Duane Wessels
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
33 #ifndef SQUID_STRING_H
34 #define SQUID_STRING_H
40 /* squid string placeholder (for printf) */
42 #define SQUIDSTRINGPH "%.*s"
43 #define SQUIDSTRINGPRINT(s) (s).psize(),(s).rawBuf()
44 #endif /* SQUIDSTRINGPH */
46 #define DEBUGSTRINGS 0
56 static StringRegistry
&Instance();
58 void add(String
const *);
62 void remove(String
const *);
67 static StringRegistry Instance_
;
69 static SplayNode
<String
const *>::SPLAYWALKEE Stater
;
71 Splay
<String
const *> entries
;
84 _SQUID_INLINE_
String();
86 String(String
const &);
89 typedef size_t size_type
; //storage size intentionally unspecified
90 const static size_type npos
= std::string::npos
;
92 String
&operator =(char const *);
93 String
&operator =(String
const &);
94 bool operator ==(String
const &) const;
95 bool operator !=(String
const &) const;
98 * Retrieve a single character in the string.
99 \param pos Position of character to retrieve.
101 _SQUID_INLINE_
char operator [](unsigned int pos
) const;
103 _SQUID_INLINE_ size_type
size() const;
104 /// variant of size() suited to be used for printf-alikes.
105 /// throws when size() > MAXINT
109 * \retval true the String has some contents
111 _SQUID_INLINE_
bool defined() const;
113 * \retval true the String does not hold any contents
115 _SQUID_INLINE_
bool undefined() const;
117 * Returns a raw pointer to the underlying backing store. The caller has been
118 * verified not to make any assumptions about null-termination
120 _SQUID_INLINE_
char const * rawBuf() const;
122 * Returns a raw pointer to the underlying backing store.
123 * The caller requires it to be null-terminated.
125 _SQUID_INLINE_
char const * termedBuf() const;
126 void limitInit(const char *str
, int len
); // TODO: rename to assign()
128 void reset(char const *str
);
129 void append(char const *buf
, int len
);
130 void append(char const *buf
);
131 void append(char const);
132 void append(String
const &);
133 void absorb(String
&old
);
134 const char * pos(char const *aString
) const;
135 const char * pos(char const ch
) const;
136 ///offset from string start of the first occurrence of ch
137 /// returns String::npos if ch is not found
138 size_type
find(char const ch
) const;
139 size_type
find(char const *aString
) const;
140 const char * rpos(char const ch
) const;
141 size_type
rfind(char const ch
) const;
142 _SQUID_INLINE_
int cmp(char const *) const;
143 _SQUID_INLINE_
int cmp(char const *, size_type count
) const;
144 _SQUID_INLINE_
int cmp(String
const &) const;
145 _SQUID_INLINE_
int caseCmp(char const *) const;
146 _SQUID_INLINE_
int caseCmp(char const *, size_type count
) const;
147 _SQUID_INLINE_
int caseCmp(String
const &) const;
149 String
substr(size_type from
, size_type to
) const;
151 _SQUID_INLINE_
void cut(size_type newLength
);
154 void stat(StoreEntry
*) const;
158 void allocAndFill(const char *str
, int len
);
159 void allocBuffer(size_type sz
);
160 void setBuffer(char *buf
, size_type sz
);
162 _SQUID_INLINE_
bool nilCmp(bool, bool, int &) const;
164 /* never reference these directly! */
165 size_type size_
; /* buffer size; 64K limit */
167 size_type len_
; /* current length */
171 _SQUID_INLINE_
void set(char const *loc
, char const ch
);
172 _SQUID_INLINE_
void cutPointer(char const *loc
);
176 _SQUID_INLINE_
std::ostream
& operator<<(std::ostream
& os
, String
const &aString
);
178 _SQUID_INLINE_
bool operator<(const String
&a
, const String
&b
);
181 #include "String.cci"
184 const char *checkNullString(const char *p
);
185 int stringHasWhitespace(const char *);
186 int stringHasCntl(const char *);
187 char *strwordtok(char *buf
, char **t
);
189 #endif /* SQUID_STRING_H */