PVRTString.h 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. /*!****************************************************************************
  2. @file PVRTString.h
  3. @copyright Copyright (c) Imagination Technologies Limited.
  4. @brief A string class that can be used as drop-in replacement for
  5. std::string on platforms/compilers that don't provide a full C++
  6. standard library.
  7. ******************************************************************************/
  8. #ifndef _PVRTSTRING_H_
  9. #define _PVRTSTRING_H_
  10. #include <stdio.h>
  11. #define _USING_PVRTSTRING_
  12. /*!***************************************************************************
  13. @class CPVRTString
  14. @brief A string class
  15. *****************************************************************************/
  16. #if defined(_WINDLL_EXPORT)
  17. class __declspec(dllexport) CPVRTString
  18. #elif defined(_WINDLL_IMPORT)
  19. class __declspec(dllimport) CPVRTString
  20. #else
  21. class CPVRTString
  22. #endif
  23. {
  24. private:
  25. // Checking printf and scanf format strings
  26. #if defined(_CC_GNU_) || defined(__GNUG__) || defined(__GNUC__)
  27. #define FX_PRINTF(fmt,arg) __attribute__((format(printf,fmt,arg)))
  28. #define FX_SCANF(fmt,arg) __attribute__((format(scanf,fmt,arg)))
  29. #else
  30. #define FX_PRINTF(fmt,arg)
  31. #define FX_SCANF(fmt,arg)
  32. #endif
  33. public:
  34. typedef size_t size_type;
  35. typedef char value_type;
  36. typedef char& reference;
  37. typedef const char& const_reference;
  38. static const size_type npos;
  39. /*!***********************************************************************
  40. @brief CPVRTString constructor
  41. @param[in] _Ptr A string
  42. @param[in] _Count Length of _Ptr
  43. ************************************************************************/
  44. CPVRTString(const char* _Ptr, size_t _Count = npos);
  45. /*!***********************************************************************
  46. @brief CPVRTString constructor
  47. @param[in] _Right A string
  48. @param[in] _Roff Offset into _Right
  49. @param[in] _Count Number of chars from _Right to assign to the new string
  50. ************************************************************************/
  51. CPVRTString(const CPVRTString& _Right, size_t _Roff = 0, size_t _Count = npos);
  52. /*!***********************************************************************
  53. @brief CPVRTString constructor
  54. @param[in] _Count Length of new string
  55. @param[in] _Ch A char to fill it with
  56. *************************************************************************/
  57. CPVRTString(size_t _Count, const char _Ch);
  58. /*!***********************************************************************
  59. @brief Constructor
  60. @param[in] _Ch A char
  61. *************************************************************************/
  62. CPVRTString(const char _Ch);
  63. /*!***********************************************************************
  64. @brief Constructor
  65. ************************************************************************/
  66. CPVRTString();
  67. /*!***********************************************************************
  68. @brief Destructor
  69. ************************************************************************/
  70. virtual ~CPVRTString();
  71. /*!***********************************************************************
  72. @brief Appends a string
  73. @param[in] _Ptr A string
  74. @return Updated string
  75. *************************************************************************/
  76. CPVRTString& append(const char* _Ptr);
  77. /*!***********************************************************************
  78. @brief Appends a string of length _Count
  79. @param[in] _Ptr A string
  80. @param[in] _Count String length
  81. @return Updated string
  82. *************************************************************************/
  83. CPVRTString& append(const char* _Ptr, size_t _Count);
  84. /*!***********************************************************************
  85. @brief Appends a string
  86. @param[in] _Str A string
  87. @return Updated string
  88. *************************************************************************/
  89. CPVRTString& append(const CPVRTString& _Str);
  90. /*!***********************************************************************
  91. @brief Appends _Count letters of _Str from _Off in _Str
  92. @param[in] _Str A string
  93. @param[in] _Off A position in string
  94. @param[in] _Count Number of letters to append
  95. @return Updated string
  96. *************************************************************************/
  97. CPVRTString& append(const CPVRTString& _Str, size_t _Off, size_t _Count);
  98. /*!***********************************************************************
  99. @brief Appends _Ch _Count times
  100. @param[in] _Ch A char
  101. @param[in] _Count Number of times to append _Ch
  102. @return Updated string
  103. *************************************************************************/
  104. CPVRTString& append(size_t _Count, const char _Ch);
  105. //template<class InputIterator> CPVRTString& append(InputIterator _First, InputIterator _Last);
  106. /*!***********************************************************************
  107. @brief Assigns the string to the string _Ptr
  108. @param[in] _Ptr A string
  109. @return Updated string
  110. *************************************************************************/
  111. CPVRTString& assign(const char* _Ptr);
  112. /*!***********************************************************************
  113. @brief Assigns the string to the string _Ptr
  114. @param[in] _Ptr A string
  115. @param[in] _Count Length of _Ptr
  116. @return Updated string
  117. *************************************************************************/
  118. CPVRTString& assign(const char* _Ptr, size_t _Count);
  119. /*!***********************************************************************
  120. @brief Assigns the string to the string _Str
  121. @param[in] _Str A string
  122. @return Updated string
  123. *************************************************************************/
  124. CPVRTString& assign(const CPVRTString& _Str);
  125. /*!***********************************************************************
  126. @brief Assigns the string to _Count characters in string _Str starting at _Off
  127. @param[in] _Str A string
  128. @param[in] _Off First char to start assignment from
  129. @param[in] _Count Length of _Str
  130. @return Updated string
  131. *************************************************************************/
  132. CPVRTString& assign(const CPVRTString& _Str, size_t _Off, size_t _Count=npos);
  133. /*!***********************************************************************
  134. @brief Assigns the string to _Count copies of _Ch
  135. @param[in] _Ch A string
  136. @param[in] _Count Number of times to repeat _Ch
  137. @return Updated string
  138. *************************************************************************/
  139. CPVRTString& assign(size_t _Count, char _Ch);
  140. //template<class InputIterator> CPVRTString& assign(InputIterator _First, InputIterator _Last);
  141. //const_reference at(size_t _Off) const;
  142. //reference at(size_t _Off);
  143. // const_iterator begin() const;
  144. // iterator begin();
  145. /*!***********************************************************************
  146. @brief Returns a const char* pointer of the string
  147. @return const char* pointer of the string
  148. *************************************************************************/
  149. const char* c_str() const;
  150. /*!***********************************************************************
  151. @brief Returns the size of the character array reserved
  152. @return The size of the character array reserved
  153. *************************************************************************/
  154. size_t capacity() const;
  155. /*!***********************************************************************
  156. @brief Clears the string
  157. *************************************************************************/
  158. void clear();
  159. /*!***********************************************************************
  160. @brief Compares the string with _Str
  161. @param[in] _Str A string to compare with
  162. @return 0 if the strings match
  163. *************************************************************************/
  164. int compare(const CPVRTString& _Str) const;
  165. /*!***********************************************************************
  166. @brief Compares the string with _Str
  167. @param[in] _Pos1 Position to start comparing from
  168. @param[in] _Num1 Number of chars to compare
  169. @param[in] _Str A string to compare with
  170. @return 0 if the strings match
  171. *************************************************************************/
  172. int compare(size_t _Pos1, size_t _Num1, const CPVRTString& _Str) const;
  173. /*!***********************************************************************
  174. @brief Compares the string with _Str
  175. @param[in] _Pos1 Position to start comparing from
  176. @param[in] _Num1 Number of chars to compare
  177. @param[in] _Str A string to compare with
  178. @param[in] _Off Position in _Str to compare from
  179. @param[in] _Count Number of chars in _Str to compare with
  180. @return 0 if the strings match
  181. *************************************************************************/
  182. int compare(size_t _Pos1, size_t _Num1, const CPVRTString& _Str, size_t _Off, size_t _Count) const;
  183. /*!***********************************************************************
  184. @brief Compares the string with _Ptr
  185. @param[in] _Ptr A string to compare with
  186. @return 0 if the strings match
  187. *************************************************************************/
  188. int compare(const char* _Ptr) const;
  189. /*!***********************************************************************
  190. @brief Compares the string with _Ptr
  191. @param[in] _Pos1 Position to start comparing from
  192. @param[in] _Num1 Number of chars to compare
  193. @param[in] _Ptr A string to compare with
  194. @return 0 if the strings match
  195. *************************************************************************/
  196. int compare(size_t _Pos1, size_t _Num1, const char* _Ptr) const;
  197. /*!***********************************************************************
  198. @brief Compares the string with _Str
  199. @param[in] _Pos1 Position to start comparing from
  200. @param[in] _Num1 Number of chars to compare
  201. @param[in] _Ptr A string to compare with
  202. @param[in] _Count Number of chars to compare
  203. @return 0 if the strings match
  204. *************************************************************************/
  205. int compare(size_t _Pos1, size_t _Num1, const char* _Ptr, size_t _Count) const;
  206. /*!***********************************************************************
  207. @brief Less than operator
  208. @param[in] _Str A string to compare with
  209. @return True on success
  210. *************************************************************************/
  211. bool operator<(const CPVRTString & _Str) const;
  212. /*!***********************************************************************
  213. @brief == Operator
  214. @param[in] _Str A string to compare with
  215. @return True if they match
  216. *************************************************************************/
  217. bool operator==(const CPVRTString& _Str) const;
  218. /*!***********************************************************************
  219. @brief == Operator
  220. @param[in] _Ptr A string to compare with
  221. @return True if they match
  222. *************************************************************************/
  223. bool operator==(const char* const _Ptr) const;
  224. /*!***********************************************************************
  225. @brief != Operator
  226. @param[in] _Str A string to compare with
  227. @return True if they don't match
  228. *************************************************************************/
  229. bool operator!=(const CPVRTString& _Str) const;
  230. /*!***********************************************************************
  231. @brief != Operator
  232. @param[in] _Ptr A string to compare with
  233. @return True if they don't match
  234. *************************************************************************/
  235. bool operator!=(const char* const _Ptr) const;
  236. /*!***********************************************************************
  237. @fn copy
  238. @param[in,out] _Ptr A string to copy to
  239. @param[in] _Count Size of _Ptr
  240. @param[in] _Off Position to start copying from
  241. @return Number of bytes copied
  242. @brief Copies the string to _Ptr
  243. *************************************************************************/
  244. size_t copy(char* _Ptr, size_t _Count, size_t _Off = 0) const;
  245. /*!***********************************************************************
  246. @fn data
  247. @return A const char* version of the string
  248. @brief Returns a const char* version of the string
  249. *************************************************************************/
  250. const char* data( ) const;
  251. /*!***********************************************************************
  252. @fn empty
  253. @return True if the string is empty
  254. @brief Returns true if the string is empty
  255. *************************************************************************/
  256. bool empty() const;
  257. // const_iterator end() const;
  258. // iterator end();
  259. //iterator erase(iterator _First, iterator _Last);
  260. //iterator erase(iterator _It);
  261. /*!***********************************************************************
  262. @brief Erases a portion of the string
  263. @param[in] _Pos The position to start erasing from
  264. @param[in] _Count Number of chars to erase
  265. @return An updated string
  266. *************************************************************************/
  267. CPVRTString& erase(size_t _Pos = 0, size_t _Count = npos);
  268. /*!***********************************************************************
  269. @brief Erases a portion of the string
  270. @param[in] _src Character to search
  271. @param[in] _subDes Character to substitute for
  272. @param[in] _all Substitute all
  273. @return An updated string
  274. *************************************************************************/
  275. CPVRTString& substitute(char _src,char _subDes, bool _all = true);
  276. /*!***********************************************************************
  277. @brief Erases a portion of the string
  278. @param[in] _src Character to search
  279. @param[in] _subDes Character to substitute for
  280. @param[in] _all Substitute all
  281. @return An updated string
  282. *************************************************************************/
  283. CPVRTString& substitute(const char* _src, const char* _subDes, bool _all = true);
  284. //size_t find(char _Ch, size_t _Off = 0) const;
  285. //size_t find(const char* _Ptr, size_t _Off = 0) const;
  286. /*!***********************************************************************
  287. @brief Finds a substring within this string.
  288. @param[in] _Ptr String to search.
  289. @param[in] _Off Offset to search from.
  290. @param[in] _Count Number of characters in this string.
  291. @return Position of the first matched string.
  292. *************************************************************************/
  293. size_t find(const char* _Ptr, size_t _Off, size_t _Count) const;
  294. /*!***********************************************************************
  295. @brief Finds a substring within this string.
  296. @param[in] _Str String to search.
  297. @param[in] _Off Offset to search from.
  298. @return Position of the first matched string.
  299. *************************************************************************/
  300. size_t find(const CPVRTString& _Str, size_t _Off = 0) const;
  301. /*!***********************************************************************
  302. @brief Returns the position of the first char that is not _Ch
  303. @param[in] _Ch A char
  304. @param[in] _Off Start position of the find
  305. @return Position of the first char that is not _Ch
  306. *************************************************************************/
  307. size_t find_first_not_of(char _Ch, size_t _Off = 0) const;
  308. /*!***********************************************************************
  309. @brief Returns the position of the first char that is not in _Ptr
  310. @param[in] _Ptr A string
  311. @param[in] _Off Start position of the find
  312. @return Position of the first char that is not in _Ptr
  313. *************************************************************************/
  314. size_t find_first_not_of(const char* _Ptr, size_t _Off = 0) const;
  315. /*!***********************************************************************
  316. @brief Returns the position of the first char that is not in _Ptr
  317. @param[in] _Ptr A string
  318. @param[in] _Off Start position of the find
  319. @param[in] _Count Number of chars in _Ptr
  320. @return Position of the first char that is not in _Ptr
  321. *************************************************************************/
  322. size_t find_first_not_of(const char* _Ptr, size_t _Off, size_t _Count) const;
  323. /*!***********************************************************************
  324. @brief Returns the position of the first char that is not in _Str
  325. @param[in] _Str A string
  326. @param[in] _Off Start position of the find
  327. @return Position of the first char that is not in _Str
  328. *************************************************************************/
  329. size_t find_first_not_of(const CPVRTString& _Str, size_t _Off = 0) const;
  330. /*!***********************************************************************
  331. @brief Returns the position of the first char that is _Ch
  332. @param[in] _Ch A char
  333. @param[in] _Off Start position of the find
  334. @return Position of the first char that is _Ch
  335. *************************************************************************/
  336. size_t find_first_of(char _Ch, size_t _Off = 0) const;
  337. /*!***********************************************************************
  338. @brief Returns the position of the first char that matches a char in _Ptr
  339. @param[in] _Ptr A string
  340. @param[in] _Off Start position of the find
  341. @return Position of the first char that matches a char in _Ptr
  342. *************************************************************************/
  343. size_t find_first_of(const char* _Ptr, size_t _Off = 0) const;
  344. /*!***********************************************************************
  345. @brief Returns the position of the first char that matches a char in _Ptr
  346. @param[in] _Ptr A string
  347. @param[in] _Off Start position of the find
  348. @param[in] _Count Size of _Ptr
  349. @return Position of the first char that matches a char in _Ptr
  350. *************************************************************************/
  351. size_t find_first_of(const char* _Ptr, size_t _Off, size_t _Count) const;
  352. /*!***********************************************************************
  353. @brief Returns the position of the first char that matches all chars in _Ptr
  354. @param[in] _Ptr A string
  355. @param[in] _Off Start position of the find
  356. @param[in] _Count Size of _Ptr
  357. @return Position of the first char that matches a char in _Ptr
  358. *************************************************************************/
  359. size_t find_first_ofn(const char* _Ptr, size_t _Off, size_t _Count) const;
  360. /*!***********************************************************************
  361. @brief Returns the position of the first char that matches a char in _Str
  362. @param[in] _Str A string
  363. @param[in] _Off Start position of the find
  364. @return Position of the first char that matches a char in _Str
  365. *************************************************************************/
  366. size_t find_first_of(const CPVRTString& _Str, size_t _Off = 0) const;
  367. /*!***********************************************************************
  368. @brief Returns the position of the last char that is not _Ch
  369. @param[in] _Ch A char
  370. @param[in] _Off Start position of the find
  371. @return Position of the last char that is not _Ch
  372. *************************************************************************/
  373. size_t find_last_not_of(char _Ch, size_t _Off = 0) const;
  374. /*!***********************************************************************
  375. @brief Returns the position of the last char that is not in _Ptr
  376. @param[in] _Ptr A string
  377. @param[in] _Off Start position of the find
  378. @return Position of the last char that is not in _Ptr
  379. *************************************************************************/
  380. size_t find_last_not_of(const char* _Ptr, size_t _Off = 0) const;
  381. /*!***********************************************************************
  382. @brief Returns the position of the last char that is not in _Ptr
  383. @param[in] _Ptr A string
  384. @param[in] _Off Start position of the find
  385. @param[in] _Count Length of _Ptr
  386. @return Position of the last char that is not in _Ptr
  387. *************************************************************************/
  388. size_t find_last_not_of(const char* _Ptr, size_t _Off, size_t _Count) const;
  389. /*!***********************************************************************
  390. @brief Returns the position of the last char that is not in _Str
  391. @param[in] _Str A string
  392. @param[in] _Off Start position of the find
  393. @return Position of the last char that is not in _Str
  394. *************************************************************************/
  395. size_t find_last_not_of(const CPVRTString& _Str, size_t _Off = 0) const;
  396. /*!***********************************************************************
  397. @brief Returns the position of the last char that is _Ch
  398. @param[in] _Ch A char
  399. @param[in] _Off Start position of the find
  400. @return Position of the last char that is _Ch
  401. *************************************************************************/
  402. size_t find_last_of(char _Ch, size_t _Off = 0) const;
  403. /*!***********************************************************************
  404. @brief Returns the position of the last char that is in _Ptr
  405. @param[in] _Ptr A string
  406. @param[in] _Off Start position of the find
  407. @return Position of the last char that is in _Ptr
  408. *************************************************************************/
  409. size_t find_last_of(const char* _Ptr, size_t _Off = 0) const;
  410. /*!***********************************************************************
  411. @brief Returns the position of the last char that is in _Ptr
  412. @param[in] _Ptr A string
  413. @param[in] _Off Start position of the find
  414. @param[in] _Count Length of _Ptr
  415. @return Position of the last char that is in _Ptr
  416. *************************************************************************/
  417. size_t find_last_of(const char* _Ptr, size_t _Off, size_t _Count) const;
  418. /*!***********************************************************************
  419. @brief Returns the position of the last char that is in _Str
  420. @param[in] _Str A string
  421. @param[in] _Off Start position of the find
  422. @return Position of the last char that is in _Str
  423. *************************************************************************/
  424. size_t find_last_of(const CPVRTString& _Str, size_t _Off = 0) const;
  425. /*!***********************************************************************
  426. @brief Returns the number of occurances of _Ch in the parent string.
  427. @param[in] _Ch A char
  428. @param[in] _Off Start position of the find
  429. @return Number of occurances of _Ch in the parent string.
  430. *************************************************************************/
  431. size_t find_number_of(char _Ch, size_t _Off = 0) const;
  432. /*!***********************************************************************
  433. @brief Returns the number of occurances of _Ptr in the parent string.
  434. @param[in] _Ptr A string
  435. @param[in] _Off Start position of the find
  436. @return Number of occurances of _Ptr in the parent string.
  437. *************************************************************************/
  438. size_t find_number_of(const char* _Ptr, size_t _Off = 0) const;
  439. /*!***********************************************************************
  440. @brief Returns the number of occurances of _Ptr in the parent string.
  441. @param[in] _Ptr A string
  442. @param[in] _Off Start position of the find
  443. @param[in] _Count Size of _Ptr
  444. @return Number of occurances of _Ptr in the parent string.
  445. *************************************************************************/
  446. size_t find_number_of(const char* _Ptr, size_t _Off, size_t _Count) const;
  447. /*!***********************************************************************
  448. @brief Returns the number of occurances of _Str in the parent string.
  449. @param[in] _Str A string
  450. @param[in] _Off Start position of the find
  451. @return Number of occurances of _Str in the parent string.
  452. *************************************************************************/
  453. size_t find_number_of(const CPVRTString& _Str, size_t _Off = 0) const;
  454. /*!***********************************************************************
  455. @brief Returns the next occurance of _Ch in the parent string
  456. after or at _Off. If not found, returns the length of the string.
  457. @param[in] _Ch A char
  458. @param[in] _Off Start position of the find
  459. @return Next occurance of _Ch in the parent string.
  460. *************************************************************************/
  461. int find_next_occurance_of(char _Ch, size_t _Off = 0) const;
  462. /*!***********************************************************************
  463. @brief Returns the next occurance of _Ptr in the parent string
  464. after or at _Off. If not found, returns the length of the string.
  465. @param[in] _Ptr A string
  466. @param[in] _Off Start position of the find
  467. @return Next occurance of _Ptr in the parent string.
  468. *************************************************************************/
  469. int find_next_occurance_of(const char* _Ptr, size_t _Off = 0) const;
  470. /*!***********************************************************************
  471. @brief Returns the next occurance of _Ptr in the parent string
  472. after or at _Off. If not found, returns the length of the string.
  473. @param[in] _Ptr A string
  474. @param[in] _Off Start position of the find
  475. @param[in] _Count Size of _Ptr
  476. @return Next occurance of _Ptr in the parent string.
  477. *************************************************************************/
  478. int find_next_occurance_of(const char* _Ptr, size_t _Off, size_t _Count) const;
  479. /*!***********************************************************************
  480. @brief Returns the next occurance of _Str in the parent string
  481. after or at _Off. If not found, returns the length of the string.
  482. @param[in] _Str A string
  483. @param[in] _Off Start position of the find
  484. @return Next occurance of _Str in the parent string.
  485. *************************************************************************/
  486. int find_next_occurance_of(const CPVRTString& _Str, size_t _Off = 0) const;
  487. /*!***********************************************************************
  488. @brief Returns the previous occurance of _Ch in the parent string
  489. before _Off. If not found, returns -1.
  490. @param[in] _Ch A char
  491. @param[in] _Off Start position of the find
  492. @return Previous occurance of _Ch in the parent string.
  493. *************************************************************************/
  494. int find_previous_occurance_of(char _Ch, size_t _Off = 0) const;
  495. /*!***********************************************************************
  496. @brief Returns the previous occurance of _Ptr in the parent string
  497. before _Off. If not found, returns -1.
  498. @param[in] _Ptr A string
  499. @param[in] _Off Start position of the find
  500. @return Previous occurance of _Ptr in the parent string.
  501. *************************************************************************/
  502. int find_previous_occurance_of(const char* _Ptr, size_t _Off = 0) const;
  503. /*!***********************************************************************
  504. @brief Returns the previous occurance of _Ptr in the parent string
  505. before _Off. If not found, returns -1.
  506. @param[in] _Ptr A string
  507. @param[in] _Off Start position of the find
  508. @param[in] _Count Size of _Ptr
  509. @return Previous occurance of _Ptr in the parent string.
  510. *************************************************************************/
  511. int find_previous_occurance_of(const char* _Ptr, size_t _Off, size_t _Count) const;
  512. /*!***********************************************************************
  513. @brief Returns the previous occurance of _Str in the parent string
  514. before _Off. If not found, returns -1.
  515. @param[in] _Str A string
  516. @param[in] _Off Start position of the find
  517. @return Previous occurance of _Str in the parent string.
  518. *************************************************************************/
  519. int find_previous_occurance_of(const CPVRTString& _Str, size_t _Off = 0) const;
  520. /*!***********************************************************************
  521. @fn left
  522. @param[in] iSize number of characters to return (excluding null character)
  523. @return The leftmost 'iSize' characters of the string.
  524. @brief Returns the leftmost characters of the string (excluding
  525. the null character) in a new CPVRTString. If iSize is
  526. larger than the string, a copy of the original string is returned.
  527. *************************************************************************/
  528. CPVRTString left(size_t iSize) const;
  529. /*!***********************************************************************
  530. @fn right
  531. @param[in] iSize number of characters to return (excluding null character)
  532. @return The rightmost 'iSize' characters of the string.
  533. @brief Returns the rightmost characters of the string (excluding
  534. the null character) in a new CPVRTString. If iSize is
  535. larger than the string, a copy of the original string is returned.
  536. *************************************************************************/
  537. CPVRTString right(size_t iSize) const;
  538. //allocator_type get_allocator( ) const;
  539. //CPVRTString& insert(size_t _P0, const char* _Ptr);
  540. //CPVRTString& insert(size_t _P0, const char* _Ptr, size_t _Count);
  541. //CPVRTString& insert(size_t _P0, const CPVRTString& _Str);
  542. //CPVRTString& insert(size_t _P0, const CPVRTString& _Str, size_t _Off, size_t _Count);
  543. //CPVRTString& insert(size_t _P0, size_t _Count, char _Ch);
  544. //iterator insert(iterator _It, char _Ch = char());
  545. //template<class InputIterator> void insert(iterator _It, InputIterator _First, InputIterator _Last);
  546. //void insert(iterator _It, size_t _Count, char _Ch);
  547. /*!***********************************************************************
  548. @fn length
  549. @return Length of the string
  550. @brief Returns the length of the string
  551. *************************************************************************/
  552. size_t length() const;
  553. /*!***********************************************************************
  554. @fn max_size
  555. @return The maximum number of chars that the string can contain
  556. @brief Returns the maximum number of chars that the string can contain
  557. *************************************************************************/
  558. size_t max_size() const;
  559. /*!***********************************************************************
  560. @fn push_back
  561. @param[in] _Ch A char to append
  562. @brief Appends _Ch to the string
  563. *************************************************************************/
  564. void push_back(char _Ch);
  565. // const_reverse_iterator rbegin() const;
  566. // reverse_iterator rbegin();
  567. // const_reverse_iterator rend() const;
  568. // reverse_iterator rend();
  569. //CPVRTString& replace(size_t _Pos1, size_t _Num1, const char* _Ptr);
  570. //CPVRTString& replace(size_t _Pos1, size_t _Num1, const CPVRTString& _Str);
  571. //CPVRTString& replace(size_t _Pos1, size_t _Num1, const char* _Ptr, size_t _Num2);
  572. //CPVRTString& replace(size_t _Pos1, size_t _Num1, const CPVRTString& _Str, size_t _Pos2, size_t _Num2);
  573. //CPVRTString& replace(size_t _Pos1, size_t _Num1, size_t _Count, char _Ch);
  574. //CPVRTString& replace(iterator _First0, iterator _Last0, const char* _Ptr);
  575. //CPVRTString& replace(iterator _First0, iterator _Last0, const CPVRTString& _Str);
  576. //CPVRTString& replace(iterator _First0, iterator _Last0, const char* _Ptr, size_t _Num2);
  577. //CPVRTString& replace(iterator _First0, iterator _Last0, size_t _Num2, char _Ch);
  578. //template<class InputIterator> CPVRTString& replace(iterator _First0, iterator _Last0, InputIterator _First, InputIterator _Last);
  579. /*!***********************************************************************
  580. @fn reserve
  581. @param[in] _Count Size of string to reserve
  582. @brief Reserves space for _Count number of chars
  583. *************************************************************************/
  584. void reserve(size_t _Count = 0);
  585. /*!***********************************************************************
  586. @fn resize
  587. @param[in] _Count Size of string to resize to
  588. @param[in] _Ch Character to use to fill any additional space
  589. @brief Resizes the string to _Count in length
  590. *************************************************************************/
  591. void resize(size_t _Count, char _Ch = char());
  592. //size_t rfind(char _Ch, size_t _Off = npos) const;
  593. //size_t rfind(const char* _Ptr, size_t _Off = npos) const;
  594. //size_t rfind(const char* _Ptr, size_t _Off = npos, size_t _Count) const;
  595. //size_t rfind(const CPVRTString& _Str, size_t _Off = npos) const;
  596. /*!***********************************************************************
  597. @fn size
  598. @return Size of the string
  599. @brief Returns the size of the string
  600. *************************************************************************/
  601. size_t size() const;
  602. /*!***********************************************************************
  603. @fn substr
  604. @param[in] _Off Start of the substring
  605. @param[in] _Count Length of the substring
  606. @return A substring of the string
  607. @brief Returns the size of the string
  608. *************************************************************************/
  609. CPVRTString substr(size_t _Off = 0, size_t _Count = npos) const;
  610. /*!***********************************************************************
  611. @fn swap
  612. @param[in] _Str A string to swap with
  613. @brief Swaps the contents of the string with _Str
  614. *************************************************************************/
  615. void swap(CPVRTString& _Str);
  616. /*!***********************************************************************
  617. @fn toLower
  618. @return An updated string
  619. @brief Converts the string to lower case
  620. *************************************************************************/
  621. CPVRTString& toLower();
  622. /*!***********************************************************************
  623. @fn toUpper
  624. @return An updated string
  625. @brief Converts the string to upper case
  626. *************************************************************************/
  627. CPVRTString& toUpper();
  628. /*!***********************************************************************
  629. @fn format
  630. @param[in] pFormat A string containing the formating
  631. @return A formatted string
  632. @brief return the formatted string
  633. ************************************************************************/
  634. CPVRTString format(const char *pFormat, ...);
  635. #ifndef UNDER_CE
  636. /*!***********************************************************************
  637. @fn formatPositional
  638. @param[in] pFormat A string containing the formatting.
  639. Positional modifiers may be used.
  640. @return A formatted string
  641. @brief return the formatted string
  642. ************************************************************************/
  643. CPVRTString formatPositional(const char *pFormat, ...);
  644. #endif
  645. /*!***********************************************************************
  646. @brief += Operator
  647. @param[in] _Ch A char
  648. @return An updated string
  649. *************************************************************************/
  650. CPVRTString& operator+=(char _Ch);
  651. /*!***********************************************************************
  652. @brief += Operator
  653. @param[in] _Ptr A string
  654. @return An updated string
  655. *************************************************************************/
  656. CPVRTString& operator+=(const char* _Ptr);
  657. /*!***********************************************************************
  658. @brief += Operator
  659. @param[in] _Right A string
  660. @return An updated string
  661. *************************************************************************/
  662. CPVRTString& operator+=(const CPVRTString& _Right);
  663. /*!***********************************************************************
  664. @brief = Operator
  665. @param[in] _Ch A char
  666. @return An updated string
  667. *************************************************************************/
  668. CPVRTString& operator=(char _Ch);
  669. /*!***********************************************************************
  670. @brief = Operator
  671. @param[in] _Ptr A string
  672. @return An updated string
  673. *************************************************************************/
  674. CPVRTString& operator=(const char* _Ptr);
  675. /*!***********************************************************************
  676. @brief = Operator
  677. @param[in] _Right A string
  678. @return An updated string
  679. *************************************************************************/
  680. CPVRTString& operator=(const CPVRTString& _Right);
  681. /*!***********************************************************************
  682. @brief [] Operator
  683. @param[in] _Off An index into the string
  684. @return A character
  685. *************************************************************************/
  686. const_reference operator[](size_t _Off) const;
  687. /*!***********************************************************************
  688. @brief [] Operator
  689. @param[in] _Off An index into the string
  690. @return A character
  691. *************************************************************************/
  692. reference operator[](size_t _Off);
  693. /*!***********************************************************************
  694. @brief + Operator
  695. @param[in] _Left A string
  696. @param[in] _Right A string
  697. @return An updated string
  698. *************************************************************************/
  699. friend CPVRTString operator+ (const CPVRTString& _Left, const CPVRTString& _Right);
  700. /*!***********************************************************************
  701. @brief + Operator
  702. @param[in] _Left A string
  703. @param[in] _Right A string
  704. @return An updated string
  705. *************************************************************************/
  706. friend CPVRTString operator+ (const CPVRTString& _Left, const char* _Right);
  707. /*!***********************************************************************
  708. @brief + Operator
  709. @param[in] _Left A string
  710. @param[in] _Right A string
  711. @return An updated string
  712. *************************************************************************/
  713. friend CPVRTString operator+ (const CPVRTString& _Left, const char _Right);
  714. /*!***********************************************************************
  715. @brief + Operator
  716. @param[in] _Left A string
  717. @param[in] _Right A string
  718. @return An updated string
  719. *************************************************************************/
  720. friend CPVRTString operator+ (const char* _Left, const CPVRTString& _Right);
  721. /*!***********************************************************************
  722. @brief + Operator
  723. @param[in] _Left A string
  724. @param[in] _Right A string
  725. @return An updated string
  726. *************************************************************************/
  727. friend CPVRTString operator+ (const char _Left, const CPVRTString& _Right);
  728. protected:
  729. char* m_pString;
  730. size_t m_Size;
  731. size_t m_Capacity;
  732. };
  733. /*************************************************************************
  734. * MISCELLANEOUS UTILITY FUNCTIONS
  735. *************************************************************************/
  736. /*!***********************************************************************
  737. @fn PVRTStringGetFileExtension
  738. @param[in] strFilePath A string
  739. @return Extension
  740. @brief Extracts the file extension from a file path.
  741. Returns an empty CPVRTString if no extension is found.
  742. ************************************************************************/
  743. CPVRTString PVRTStringGetFileExtension(const CPVRTString& strFilePath);
  744. /*!***********************************************************************
  745. @fn PVRTStringGetContainingDirectoryPath
  746. @param[in] strFilePath A string
  747. @return Directory
  748. @brief Extracts the directory portion from a file path.
  749. ************************************************************************/
  750. CPVRTString PVRTStringGetContainingDirectoryPath(const CPVRTString& strFilePath);
  751. /*!***********************************************************************
  752. @fn PVRTStringGetFileName
  753. @param[in] strFilePath A string
  754. @return FileName
  755. @brief Extracts the name and extension portion from a file path.
  756. ************************************************************************/
  757. CPVRTString PVRTStringGetFileName(const CPVRTString& strFilePath);
  758. /*!***********************************************************************
  759. @fn PVRTStringStripWhiteSpaceFromStartOf
  760. @param[in] strLine A string
  761. @return Result of the white space stripping
  762. @brief strips white space characters from the beginning of a CPVRTString.
  763. ************************************************************************/
  764. CPVRTString PVRTStringStripWhiteSpaceFromStartOf(const CPVRTString& strLine);
  765. /*!***********************************************************************
  766. @fn PVRTStringStripWhiteSpaceFromEndOf
  767. @param[in] strLine A string
  768. @return Result of the white space stripping
  769. @brief strips white space characters from the end of a CPVRTString.
  770. ************************************************************************/
  771. CPVRTString PVRTStringStripWhiteSpaceFromEndOf(const CPVRTString& strLine);
  772. /*!***********************************************************************
  773. @fn PVRTStringFromFormattedStr
  774. @param[in] pFormat A string containing the formating
  775. @return A formatted string
  776. @brief Creates a formatted string
  777. ************************************************************************/
  778. CPVRTString PVRTStringFromFormattedStr(const char *pFormat, ...);
  779. #ifndef UNDER_CE
  780. /*!***********************************************************************
  781. @Function PVRTStringFromFormattedStrPositional
  782. @Input pFormat A string containing the formatting
  783. with optional positional qualifiers
  784. @Returns A formatted string
  785. @Description Creates a formatted string
  786. ************************************************************************/
  787. CPVRTString PVRTStringFromFormattedStrPositional(const char *pFormat, ...);
  788. #endif
  789. #endif // _PVRTSTRING_H_
  790. /*****************************************************************************
  791. End of file (PVRTString.h)
  792. *****************************************************************************/