1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2004, 2009, 2011 Free Software Foundation
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 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but 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.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #ifndef __PSPPIRE_DICT_H__
19 #define __PSPPIRE_DICT_H__
22 #include <glib-object.h>
25 #include <data/dictionary.h>
26 #include <data/variable.h>
32 /* --- type macros --- */
33 #define PSPPIRE_TYPE_DICT (psppire_dict_get_type ())
34 #define PSPPIRE_DICT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PSPPIRE_TYPE_DICT, PsppireDict))
35 #define PSPPIRE_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PSPPIRE_TYPE_DICT, PsppireDictClass))
36 #define PSPPIRE_IS_DICT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PSPPIRE_TYPE_DICT))
37 #define PSPPIRE_IS_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DICT))
38 #define PSPPIRE_DICT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PSPPIRE_TYPE_DICT, PsppireDictClass))
41 /* --- typedefs & structures --- */
42 typedef struct _PsppireDict PsppireDict;
43 typedef struct _PsppireDictClass PsppireDictClass;
45 enum {DICT_TVM_COL_NAME=0,
50 DICT_TVM_COL_VALUE_LABELS,
51 DICT_TVM_COL_MISSING_VALUES,
53 DICT_TVM_COL_ALIGNMENT,
62 struct dictionary *dict;
64 gboolean dispose_has_run;
66 gboolean disable_insert_signal;
67 /* For GtkTreeModelIface */
71 struct _PsppireDictClass
73 GObjectClass parent_class;
77 /* -- PsppireDict --- */
78 GType psppire_dict_get_type (void);
79 PsppireDict* psppire_dict_new_from_dict (struct dictionary *d);
80 gboolean psppire_dict_set_name (PsppireDict* s, gint idx, const gchar *name);
81 void psppire_dict_delete_var (PsppireDict *s, gint idx);
83 /* Return the number of variables in the dictionary */
84 gint psppire_dict_get_n_vars (const PsppireDict *d);
86 /* Returns the prototype for the cases that match the dictionary */
87 const struct caseproto *psppire_dict_get_proto (const PsppireDict *d);
89 /* Return a variable by name.
90 Return NULL if it doesn't exist
92 struct variable * psppire_dict_lookup_var (const PsppireDict *d, const gchar *name);
94 /* Clears the contents of D */
95 void psppire_dict_clear (PsppireDict *d);
97 /* Return the IDXth variable */
98 struct variable * psppire_dict_get_variable (const PsppireDict *d, gint idx);
100 /* Delete N variables beginning at FIRST */
101 void psppire_dict_delete_variables (PsppireDict *d, gint first, gint n);
103 /* Insert a new variable at posn IDX */
104 struct variable *psppire_dict_insert_variable (PsppireDict *d, gint idx,
107 gboolean psppire_dict_check_name (const PsppireDict *, const gchar *name);
109 bool psppire_dict_generate_name (const PsppireDict *, char *name, size_t size);
111 gboolean psppire_dict_rename_var (PsppireDict *dict, struct variable *v,
114 void psppire_dict_replace_dictionary (PsppireDict *, struct dictionary *);
116 struct variable * psppire_dict_get_weight_variable (const PsppireDict *);
118 const gchar *psppire_dict_encoding (const PsppireDict *);
122 #endif /* __PSPPIRE_DICT_H__ */