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