Characters Cursor. More...
#include <rstring.h>
Public Member Functions | |
RCharCursor (void) | |
RCharCursor (const RString &src, size_t min=0, size_t max=SIZE_MAX) | |
void | Set (const RString &src, size_t min=0, size_t max=SIZE_MAX) |
void | Start (void) |
void | StartFromEnd (void) |
void | GoTo (size_t idx) |
size_t | GetNb (void) |
size_t | GetPos (void) |
bool | Begin (void) const |
bool | End (void) const |
void | Next (size_t inc=1) |
void | Prev (size_t inc=1) |
RChar | operator() (void) const |
RChar | operator[] (size_t idx) const |
const RChar * | GetCurrent (void) const |
Private Attributes | |
const RChar * | Current |
size_t | ActPtr |
const RString * | Str |
size_t | CurNbPtr |
size_t | FirstPtr |
size_t | LastPtr |
Detailed Description
Characters Cursor.
This class represent a cursor to iterate a RString. When the string parsed by the cursor is modified, the cursor is not valid anymore.
Here is an example of a cursor used:
Constructor & Destructor Documentation
RCharCursor | ( | void | ) |
Construct the cursor.
RCharCursor | ( | const RString & | src, |
size_t | min = 0 , |
||
size_t | max = SIZE_MAX |
||
) |
Construct the cursor. param src String to iterate.
- Parameters
-
min Minimum position of the string to iterate. max Maximum position of the string to iterate (included max). If SIZE_MAX, iterate until the end of the string.
Member Function Documentation
Set the string and start the iterator. param src String to iterate.
- Parameters
-
min Minimum position of the string to iterate. max Maximum position of the string to iterate (included max). If SIZE_MAX, iterate until the end of the string.
void Start | ( | void | ) |
Start the iterator to go trough the string.
void StartFromEnd | ( | void | ) |
Start the iterator at the end of the string.
void GoTo | ( | size_t | idx | ) |
Go to the i-th character of the string.
- Parameters
-
idx Index of the character.
size_t GetNb | ( | void | ) |
Return the number of characters in the string.
size_t GetPos | ( | void | ) |
Return the position of the cursor in the string.
bool Begin | ( | void | ) | const |
Test if the begin of the cursor is reached.
bool End | ( | void | ) | const |
Test if the end of the string is reached.
void Next | ( | size_t | inc = 1 | ) |
Goto the next character, if the end is reached, go to the beginning.
- Parameters
-
inc Number of elements to go to.
void Prev | ( | size_t | inc = 1 | ) |
Go to a given number of previous elements. If the begin is reached, go to the end.
- Parameters
-
inc Number of elements to go to.
RChar operator() | ( | void | ) | const |
Return the current character.
RChar operator[] | ( | size_t | idx | ) | const |
This function returns the character at a given position in the string iterated.
- Parameters
-
idx Index of the character.
- Returns
- RChar.
const RChar* GetCurrent | ( | void | ) | const |
Get the pointer to the current place of the string.
- Returns
- a constant pointer on the current character.
Field Documentation
|
private |
This variable is used to go through the container.
|
private |
This variable is used to see if the end of the string is reached.
|
private |
A Pointer to the string used.
|
private |
The number of characters in the cursor.
|
private |
The first position in the string handled by the cursor.
|
private |
The last position in the string handled by the cursor.