]>
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();
69 static StringRegistry Instance_
;
71 static SplayNode
<String
const *>::SPLAYWALKEE Stater
;
73 Splay
<String
const *> entries
;
86 _SQUID_INLINE_
String();
87 String (char const *);
88 String (String
const &);
91 typedef size_t size_type
; //storage size intentionally unspecified
92 const static size_type npos
= std::string::npos
;
94 String
&operator =(char const *);
95 String
&operator =(String
const &);
96 bool operator ==(String
const &) const;
97 bool operator !=(String
const &) const;
100 * Retrieve a single character in the string.
101 \param pos Position of character to retrieve.
103 _SQUID_INLINE_
char operator [](unsigned int pos
) const;
105 _SQUID_INLINE_ size_type
size() const;
106 /// variant of size() suited to be used for printf-alikes.
107 /// throws when size() > MAXINT
111 * \retval true the String has some contents
113 _SQUID_INLINE_
bool defined() const;
115 * \retval true the String does not hold any contents
117 _SQUID_INLINE_
bool undefined() const;
119 * Returns a raw pointer to the underlying backing store. The caller has been
120 * verified not to make any assumptions about null-termination
122 _SQUID_INLINE_
char const * rawBuf() const;
124 * Returns a raw pointer to the underlying backing store.
125 * The caller requires it to be null-terminated.
127 _SQUID_INLINE_
char const * termedBuf() const;
128 void limitInit(const char *str
, int len
); // TODO: rename to assign()
130 void reset(char const *str
);
131 void append(char const *buf
, int len
);
132 void append(char const *buf
);
133 void append(char const);
134 void append (String
const &);
135 void absorb(String
&old
);
136 const char * pos(char const *aString
) const;
137 const char * pos(char const ch
) const;
138 ///offset from string start of the first occurrence of ch
139 /// returns String::npos if ch is not found
140 size_type
find(char const ch
) const;
141 size_type
find(char const *aString
) const;
142 const char * rpos(char const ch
) const;
143 size_type
rfind(char const ch
) const;
144 _SQUID_INLINE_
int cmp (char const *) const;
145 _SQUID_INLINE_
int cmp (char const *, size_type count
) const;
146 _SQUID_INLINE_
int cmp (String
const &) const;
147 _SQUID_INLINE_
int caseCmp (char const *) const;
148 _SQUID_INLINE_
int caseCmp (char const *, size_type count
) const;
149 _SQUID_INLINE_
int caseCmp (String
const &) const;
151 String
substr(size_type from
, size_type to
) const;
153 _SQUID_INLINE_
void cut(size_type newLength
);
156 void stat (StoreEntry
*) const;
160 void allocAndFill(const char *str
, int len
);
161 void allocBuffer(size_type sz
);
162 void setBuffer(char *buf
, size_type sz
);
164 _SQUID_INLINE_
bool nilCmp(bool, bool, int &) const;
166 /* never reference these directly! */
167 size_type size_
; /* buffer size; 64K limit */
169 size_type len_
; /* current length */
173 _SQUID_INLINE_
void set(char const *loc
, char const ch
);
174 _SQUID_INLINE_
void cutPointer(char const *loc
);
178 _SQUID_INLINE_
std::ostream
& operator<<(std::ostream
& os
, String
const &aString
);
180 _SQUID_INLINE_
bool operator<(const String
&a
, const String
&b
);
183 #include "String.cci"
186 extern const char *checkNullString(const char *p
);
187 extern int stringHasWhitespace(const char *);
188 extern int stringHasCntl(const char *);
189 extern char *strwordtok(char *buf
, char **t
);
191 #endif /* SQUID_STRING_H */