]> git.sur5r.net Git - glabels/blob - libglabels/db.h
Imported Upstream version 2.2.8
[glabels] / libglabels / db.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2
3 /*
4  *  (LIBGLABELS) Template library for GLABELS
5  *
6  *  db.h:  template db module header file
7  *
8  *  Copyright (C) 2006-2007  Jim Evins <evins@snaught.com>.
9  *
10  *  This file is part of the LIBGLABELS library.
11  *
12  *  This library is free software; you can redistribute it and/or
13  *  modify it under the terms of the GNU Library General Public
14  *  License as published by the Free Software Foundation; either
15  *  version 2 of the License, or (at your option) any later version.
16  *
17  *  This library is distributed in the hope that it will be useful,
18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  *  Library General Public License for more details.
21  *
22  *  You should have received a copy of the GNU Library General Public
23  *  License along with this library; if not, write to the Free
24  *  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25  *  MA 02111-1307, USA
26  */
27
28 #ifndef __DB_H__
29 #define __DB_H__
30
31 #include <glib/gtypes.h>
32 #include <glib/glist.h>
33
34 #include "paper.h"
35 #include "category.h"
36 #include "template.h"
37
38 G_BEGIN_DECLS
39
40 typedef enum
41 {
42         LGL_DB_REG_OK                =  0,
43         LGL_DB_REG_BAD_PAPER_ID      = -1,
44         LGL_DB_REG_BRAND_PART_EXISTS = -2,
45         LGL_DB_REG_FILE_WRITE_ERROR  = -3
46 } lglDbRegStatus;
47
48 /*
49  * Module initialization
50  */
51 void           lgl_db_init                           (void);
52
53
54 /*
55  * Paper
56  */
57 GList         *lgl_db_get_paper_id_list              (void);
58
59 void           lgl_db_free_paper_id_list             (GList               *ids);
60
61 GList         *lgl_db_get_paper_name_list            (void);
62
63 void           lgl_db_free_paper_name_list           (GList               *names);
64
65 lglPaper      *lgl_db_lookup_paper_from_name         (const gchar         *name);
66
67 lglPaper      *lgl_db_lookup_paper_from_id           (const gchar         *id);
68
69 gchar         *lgl_db_lookup_paper_id_from_name      (const gchar         *name);
70
71 gchar         *lgl_db_lookup_paper_name_from_id      (const gchar         *id);
72
73 gboolean       lgl_db_is_paper_id_known              (const gchar         *id);
74
75 gboolean       lgl_db_is_paper_id_other              (const gchar         *id);
76
77
78
79 /*
80  * Template categories
81  */
82 GList         *lgl_db_get_category_id_list           (void);
83
84 void           lgl_db_free_category_id_list          (GList              *ids);
85
86 GList         *lgl_db_get_category_name_list         (void);
87
88 void           lgl_db_free_category_name_list        (GList               *names);
89
90 lglCategory   *lgl_db_lookup_category_from_name      (const gchar         *name);
91
92 lglCategory   *lgl_db_lookup_category_from_id        (const gchar         *id);
93
94 gchar         *lgl_db_lookup_category_id_from_name   (const gchar         *name);
95
96 gchar         *lgl_db_lookup_category_name_from_id   (const gchar         *id);
97
98 gboolean       lgl_db_is_category_id_known           (const gchar         *id);
99
100
101 /*
102  * Template brands
103  */
104 GList         *lgl_db_get_brand_list                 (const gchar         *paper_id,
105                                                       const gchar         *category_id);
106
107 void           lgl_db_free_brand_list                (GList               *brands);
108
109
110 /*
111  * Templates
112  */
113 lglDbRegStatus lgl_db_register_template              (const lglTemplate   *template);
114
115 gboolean       lgl_db_does_template_exist            (const gchar         *brand,
116                                                       const gchar         *part);
117
118 gboolean       lgl_db_does_template_name_exist       (const gchar         *name);
119
120 GList         *lgl_db_get_template_name_list_unique  (const gchar         *brand,
121                                                       const gchar         *paper_id,
122                                                       const gchar         *category_id);
123
124 GList         *lgl_db_get_template_name_list_all     (const gchar         *brand,
125                                                       const gchar         *paper_id,
126                                                       const gchar         *category_id);
127
128 void           lgl_db_free_template_name_list        (GList               *names);
129
130 lglTemplate   *lgl_db_lookup_template_from_name      (const gchar         *name);
131
132
133 /*
134  * Debugging functions
135  */
136 void           lgl_db_print_known_papers             (void);
137
138 void           lgl_db_print_known_categories         (void);
139
140 void           lgl_db_print_known_templates          (void);
141
142 void           lgl_db_print_aliases                  (const lglTemplate    *template);
143
144
145
146 G_END_DECLS
147
148 #endif