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