Programming I version 1.5.3
Programming I C Library
Loading...
Searching...
No Matches
basedefs.h
Go to the documentation of this file.
1
9#ifndef __BASEDEFS_H__
10#define __BASEDEFS_H__
11
12#include <stdio.h>
13#include <stdlib.h>
14#include <string.h>
15#include <ctype.h>
16#include <math.h>
17#include <time.h>
18#include <stdbool.h>
19
21typedef unsigned char Byte;
22
24typedef char* String;
25
27typedef void* Any;
28
30typedef void* AnyFn;
31
33typedef const void* ConstAny;
34
39typedef struct {
40 int i;
41 int j;
42} IntPair;
43
48typedef struct {
49 int i;
50 int j;
51 int k;
52} IntTriple;
53
58typedef struct {
59 double i;
60 double j;
62
67typedef struct {
68 double i;
69 double j;
70 double k;
72
77typedef struct {
80} AnyPair;
81
86typedef struct {
90} AnyTriple;
91
96typedef struct {
100
105typedef struct {
110
117typedef enum {
118 LT = -1, // less than
119 EQ = 0, // equal
120 GT = 1 // greater than
122
130
131// Option types
132
149typedef struct IntOption {
150 bool none;
151 int some;
153
174
191typedef struct DoubleOption {
192 bool none;
193 double some;
195
206
208// Constructors
209
216IntPair make_int_pair(int i, int j);
217
225IntTriple make_int_triple(int i, int j, int k);
226
233DoublePair make_double_pair(double i, double j);
234
242DoubleTriple make_double_triple(double i, double j, double k);
243
251
260
268
277
283
290
296
303
309
316
322
329
330#endif
331
CmpResult
The possible results of comparing two comparable entities a and b:
Definition basedefs.h:117
@ GT
Definition basedefs.h:120
@ LT
Definition basedefs.h:118
@ EQ
Definition basedefs.h:119
AnyPair make_any_pair(Any a, Any b)
Creates a pair of Anys (on the stack).
StringTriple make_string_triple(String a, String b, String c)
Creates a tuple of three Strings (on the stack).
char * String
A String is a sequence of characters.
Definition basedefs.h:24
IntTriple make_int_triple(int i, int j, int k)
Creates a pair of integers (on the stack).
AnyTriple make_any_triple(Any a, Any b, Any c)
Creates a tuple of three Anys (on the stack).
void * Any
Represents a pointer to an unspecified type.
Definition basedefs.h:27
IntPair make_int_pair(int i, int j)
Creates a pair of integers (on the stack).
const void * ConstAny
Represents a constant pointer to an unspecified type.
Definition basedefs.h:33
IntOption make_int_none(void)
Creates a non-present integer option (on the stack).
StringOption make_string_none(void)
Creates a non-present String option (on the stack).
DoublePair make_double_pair(double i, double j)
Creates a pair of doubles (on the stack).
StringOption make_string_some(String some)
Creates a String option for some value (on the stack).
void * AnyFn
Represents a pointer to a function of an unspecified type.
Definition basedefs.h:30
IntOption make_int_some(int some)
Creates an integer option for some value (on the stack).
ByteOption make_byte_none(void)
Creates a non-present byte option (on the stack).
StringPair make_string_pair(String a, String b)
Creates a pair of Strings (on the stack).
ByteOption make_byte_some(Byte some)
Creates a byte option for some value (on the stack).
DoubleTriple make_double_triple(double i, double j, double k)
Creates a pair of doubles (on the stack).
unsigned char Byte
A Byte represents a single byte of memory.
Definition basedefs.h:21
DoubleOption make_double_none(void)
Creates a non-present double option (on the stack).
CmpResult(* Comparator)(ConstAny a, ConstAny b)
A comparator is a function that take two (comparable) entities, compares them and returns a compariso...
Definition basedefs.h:129
DoubleOption make_double_some(double some)
Creates a double option for some value (on the stack).
A pair of Anys.
Definition basedefs.h:77
Any a
Definition basedefs.h:78
Any b
Definition basedefs.h:79
A tuple of three Anys.
Definition basedefs.h:86
Any c
Definition basedefs.h:89
Any b
Definition basedefs.h:88
Any a
Definition basedefs.h:87
A byte option represents either a byte or nothing.
Definition basedefs.h:170
Byte some
Definition basedefs.h:172
bool none
Definition basedefs.h:171
A double option represents either an double or nothing.
Definition basedefs.h:191
bool none
Definition basedefs.h:192
double some
Definition basedefs.h:193
A pair of doubles.
Definition basedefs.h:58
double j
Definition basedefs.h:60
double i
Definition basedefs.h:59
Three doubles.
Definition basedefs.h:67
double k
Definition basedefs.h:70
double i
Definition basedefs.h:68
double j
Definition basedefs.h:69
An integer option represents either an integer or nothing.
Definition basedefs.h:149
int some
Definition basedefs.h:151
bool none
Definition basedefs.h:150
A pair of integers.
Definition basedefs.h:39
int i
Definition basedefs.h:40
int j
Definition basedefs.h:41
Three integers.
Definition basedefs.h:48
int k
Definition basedefs.h:51
int j
Definition basedefs.h:50
int i
Definition basedefs.h:49
A String option represents either a String or nothing.
Definition basedefs.h:202
bool none
Definition basedefs.h:203
String some
Definition basedefs.h:204
A pair of Strings.
Definition basedefs.h:96
String b
Definition basedefs.h:98
String a
Definition basedefs.h:97
A tuple of three Strings.
Definition basedefs.h:105
String c
Definition basedefs.h:108
String a
Definition basedefs.h:106
String b
Definition basedefs.h:107