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