Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

String.h 54KB

6 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210
  1. /*
  2. ==============================================================================
  3. This file is part of the Water library.
  4. Copyright (c) 2016 ROLI Ltd.
  5. Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
  6. Permission is granted to use this software under the terms of the ISC license
  7. http://www.isc.org/downloads/software-support-policy/isc-license/
  8. Permission to use, copy, modify, and/or distribute this software for any
  9. purpose with or without fee is hereby granted, provided that the above
  10. copyright notice and this permission notice appear in all copies.
  11. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  12. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  13. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  14. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  15. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  17. OF THIS SOFTWARE.
  18. ==============================================================================
  19. */
  20. #ifndef WATER_STRING_H_INCLUDED
  21. #define WATER_STRING_H_INCLUDED
  22. #include "CharPointer_UTF8.h"
  23. #include "../memory/Memory.h"
  24. #include <limits>
  25. #include <string>
  26. namespace water {
  27. //==============================================================================
  28. /**
  29. The Water String class!
  30. Using a reference-counted internal representation, these strings are fast
  31. and efficient, and there are methods to do just about any operation you'll ever
  32. dream of.
  33. @see StringArray, StringPairArray
  34. */
  35. class String
  36. {
  37. public:
  38. //==============================================================================
  39. /** Creates an empty string.
  40. @see empty
  41. */
  42. String() noexcept;
  43. /** Creates a copy of another string. */
  44. String (const String& other) noexcept;
  45. #if WATER_COMPILER_SUPPORTS_MOVE_SEMANTICS
  46. String (String&& other) noexcept;
  47. #endif
  48. /** Creates a string from a zero-terminated ascii text string.
  49. The string passed-in must not contain any characters with a value above 127, because
  50. these can't be converted to unicode without knowing the original encoding that was
  51. used to create the string. If you attempt to pass-in values above 127, you'll get an
  52. assertion.
  53. To create strings with extended characters from UTF-8, you should explicitly call
  54. String (CharPointer_UTF8 ("my utf8 string..")). It's *highly* recommended that you
  55. use UTF-8 with escape characters in your source code to represent extended characters,
  56. because there's no other way to represent unicode strings in a way that isn't dependent
  57. on the compiler, source code editor and platform.
  58. */
  59. String (const char* text);
  60. /** Creates a string from a string of 8-bit ascii characters.
  61. The string passed-in must not contain any characters with a value above 127, because
  62. these can't be converted to unicode without knowing the original encoding that was
  63. used to create the string. If you attempt to pass-in values above 127, you'll get an
  64. assertion.
  65. To create strings with extended characters from UTF-8, you should explicitly call
  66. String (CharPointer_UTF8 ("my utf8 string..")). It's *highly* recommended that you
  67. use UTF-8 with escape characters in your source code to represent extended characters,
  68. because there's no other way to represent unicode strings in a way that isn't dependent
  69. on the compiler, source code editor and platform.
  70. This will use up to the first maxChars characters of the string (or less if the string
  71. is actually shorter).
  72. */
  73. String (const char* text, size_t maxChars);
  74. //==============================================================================
  75. /** Creates a string from a UTF-8 character string */
  76. String (const CharPointer_UTF8 text);
  77. /** Creates a string from a UTF-8 character string */
  78. String (const CharPointer_UTF8 text, size_t maxChars);
  79. /** Creates a string from a UTF-8 character string */
  80. String (const CharPointer_UTF8 start, const CharPointer_UTF8 end);
  81. //==============================================================================
  82. /** Creates a string from a UTF-8 encoded std::string. */
  83. String (const std::string&);
  84. /** Creates a string from a StringRef */
  85. String (StringRef);
  86. //==============================================================================
  87. /** Creates a string from a single character. */
  88. static String charToString (water_uchar character);
  89. /** Destructor. */
  90. ~String() noexcept;
  91. /** This is the character encoding type used internally to store the string. */
  92. typedef CharPointer_UTF8 CharPointerType;
  93. //==============================================================================
  94. /** Generates a probably-unique 32-bit hashcode from this string. */
  95. int hashCode() const noexcept;
  96. /** Generates a probably-unique 64-bit hashcode from this string. */
  97. int64 hashCode64() const noexcept;
  98. /** Generates a probably-unique hashcode from this string. */
  99. size_t hash() const noexcept;
  100. /** Returns the number of characters in the string. */
  101. int length() const noexcept;
  102. //==============================================================================
  103. // Assignment and concatenation operators..
  104. /** Replaces this string's contents with another string. */
  105. String& operator= (const String& other) noexcept;
  106. #if WATER_COMPILER_SUPPORTS_MOVE_SEMANTICS
  107. String& operator= (String&& other) noexcept;
  108. #endif
  109. /** Appends another string at the end of this one. */
  110. String& operator+= (const String& stringToAppend);
  111. /** Appends another string at the end of this one. */
  112. String& operator+= (const char* textToAppend);
  113. /** Appends another string at the end of this one. */
  114. String& operator+= (StringRef textToAppend);
  115. /** Appends a decimal number at the end of this string. */
  116. String& operator+= (int numberToAppend);
  117. /** Appends a decimal number at the end of this string. */
  118. String& operator+= (long numberToAppend);
  119. /** Appends a decimal number at the end of this string. */
  120. String& operator+= (int64 numberToAppend);
  121. /** Appends a decimal number at the end of this string. */
  122. String& operator+= (uint64 numberToAppend);
  123. /** Appends a character at the end of this string. */
  124. String& operator+= (char characterToAppend);
  125. /** Appends a character at the end of this string. */
  126. String& operator+= (water_uchar characterToAppend);
  127. /** Appends a string to the end of this one.
  128. @param textToAppend the string to add
  129. @param maxCharsToTake the maximum number of characters to take from the string passed in
  130. */
  131. void append (const String& textToAppend, size_t maxCharsToTake);
  132. /** Appends a string to the end of this one.
  133. @param startOfTextToAppend the start of the string to add. This must not be a nullptr
  134. @param endOfTextToAppend the end of the string to add. This must not be a nullptr
  135. */
  136. void appendCharPointer (const CharPointerType startOfTextToAppend,
  137. const CharPointerType endOfTextToAppend);
  138. /** Appends a string to the end of this one.
  139. @param startOfTextToAppend the start of the string to add. This must not be a nullptr
  140. @param endOfTextToAppend the end of the string to add. This must not be a nullptr
  141. */
  142. template <class CharPointer>
  143. void appendCharPointer (const CharPointer startOfTextToAppend,
  144. const CharPointer endOfTextToAppend)
  145. {
  146. wassert (startOfTextToAppend.getAddress() != nullptr && endOfTextToAppend.getAddress() != nullptr);
  147. size_t extraBytesNeeded = 0, numChars = 1;
  148. for (CharPointer t (startOfTextToAppend); t != endOfTextToAppend && ! t.isEmpty(); ++numChars)
  149. extraBytesNeeded += CharPointerType::getBytesRequiredFor (t.getAndAdvance());
  150. if (extraBytesNeeded > 0)
  151. {
  152. const size_t byteOffsetOfNull = getByteOffsetOfEnd();
  153. preallocateBytes (byteOffsetOfNull + extraBytesNeeded);
  154. CharPointerType (addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull))
  155. .writeWithCharLimit (startOfTextToAppend, (int) numChars);
  156. }
  157. }
  158. /** Appends a string to the end of this one. */
  159. void appendCharPointer (const CharPointerType textToAppend);
  160. /** Appends a string to the end of this one.
  161. @param textToAppend the string to add
  162. @param maxCharsToTake the maximum number of characters to take from the string passed in
  163. */
  164. template <class CharPointer>
  165. void appendCharPointer (const CharPointer textToAppend, size_t maxCharsToTake)
  166. {
  167. if (textToAppend.getAddress() != nullptr)
  168. {
  169. size_t extraBytesNeeded = 0, numChars = 1;
  170. for (CharPointer t (textToAppend); numChars <= maxCharsToTake && ! t.isEmpty(); ++numChars)
  171. extraBytesNeeded += CharPointerType::getBytesRequiredFor (t.getAndAdvance());
  172. if (extraBytesNeeded > 0)
  173. {
  174. const size_t byteOffsetOfNull = getByteOffsetOfEnd();
  175. preallocateBytes (byteOffsetOfNull + extraBytesNeeded);
  176. CharPointerType (addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull))
  177. .writeWithCharLimit (textToAppend, (int) numChars);
  178. }
  179. }
  180. }
  181. /** Appends a string to the end of this one. */
  182. template <class CharPointer>
  183. void appendCharPointer (const CharPointer textToAppend)
  184. {
  185. appendCharPointer (textToAppend, std::numeric_limits<size_t>::max());
  186. }
  187. //==============================================================================
  188. // Comparison methods..
  189. /** Returns true if the string contains no characters.
  190. Note that there's also an isNotEmpty() method to help write readable code.
  191. @see containsNonWhitespaceChars()
  192. */
  193. inline bool isEmpty() const noexcept { return text.isEmpty(); }
  194. /** Returns true if the string contains at least one character.
  195. Note that there's also an isEmpty() method to help write readable code.
  196. @see containsNonWhitespaceChars()
  197. */
  198. inline bool isNotEmpty() const noexcept { return ! text.isEmpty(); }
  199. /** Resets this string to be empty. */
  200. void clear() noexcept;
  201. /** Case-insensitive comparison with another string. */
  202. bool equalsIgnoreCase (const String& other) const noexcept;
  203. /** Case-insensitive comparison with another string. */
  204. bool equalsIgnoreCase (StringRef other) const noexcept;
  205. /** Case-insensitive comparison with another string. */
  206. bool equalsIgnoreCase (const char* other) const noexcept;
  207. /** Case-sensitive comparison with another string.
  208. @returns 0 if the two strings are identical; negative if this string comes before
  209. the other one alphabetically, or positive if it comes after it.
  210. */
  211. int compare (const String& other) const noexcept;
  212. /** Case-sensitive comparison with another string.
  213. @returns 0 if the two strings are identical; negative if this string comes before
  214. the other one alphabetically, or positive if it comes after it.
  215. */
  216. int compare (const char* other) const noexcept;
  217. /** Case-insensitive comparison with another string.
  218. @returns 0 if the two strings are identical; negative if this string comes before
  219. the other one alphabetically, or positive if it comes after it.
  220. */
  221. int compareIgnoreCase (const String& other) const noexcept;
  222. /** Compares two strings, taking into account textual characteristics like numbers and spaces.
  223. This comparison is case-insensitive and can detect words and embedded numbers in the
  224. strings, making it good for sorting human-readable lists of things like filenames.
  225. @returns 0 if the two strings are identical; negative if this string comes before
  226. the other one alphabetically, or positive if it comes after it.
  227. */
  228. int compareNatural (StringRef other, bool isCaseSensitive = false) const noexcept;
  229. /** Tests whether the string begins with another string.
  230. If the parameter is an empty string, this will always return true.
  231. Uses a case-sensitive comparison.
  232. */
  233. bool startsWith (StringRef text) const noexcept;
  234. /** Tests whether the string begins with a particular character.
  235. If the character is 0, this will always return false.
  236. Uses a case-sensitive comparison.
  237. */
  238. bool startsWithChar (water_uchar character) const noexcept;
  239. /** Tests whether the string begins with another string.
  240. If the parameter is an empty string, this will always return true.
  241. Uses a case-insensitive comparison.
  242. */
  243. bool startsWithIgnoreCase (StringRef text) const noexcept;
  244. /** Tests whether the string ends with another string.
  245. If the parameter is an empty string, this will always return true.
  246. Uses a case-sensitive comparison.
  247. */
  248. bool endsWith (StringRef text) const noexcept;
  249. /** Tests whether the string ends with a particular character.
  250. If the character is 0, this will always return false.
  251. Uses a case-sensitive comparison.
  252. */
  253. bool endsWithChar (water_uchar character) const noexcept;
  254. /** Tests whether the string ends with another string.
  255. If the parameter is an empty string, this will always return true.
  256. Uses a case-insensitive comparison.
  257. */
  258. bool endsWithIgnoreCase (StringRef text) const noexcept;
  259. /** Tests whether the string contains another substring.
  260. If the parameter is an empty string, this will always return true.
  261. Uses a case-sensitive comparison.
  262. */
  263. bool contains (StringRef text) const noexcept;
  264. /** Tests whether the string contains a particular character.
  265. Uses a case-sensitive comparison.
  266. */
  267. bool containsChar (water_uchar character) const noexcept;
  268. /** Tests whether the string contains another substring.
  269. Uses a case-insensitive comparison.
  270. */
  271. bool containsIgnoreCase (StringRef text) const noexcept;
  272. /** Tests whether the string contains another substring as a distinct word.
  273. @returns true if the string contains this word, surrounded by
  274. non-alphanumeric characters
  275. @see indexOfWholeWord, containsWholeWordIgnoreCase
  276. */
  277. bool containsWholeWord (StringRef wordToLookFor) const noexcept;
  278. /** Tests whether the string contains another substring as a distinct word.
  279. @returns true if the string contains this word, surrounded by
  280. non-alphanumeric characters
  281. @see indexOfWholeWordIgnoreCase, containsWholeWord
  282. */
  283. bool containsWholeWordIgnoreCase (StringRef wordToLookFor) const noexcept;
  284. /** Finds an instance of another substring if it exists as a distinct word.
  285. @returns if the string contains this word, surrounded by non-alphanumeric characters,
  286. then this will return the index of the start of the substring. If it isn't
  287. found, then it will return -1
  288. @see indexOfWholeWordIgnoreCase, containsWholeWord
  289. */
  290. int indexOfWholeWord (StringRef wordToLookFor) const noexcept;
  291. /** Finds an instance of another substring if it exists as a distinct word.
  292. @returns if the string contains this word, surrounded by non-alphanumeric characters,
  293. then this will return the index of the start of the substring. If it isn't
  294. found, then it will return -1
  295. @see indexOfWholeWord, containsWholeWordIgnoreCase
  296. */
  297. int indexOfWholeWordIgnoreCase (StringRef wordToLookFor) const noexcept;
  298. /** Looks for any of a set of characters in the string.
  299. Uses a case-sensitive comparison.
  300. @returns true if the string contains any of the characters from
  301. the string that is passed in.
  302. */
  303. bool containsAnyOf (StringRef charactersItMightContain) const noexcept;
  304. /** Looks for a set of characters in the string.
  305. Uses a case-sensitive comparison.
  306. @returns Returns false if any of the characters in this string do not occur in
  307. the parameter string. If this string is empty, the return value will
  308. always be true.
  309. */
  310. bool containsOnly (StringRef charactersItMightContain) const noexcept;
  311. /** Returns true if this string contains any non-whitespace characters.
  312. This will return false if the string contains only whitespace characters, or
  313. if it's empty.
  314. It is equivalent to calling "myString.trim().isNotEmpty()".
  315. */
  316. bool containsNonWhitespaceChars() const noexcept;
  317. /** Returns true if the string matches this simple wildcard expression.
  318. So for example String ("abcdef").matchesWildcard ("*DEF", true) would return true.
  319. This isn't a full-blown regex though! The only wildcard characters supported
  320. are "*" and "?". It's mainly intended for filename pattern matching.
  321. */
  322. bool matchesWildcard (StringRef wildcard, bool ignoreCase) const noexcept;
  323. //==============================================================================
  324. // Substring location methods..
  325. /** Searches for a character inside this string.
  326. Uses a case-sensitive comparison.
  327. @returns the index of the first occurrence of the character in this
  328. string, or -1 if it's not found.
  329. */
  330. int indexOfChar (water_uchar characterToLookFor) const noexcept;
  331. /** Searches for a character inside this string.
  332. Uses a case-sensitive comparison.
  333. @param startIndex the index from which the search should proceed
  334. @param characterToLookFor the character to look for
  335. @returns the index of the first occurrence of the character in this
  336. string, or -1 if it's not found.
  337. */
  338. int indexOfChar (int startIndex, water_uchar characterToLookFor) const noexcept;
  339. /** Returns the index of the first character that matches one of the characters
  340. passed-in to this method.
  341. This scans the string, beginning from the startIndex supplied, and if it finds
  342. a character that appears in the string charactersToLookFor, it returns its index.
  343. If none of these characters are found, it returns -1.
  344. If ignoreCase is true, the comparison will be case-insensitive.
  345. @see indexOfChar, lastIndexOfAnyOf
  346. */
  347. int indexOfAnyOf (StringRef charactersToLookFor,
  348. int startIndex = 0,
  349. bool ignoreCase = false) const noexcept;
  350. /** Searches for a substring within this string.
  351. Uses a case-sensitive comparison.
  352. @returns the index of the first occurrence of this substring, or -1 if it's not found.
  353. If textToLookFor is an empty string, this will always return 0.
  354. */
  355. int indexOf (StringRef textToLookFor) const noexcept;
  356. /** Searches for a substring within this string.
  357. Uses a case-sensitive comparison.
  358. @param startIndex the index from which the search should proceed
  359. @param textToLookFor the string to search for
  360. @returns the index of the first occurrence of this substring, or -1 if it's not found.
  361. If textToLookFor is an empty string, this will always return -1.
  362. */
  363. int indexOf (int startIndex, StringRef textToLookFor) const noexcept;
  364. /** Searches for a substring within this string.
  365. Uses a case-insensitive comparison.
  366. @returns the index of the first occurrence of this substring, or -1 if it's not found.
  367. If textToLookFor is an empty string, this will always return 0.
  368. */
  369. int indexOfIgnoreCase (StringRef textToLookFor) const noexcept;
  370. /** Searches for a substring within this string.
  371. Uses a case-insensitive comparison.
  372. @param startIndex the index from which the search should proceed
  373. @param textToLookFor the string to search for
  374. @returns the index of the first occurrence of this substring, or -1 if it's not found.
  375. If textToLookFor is an empty string, this will always return -1.
  376. */
  377. int indexOfIgnoreCase (int startIndex, StringRef textToLookFor) const noexcept;
  378. /** Searches for a character inside this string (working backwards from the end of the string).
  379. Uses a case-sensitive comparison.
  380. @returns the index of the last occurrence of the character in this string, or -1 if it's not found.
  381. */
  382. int lastIndexOfChar (water_uchar character) const noexcept;
  383. /** Searches for a substring inside this string (working backwards from the end of the string).
  384. Uses a case-sensitive comparison.
  385. @returns the index of the start of the last occurrence of the substring within this string,
  386. or -1 if it's not found. If textToLookFor is an empty string, this will always return -1.
  387. */
  388. int lastIndexOf (StringRef textToLookFor) const noexcept;
  389. /** Searches for a substring inside this string (working backwards from the end of the string).
  390. Uses a case-insensitive comparison.
  391. @returns the index of the start of the last occurrence of the substring within this string, or -1
  392. if it's not found. If textToLookFor is an empty string, this will always return -1.
  393. */
  394. int lastIndexOfIgnoreCase (StringRef textToLookFor) const noexcept;
  395. /** Returns the index of the last character in this string that matches one of the
  396. characters passed-in to this method.
  397. This scans the string backwards, starting from its end, and if it finds
  398. a character that appears in the string charactersToLookFor, it returns its index.
  399. If none of these characters are found, it returns -1.
  400. If ignoreCase is true, the comparison will be case-insensitive.
  401. @see lastIndexOf, indexOfAnyOf
  402. */
  403. int lastIndexOfAnyOf (StringRef charactersToLookFor,
  404. bool ignoreCase = false) const noexcept;
  405. //==============================================================================
  406. // Substring extraction and manipulation methods..
  407. /** Returns the character at this index in the string.
  408. In a release build, no checks are made to see if the index is within a valid range, so be
  409. careful! In a debug build, the index is checked and an assertion fires if it's out-of-range.
  410. Also beware that depending on the encoding format that the string is using internally, this
  411. method may execute in either O(1) or O(n) time, so be careful when using it in your algorithms.
  412. If you're scanning through a string to inspect its characters, you should never use this operator
  413. for random access, it's far more efficient to call getCharPointer() to return a pointer, and
  414. then to use that to iterate the string.
  415. @see getCharPointer
  416. */
  417. water_uchar operator[] (int index) const noexcept;
  418. /** Returns the final character of the string.
  419. If the string is empty this will return 0.
  420. */
  421. water_uchar getLastCharacter() const noexcept;
  422. //==============================================================================
  423. /** Returns a subsection of the string.
  424. If the range specified is beyond the limits of the string, as much as
  425. possible is returned.
  426. @param startIndex the index of the start of the substring needed
  427. @param endIndex all characters from startIndex up to (but not including)
  428. this index are returned
  429. @see fromFirstOccurrenceOf, dropLastCharacters, getLastCharacters, upToFirstOccurrenceOf
  430. */
  431. String substring (int startIndex, int endIndex) const;
  432. /** Returns a section of the string, starting from a given position.
  433. @param startIndex the first character to include. If this is beyond the end
  434. of the string, an empty string is returned. If it is zero or
  435. less, the whole string is returned.
  436. @returns the substring from startIndex up to the end of the string
  437. @see dropLastCharacters, getLastCharacters, fromFirstOccurrenceOf, upToFirstOccurrenceOf, fromLastOccurrenceOf
  438. */
  439. String substring (int startIndex) const;
  440. /** Returns a version of this string with a number of characters removed
  441. from the end.
  442. @param numberToDrop the number of characters to drop from the end of the
  443. string. If this is greater than the length of the string,
  444. an empty string will be returned. If zero or less, the
  445. original string will be returned.
  446. @see substring, fromFirstOccurrenceOf, upToFirstOccurrenceOf, fromLastOccurrenceOf, getLastCharacter
  447. */
  448. String dropLastCharacters (int numberToDrop) const;
  449. /** Returns a number of characters from the end of the string.
  450. This returns the last numCharacters characters from the end of the string. If the
  451. string is shorter than numCharacters, the whole string is returned.
  452. @see substring, dropLastCharacters, getLastCharacter
  453. */
  454. String getLastCharacters (int numCharacters) const;
  455. //==============================================================================
  456. /** Returns a section of the string starting from a given substring.
  457. This will search for the first occurrence of the given substring, and
  458. return the section of the string starting from the point where this is
  459. found (optionally not including the substring itself).
  460. e.g. for the string "123456", fromFirstOccurrenceOf ("34", true) would return "3456", and
  461. fromFirstOccurrenceOf ("34", false) would return "56".
  462. If the substring isn't found, the method will return an empty string.
  463. If ignoreCase is true, the comparison will be case-insensitive.
  464. @see upToFirstOccurrenceOf, fromLastOccurrenceOf
  465. */
  466. String fromFirstOccurrenceOf (StringRef substringToStartFrom,
  467. bool includeSubStringInResult,
  468. bool ignoreCase) const;
  469. /** Returns a section of the string starting from the last occurrence of a given substring.
  470. Similar to fromFirstOccurrenceOf(), but using the last occurrence of the substring, and
  471. unlike fromFirstOccurrenceOf(), if the substring isn't found, this method will
  472. return the whole of the original string.
  473. @see fromFirstOccurrenceOf, upToLastOccurrenceOf
  474. */
  475. String fromLastOccurrenceOf (StringRef substringToFind,
  476. bool includeSubStringInResult,
  477. bool ignoreCase) const;
  478. /** Returns the start of this string, up to the first occurrence of a substring.
  479. This will search for the first occurrence of a given substring, and then
  480. return a copy of the string, up to the position of this substring,
  481. optionally including or excluding the substring itself in the result.
  482. e.g. for the string "123456", upTo ("34", false) would return "12", and
  483. upTo ("34", true) would return "1234".
  484. If the substring isn't found, this will return the whole of the original string.
  485. @see upToLastOccurrenceOf, fromFirstOccurrenceOf
  486. */
  487. String upToFirstOccurrenceOf (StringRef substringToEndWith,
  488. bool includeSubStringInResult,
  489. bool ignoreCase) const;
  490. /** Returns the start of this string, up to the last occurrence of a substring.
  491. Similar to upToFirstOccurrenceOf(), but this finds the last occurrence rather than the first.
  492. If the substring isn't found, this will return the whole of the original string.
  493. @see upToFirstOccurrenceOf, fromFirstOccurrenceOf
  494. */
  495. String upToLastOccurrenceOf (StringRef substringToFind,
  496. bool includeSubStringInResult,
  497. bool ignoreCase) const;
  498. //==============================================================================
  499. /** Returns a copy of this string with any whitespace characters removed from the start and end. */
  500. String trim() const;
  501. /** Returns a copy of this string with any whitespace characters removed from the start. */
  502. String trimStart() const;
  503. /** Returns a copy of this string with any whitespace characters removed from the end. */
  504. String trimEnd() const;
  505. /** Returns a copy of this string, having removed a specified set of characters from its start.
  506. Characters are removed from the start of the string until it finds one that is not in the
  507. specified set, and then it stops.
  508. @param charactersToTrim the set of characters to remove.
  509. @see trim, trimStart, trimCharactersAtEnd
  510. */
  511. String trimCharactersAtStart (StringRef charactersToTrim) const;
  512. /** Returns a copy of this string, having removed a specified set of characters from its end.
  513. Characters are removed from the end of the string until it finds one that is not in the
  514. specified set, and then it stops.
  515. @param charactersToTrim the set of characters to remove.
  516. @see trim, trimEnd, trimCharactersAtStart
  517. */
  518. String trimCharactersAtEnd (StringRef charactersToTrim) const;
  519. //==============================================================================
  520. /** Returns an upper-case version of this string. */
  521. String toUpperCase() const;
  522. /** Returns an lower-case version of this string. */
  523. String toLowerCase() const;
  524. //==============================================================================
  525. /** Replaces a sub-section of the string with another string.
  526. This will return a copy of this string, with a set of characters
  527. from startIndex to startIndex + numCharsToReplace removed, and with
  528. a new string inserted in their place.
  529. Note that this is a const method, and won't alter the string itself.
  530. @param startIndex the first character to remove. If this is beyond the bounds of the string,
  531. it will be constrained to a valid range.
  532. @param numCharactersToReplace the number of characters to remove. If zero or less, no
  533. characters will be taken out.
  534. @param stringToInsert the new string to insert at startIndex after the characters have been
  535. removed.
  536. */
  537. String replaceSection (int startIndex,
  538. int numCharactersToReplace,
  539. StringRef stringToInsert) const;
  540. /** Replaces all occurrences of a substring with another string.
  541. Returns a copy of this string, with any occurrences of stringToReplace
  542. swapped for stringToInsertInstead.
  543. Note that this is a const method, and won't alter the string itself.
  544. */
  545. String replace (StringRef stringToReplace,
  546. StringRef stringToInsertInstead,
  547. bool ignoreCase = false) const;
  548. /** Returns a string with all occurrences of a character replaced with a different one. */
  549. String replaceCharacter (water_uchar characterToReplace,
  550. water_uchar characterToInsertInstead) const;
  551. /** Replaces a set of characters with another set.
  552. Returns a string in which each character from charactersToReplace has been replaced
  553. by the character at the equivalent position in newCharacters (so the two strings
  554. passed in must be the same length).
  555. e.g. replaceCharacters ("abc", "def") replaces 'a' with 'd', 'b' with 'e', etc.
  556. Note that this is a const method, and won't affect the string itself.
  557. */
  558. String replaceCharacters (StringRef charactersToReplace,
  559. StringRef charactersToInsertInstead) const;
  560. /** Returns a version of this string that only retains a fixed set of characters.
  561. This will return a copy of this string, omitting any characters which are not
  562. found in the string passed-in.
  563. e.g. for "1122334455", retainCharacters ("432") would return "223344"
  564. Note that this is a const method, and won't alter the string itself.
  565. */
  566. String retainCharacters (StringRef charactersToRetain) const;
  567. /** Returns a version of this string with a set of characters removed.
  568. This will return a copy of this string, omitting any characters which are
  569. found in the string passed-in.
  570. e.g. for "1122334455", removeCharacters ("432") would return "1155"
  571. Note that this is a const method, and won't alter the string itself.
  572. */
  573. String removeCharacters (StringRef charactersToRemove) const;
  574. /** Returns a section from the start of the string that only contains a certain set of characters.
  575. This returns the leftmost section of the string, up to (and not including) the
  576. first character that doesn't appear in the string passed in.
  577. */
  578. String initialSectionContainingOnly (StringRef permittedCharacters) const;
  579. /** Returns a section from the start of the string that only contains a certain set of characters.
  580. This returns the leftmost section of the string, up to (and not including) the
  581. first character that occurs in the string passed in. (If none of the specified
  582. characters are found in the string, the return value will just be the original string).
  583. */
  584. String initialSectionNotContaining (StringRef charactersToStopAt) const;
  585. //==============================================================================
  586. /** Checks whether the string might be in quotation marks.
  587. @returns true if the string begins with a quote character (either a double or single quote).
  588. It is also true if there is whitespace before the quote, but it doesn't check the end of the string.
  589. @see unquoted, quoted
  590. */
  591. bool isQuotedString() const;
  592. /** Removes quotation marks from around the string, (if there are any).
  593. Returns a copy of this string with any quotes removed from its ends. Quotes that aren't
  594. at the ends of the string are not affected. If there aren't any quotes, the original string
  595. is returned.
  596. Note that this is a const method, and won't alter the string itself.
  597. @see isQuotedString, quoted
  598. */
  599. String unquoted() const;
  600. /** Adds quotation marks around a string.
  601. This will return a copy of the string with a quote at the start and end, (but won't
  602. add the quote if there's already one there, so it's safe to call this on strings that
  603. may already have quotes around them).
  604. Note that this is a const method, and won't alter the string itself.
  605. @param quoteCharacter the character to add at the start and end
  606. @see isQuotedString, unquoted
  607. */
  608. String quoted (water_uchar quoteCharacter = '"') const;
  609. //==============================================================================
  610. /** Creates a string which is a version of a string repeated and joined together.
  611. @param stringToRepeat the string to repeat
  612. @param numberOfTimesToRepeat how many times to repeat it
  613. */
  614. static String repeatedString (StringRef stringToRepeat,
  615. int numberOfTimesToRepeat);
  616. /** Returns a copy of this string with the specified character repeatedly added to its
  617. beginning until the total length is at least the minimum length specified.
  618. */
  619. String paddedLeft (water_uchar padCharacter, int minimumLength) const;
  620. /** Returns a copy of this string with the specified character repeatedly added to its
  621. end until the total length is at least the minimum length specified.
  622. */
  623. String paddedRight (water_uchar padCharacter, int minimumLength) const;
  624. /** Creates a string from data in an unknown format.
  625. This looks at some binary data and tries to guess whether it's Unicode
  626. or 8-bit characters, then returns a string that represents it correctly.
  627. Should be able to handle Unicode endianness correctly, by looking at
  628. the first two bytes.
  629. */
  630. static String createStringFromData (const void* data, int size);
  631. /** Creates a String from a printf-style parameter list.
  632. I don't like this method. I don't use it myself, and I recommend avoiding it and
  633. using the operator<< methods or pretty much anything else instead. It's only provided
  634. here because of the popular unrest that was stirred-up when I tried to remove it...
  635. If you're really determined to use it, at least make sure that you never, ever,
  636. pass any String objects to it as parameters.
  637. */
  638. static String formatted (const String formatString, ... );
  639. //==============================================================================
  640. // Numeric conversions..
  641. /** Creates a string containing this signed 32-bit integer as a decimal number.
  642. @see getIntValue, getFloatValue, getDoubleValue, toHexString
  643. */
  644. explicit String (int decimalInteger);
  645. /** Creates a string containing this unsigned 32-bit integer as a decimal number.
  646. @see getIntValue, getFloatValue, getDoubleValue, toHexString
  647. */
  648. explicit String (unsigned int decimalInteger);
  649. /** Creates a string containing this signed 16-bit integer as a decimal number.
  650. @see getIntValue, getFloatValue, getDoubleValue, toHexString
  651. */
  652. explicit String (short decimalInteger);
  653. /** Creates a string containing this unsigned 16-bit integer as a decimal number.
  654. @see getIntValue, getFloatValue, getDoubleValue, toHexString
  655. */
  656. explicit String (unsigned short decimalInteger);
  657. /** Creates a string containing this signed 64-bit integer as a decimal number.
  658. @see getLargeIntValue, getFloatValue, getDoubleValue, toHexString
  659. */
  660. explicit String (int64 largeIntegerValue);
  661. /** Creates a string containing this unsigned 64-bit integer as a decimal number.
  662. @see getLargeIntValue, getFloatValue, getDoubleValue, toHexString
  663. */
  664. explicit String (uint64 largeIntegerValue);
  665. /** Creates a string containing this signed long integer as a decimal number.
  666. @see getIntValue, getFloatValue, getDoubleValue, toHexString
  667. */
  668. explicit String (long decimalInteger);
  669. /** Creates a string containing this unsigned long integer as a decimal number.
  670. @see getIntValue, getFloatValue, getDoubleValue, toHexString
  671. */
  672. explicit String (unsigned long decimalInteger);
  673. /** Creates a string representing this floating-point number.
  674. @param floatValue the value to convert to a string
  675. @see getDoubleValue, getIntValue
  676. */
  677. explicit String (float floatValue);
  678. /** Creates a string representing this floating-point number.
  679. @param doubleValue the value to convert to a string
  680. @see getFloatValue, getIntValue
  681. */
  682. explicit String (double doubleValue);
  683. /** Creates a string representing this floating-point number.
  684. @param floatValue the value to convert to a string
  685. @param numberOfDecimalPlaces if this is > 0, it will format the number using that many
  686. decimal places, and will not use exponent notation. If 0 or
  687. less, it will use exponent notation if necessary.
  688. @see getDoubleValue, getIntValue
  689. */
  690. String (float floatValue, int numberOfDecimalPlaces);
  691. /** Creates a string representing this floating-point number.
  692. @param doubleValue the value to convert to a string
  693. @param numberOfDecimalPlaces if this is > 0, it will format the number using that many
  694. decimal places, and will not use exponent notation. If 0 or
  695. less, it will use exponent notation if necessary.
  696. @see getFloatValue, getIntValue
  697. */
  698. String (double doubleValue, int numberOfDecimalPlaces);
  699. /** Reads the value of the string as a decimal number (up to 32 bits in size).
  700. @returns the value of the string as a 32 bit signed base-10 integer.
  701. @see getTrailingIntValue, getHexValue32, getHexValue64
  702. */
  703. int getIntValue() const noexcept;
  704. /** Reads the value of the string as a decimal number (up to 64 bits in size).
  705. @returns the value of the string as a 64 bit signed base-10 integer.
  706. */
  707. int64 getLargeIntValue() const noexcept;
  708. /** Parses a decimal number from the end of the string.
  709. This will look for a value at the end of the string.
  710. e.g. for "321 xyz654" it will return 654; for "2 3 4" it'll return 4.
  711. Negative numbers are not handled, so "xyz-5" returns 5.
  712. @see getIntValue
  713. */
  714. int getTrailingIntValue() const noexcept;
  715. /** Parses this string as a floating point number.
  716. @returns the value of the string as a 32-bit floating point value.
  717. @see getDoubleValue
  718. */
  719. float getFloatValue() const noexcept;
  720. /** Parses this string as a floating point number.
  721. @returns the value of the string as a 64-bit floating point value.
  722. @see getFloatValue
  723. */
  724. double getDoubleValue() const noexcept;
  725. /** Parses the string as a hexadecimal number.
  726. Non-hexadecimal characters in the string are ignored.
  727. If the string contains too many characters, then the lowest significant
  728. digits are returned, e.g. "ffff12345678" would produce 0x12345678.
  729. @returns a 32-bit number which is the value of the string in hex.
  730. */
  731. int getHexValue32() const noexcept;
  732. /** Parses the string as a hexadecimal number.
  733. Non-hexadecimal characters in the string are ignored.
  734. If the string contains too many characters, then the lowest significant
  735. digits are returned, e.g. "ffff1234567812345678" would produce 0x1234567812345678.
  736. @returns a 64-bit number which is the value of the string in hex.
  737. */
  738. int64 getHexValue64() const noexcept;
  739. /** Creates a string representing this 32-bit value in hexadecimal. */
  740. static String toHexString (int number);
  741. /** Creates a string representing this 64-bit value in hexadecimal. */
  742. static String toHexString (int64 number);
  743. /** Creates a string representing this 16-bit value in hexadecimal. */
  744. static String toHexString (short number);
  745. /** Creates a string containing a hex dump of a block of binary data.
  746. @param data the binary data to use as input
  747. @param size how many bytes of data to use
  748. @param groupSize how many bytes are grouped together before inserting a
  749. space into the output. e.g. group size 0 has no spaces,
  750. group size 1 looks like: "be a1 c2 ff", group size 2 looks
  751. like "bea1 c2ff".
  752. */
  753. static String toHexString (const void* data, int size, int groupSize = 1);
  754. //==============================================================================
  755. /** Returns the character pointer currently being used to store this string.
  756. Because it returns a reference to the string's internal data, the pointer
  757. that is returned must not be stored anywhere, as it can be deleted whenever the
  758. string changes.
  759. */
  760. inline CharPointerType getCharPointer() const noexcept { return text; }
  761. /** Returns a pointer to a UTF-8 version of this string.
  762. Because it returns a reference to the string's internal data, the pointer
  763. that is returned must not be stored anywhere, as it can be deleted whenever the
  764. string changes.
  765. To find out how many bytes you need to store this string as UTF-8, you can call
  766. CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer())
  767. @see toRawUTF8, getCharPointer, toUTF16, toUTF32
  768. */
  769. CharPointer_UTF8 toUTF8() const;
  770. /** Returns a pointer to a UTF-8 version of this string.
  771. Because it returns a reference to the string's internal data, the pointer
  772. that is returned must not be stored anywhere, as it can be deleted whenever the
  773. string changes.
  774. To find out how many bytes you need to store this string as UTF-8, you can call
  775. CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer())
  776. @see getCharPointer, toUTF8, toUTF16, toUTF32
  777. */
  778. const char* toRawUTF8() const;
  779. /** */
  780. std::string toStdString() const;
  781. //==============================================================================
  782. /** Creates a String from a UTF-8 encoded buffer.
  783. If the size is < 0, it'll keep reading until it hits a zero.
  784. */
  785. static String fromUTF8 (const char* utf8buffer, int bufferSizeBytes = -1);
  786. /** Returns the number of bytes required to represent this string as UTF8.
  787. The number returned does NOT include the trailing zero.
  788. @see toUTF8, copyToUTF8
  789. */
  790. size_t getNumBytesAsUTF8() const noexcept;
  791. //==============================================================================
  792. /** Copies the string to a buffer as UTF-8 characters.
  793. Returns the number of bytes copied to the buffer, including the terminating null
  794. character.
  795. To find out how many bytes you need to store this string as UTF-8, you can call
  796. CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer())
  797. @param destBuffer the place to copy it to; if this is a null pointer, the method just
  798. returns the number of bytes required (including the terminating null character).
  799. @param maxBufferSizeBytes the size of the destination buffer, in bytes. If the string won't fit, it'll
  800. put in as many as it can while still allowing for a terminating null char at the
  801. end, and will return the number of bytes that were actually used.
  802. @see CharPointer_UTF8::writeWithDestByteLimit
  803. */
  804. size_t copyToUTF8 (CharPointer_UTF8::CharType* destBuffer, size_t maxBufferSizeBytes) const noexcept;
  805. //==============================================================================
  806. /** Increases the string's internally allocated storage.
  807. Although the string's contents won't be affected by this call, it will
  808. increase the amount of memory allocated internally for the string to grow into.
  809. If you're about to make a large number of calls to methods such
  810. as += or <<, it's more efficient to preallocate enough extra space
  811. beforehand, so that these methods won't have to keep resizing the string
  812. to append the extra characters.
  813. @param numBytesNeeded the number of bytes to allocate storage for. If this
  814. value is less than the currently allocated size, it will
  815. have no effect.
  816. */
  817. void preallocateBytes (size_t numBytesNeeded);
  818. /** Swaps the contents of this string with another one.
  819. This is a very fast operation, as no allocation or copying needs to be done.
  820. */
  821. void swapWith (String& other) noexcept;
  822. //==============================================================================
  823. #if 0 //def CARLA_OS_MAC
  824. /** OSX ONLY - Creates a String from an OSX CFString. */
  825. static String fromCFString (CFStringRef cfString);
  826. /** OSX ONLY - Converts this string to a CFString.
  827. Remember that you must use CFRelease() to free the returned string when you're
  828. finished with it.
  829. */
  830. CFStringRef toCFString() const;
  831. #endif
  832. #ifdef CARLA_OS_MAC
  833. /** OSX ONLY - Returns a copy of this string in which any decomposed unicode characters have
  834. been converted to their precomposed equivalents. */
  835. String convertToPrecomposedUnicode() const;
  836. #endif
  837. /** Returns the number of String objects which are currently sharing the same internal
  838. data as this one.
  839. */
  840. int getReferenceCount() const noexcept;
  841. private:
  842. //==============================================================================
  843. CharPointerType text;
  844. //==============================================================================
  845. struct PreallocationBytes
  846. {
  847. explicit PreallocationBytes (size_t) noexcept;
  848. size_t numBytes;
  849. };
  850. explicit String (const PreallocationBytes&); // This constructor preallocates a certain amount of memory
  851. size_t getByteOffsetOfEnd() const noexcept;
  852. };
  853. //==============================================================================
  854. /** Concatenates two strings. */
  855. String operator+ (const char* string1, const String& string2);
  856. /** Concatenates two strings. */
  857. String operator+ (char string1, const String& string2);
  858. /** Concatenates two strings. */
  859. String operator+ (water_uchar string1, const String& string2);
  860. /** Concatenates two strings. */
  861. String operator+ (String string1, const String& string2);
  862. /** Concatenates two strings. */
  863. String operator+ (String string1, const char* string2);
  864. /** Concatenates two strings. */
  865. String operator+ (String string1, char characterToAppend);
  866. /** Concatenates two strings. */
  867. String operator+ (String string1, water_uchar characterToAppend);
  868. //==============================================================================
  869. /** Appends a character at the end of a string. */
  870. String& operator<< (String& string1, char characterToAppend);
  871. /** Appends a character at the end of a string. */
  872. String& operator<< (String& string1, water_uchar characterToAppend);
  873. /** Appends a string to the end of the first one. */
  874. String& operator<< (String& string1, const char* string2);
  875. /** Appends a string to the end of the first one. */
  876. String& operator<< (String& string1, const String& string2);
  877. /** Appends a string to the end of the first one. */
  878. String& operator<< (String& string1, StringRef string2);
  879. /** Appends a decimal number at the end of a string. */
  880. String& operator<< (String& string1, short number);
  881. /** Appends a decimal number at the end of a string. */
  882. String& operator<< (String& string1, int number);
  883. /** Appends a decimal number at the end of a string. */
  884. String& operator<< (String& string1, long number);
  885. /** Appends a decimal number at the end of a string. */
  886. String& operator<< (String& string1, int64 number);
  887. /** Appends a decimal number at the end of a string. */
  888. String& operator<< (String& string1, uint64 number);
  889. /** Appends a decimal number at the end of a string. */
  890. String& operator<< (String& string1, float number);
  891. /** Appends a decimal number at the end of a string. */
  892. String& operator<< (String& string1, double number);
  893. //==============================================================================
  894. /** Case-sensitive comparison of two strings. */
  895. bool operator== (const String& string1, const String& string2) noexcept;
  896. /** Case-sensitive comparison of two strings. */
  897. bool operator== (const String& string1, const char* string2) noexcept;
  898. /** Case-sensitive comparison of two strings. */
  899. bool operator== (const String& string1, const CharPointer_UTF8 string2) noexcept;
  900. /** Case-sensitive comparison of two strings. */
  901. bool operator!= (const String& string1, const String& string2) noexcept;
  902. /** Case-sensitive comparison of two strings. */
  903. bool operator!= (const String& string1, const char* string2) noexcept;
  904. /** Case-sensitive comparison of two strings. */
  905. bool operator!= (const String& string1, const CharPointer_UTF8 string2) noexcept;
  906. /** Case-sensitive comparison of two strings. */
  907. bool operator> (const String& string1, const String& string2) noexcept;
  908. /** Case-sensitive comparison of two strings. */
  909. bool operator< (const String& string1, const String& string2) noexcept;
  910. /** Case-sensitive comparison of two strings. */
  911. bool operator>= (const String& string1, const String& string2) noexcept;
  912. /** Case-sensitive comparison of two strings. */
  913. bool operator<= (const String& string1, const String& string2) noexcept;
  914. //==============================================================================
  915. /** This operator allows you to write a water String directly to std output streams.
  916. This is handy for writing strings to std::cout, std::cerr, etc.
  917. */
  918. template <class traits>
  919. std::basic_ostream <char, traits>& operator<< (std::basic_ostream <char, traits>& stream, const String& stringToWrite)
  920. {
  921. return stream << stringToWrite.toRawUTF8();
  922. }
  923. /** Writes a string to an OutputStream as UTF8. */
  924. OutputStream& operator<< (OutputStream& stream, const String& stringToWrite);
  925. /** Writes a string to an OutputStream as UTF8. */
  926. OutputStream& operator<< (OutputStream& stream, StringRef stringToWrite);
  927. //==============================================================================
  928. struct StartEndString {
  929. StartEndString (String::CharPointerType s, String::CharPointerType e) noexcept : start (s), end (e) {}
  930. operator String() const { return String (start, end); }
  931. String::CharPointerType start, end;
  932. };
  933. }
  934. #include "StringRef.h"
  935. #endif // WATER_STRING_H_INCLUDED