Loading...
Searching...
No Matches
comps_doc.h
Go to the documentation of this file.
/* libcomps - C alternative to yum.comps library
* Copyright (C) 2013 Jindrich Luza
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA
*/
#ifndef COMPS_DOC_H
#define COMPS_DOC_H
#include "comps_obj.h"
#include "comps_objdict.h"
#include "comps_objlist.h"
#include "comps_log.h"
#include "comps_types.h"
#include "comps_docgroup.h"
#include "comps_doccategory.h"
#include "comps_docenv.h"
#include "comps_validate.h"
#include "comps_default.h"
#define COMPS_DOC_GETOBJLIST(OBJS) COMPS_ObjList* CONCAT(comps_doc_, OBJS)\
(COMPS_Doc *doc){\
COMPS_ObjList *ret;\
ret = (COMPS_ObjList*)comps_objdict_get(doc->objects, #OBJS);\
if (!ret) {\
ret = COMPS_OBJECT_CREATE(COMPS_ObjList, NULL);\
comps_objdict_set_x(doc->objects, #OBJS, (COMPS_Object*)ret);\
ret = (COMPS_ObjList*)comps_object_incref((COMPS_Object*)ret);\
}\
return ret;\
}
#define HEAD_COMPS_DOC_GETOBJLIST(OBJS) COMPS_ObjList* CONCAT(comps_doc_, OBJS)\
(COMPS_Doc *doc);
#define COMPS_DOC_SETOBJLIST(OBJS) void CONCAT(comps_doc_set_, OBJS)\
(COMPS_Doc *doc,\
COMPS_ObjList *list){\
comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)list);\
}
#define HEAD_COMPS_DOC_SETOBJLIST(OBJS) void CONCAT(comps_doc_set_, OBJS)\
(COMPS_Doc *doc,\
COMPS_ObjList *list);
#define COMPS_DOC_GETOBJDICT(OBJNAME) COMPS_ObjDict* CONCAT(comps_doc_, OBJNAME)\
(COMPS_Doc *doc){\
COMPS_ObjDict *ret;\
ret = (COMPS_ObjDict*)comps_objdict_get(doc->objects, #OBJNAME);\
if (!ret) {\
ret = COMPS_OBJECT_CREATE(COMPS_ObjDict, NULL);\
comps_objdict_set_x(doc->objects, #OBJNAME, (COMPS_Object*)ret);\
ret = (COMPS_ObjDict*)comps_object_incref((COMPS_Object*)ret);\
}\
return ret;\
}
#define HEAD_COMPS_DOC_GETOBJDICT(OBJNAME) COMPS_ObjDict* CONCAT(comps_doc_, OBJNAME)\
(COMPS_Doc *doc);
#define COMPS_DOC_GETOBJMDICT(OBJNAME) COMPS_ObjMDict* CONCAT(comps_doc_, OBJNAME)\
(COMPS_Doc *doc){\
COMPS_ObjMDict *ret;\
ret = (COMPS_ObjMDict*)comps_objdict_get(doc->objects, #OBJNAME);\
if (!ret) {\
ret = COMPS_OBJECT_CREATE(COMPS_ObjMDict, NULL);\
comps_objdict_set_x(doc->objects, #OBJNAME, (COMPS_Object*)ret);\
ret = (COMPS_ObjMDict*)comps_object_incref((COMPS_Object*)ret);\
}\
return ret;\
}
#define HEAD_COMPS_DOC_GETOBJMDICT(OBJNAME) COMPS_ObjMDict* CONCAT(comps_doc_, OBJNAME)\
(COMPS_Doc *doc);
#define COMPS_DOC_SETOBJDICT(OBJS) void CONCAT(comps_doc_set_, OBJS)\
(COMPS_Doc *doc,\
COMPS_ObjDict *dict){\
comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)dict);\
}
#define HEAD_COMPS_DOC_SETOBJDICT(OBJS) void CONCAT(comps_doc_set_, OBJS)\
(COMPS_Doc *doc,\
COMPS_ObjDict *dict);
#define COMPS_DOC_SETOBJMDICT(OBJS) void CONCAT(comps_doc_set_, OBJS)\
(COMPS_Doc *doc,\
COMPS_ObjMDict *dict){\
comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)dict);\
}
#define HEAD_COMPS_DOC_SETOBJMDICT(OBJS) void CONCAT(comps_doc_set_, OBJS)\
(COMPS_Doc *doc,\
COMPS_ObjMDict *dict);
#define COMPS_DOC_ADDOBJLIST(OBJS, OBJNAME, OBJTYPE) void CONCAT(comps_doc_add_,\
OBJNAME)\
(COMPS_Doc *doc,\
OBJTYPE *obj){\
COMPS_ObjList *ret;\
ret = (COMPS_ObjList*)comps_objdict_get(doc->objects, #OBJS);\
if (!ret) {\
ret = COMPS_OBJECT_CREATE(COMPS_ObjList, NULL);\
comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)ret);\
} else {\
}\
comps_objlist_append_x(ret, (COMPS_Object*)obj);\
COMPS_OBJECT_DESTROY(ret);\
}
#define HEAD_COMPS_DOC_ADDOBJLIST(OBJNAME, OBJTYPE) void CONCAT(comps_doc_add_,\
OBJNAME)\
(COMPS_Doc *doc,\
OBJTYPE *obj);
#define COMPS_DOC_ADDOBJDICT(OBJS, OBJNAME) void CONCAT(comps_doc_add_,\
OBJNAME)\
(COMPS_Doc *doc,\
char *key,\
COMPS_Str *obj){\
COMPS_ObjDict *ret;\
ret = (COMPS_ObjDict*)comps_objdict_get(doc->objects, #OBJS);\
if (!ret) {\
ret = COMPS_OBJECT_CREATE(COMPS_ObjDict, NULL);\
comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)ret);\
}\
comps_objdict_set_x(ret, key, (COMPS_Object*)obj);\
COMPS_OBJECT_DESTROY(ret);\
}
#define HEAD_COMPS_DOC_ADDOBJDICT(OBJNAME) void CONCAT(comps_doc_add_,\
OBJNAME)\
(COMPS_Doc *doc,\
char *key,\
COMPS_Str *obj);
#define COMPS_DOC_ADDOBJMDICT(OBJS, OBJNAME) void CONCAT(comps_doc_add_,\
OBJNAME)\
(COMPS_Doc *doc,\
char *key,\
COMPS_Str *obj){\
COMPS_ObjMDict *ret;\
ret = (COMPS_ObjMDict*)comps_objdict_get(doc->objects, #OBJS);\
if (!ret) {\
ret = COMPS_OBJECT_CREATE(COMPS_ObjMDict, NULL);\
comps_objdict_set(doc->objects, #OBJS, (COMPS_Object*)ret);\
}\
comps_objmdict_set_x(ret, key, (COMPS_Object*)obj);\
COMPS_OBJECT_DESTROY(ret);\
}
#define HEAD_COMPS_DOC_ADDOBJMDICT(OBJNAME) void CONCAT(comps_doc_add_,\
OBJNAME)\
(COMPS_Doc *doc,\
char *key,\
COMPS_Str *obj);
#define COMPS_DOC_GETPROP(OBJ,TYPE) CONCAT(TYPE,CONCAT(* ,CONCAT(comps_doc_, OBJ)))\
(COMPS_Doc *doc){\
TYPE *ret;\
ret = (COMPS_Str*)comps_objdict_get(doc->objects, #OBJ);\
if (!ret) {\
ret = COMPS_OBJECT_CREATE(TYPE, NULL);\
comps_objdict_set_x(doc->objects, #OBJ, (COMPS_Object*)ret);\
ret = (TYPE*)comps_object_incref((COMPS_Object*)ret);\
}\
return ret;\
}
#define HEAD_COMPS_DOC_GETPROP(OBJ, TYPE) CONCAT(TYPE,CONCAT(*,CONCAT(comps_doc_, OBJS)))\
(COMPS_Doc *doc);
#define COMPS_DOC_SETPROP(OBJ, TYPE) void CONCAT(comps_doc_set_, OBJ)\
(COMPS_Doc *doc,\
TYPE *value){\
comps_objdict_set(doc->objects, #OBJ, (COMPS_Object*)value);\
}
#define HEAD_COMPS_DOC_SETPROP(OBJ, TYPE) void CONCAT(comps_doc_set_, OBJ)\
(COMPS_Doc *doc,\
TYPE *value);
typedef struct {
COMPS_Object_HEAD;
COMPS_ObjDict *objects;
COMPS_Log *log;
COMPS_Str *encoding;
COMPS_Str *doctype_name;
COMPS_Str *doctype_sysid;
COMPS_Str *doctype_pubid;
COMPS_Str *lang;
} COMPS_Doc;
COMPS_Object_TAIL(COMPS_Doc);
//HEAD_COMPS_CREATE_u(doc, COMPS_Doc) /*comps_utils.h macro*/
//HEAD_COMPS_COPY_u(doc, COMPS_Doc) /*comps_utils.h macro*/
//HEAD_COMPS_DESTROY_u(doc, COMPS_Doc) /*comps_utils.h macro*/
void comps_doc_create(COMPS_Doc* doc, COMPS_Object **args);
void comps_doc_copy(COMPS_Doc *doc_dst, COMPS_Doc *doc_src);
void comps_doc_destroy(COMPS_Doc *doc);
signed char comps_doc_cmp_u(COMPS_Object *obj1, COMPS_Object *obj2);
HEAD_COMPS_DOC_GETOBJLIST(groups) /*comps_doc.h macro*/
HEAD_COMPS_DOC_GETOBJLIST(categories) /*comps_doc.h macro*/
HEAD_COMPS_DOC_GETOBJLIST(environments) /*comps_doc.h macro*/
HEAD_COMPS_DOC_GETOBJDICT(langpacks) /*comps_doc.h macro*/
HEAD_COMPS_DOC_GETOBJMDICT(blacklist) /*comps_doc.h macro*/
HEAD_COMPS_DOC_GETOBJMDICT(whiteout) /*comps_doc.h macro*/
HEAD_COMPS_DOC_SETOBJLIST(groups) /*comps_doc.h macro*/
HEAD_COMPS_DOC_SETOBJLIST(categories) /*comps_doc.h macro*/
HEAD_COMPS_DOC_SETOBJLIST(environments) /*comps_doc.h macro*/
HEAD_COMPS_DOC_SETOBJDICT(langpacks) /*comps_doc.h macro*/
HEAD_COMPS_DOC_SETOBJMDICT(blacklist) /*comps_doc.h macro*/
HEAD_COMPS_DOC_SETOBJMDICT(whiteout) /*comps_doc.h macro*/
HEAD_COMPS_DOC_ADDOBJLIST(group, COMPS_DocGroup) /*comps_doc.h macro*/
HEAD_COMPS_DOC_ADDOBJLIST(category, COMPS_DocCategory) /*comps_doc.h macro*/
HEAD_COMPS_DOC_ADDOBJLIST(environment, COMPS_DocEnv) /*comps_doc.h macro*/
HEAD_COMPS_DOC_ADDOBJDICT(langpack) /*comps_doc.h macro*/
HEAD_COMPS_DOC_ADDOBJMDICT(blacklist) /*comps_doc.h macro*/
HEAD_COMPS_DOC_ADDOBJMDICT(whiteout) /*comps_doc.h macro*/
HEAD_COMPS_DOC_SETPROP(lang, COMPS_Str) /*comps_doc.h macro*/
COMPS_ObjList* comps_doc_get_groups(COMPS_Doc *doc, char *id, char *name,
char *desc, char *lang, int flags);
COMPS_ObjList* comps_doc_get_categories(COMPS_Doc *doc, char *id, char *name,
char *desc, char *lang, int flags);
COMPS_ObjList* comps_doc_get_envs(COMPS_Doc *doc, char *id, char *name,
char *desc, char *lang, int flags);
//char* comps_doc_xml_str(COMPS_Doc* doc, char *enc, COMPS_Log *log);
//static signed char comps_doc_xml(COMPS_Doc *doc, xmlTextWriterPtr writer);
signed char comps2xml_f(COMPS_Doc * doc, char *filename, char stdoutredirect,
COMPS_XMLOptions *xml_options,
COMPS_DefaultsOptions *def_options);
char* comps2xml_str(COMPS_Doc *doc, COMPS_XMLOptions *options,
COMPS_DefaultsOptions *def_options);
COMPS_Doc* comps_doc_union(COMPS_Doc *c1, COMPS_Doc *c2);
COMPS_Doc* comps_doc_intersect(COMPS_Doc *c1, COMPS_Doc *c2);
COMPS_Doc* comps_doc_arch_filter(COMPS_Doc *source, COMPS_ObjList *arches);
COMPS_Str* comps_doc_doctype_name_get(COMPS_Doc* doc);
COMPS_Str* comps_doc_doctype_pubid_get(COMPS_Doc* doc);
COMPS_Str* comps_doc_doctype_sysid_get(COMPS_Doc* doc);
void comps_doc_doctype_name_set(COMPS_Doc* doc, COMPS_Str *val);
void comps_doc_doctype_sysid_set(COMPS_Doc* doc, COMPS_Str *val);
void comps_doc_doctype_pubid_set(COMPS_Doc* doc, COMPS_Str *val);
//extern COMPS_ObjectInfo COMPS_Doc_ObjInfo;
extern COMPS_ValRuleGeneric* COMPS_Doc_ValidateRules[];
#endif //COMPS_DOC_H
comps2xml_str
char * comps2xml_str(COMPS_Doc *doc, COMPS_XMLOptions *options, COMPS_DefaultsOptions *def_options)
comps_doc_union
COMPS_Doc * comps_doc_union(COMPS_Doc *c1, COMPS_Doc *c2)
comps_doc_create
void comps_doc_create(COMPS_Doc *doc, COMPS_Object **args)
comps_doc_copy
void comps_doc_copy(COMPS_Doc *doc_dst, COMPS_Doc *doc_src)
comps_doc_destroy
void comps_doc_destroy(COMPS_Doc *doc)
comps2xml_f
signed char comps2xml_f(COMPS_Doc *doc, char *filename, char stdoutredirect, COMPS_XMLOptions *xml_options, COMPS_DefaultsOptions *def_options)
comps_doc_cmp_u
signed char comps_doc_cmp_u(COMPS_Object *obj1, COMPS_Object *obj2)
comps_doccategory.h
COMPS_DocCategory header file.
comps_docenv.h
COMPS_DocEnv header file.
comps_docgroup.h
COMPS_DocGroup header file.
comps_obj.h
COMPS_Object header file.
COMPS_Object_HEAD
#define COMPS_Object_HEAD
Definition comps_obj.h:86
COMPS_Object_TAIL
#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
comps_objdict.h
Libcomps dictionary and multi-dictionary. COMPS_ObjDict and COMPS_ObjMDict are both derivates of COMP...
comps_objlist.h
A Documented file. Details.
COMPS_DocCategory
Definition comps_doccategory.h:49
COMPS_DocEnv
Definition comps_docenv.h:18
COMPS_DocGroup
Definition comps_docgroup.h:49
COMPS_Doc
Definition comps_doc.h:229
COMPS_Doc::encoding
COMPS_Str * encoding
Definition comps_doc.h:235
COMPS_Doc::objects
COMPS_ObjDict * objects
Definition comps_doc.h:231
COMPS_Doc::log
COMPS_Log * log
Definition comps_doc.h:232
COMPS_ObjList
Definition comps_objlist.h:41
COMPS_Object
Definition comps_obj.h:124
COMPS_Str
Definition comps_obj.h:143