2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2004 Free Software Foundation
4 Written by John Darrington
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #ifndef __PSPPIRE_DICT_H__
23 #define __PSPPIRE_DICT_H__
26 #include <glib-object.h>
29 #include <data/dictionary.h>
30 #include <data/variable.h>
36 /* --- type macros --- */
37 #define G_TYPE_PSPPIRE_DICT (psppire_dict_get_type ())
38 #define PSPPIRE_DICT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_PSPPIRE_DICT, PsppireDict))
39 #define PSPPIRE_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_PSPPIRE_DICT, PsppireDictClass))
40 #define G_IS_PSPPIRE_DICT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_PSPPIRE_DICT))
41 #define G_IS_PSPPIRE_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_PSPPIRE_DICT))
42 #define PSPPIRE_DICT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_PSPPIRE_DICT, PsppireDictClass))
46 /* --- typedefs & structures --- */
47 typedef struct _PsppireDict PsppireDict;
48 typedef struct _PsppireDictClass PsppireDictClass;
53 struct dictionary *dict;
55 /* Cache of variables */
56 struct PsppireVariable **variables;
61 struct _PsppireDictClass
63 GObjectClass parent_class;
68 /* -- PsppireDict --- */
69 GType psppire_dict_get_type (void);
70 PsppireDict* psppire_dict_new (void);
71 PsppireDict* psppire_dict_new_from_dict (struct dictionary *d);
72 void psppire_dict_set_name (PsppireDict* s, gint idx, const gchar *name);
73 void psppire_dict_delete_var (PsppireDict *s, gint idx);
75 /* Return the variable indexed by IDX.
76 returns NULL if IDX is not valid.
78 struct variable *psppire_dict_get_var(PsppireDict *d, gint idx);
80 /* Return the number of variables in the dictionary */
81 gint psppire_dict_get_var_cnt(const PsppireDict *d);
83 /* Return a variable by name.
84 Return NULL if it doesn't exist
86 struct variable * psppire_dict_lookup_var (const PsppireDict *d, const gchar *name);
88 /* Tell the dictionary that one of its variable has changed */
89 void psppire_dict_var_changed(PsppireDict *d, gint idx);
92 /* Clears the contents of D */
93 void psppire_dict_clear(PsppireDict *d);
95 /* Return the IDXth variable */
97 struct PsppireVariable * psppire_dict_get_variable(PsppireDict *d, gint idx);
99 /* Delete N variables beginning at FIRST */
100 void psppire_dict_delete_variables(PsppireDict *d, gint first, gint n);
102 /* Insert a new variable at posn IDX */
103 void psppire_dict_insert_variable(PsppireDict *d, gint idx, const gchar *name);
105 gboolean psppire_dict_check_name(const PsppireDict *dict,
106 const gchar *name, gboolean report);
111 #endif /* __PSPPIRE_DICT_H__ */