/usr/include/crystalspace-2.0/iutil/string.h is in libcrystalspace-dev 2.0+dfsg-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | /*
Crystal Space String interface
Copyright (C) 1999 by Brandon Ehle (Azverkan)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CS_IUTIL_STRING_H__
#define __CS_IUTIL_STRING_H__
/**\file
* String interface
*/
/**\addtogroup util
* @{ */
#include "csutil/scf_interface.h"
/// This is a SCF-compatible interface for csString.
struct iString : public virtual iBase
{
SCF_INTERFACE(iString, 2,1,0);
/**
* Advise the string that it should allocate enough space to hold up to
* NewSize characters.
* \remarks After calling this method, the string's capacity will be at least
* NewSize + 1 (one for the implicit null terminator). Never shrinks
* capacity. If you need to actually reclaim memory, then use Free() or
* Reclaim().
*/
virtual void SetCapacity (size_t NewSize) = 0;
/// Return the current capacity.
virtual size_t GetCapacity () const = 0;
/**
* Advise the string that it should grow its allocated buffer by
* approximately this many bytes when more space is required. This is an
* optimization to avoid excessive memory reallocation and heap management,
* which can be quite slow.
* \remarks This value is only a suggestion. The actual value by which it
* grows may be rounded up or down to an implementation-dependent
* allocation multiple.
* <p>
* \remarks If the value is zero, then the internal buffer grows
* exponentially by doubling its size, rather than by fixed increments.
*/
virtual void SetGrowsBy(size_t) = 0;
/**
* Return the number of bytes by which the string grows.
* \remarks If the return value is zero, then the internal buffer grows
* exponentially by doubling its size, rather than by fixed increments.
*/
virtual size_t GetGrowsBy() const = 0;
/**
* Truncate the string.
* \param Len The number of characters to which the string should be
* truncated (possibly 0).
* \remarks Will only make a string shorter; will never extend it. This
* method may or may not reclaim memory depending upon the implementation.
* If you positively need to reclaim memory after truncating the string,
* then invoke Reclaim().
*/
virtual void Truncate (size_t Len) = 0;
/**
* Set string buffer capacity to hold exactly the current content.
* \remarks If the string length is greater than zero, then the buffer's
* capacity will be adjusted to exactly that size. If the string length is
* zero, then the implementation may shrink the allocation so that it only
* holds the implicit null terminator, or it may free the string's memory
* completely.
*/
virtual void ShrinkBestFit () = 0;
/**
* Clear the string (so that it contains only a null terminator).
* \remarks This is typically shorthand for Truncate(0), but more idiomatic
* in terms of human language.
*/
virtual void Empty () = 0;
/// Get a copy of this string
virtual csRef<iString> Clone () const = 0;
/**
* Get a pointer to the null-terminated character array.
* \return A C-string pointer to the null-terminated character array; or zero
* if the string represents a null-pointer.
*/
virtual char const* GetData () const = 0;
/**
* Query string length.
* \return The string length.
* \remarks The returned length does not count the implicit null terminator.
*/
virtual size_t Length () const = 0;
/**
* Check if string is empty.
* \return True if the string is empty; false if it is not.
* \remarks This is equivalent to the expression 'Length() == 0'.
*/
virtual bool IsEmpty () const = 0;
/// Get a modifiable reference to n'th character.
virtual char& operator [] (size_t n) = 0;
/// Get n'th character.
virtual char operator [] (size_t n) const = 0;
/**
* Set the n'th character.
* \remarks The n'th character position must be a valid position in the
* string. You can not expand the string by setting a character beyond the
* end of string.
*/
virtual void SetAt (size_t n, char iChar) = 0;
/// Get the n'th character.
virtual char GetAt (size_t n) const = 0;
/**
* Delete a range of characters from the string.
* \param Pos Beginning of range to be deleted (zero-based).
* \param Count Number of characters to delete.
*/
virtual void DeleteAt (size_t Pos, size_t Count = 1) = 0;
/**
* Insert another string into this one.
* \param Pos Position at which to insert the other string (zero-based).
* \param Str String to insert.
*/
virtual void Insert (size_t Pos, iString const* Str) = 0;
/**
* Overlay another string onto a part of this string.
* \param Pos Position at which to insert the other string (zero-based).
* \param Str String which will be overlayed atop this string.
* \remarks The target string will grow as necessary to accept the new
* string.
*/
virtual void Overwrite (size_t Pos, iString const* Str) = 0;
/**
* Append a null-terminated C-string to this one.
* \param Str String which will be appended.
* \param Count Number of characters from Str to append; if -1 (the default),
* then all characters from Str will be appended.
*/
virtual void Append (const char* Str, size_t Count = (size_t)-1) = 0;
/**
* Append a string to this one.
* \param Str String which will be appended.
* \param Count Number of characters from Str to append; if -1 (the default),
* then all characters from Str will be appended.
*/
virtual void Append (const iString* Str, size_t Count = (size_t)-1) = 0;
/**
* Copy and return a portion of this string.
* \param start Start position of slice (zero-based).
* \param len Number of characters in slice.
* \return The indicated string slice.
*/
virtual csRef<iString> Slice (size_t start, size_t len) const = 0;
/**
* Copy a portion of this string.
* \param sub String which will receive the indicated substring copy.
* \param start Start position of slice (zero-based).
* \param len Number of characters in slice.
* \remarks Use this method instead of Slice() for cases where you expect to
* extract many substrings in a tight loop, and want to avoid the overhead
* of allocation of a new string object for each operation. Simply re-use
* 'sub' for each operation.
*/
virtual void SubString (iString* sub, size_t start, size_t len) const = 0;
/**
* Find the first occurrence of a character in the string.
* \param c Character to locate.
* \param p Start position of search (default 0).
* \return First position of character, or (size_t)-1 if not found.
*/
virtual size_t FindFirst (const char c, size_t p = (size_t)-1) const = 0;
/**
* Find the last occurrence of a character in the string.
* \param c Character to locate.
* \param p Start position of reverse search. Specify (size_t)-1 if you want
* the search to begin at the very end of string.
* \return Last position of character, or (size_t)-1 if not found.
*/
virtual size_t FindLast (const char c, size_t p = (size_t)-1) const = 0;
/**
* Find the first occurrence of \p search in this string starting at \p pos.
* \param search String to locate.
* \param pos Start position of search (default 0).
* \return First position of \p search, or (size_t)-1 if not found.
*/
virtual size_t Find (const char* search, size_t pos = 0) const = 0;
/**
* Find all occurrences of \p search in this string and replace them with
* \p replacement.
*/
virtual void ReplaceAll (const char* search, const char* replacement) = 0;
/**
* Format this string using sprintf()-style formatting directives.
* \remarks Automatically allocates sufficient memory to hold result. Newly
* formatted string replaces previous string value.
* \sa \ref FormatterNotes
*/
virtual void Format (const char* format, ...) CS_GNUC_PRINTF (2, 3) = 0;
/**
* Format this string using sprintf() formatting directives in a va_list.
* \return Reference to itself.
* \remarks Automatically allocates sufficient memory to hold result. Newly
* formatted string replaces previous string value.
* \sa \ref FormatterNotes
*/
virtual void FormatV (const char* format, va_list args) = 0;
/**
* Replace contents of this string with the contents of another.
* \param str String from which new content of this string will be copied.
* \param count Number of characters to copy. If (size_t)-1 is specified,
* then all characters will be copied.
*/
virtual void Replace (const iString* str, size_t count = (size_t)-1) = 0;
/**
* Replace contents of this string with the contents of another.
* \param str String from which new content of this string will be copied.
* \param count Number of characters to copy. If (size_t)-1 is specified,
* then all characters will be copied.
*/
virtual void Replace (const char* str, size_t count = (size_t)-1) = 0;
/**
* Check if another string is equal to this one.
* \param Str Other string.
* \return True if they are equal; false if not.
* \remarks The comparison is case-sensitive.
*/
virtual bool Compare (const iString* Str) const = 0;
/**
* Check if another string is equal to this one.
* \param Str Other string.
* \return True if they are equal; false if not.
* \remarks The comparison is case-insensitive.
*/
virtual bool CompareNoCase (const iString* Str) const = 0;
/**
* Check if this string starts with another one.
* \param Str Other string.
* \param ignore_case Causes the comparison to be case insensitive if true.
* \return True if they are equal up to the length of Str; false if not.
*/
virtual bool StartsWith (const iString* Str, bool ignore_case = false) const = 0;
/**
* Check if this string starts with another null-terminated C-string.
* \param Str Other string.
* \param ignore_case Causes the comparison to be case insensitive if true.
* \return True if they are equal up to the length of Str; false if not.
*/
virtual bool StartsWith (const char* Str, bool ignore_case = false) const = 0;
/// Append another string to this one.
virtual void operator += (const iString& iStr) = 0;
/// Append a null-terminated C-string to this string
virtual void operator += (const char* iStr) = 0;
/// Concatenate two strings and return a third one.
virtual csRef<iString> operator + (const iString& iStr) const = 0;
/**
* Get a pointer to the null-terminated character array.
* \return A C-string pointer to the null-terminated character array; or zero
* if the string represents a null-pointer.
*/
virtual operator char const* () const = 0;
/**
* Check if another string is equal to this one.
* \param Str Other string.
* \return True if they are equal; false if not.
* \remarks The comparison is case-sensitive.
*/
virtual bool operator == (const iString& Str) const = 0;
/**
* Check if another string is not equal to this one.
* \param Str Other string.
* \return False if they are equal; true if not.
* \remarks The comparison is case-sensitive.
*/
virtual bool operator != (const iString& Str) const = 0;
/// Convert string to lowercase.
virtual void Downcase() = 0;
/// Convert string to uppercase.
virtual void Upcase() = 0;
};
/** @} */
#endif // __CS_IUTIL_STRING_H__
|