Add methods _cget.
This commit is contained in:
1 parent
cd1d59264e
commit
aa195f9f6f
2 files changed
+15
-1
No files matched your search
@@ -244,7 +244,7 @@
|
|||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static inline value_type * \
|
static inline value_type * \
|
||||||
M_C(name, _get)(const dict_t map, const key_type key) \
|
M_C(name, _get)(const dict_t map, key_type const key) \
|
||||||
{ \
|
{ \
|
||||||
DICTI_CONTRACT(name, map); \
|
DICTI_CONTRACT(name, map); \
|
||||||
size_t hash = M_GET_HASH key_oplist (key); \
|
size_t hash = M_GET_HASH key_oplist (key); \
|
||||||
@@ -263,6 +263,12 @@
|
|||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
static inline value_type const * \
|
||||||
|
M_C(name, _cget)(const dict_t map, key_type const key) \
|
||||||
|
{ \
|
||||||
|
return M_CONST_CAST(value_type, M_C(name,_get)(map,key)); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
static inline void \
|
static inline void \
|
||||||
M_C(name, _int_resize_up)(dict_t map) \
|
M_C(name, _int_resize_up)(dict_t map) \
|
||||||
{ \
|
{ \
|
||||||
@@ -836,6 +842,12 @@ typedef enum {
|
|||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
static inline value_type const * \
|
||||||
|
M_C(name, _cget)(const dict_t map, key_type const key) \
|
||||||
|
{ \
|
||||||
|
return M_CONST_CAST(value_type, M_C(name,_get)(map,key)); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
M_IF_DEBUG( \
|
M_IF_DEBUG( \
|
||||||
static inline bool \
|
static inline bool \
|
||||||
M_C(name,_int_control_after_resize)(const dict_t h) \
|
M_C(name,_int_control_after_resize)(const dict_t h) \
|
||||||
|
|||||||
@@ -266,6 +266,8 @@ static void test1(void)
|
|||||||
FILE *f = fopen("dict.txt", "rt");
|
FILE *f = fopen("dict.txt", "rt");
|
||||||
if (!f) abort();
|
if (!f) abort();
|
||||||
dict_str_set_at(dict, STRING_CTE("LICENCE"), STRING_CTE("BSD3"));
|
dict_str_set_at(dict, STRING_CTE("LICENCE"), STRING_CTE("BSD3"));
|
||||||
|
assert(string_equal_p(*dict_str_cget(dict, STRING_CTE("LICENCE")), STRING_CTE("BSD3")));
|
||||||
|
|
||||||
while (!feof(f) && !ferror(f)) {
|
while (!feof(f) && !ferror(f)) {
|
||||||
string_fgets(key, f, STRING_READ_PURE_LINE);
|
string_fgets(key, f, STRING_READ_PURE_LINE);
|
||||||
size_t idx = string_search_char(key, ':');
|
size_t idx = string_search_char(key, ':');
|
||||||
|
|||||||
Reference in new issue
Block a user