server/src/util/variant.h

42 lines
787 B
C
Raw Normal View History

2017-02-24 15:48:49 +01:00
#pragma once
2010-08-08 10:06:34 +02:00
#ifndef STRUCT_VARIANT_H
#define STRUCT_VARIANT_H
2017-02-24 20:47:31 +01:00
#include <stdbool.h>
2010-08-08 10:06:34 +02:00
#ifdef __cplusplus
extern "C" {
#endif
2011-03-07 08:02:35 +01:00
typedef union variant {
void *v;
2011-03-07 08:02:35 +01:00
int i;
char c;
short s;
short sa[2];
char ca[4];
2011-03-07 08:02:35 +01:00
float f;
} variant;
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
typedef enum variant_type {
VAR_NONE, VAR_INT, VAR_VOIDPTR, VAR_CHAR, VAR_SHORT, VAR_SHORTA, VAR_CHARA,
VAR_FLOAT
} variant_type;
2010-08-08 10:06:34 +02:00
2017-02-24 20:47:31 +01:00
extern const variant frac_zero;
extern const variant frac_one;
variant frac_make(int num, int den);
2017-02-24 15:48:49 +01:00
variant frac_add(variant a, variant b);
2017-02-24 17:55:06 +01:00
variant frac_sub(variant a, variant b);
2017-02-24 15:48:49 +01:00
variant frac_mul(variant a, variant b);
variant frac_div(variant a, variant b);
2017-02-24 20:47:31 +01:00
int frac_sign(variant a);
bool frac_equal(variant a, variant b);
2017-02-24 15:48:49 +01:00
2010-08-08 10:06:34 +02:00
#ifdef __cplusplus
}
#endif
#endif