libsheepy
libsheepyCSmallContainer.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2023 Remy Noulin
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 #pragma once
23 
24 // Class smallContainer
26 
32 #define helpTextSmallContainer "TODO smallContainer help brief, class description /*, definitions,*/ methods, examples"
33 
34 // for object inheriting smallContainer, cast to smallContainer to be able to use this class functions and generics
35 #define cCo(self) ( (smallContainert*) self )
36 
37 typedef void (*freeSmallContainerFt) (smallContainert *self);
38 typedef void (*terminateSmallContainerFt) (smallContainert **self);
39 typedef char* (*toStringSmallContainerFt) (smallContainert *self);
40 typedef smallContainert* (*duplicateSmallContainerFt) (smallContainert *self);
41 
45 typedef void (*finishSmallContainerFt) (smallContainert **self);
46 
47 typedef const char* (*helpSmallContainerFt) (smallContainert *self);
48 
49 // smallContainer functions
56 typedef void (*dataFreeSmallContainerFt) (void *data);
57 
66 typedef smallContainert* (*setClassDataFreeSmallContainerFt) (smallContainert *self, dataFreeSmallContainerFt free);
67 
74 typedef smallContainert* (*setObjectDataFreeSmallContainerFt) (smallContainert *self, dataFreeSmallContainerFt free);
75 
82 typedef char* (*dataToStringSmallContainerFt) (void *data);
83 
90 typedef smallContainert* (*setClassDataToStringSmallContainerFt) (smallContainert *self, dataToStringSmallContainerFt toString);
91 
98 typedef smallContainert* (*setObjectDataToStringSmallContainerFt) (smallContainert *self, dataToStringSmallContainerFt toString);
99 
106 typedef void* (*dataDuplicateSmallContainerFt) (void *data);
107 
114 typedef smallContainert* (*setClassDataDuplicateSmallContainerFt) (smallContainert *self, dataDuplicateSmallContainerFt duplicate);
115 
122 typedef smallContainert* (*setObjectDataDuplicateSmallContainerFt) (smallContainert *self, dataDuplicateSmallContainerFt duplicate);
123 
127 typedef void (*smashSmallContainerFt) (smallContainert **self);
128 
137 typedef void* (*getSmallContainerFt) (smallContainert *self);
138 
145 typedef smallContainert* (*setSmallContainerFt) (smallContainert *self, void *data);
146 
164 #define SMALLCONTAINERFUNCTIONST \
165  helpSmallContainerFt help;\
166  dataFreeSmallContainerFt dataFree;\
167  setClassDataFreeSmallContainerFt setClassDataFree;\
168  setObjectDataFreeSmallContainerFt setObjectDataFree;\
169  dataToStringSmallContainerFt dataToString;\
170  setClassDataToStringSmallContainerFt setClassDataToString;\
171  setObjectDataToStringSmallContainerFt setObjectDataToString;\
172  dataDuplicateSmallContainerFt dataDuplicate;\
173  setClassDataDuplicateSmallContainerFt setClassDataDuplicate;\
174  setObjectDataDuplicateSmallContainerFt setObjectDataDuplicate;\
175  getSmallContainerFt get;\
176  setSmallContainerFt set
177 
178 typedef struct {
187 
192  const char *type;
194 
200 };
201 
202 // smallContainer
203 
204 #define createSmallContainer(obj) ;smallContainert obj; initiateSmallContainer(&obj)
205 #define createAllocateSmallContainer(obj) ;smallContainert *obj; initiateAllocateSmallContainer(&obj)
206 
209 void finalizeRecycleSmallContainer(void *arg UNUSED);
210 void finalizeSmallContainer(void);
211 
212 // initialize class methods, call registerMethodsSmallContainer from classes inheriting this class
214 
216 
217 // terminate smallContainert val when it is out of scope
219 
220 // free smallContainert local val when it is out of scope
222 
223 // free smallContainert val when it is out of scope
225 
226 // finish smallContainert val when it is out of scope
228 
232 #define cleanSmallContainerP(name) smallContainert *name CLEANUP(cleanUpSmallContainerTerminateG)
233 
237 #define cleanAllocateSmallContainer(obj) ;cleanSmallContainerP(obj); initiateAllocateSmallContainer(&obj)
238 
242 #define cleanSmallContainer(name) smallContainert name CLEANUP(cleanUpSmallContainerFreeLocalG); initiateSmallContainer(&name)
243 
247 #define cleanFreeSmallContainer(name) smallContainert *name CLEANUP(cleanUpSmallContainerFreeG)
248 
252 #define cleanFinishSmallContainerP(name) smallContainert *name CLEANUP(cleanUpSmallContainerFinishG)
253 
255 
257 
258 void* getSmallContainerG(smallContainert *self, void* retType UNUSED, int64_t index UNUSED);
259 
261 
262 // end class smallContainer
free(s)
void(* dataFreeSmallContainerFt)(void *data)
prototype for user provided free function
void(* finishSmallContainerFt)(smallContainert **self)
free container
char *(* dataToStringSmallContainerFt)(void *data)
prototype for user provided toString function
toStringSmallContainerFt toString
void(* smashSmallContainerFt)(smallContainert **self)
free self but not the data inside
char data[7]
Definition: libsheepy.c:19690
smallContainert * allocSmallContainer(void *data)
void cleanUpSmallContainerTerminateG(smallContainert **val)
dataFreeSmallContainerFt dataFree
void * getSmallContainerG(smallContainert *self, void *retType UNUSED, int64_t index UNUSED)
void initiateSmallContainer(smallContainert *self)
void registerMethodsSmallContainer(smallContainerFunctionst *f)
void *(* dataDuplicateSmallContainerFt)(void *data)
prototype for user provided duplicate function
sContainert * data
pointer to data in smallContainer
smallContainert * setSmallContainerG(smallContainert *self, void *data)
dataToStringSmallContainerFt dataToString
smallContainerFunctionst * f
void(* terminateSmallContainerFt)(smallContainert **self)
void finalizeSmallContainer(void)
void initiateAllocateSmallContainer(smallContainert **self)
duplicateSmallContainerFt duplicate
smallContainert *(* duplicateSmallContainerFt)(smallContainert *self)
smallContainert * duplicateSmallContainerG(smallContainert *self)
void cleanUpSmallContainerFreeG(smallContainert **val)
void cleanUpSmallContainerFreeLocalG(smallContainert *val)
char *(* toStringSmallContainerFt)(smallContainert *self)
void cleanUpSmallContainerFinishG(smallContainert **val)
void freeSmallContainerG(smallContainert *self)
#define UNUSED
Definition: libsheepy.h:8195
dataDuplicateSmallContainerFt dataDuplicate
terminateSmallContainerFt terminate
void(* freeSmallContainerFt)(smallContainert *self)
void finalizeRecycleSmallContainer(void *arg UNUSED)