GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
An iterator for an UTF-8 string. More...
Go to the source code of this file.
Data Structures | |
struct | gp_utf8_pos |
Position in an UTF-8 string. More... | |
Typedefs | |
typedef struct gp_utf8_pos | gp_utf8_pos |
Position in an UTF-8 string. | |
Functions | |
static gp_utf8_pos | gp_utf8_pos_first (void) |
Moves the position to the start of the string. | |
static gp_utf8_pos | gp_utf8_pos_last (const char *str) |
Moves the position to the end of the string. | |
static int | gp_utf8_pos_at_end (const char *str, gp_utf8_pos pos) |
Returns true if the position points to the end of the string. | |
static int | gp_utf8_pos_at_home (gp_utf8_pos pos) |
Returns true if the position points to the start of the string. | |
static int | gp_utf8_pos_eq (gp_utf8_pos a, gp_utf8_pos b) |
Returns true if two positions are equal. | |
static int | gp_utf8_pos_gt (gp_utf8_pos a, gp_utf8_pos b) |
Returns true if position a is greater than position b. | |
static int | gp_utf8_pos_ge (gp_utf8_pos a, gp_utf8_pos b) |
Returns true if position a is greater or equal to position b. | |
static gp_utf8_pos | gp_utf8_pos_sub (gp_utf8_pos a, gp_utf8_pos b) |
Substracts two positions. | |
static gp_utf8_pos | gp_utf8_pos_add (gp_utf8_pos a, gp_utf8_pos b) |
Adds two positions. | |
static gp_utf8_pos | gp_utf8_pos_min (gp_utf8_pos a, gp_utf8_pos b) |
Returns smaller of two positions. | |
static gp_utf8_pos | gp_utf8_pos_max (gp_utf8_pos a, gp_utf8_pos b) |
Returns bigger of two positions. | |
static ssize_t | gp_utf8_pos_move (const char *str, gp_utf8_pos *cur_pos, ssize_t dir) |
Moves a position in a string by dir characters. | |
static uint32_t | gp_utf8_pos_prev (const char *str, gp_utf8_pos *pos) |
Moves a single character towards the string start and returns current character. | |
static uint32_t | gp_utf8_pos_next (const char *str, gp_utf8_pos *pos) |
Moves a single character towards the string end and returns current character. | |
An iterator for an UTF-8 string.
Helper functions to move by whole characters in an UTF-8 string. This is mainly used for maitaining cursor position in an UTF-8 strings.
Definition in file gp_utf_pos.h.
|
inlinestatic |
Adds two positions.
a | A position in a string. |
b | A position in a string. |
Definition at line 149 of file gp_utf_pos.h.
References gp_utf8_pos::bytes, and gp_utf8_pos::chars.
|
inlinestatic |
Returns true if the position points to the end of the string.
str | An UTF-8 string. |
pos | A position in the string. |
Definition at line 73 of file gp_utf_pos.h.
References gp_utf8_pos::bytes.
|
inlinestatic |
Returns true if the position points to the start of the string.
pos | A position in the string. |
Definition at line 84 of file gp_utf_pos.h.
References gp_utf8_pos::bytes.
|
inlinestatic |
Returns true if two positions are equal.
a | A position in a string. |
b | A position in a string. |
Definition at line 96 of file gp_utf_pos.h.
References gp_utf8_pos::bytes.
|
inlinestatic |
Moves the position to the start of the string.
Definition at line 37 of file gp_utf_pos.h.
|
inlinestatic |
Returns true if position a is greater or equal to position b.
a | A position in a string. |
b | A position in a string. |
Definition at line 120 of file gp_utf_pos.h.
References gp_utf8_pos::bytes.
|
inlinestatic |
Returns true if position a is greater than position b.
a | A position in a string. |
b | A position in a string. |
Definition at line 108 of file gp_utf_pos.h.
References gp_utf8_pos::bytes.
|
inlinestatic |
Moves the position to the end of the string.
The position bytes will point exactly to the null byte at the end of the string. The chars counter will be less or equal to bytes.
str | An UTF-8 string. |
Definition at line 51 of file gp_utf_pos.h.
References gp_utf8_pos::bytes, gp_utf8_pos::chars, and gp_utf8_next_chsz().
|
inlinestatic |
Returns bigger of two positions.
a | A position in a string. |
b | A position in a string. |
Definition at line 181 of file gp_utf_pos.h.
References gp_utf8_pos::bytes.
|
inlinestatic |
Returns smaller of two positions.
a | A position in a string. |
b | A position in a string. |
Definition at line 166 of file gp_utf_pos.h.
References gp_utf8_pos::bytes.
|
inlinestatic |
Moves a position in a string by dir characters.
str | An UTF-8 string. |
cur_pos | Pointer to a current position in the UTF-8 string that is going to move. |
dir | A number of characters to move. Negative number moves towards the start, positive towards the end. |
Definition at line 200 of file gp_utf_pos.h.
References gp_utf8_pos::bytes, gp_utf8_pos::chars, gp_utf8_next_chsz(), and gp_utf8_prev_chsz().
|
inlinestatic |
Moves a single character towards the string end and returns current character.
str | An UTF-8 string. |
pos | Pointer to a current position in the UTF-8 string that is going to move. |
Definition at line 277 of file gp_utf_pos.h.
References gp_utf8_pos::bytes, gp_utf8_pos::chars, gp_utf8_next(), and gp_utf8_next_chsz().
|
inlinestatic |
Moves a single character towards the string start and returns current character.
str | An UTF-8 string. |
pos | Pointer to a current position in the UTF-8 string that is going to move. |
Definition at line 249 of file gp_utf_pos.h.
References gp_utf8_pos::bytes, gp_utf8_pos::chars, gp_utf8_next(), and gp_utf8_prev_chsz().
|
inlinestatic |
Substracts two positions.
a | A position in a string. |
b | A position in a string. |
Definition at line 132 of file gp_utf_pos.h.
References gp_utf8_pos::bytes, and gp_utf8_pos::chars.