-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.h
27 lines (22 loc) · 1.12 KB
/
types.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef VARIABLE_TYPES_H
#define VARIABLE_TYPES_H
#include <stddef.h>
// Structure to map variable types to sizes and conversion functions
typedef struct {
const char* typeName; // The name of the type (e.g., "Binary", "Float")
size_t typeSize; // Size of the type in bytes
void (*convert)(void* value, const char* valueStr); // Function to convert the string to the type
} VariableTypeMap;
// Type conversion functions for different data types
void convertBinary(void* value, const char* valueStr);
void convertByte(void* value, const char* valueStr);
void convert2Bytes(void* value, const char* valueStr);
void convert4Bytes(void* value, const char* valueStr);
void convert8Bytes(void* value, const char* valueStr);
void convertFloat(void* value, const char* valueStr);
void convertDouble(void* value, const char* valueStr);
void convertString(void* value, const char* valueStr);
void convertArrayOfByte(void* value, const char* valueStr);
// Function to convert the value based on the type name
int convertValue(const char* typeName, const char* valueStr, void** value);
#endif // VARIABLE_TYPES_H