libcomps ..
Loading...
Searching...
No Matches
comps_obj.h
Go to the documentation of this file.
1/* libcomps - C alternative to yum.comps library
2 * Copyright (C) 2013 Jindrich Luza
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17 * USA
18 */
19
20#ifndef COMPS_OBJECT_H
21#define COMPS_OBJECT_H
22
23#include "comps_mm.h"
24
29
37
42
47
52
58
59#define COMPS_OBJECT_CREATE(objtype, args)\
60 (objtype*)comps_object_create(&objtype##_ObjInfo, args)
61
62
63#define COMPS_OBJECT_CMP(obj1,obj2)\
64 comps_object_cmp((COMPS_Object*)obj1, (COMPS_Object*)obj2)
65
66#define COMPS_OBJECT_DESTROY(obj1)\
67 comps_object_destroy((COMPS_Object*)obj1)
68
69#define COMPS_OBJECT_COPY(obj)\
70 comps_object_copy(((COMPS_Object*)obj))
71
72#define COMPS_OBJECT_INCREF(obj)\
73 comps_object_incref(((COMPS_Object*)obj))
74
75#define COMPS_OBJECT_REPLACE(oldobj, TYPE, new_obj)\
76 COMPS_OBJECT_DESTROY(oldobj);\
77 oldobj = (TYPE*)COMPS_OBJECT_INCREF(new_obj);
78
79
80#define COMPS_CAST_CONSTR void (*)(COMPS_Object*, COMPS_Object**)
81#define COMPS_CAST_DESTR void (*)(COMPS_Object*)
82
86#define COMPS_Object_HEAD COMPS_RefC *refc;\
87 COMPS_ObjectInfo *obj_info
88
89#define COMPS_Object_TAIL(obj) extern COMPS_ObjectInfo obj##_ObjInfo
90
91typedef struct COMPS_Object COMPS_Object;
93typedef struct COMPS_Packed COMPS_Packed;
94typedef struct COMPS_Num COMPS_Num;
95typedef struct COMPS_Str COMPS_Str;
96
97
117
128
133struct COMPS_Num {
135 int val;
136};
138
143struct COMPS_Str {
145 char *val;
146};
148
149
159
164void comps_object_destroy_v(void *comps_obj);
175
185char comps_object_cmp_v(void *obj1, void *obj2);
186
196
200
205
211COMPS_Str* comps_str(const char *s);
212
221
227void comps_str_set(COMPS_Str *str, char *s);
228
229//extern COMPS_ObjectInfo COMPS_Num_ObjInfo;
230//extern COMPS_ObjectInfo COMPS_Str_ObjInfo;
231
237signed char comps_str_fnmatch(COMPS_Str *str, char *pattern, int flags);
238
244signed char comps_str_fnmatch_o(COMPS_Str *str, COMPS_Str *pattern, int flags);
245
246#endif
COMPS memory management(reference counter) file.
#define COMPS_Object_HEAD
Definition comps_obj.h:86
COMPS_Num * comps_num(int n)
signed char comps_object_cmp(COMPS_Object *obj1, COMPS_Object *obj2)
void comps_object_destroy(COMPS_Object *comps_obj)
signed char comps_str_fnmatch_o(COMPS_Str *str, COMPS_Str *pattern, int flags)
COMPS_Object * comps_object_create(COMPS_ObjectInfo *obj_info, COMPS_Object **args)
signed char comps_str_fnmatch(COMPS_Str *str, char *pattern, int flags)
COMPS_Str * comps_str_x(char *s)
#define COMPS_Object_TAIL(obj)
insert "extern COMPS_ObjectInfo <obj>_ObjInfo" statement. Use this macro in combination with COMPS_OB...
Definition comps_obj.h:89
char * comps_object_tostr(COMPS_Object *obj1)
COMPS_Object * comps_object_copy(COMPS_Object *comps_obj)
void comps_str_set(COMPS_Str *str, char *s)
COMPS_Object * comps_object_incref(COMPS_Object *obj)
COMPS_Str * comps_str(const char *s)
Definition comps_obj.h:133
int val
Definition comps_obj.h:135
Definition comps_obj.h:102
signed char(* obj_cmp)(COMPS_Object *, COMPS_Object *)
Definition comps_obj.h:112
void(* copy)(COMPS_Object *, COMPS_Object *)
Definition comps_obj.h:108
void(* constructor)(COMPS_Object *, COMPS_Object **)
Definition comps_obj.h:104
size_t obj_size
Definition comps_obj.h:103
void(* destructor)(COMPS_Object *)
Definition comps_obj.h:106
Definition comps_obj.h:124
COMPS_RefC * refc
Definition comps_obj.h:125
COMPS_ObjectInfo * obj_info
Definition comps_obj.h:126
Definition comps_mm.h:36
Definition comps_obj.h:143
char * val
Definition comps_obj.h:145