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