Changed all the licence notices in all the files.
[pspp-builds.git] / src / value-labels.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000 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 VAL_LABS_H
21 #define VAL_LABS_H 1
22
23 #include <stddef.h>
24 #include "var.h"
25
26 struct val_labs;
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_set_width (struct val_labs *, int new_width);
37 void val_labs_destroy (struct val_labs *);
38 void val_labs_clear (struct val_labs *);
39 size_t val_labs_count (struct val_labs *);
40
41 int val_labs_add (struct val_labs *, union value, const char *);
42 int val_labs_replace (struct val_labs *, union value, const char *);
43 int val_labs_remove (struct val_labs *, union value);
44 char *val_labs_find (const struct val_labs *, union value);
45
46 struct val_labs_iterator;
47
48 struct val_lab *val_labs_first (const struct val_labs *,
49                                 struct val_labs_iterator **);
50 struct val_lab *val_labs_first_sorted (const struct val_labs *,
51                                        struct val_labs_iterator **);
52 struct val_lab *val_labs_next (const struct val_labs *,
53                                struct val_labs_iterator **);
54 void val_labs_done (struct val_labs_iterator **);
55
56 /* Return a string representing this value, in the form most 
57    appropriate from a human factors perspective.
58    (IE: the label if it has one, otherwise the alpha/numeric )
59 */
60 const char *value_to_string(const union value *, const struct variable *);
61
62 #endif /* value-labels.h */