ascii_parse: add function foug_checked_next_chars()
This commit is contained in:
parent
340ed4f117
commit
b41817fcad
@ -14,7 +14,7 @@ void foug_ascii_stream_fwd_iterator_init(foug_ascii_stream_fwd_iterator_t *it)
|
|||||||
foug_next_char(it);
|
foug_next_char(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *foug_current_char(foug_ascii_stream_fwd_iterator_t *it)
|
char *foug_current_char(const foug_ascii_stream_fwd_iterator_t *it)
|
||||||
{
|
{
|
||||||
if (it != NULL && it->buffer_pos < it->buffer.len)
|
if (it != NULL && it->buffer_pos < it->buffer.len)
|
||||||
return it->buffer.ptr + it->buffer_pos;
|
return it->buffer.ptr + it->buffer_pos;
|
||||||
@ -101,3 +101,17 @@ int foug_get_real32(const char *str, foug_real32_t *value_ptr)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foug_bool_t foug_checked_next_chars(foug_ascii_stream_fwd_iterator_t *it, const char *str)
|
||||||
|
{
|
||||||
|
size_t pos = 0;
|
||||||
|
const char* curr_char = foug_current_char(it);
|
||||||
|
foug_bool_t same = curr_char != NULL && *curr_char == *str;
|
||||||
|
|
||||||
|
while (same) {
|
||||||
|
curr_char = foug_next_char(it);
|
||||||
|
same = curr_char != NULL && *curr_char == str[++pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
return same;
|
||||||
|
}
|
||||||
|
@ -22,10 +22,12 @@ typedef struct
|
|||||||
} foug_ascii_stream_fwd_iterator_t;
|
} foug_ascii_stream_fwd_iterator_t;
|
||||||
|
|
||||||
void foug_ascii_stream_fwd_iterator_init(foug_ascii_stream_fwd_iterator_t* it);
|
void foug_ascii_stream_fwd_iterator_init(foug_ascii_stream_fwd_iterator_t* it);
|
||||||
char* foug_current_char(foug_ascii_stream_fwd_iterator_t* it);
|
char* foug_current_char(const foug_ascii_stream_fwd_iterator_t* it);
|
||||||
char* foug_next_char(foug_ascii_stream_fwd_iterator_t* it);
|
|
||||||
void foug_skip_spaces(foug_ascii_stream_fwd_iterator_t* it);
|
void foug_skip_spaces(foug_ascii_stream_fwd_iterator_t* it);
|
||||||
int foug_eat_word(foug_ascii_stream_fwd_iterator_t* it, foug_ascii_string_buffer_t* buffer);
|
int foug_eat_word(foug_ascii_stream_fwd_iterator_t* it, foug_ascii_string_buffer_t* buffer);
|
||||||
int foug_get_real32(const char* str, foug_real32_t* value_ptr);
|
int foug_get_real32(const char* str, foug_real32_t* value_ptr);
|
||||||
|
|
||||||
|
char* foug_next_char(foug_ascii_stream_fwd_iterator_t* it);
|
||||||
|
foug_bool_t foug_checked_next_chars(foug_ascii_stream_fwd_iterator_t* it, const char* str);
|
||||||
|
|
||||||
#endif /* FOUG_INTERNAL_ASCII_PARSE_H */
|
#endif /* FOUG_INTERNAL_ASCII_PARSE_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user