ce863a40db82df3aec7eb22653773e8358d12f49
[pspp-builds.git] / src / data / value-labels.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>. */
16
17 #ifndef VAL_LABS_H
18 #define VAL_LABS_H 1
19
20 #include <stdbool.h>
21 #include <stddef.h>
22
23 #include <data/value.h>
24
25 struct val_labs;
26 struct variable;
27
28 struct val_lab
29   {
30     union value value;
31     const char *label;
32   };
33
34 struct val_labs *val_labs_create (int width);
35 struct val_labs *val_labs_copy (const struct val_labs *);
36 void val_labs_destroy (struct val_labs *);
37 void val_labs_clear (struct val_labs *);
38 size_t val_labs_count (const struct val_labs *);
39
40 bool val_labs_can_set_width (const struct val_labs *, int new_width);
41 void val_labs_set_width (struct val_labs *, int new_width);
42
43 bool val_labs_add (struct val_labs *, union value, const char *);
44 void val_labs_replace (struct val_labs *, union value, const char *);
45 bool val_labs_remove (struct val_labs *, union value);
46 char *val_labs_find (const struct val_labs *, union value);
47
48 struct val_labs_iterator;
49
50 struct val_lab *val_labs_first (const struct val_labs *,
51                                 struct val_labs_iterator **);
52 struct val_lab *val_labs_first_sorted (const struct val_labs *,
53                                        struct val_labs_iterator **);
54 struct val_lab *val_labs_next (const struct val_labs *,
55                                struct val_labs_iterator **);
56 void val_labs_done (struct val_labs_iterator **);
57
58 #endif /* value-labels.h */