57,28 → 57,28 |
int magic; \ |
}; \ |
\ |
int name##_add( name##_ref map, const char * name, type * value ); \ |
int name##_add( name##_ref map, const char * name, const size_t length, type * value ); \ |
int name##_count( name##_ref map ); \ |
void name##_destroy( name##_ref map ); \ |
void name##_exclude( name##_ref map, const char * name ); \ |
type * name##_find( name##_ref map, const char * name ); \ |
void name##_exclude( name##_ref map, const char * name, const size_t length ); \ |
type * name##_find( name##_ref map, const char * name, const size_t length ); \ |
type * name##_get_index( name##_ref map, int index ); \ |
int name##_initialize( name##_ref map ); \ |
int name##_is_valid( name##_ref map ); |
|
|
#define GENERIC_CHAR_MAP_IMPLEMENT( name, type ) \ |
\ |
GENERIC_FIELD_IMPLEMENT( name##_items, type ) \ |
\ |
int name##_add( name##_ref map, const char * name, type * value ){ \ |
int name##_add( name##_ref map, const char * name, const size_t length, type * value ){ \ |
ERROR_DECLARE; \ |
\ |
int index; \ |
\ |
if( ! name##_is_valid( map )) return EINVAL; \ |
index = name##_items_add( & map->values, value ); \ |
if( index < 0 ) return index; \ |
if( ERROR_OCCURED( char_map_add( & map->names, name, index ))){ \ |
if( ERROR_OCCURED( char_map_add( & map->names, name, length, index ))){ \ |
name##_items_exclude_index( & map->values, index ); \ |
return ERROR_CODE; \ |
} \ |
96,11 → 96,11 |
} \ |
} \ |
\ |
void name##_exclude( name##_ref map, const char * name ){ \ |
void name##_exclude( name##_ref map, const char * name, const size_t length ){ \ |
if( name##_is_valid( map )){ \ |
int index; \ |
\ |
index = char_map_exclude( & map->names, name ); \ |
index = char_map_exclude( & map->names, name, length ); \ |
if( index != CHAR_MAP_NULL ){ \ |
name##_items_exclude_index( & map->values, index ); \ |
} \ |
107,11 → 107,11 |
} \ |
} \ |
\ |
type * name##_find( name##_ref map, const char * name ){ \ |
type * name##_find( name##_ref map, const char * name, const size_t length ){ \ |
if( name##_is_valid( map )){ \ |
int index; \ |
\ |
index = char_map_find( & map->names, name ); \ |
index = char_map_find( & map->names, name, length ); \ |
if( index != CHAR_MAP_NULL ){ \ |
return name##_items_get_index( & map->values, index ); \ |
} \ |