gmio_core: rename _ascii_ functions and files to _string_
This commit is contained in:
parent
ab3bcd96a9
commit
edf3beca79
@ -139,7 +139,7 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
|
|||||||
add_executable(test_internal EXCLUDE_FROM_ALL tests/stream_buffer.c
|
add_executable(test_internal EXCLUDE_FROM_ALL tests/stream_buffer.c
|
||||||
tests/test_internal.c
|
tests/test_internal.c
|
||||||
src/gmio_core/stream.c
|
src/gmio_core/stream.c
|
||||||
src/gmio_core/internal/ascii_parse.c)
|
src/gmio_core/internal/string_parse.c)
|
||||||
add_executable(test_platform EXCLUDE_FROM_ALL tests/test_platform.c)
|
add_executable(test_platform EXCLUDE_FROM_ALL tests/test_platform.c)
|
||||||
|
|
||||||
add_test(test_internal test_internal)
|
add_test(test_internal test_internal)
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "ascii_parse.h"
|
#include "string_parse.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void gmio_ascii_stream_fwd_iterator_init(gmio_ascii_stream_fwd_iterator_t *it)
|
void gmio_string_stream_fwd_iterator_init(gmio_string_stream_fwd_iterator_t *it)
|
||||||
{
|
{
|
||||||
/* Trick: declaring the buffer exhausted will actually trigger the first call to
|
/* Trick: declaring the buffer exhausted will actually trigger the first call to
|
||||||
* gmio_stream_read() inside gmio_next_char()
|
* gmio_stream_read() inside gmio_next_char()
|
||||||
@ -31,14 +31,14 @@ void gmio_ascii_stream_fwd_iterator_init(gmio_ascii_stream_fwd_iterator_t *it)
|
|||||||
gmio_next_char(it);
|
gmio_next_char(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *gmio_current_char(const gmio_ascii_stream_fwd_iterator_t *it)
|
char *gmio_current_char(const gmio_string_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;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *gmio_next_char(gmio_ascii_stream_fwd_iterator_t *it)
|
char *gmio_next_char(gmio_string_stream_fwd_iterator_t *it)
|
||||||
{
|
{
|
||||||
if (it == NULL)
|
if (it == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -64,14 +64,14 @@ char *gmio_next_char(gmio_ascii_stream_fwd_iterator_t *it)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gmio_skip_spaces(gmio_ascii_stream_fwd_iterator_t *it)
|
void gmio_skip_spaces(gmio_string_stream_fwd_iterator_t *it)
|
||||||
{
|
{
|
||||||
const char* curr_char = gmio_current_char(it);
|
const char* curr_char = gmio_current_char(it);
|
||||||
while (curr_char != NULL && isspace(*curr_char))
|
while (curr_char != NULL && isspace(*curr_char))
|
||||||
curr_char = gmio_next_char(it);
|
curr_char = gmio_next_char(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
int gmio_eat_word(gmio_ascii_stream_fwd_iterator_t *it, gmio_ascii_string_buffer_t *buffer)
|
int gmio_eat_word(gmio_string_stream_fwd_iterator_t *it, gmio_string_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
const char* stream_curr_char = NULL;
|
const char* stream_curr_char = NULL;
|
||||||
int isspace_res = 0;
|
int isspace_res = 0;
|
||||||
@ -119,7 +119,7 @@ int gmio_get_real32(const char *str, gmio_real32_t *value_ptr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gmio_bool_t gmio_checked_next_chars(gmio_ascii_stream_fwd_iterator_t *it, const char *str)
|
gmio_bool_t gmio_checked_next_chars(gmio_string_stream_fwd_iterator_t *it, const char *str)
|
||||||
{
|
{
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
const char* curr_char = gmio_current_char(it);
|
const char* curr_char = gmio_current_char(it);
|
@ -15,37 +15,37 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GMIO_INTERNAL_ASCII_PARSE_H
|
#ifndef GMIO_INTERNAL_STRING_PARSE_H
|
||||||
#define GMIO_INTERNAL_ASCII_PARSE_H
|
#define GMIO_INTERNAL_STRING_PARSE_H
|
||||||
|
|
||||||
#include "../global.h"
|
#include "../global.h"
|
||||||
#include "../stream.h"
|
#include "../stream.h"
|
||||||
|
|
||||||
struct gmio_ascii_string_buffer
|
struct gmio_string_buffer
|
||||||
{
|
{
|
||||||
char* ptr; /*!< Buffer contents */
|
char* ptr; /*!< Buffer contents */
|
||||||
size_t len; /*!< Size(length) of current contents */
|
size_t len; /*!< Size(length) of current contents */
|
||||||
size_t max_len; /*!< Maximum contents size(length) */
|
size_t max_len; /*!< Maximum contents size(length) */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct gmio_ascii_string_buffer gmio_ascii_string_buffer_t;
|
typedef struct gmio_string_buffer gmio_string_buffer_t;
|
||||||
|
|
||||||
struct gmio_ascii_stream_fwd_iterator
|
struct gmio_string_stream_fwd_iterator
|
||||||
{
|
{
|
||||||
gmio_stream_t* stream;
|
gmio_stream_t* stream;
|
||||||
gmio_ascii_string_buffer_t buffer;
|
gmio_string_buffer_t buffer;
|
||||||
size_t buffer_pos; /*!< Position indicator in buffer */
|
size_t buffer_pos; /*!< Position indicator in buffer */
|
||||||
|
|
||||||
void* cookie;
|
void* cookie;
|
||||||
void (*stream_read_hook)(void* cookie, const gmio_ascii_string_buffer_t* str_buffer);
|
void (*stream_read_hook)(void* cookie, const gmio_string_buffer_t* str_buffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct gmio_ascii_stream_fwd_iterator gmio_ascii_stream_fwd_iterator_t;
|
typedef struct gmio_string_stream_fwd_iterator gmio_string_stream_fwd_iterator_t;
|
||||||
|
|
||||||
void gmio_ascii_stream_fwd_iterator_init(gmio_ascii_stream_fwd_iterator_t* it);
|
void gmio_string_stream_fwd_iterator_init(gmio_string_stream_fwd_iterator_t* it);
|
||||||
char* gmio_current_char(const gmio_ascii_stream_fwd_iterator_t* it);
|
char* gmio_current_char(const gmio_string_stream_fwd_iterator_t* it);
|
||||||
void gmio_skip_spaces(gmio_ascii_stream_fwd_iterator_t* it);
|
void gmio_skip_spaces(gmio_string_stream_fwd_iterator_t* it);
|
||||||
int gmio_eat_word(gmio_ascii_stream_fwd_iterator_t* it, gmio_ascii_string_buffer_t* buffer);
|
int gmio_eat_word(gmio_string_stream_fwd_iterator_t* it, gmio_string_buffer_t* buffer);
|
||||||
|
|
||||||
/*! \brief Converts the string pointed to by \p str to gmio_real32_t representation
|
/*! \brief Converts the string pointed to by \p str to gmio_real32_t representation
|
||||||
*
|
*
|
||||||
@ -54,7 +54,7 @@ int gmio_eat_word(gmio_ascii_stream_fwd_iterator_t* it, gmio_ascii_string_buff
|
|||||||
*/
|
*/
|
||||||
int gmio_get_real32(const char* str, gmio_real32_t* value_ptr);
|
int gmio_get_real32(const char* str, gmio_real32_t* value_ptr);
|
||||||
|
|
||||||
char* gmio_next_char(gmio_ascii_stream_fwd_iterator_t* it);
|
char* gmio_next_char(gmio_string_stream_fwd_iterator_t* it);
|
||||||
gmio_bool_t gmio_checked_next_chars(gmio_ascii_stream_fwd_iterator_t* it, const char* str);
|
gmio_bool_t gmio_checked_next_chars(gmio_string_stream_fwd_iterator_t* it, const char* str);
|
||||||
|
|
||||||
#endif /* GMIO_INTERNAL_ASCII_PARSE_H */
|
#endif /* GMIO_INTERNAL_STRING_PARSE_H */
|
@ -21,7 +21,7 @@
|
|||||||
#include "internal/stl_rw_common.h"
|
#include "internal/stl_rw_common.h"
|
||||||
|
|
||||||
#include "../gmio_core/error.h"
|
#include "../gmio_core/error.h"
|
||||||
#include "../gmio_core/internal/ascii_parse.h"
|
#include "../gmio_core/internal/string_parse.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -106,14 +106,14 @@ typedef struct
|
|||||||
{
|
{
|
||||||
gmio_stla_token_t token;
|
gmio_stla_token_t token;
|
||||||
gmio_bool_t error;
|
gmio_bool_t error;
|
||||||
gmio_ascii_stream_fwd_iterator_t stream_iterator;
|
gmio_string_stream_fwd_iterator_t stream_iterator;
|
||||||
_internal_gmio_fwd_iterator_cookie_t stream_iterator_cookie;
|
_internal_gmio_fwd_iterator_cookie_t stream_iterator_cookie;
|
||||||
gmio_ascii_string_buffer_t string_buffer;
|
gmio_string_buffer_t string_buffer;
|
||||||
gmio_stl_mesh_creator_t* creator;
|
gmio_stl_mesh_creator_t* creator;
|
||||||
} gmio_stla_parse_data_t;
|
} gmio_stla_parse_data_t;
|
||||||
|
|
||||||
static void gmio_stream_fwd_iterator_stla_read_hook(void* cookie,
|
static void gmio_stream_fwd_iterator_stla_read_hook(void* cookie,
|
||||||
const gmio_ascii_string_buffer_t* buffer)
|
const gmio_string_buffer_t* buffer)
|
||||||
{
|
{
|
||||||
_internal_gmio_fwd_iterator_cookie_t* tcookie = (_internal_gmio_fwd_iterator_cookie_t*)(cookie);
|
_internal_gmio_fwd_iterator_cookie_t* tcookie = (_internal_gmio_fwd_iterator_cookie_t*)(cookie);
|
||||||
const gmio_task_control_t* ctrl = tcookie != NULL ? tcookie->task_control : NULL;
|
const gmio_task_control_t* ctrl = tcookie != NULL ? tcookie->task_control : NULL;
|
||||||
@ -152,7 +152,7 @@ GMIO_INLINE static void parsing_error(gmio_stla_parse_data_t* data)
|
|||||||
data->string_buffer.ptr);
|
data->string_buffer.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gmio_stla_token_t parsing_find_token(const gmio_ascii_string_buffer_t* str_buffer)
|
static gmio_stla_token_t parsing_find_token(const gmio_string_buffer_t* str_buffer)
|
||||||
{
|
{
|
||||||
const char* word = str_buffer->ptr;
|
const char* word = str_buffer->ptr;
|
||||||
const size_t word_len = str_buffer->len;
|
const size_t word_len = str_buffer->len;
|
||||||
@ -428,7 +428,7 @@ int gmio_stla_read(gmio_stl_mesh_creator_t* creator,
|
|||||||
parse_data.stream_iterator.buffer.max_len = trsf->buffer_size;
|
parse_data.stream_iterator.buffer.max_len = trsf->buffer_size;
|
||||||
parse_data.stream_iterator.cookie = &parse_data.stream_iterator_cookie;
|
parse_data.stream_iterator.cookie = &parse_data.stream_iterator_cookie;
|
||||||
parse_data.stream_iterator.stream_read_hook = gmio_stream_fwd_iterator_stla_read_hook;
|
parse_data.stream_iterator.stream_read_hook = gmio_stream_fwd_iterator_stla_read_hook;
|
||||||
gmio_ascii_stream_fwd_iterator_init(&parse_data.stream_iterator);
|
gmio_string_stream_fwd_iterator_init(&parse_data.stream_iterator);
|
||||||
|
|
||||||
parse_data.string_buffer.ptr = &fixed_buffer[0];
|
parse_data.string_buffer.ptr = &fixed_buffer[0];
|
||||||
parse_data.string_buffer.len = 0;
|
parse_data.string_buffer.len = 0;
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
#include "utest_lib.h"
|
#include "utest_lib.h"
|
||||||
|
|
||||||
#include "../src/gmio_core/internal/ascii_parse.h"
|
|
||||||
#include "../src/gmio_core/internal/byte_swap.h"
|
|
||||||
#include "../src/gmio_core/internal/byte_codec.h"
|
#include "../src/gmio_core/internal/byte_codec.h"
|
||||||
|
#include "../src/gmio_core/internal/byte_swap.h"
|
||||||
|
#include "../src/gmio_core/internal/string_parse.h"
|
||||||
|
|
||||||
#include "stream_buffer.h"
|
#include "stream_buffer.h"
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ const char* test_internal__byte_codec()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* test_internal__ascii_parse()
|
const char* test_internal__string_parse()
|
||||||
{
|
{
|
||||||
char text[] =
|
char text[] =
|
||||||
"Une citation,\to je crois qu'elle est de moi :"
|
"Une citation,\to je crois qu'elle est de moi :"
|
||||||
@ -69,10 +69,10 @@ const char* test_internal__ascii_parse()
|
|||||||
|
|
||||||
char small_fwd_it_str[4];
|
char small_fwd_it_str[4];
|
||||||
char fwd_it_str[32];
|
char fwd_it_str[32];
|
||||||
gmio_ascii_stream_fwd_iterator_t fwd_it = {0};
|
gmio_string_stream_fwd_iterator_t fwd_it = {0};
|
||||||
|
|
||||||
char copy_str[128];
|
char copy_str[128];
|
||||||
gmio_ascii_string_buffer_t copy_strbuff;
|
gmio_string_buffer_t copy_strbuff;
|
||||||
|
|
||||||
buff.ptr = text;
|
buff.ptr = text;
|
||||||
buff.len = strlen(text);
|
buff.len = strlen(text);
|
||||||
@ -82,7 +82,7 @@ const char* test_internal__ascii_parse()
|
|||||||
fwd_it.stream = &stream;
|
fwd_it.stream = &stream;
|
||||||
fwd_it.buffer.ptr = fwd_it_str;
|
fwd_it.buffer.ptr = fwd_it_str;
|
||||||
fwd_it.buffer.max_len = sizeof(fwd_it_str);
|
fwd_it.buffer.max_len = sizeof(fwd_it_str);
|
||||||
gmio_ascii_stream_fwd_iterator_init(&fwd_it);
|
gmio_string_stream_fwd_iterator_init(&fwd_it);
|
||||||
|
|
||||||
copy_strbuff.ptr = copy_str;
|
copy_strbuff.ptr = copy_str;
|
||||||
copy_strbuff.max_len = sizeof(copy_str);
|
copy_strbuff.max_len = sizeof(copy_str);
|
||||||
@ -111,7 +111,7 @@ const char* test_internal__ascii_parse()
|
|||||||
buff.pos = 0;
|
buff.pos = 0;
|
||||||
fwd_it.buffer.ptr = small_fwd_it_str;
|
fwd_it.buffer.ptr = small_fwd_it_str;
|
||||||
fwd_it.buffer.max_len = sizeof(small_fwd_it_str);
|
fwd_it.buffer.max_len = sizeof(small_fwd_it_str);
|
||||||
gmio_ascii_stream_fwd_iterator_init(&fwd_it);
|
gmio_string_stream_fwd_iterator_init(&fwd_it);
|
||||||
|
|
||||||
UTEST_ASSERT(*gmio_current_char(&fwd_it) == 'U');
|
UTEST_ASSERT(*gmio_current_char(&fwd_it) == 'U');
|
||||||
UTEST_ASSERT(gmio_eat_word(&fwd_it, ©_strbuff) == 0);
|
UTEST_ASSERT(gmio_eat_word(&fwd_it, ©_strbuff) == 0);
|
||||||
@ -127,7 +127,7 @@ const char* all_tests()
|
|||||||
UTEST_SUITE_START();
|
UTEST_SUITE_START();
|
||||||
UTEST_RUN(test_internal__byte_swap);
|
UTEST_RUN(test_internal__byte_swap);
|
||||||
UTEST_RUN(test_internal__byte_codec);
|
UTEST_RUN(test_internal__byte_codec);
|
||||||
UTEST_RUN(test_internal__ascii_parse);
|
UTEST_RUN(test_internal__string_parse);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user