Add files via upload
This commit is contained in:
22
type_info.h
Normal file
22
type_info.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef TYPE_INFO_H
|
||||
#define TYPE_INFO_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct TypeInfo {
|
||||
size_t element_size;
|
||||
void (*copy)(void *dest, const void *src);
|
||||
void (*destroy)(void *elem);
|
||||
int (*compare)(const void *a, const void *b); // <0, 0, >0
|
||||
void (*print)(const void *elem);
|
||||
bool (*parse)(void *dest, const char *str); // для ввода
|
||||
const char *type_name;
|
||||
} TypeInfo;
|
||||
|
||||
// static inline используется для создания копии функции в каждом файле
|
||||
static inline bool types_equal(const TypeInfo *a, const TypeInfo *b) {
|
||||
return a == b;
|
||||
}
|
||||
|
||||
#endif // TYPE_INFO_H
|
||||
Reference in New Issue
Block a user