INGOR
Loading...
Searching...
No Matches
ytType.h
1/*
2 lang/ytType.{h,c} : Type abstraction
3 Copyright (C) 2018, Yoshinori Tamada <tamada A T ytlab.jp>
4 All rights reserved.
5
6 See LICENSE.txt for details of the licensing agreement.
7*/
8#ifndef __YTLIB_TYPE_H
9#define __YTLIB_TYPE_H
10
14typedef enum {
17
20
23
26 ytType_UINT_P,
27
30
31 ytType_DOUBLE_P,
32
35
38
41
44
47
50 ytType_Array_P,
51
54 ytType_IntArray_P,
55
58 ytType_DoubleArray_P,
59
62
65 ytType_StrBuff,
66 ytType_KeyValues,
67 ytType_KeyValues_P,
68 ytType_ParseArgs,
69
70 ytType_Data,
71
72 ytType_Graph,
73 ytType_PGraph,
74 ytType_PCGraph,
75 ytType_CompleteGraph,
76 ytType_AdjGraph,
77 ytType_MapGraph,
78 ytType_DBNGraph,
79
80 ytType_Network,
81 ytType_Node,
82 ytType_Edge,
83
84 ytType_FUNC,
85
86 ytType_VOID_P,
87
88 ytType_Value,
89
92} ytType;
93
94#include <stdio.h>
95#include <stdint.h>
96
97typedef struct ytObject_t ytObject;
98typedef uint8_t ytByte;
99
100typedef ytObject * (*ytType_new_f)();
101typedef void (*ytType_delete_f)(void *);
102typedef ytObject * (*ytType_parse_f)(const char *);
103typedef ytObject * (*ytType_clone_f)(const ytObject *);
104typedef void (*ytType_copy_f)(ytObject *, const ytObject *);
105typedef void (*ytType_print_f)(const ytObject *, FILE *);
106typedef int (*ytType_sprint_f)(const ytObject *, char *, size_t);
107typedef int (*ytType_compare_f)(const ytObject *, const ytObject *);
108typedef void (*ytType_dump_f)(const ytObject *, FILE *);
109typedef size_t (*ytType_size_f)(const ytObject *);
110typedef ytByte * (*ytType_serialize_f)(const ytObject *, ytByte **);
111typedef ytObject * (*ytType_deserialize_f)(ytByte ** const);
112#ifdef USE_MPI
113#include <mpi.h>
114typedef void (*ytType_MPI_Bcast_f)(ytObject **, int, MPI_Comm);
115#else
116typedef void (*ytType_MPI_Bcast_f)(ytObject **);
117#endif
118
119const char * ytType_name(ytType type);
120ytType ytType_parse(const char * name);
121int ytType_super(ytType super, ytType sub);
122ytType_new_f ytType_getNew(ytType type);
123ytType_delete_f ytType_getDelete(ytType type);
124ytType_parse_f ytType_getParse(ytType type);
125ytType_clone_f ytType_getClone(ytType type);
126ytType_copy_f ytType_getCopy(ytType type);
127ytType_print_f ytType_getPrint(ytType type);
128ytType_sprint_f ytType_getSprint(ytType type);
129ytType_compare_f ytType_getCompare(ytType type);
130ytType_dump_f ytType_getDump(ytType type);
131ytType_size_f ytType_getSize(ytType type);
132ytType_serialize_f ytType_getSerialize(ytType type);
133ytType_deserialize_f ytType_getDeserialize(ytType type);
134ytType_MPI_Bcast_f ytType_get_MPI_Bcast(ytType type);
135
136ytObject * ytType_IntArrayParse(const char * str);
137ytObject * ytType_DoubleArrayParse(const char * str);
138ytObject * ytType_StrArrayParse(const char * str);
139
140void ytType_intSerialize2(const int * value, ytByte ** pptr);
141int ytType_intDeserialize2(ytByte ** const ptr);
142void ytType_doubleSerialize2(const double * value, ytByte ** pptr);
143double ytType_doubleDeserialize2(ytByte ** const ptr);
144void ytType_strSerialize2(const char * value, ytByte ** pptr);
145
146
147int ytType_test(int argc, char * argv[]);
148
149#endif /* __YTLIB_TYPE_H */
The basis class.
int ytType_super(ytType super, ytType sub)
Checks if the type is a subclass of the given type.
Definition ytType.c:314
ytType
Types supported by ytLib.
Definition ytType.h:14
ytType_copy_f ytType_getCopy(ytType type)
Returns the copy function for the given type.
Definition ytType.c:361
ytType_new_f ytType_getNew(ytType type)
Returns the default constructor of the given type.
Definition ytType.c:341
const char * ytType_name(ytType type)
Returns the name of the type.
Definition ytType.c:307
ytType_clone_f ytType_getClone(ytType type)
Returns the copy function for the given type.
Definition ytType.c:355
ytType ytType_parse(const char *name)
Returns the ytType value of the given type name.
Definition ytType.c:329
@ ytType_ERROR
For representing errors.
Definition ytType.h:91
@ ytType_SIZE_T_P
primitive size_t *.
Definition ytType.h:43
@ ytType_Object
ytObject.
Definition ytType.h:46
@ ytType_INT_P
primitive int *.
Definition ytType.h:22
@ ytType_DOUBLE
primitive double.
Definition ytType.h:29
@ ytType_CHAR_P
primitive char *.
Definition ytType.h:34
@ ytType_Array
ytArray.
Definition ytType.h:49
@ ytType_StrArray_P
pointer to ytStrArray.
Definition ytType.h:64
@ ytType_NULL
NULL.
Definition ytType.h:16
@ ytType_UINT
primitive unsigned int.
Definition ytType.h:25
@ ytType_INT
primitive int.
Definition ytType.h:19
@ ytType_SIZE_T
primitive size_t.
Definition ytType.h:40
@ ytType_CHAR_PP
primitive char **.
Definition ytType.h:37
@ ytType_IntArray
ytIntArray.
Definition ytType.h:53
@ ytType_DoubleArray
ytDoubleArray.
Definition ytType.h:57
@ ytType_StrArray
ytStrArray.
Definition ytType.h:61