37eb1192ba7dc3adede0c31d9d29bade91bc0cd9
[pspp-builds.git] / src / data / dictionary.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2004 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 #ifndef DICTIONARY_H
21 #define DICTIONARY_H
22
23 #include <stdbool.h>
24 #include <stddef.h>
25
26 /* Dictionary. */ 
27
28 struct variable;
29 struct dictionary *dict_create (void);
30 struct dictionary *dict_clone (const struct dictionary *);
31 void dict_clear (struct dictionary *);
32 void dict_clear_aux (struct dictionary *);
33 void dict_destroy (struct dictionary *);
34
35 size_t dict_get_var_cnt (const struct dictionary *);
36 struct variable *dict_get_var (const struct dictionary *, size_t idx);
37 void dict_get_vars (const struct dictionary *,
38                     struct variable ***vars, size_t *cnt,
39                     unsigned exclude_classes);
40
41 struct variable *dict_create_var (struct dictionary *, const char *,
42                                   int width);
43
44 struct variable *dict_create_var_assert (struct dictionary *, const char *,
45                                   int width);
46 struct variable *dict_clone_var (struct dictionary *, const struct variable *,
47                                  const char *);
48 struct variable *dict_clone_var_assert (struct dictionary *,
49                                         const struct variable *, const char *);
50
51 struct variable *dict_lookup_var (const struct dictionary *, const char *);
52 struct variable *dict_lookup_var_assert (const struct dictionary *,
53                                          const char *);
54 bool dict_contains_var (const struct dictionary *, const struct variable *);
55 void dict_delete_var (struct dictionary *, struct variable *);
56 void dict_delete_vars (struct dictionary *,
57                        struct variable *const *, size_t count);
58 void dict_delete_consecutive_vars (struct dictionary *d,
59                                    size_t idx, size_t count);
60 void dict_delete_scratch_vars (struct dictionary *);
61 void dict_reorder_var (struct dictionary *d, struct variable *v,
62                        size_t new_index);
63 void dict_reorder_vars (struct dictionary *,
64                         struct variable *const *, size_t count);
65 void dict_rename_var (struct dictionary *, struct variable *, const char *);
66 bool dict_rename_vars (struct dictionary *,
67                        struct variable **, char **new_names,
68                        size_t count, char **err_name);
69
70 struct ccase;
71 struct variable *dict_get_weight (const struct dictionary *);
72 double dict_get_case_weight (const struct dictionary *, 
73                              const struct ccase *, bool *);
74 void dict_set_weight (struct dictionary *, struct variable *);
75
76 struct variable *dict_get_filter (const struct dictionary *);
77 void dict_set_filter (struct dictionary *, struct variable *);
78
79 size_t dict_get_case_limit (const struct dictionary *);
80 void dict_set_case_limit (struct dictionary *, size_t);
81
82 int dict_get_next_value_idx (const struct dictionary *);
83 size_t dict_get_case_size (const struct dictionary *);
84
85 void dict_compact_values (struct dictionary *);
86 size_t dict_get_compacted_value_cnt (const struct dictionary *);
87 int *dict_get_compacted_dict_index_to_case_index (const struct dictionary *);
88 bool dict_compacting_would_shrink (const struct dictionary *);
89 bool dict_compacting_would_change (const struct dictionary *);
90
91 struct dict_compactor *dict_make_compactor (const struct dictionary *);
92 void dict_compactor_compact (const struct dict_compactor *,
93                              struct ccase *, const struct ccase *);
94 void dict_compactor_destroy (struct dict_compactor *);
95
96 struct variable *const *dict_get_split_vars (const struct dictionary *);
97 size_t dict_get_split_cnt (const struct dictionary *);
98 void dict_set_split_vars (struct dictionary *,
99                           struct variable *const *, size_t cnt);
100
101 const char *dict_get_label (const struct dictionary *);
102 void dict_set_label (struct dictionary *, const char *);
103
104 const char *dict_get_documents (const struct dictionary *);
105 void dict_set_documents (struct dictionary *, const char *);
106
107 bool dict_create_vector (struct dictionary *,
108                          const char *name,
109                          struct variable **, size_t cnt);
110 const struct vector *dict_get_vector (const struct dictionary *,
111                                       size_t idx);
112 size_t dict_get_vector_cnt (const struct dictionary *);
113 const struct vector *dict_lookup_vector (const struct dictionary *,
114                                          const char *name);
115 void dict_clear_vectors (struct dictionary *);
116
117 void dict_assign_short_names (struct dictionary *);
118
119 #endif /* dictionary.h */