psppire: Sort by name or label case-insensitively in dictionary view.
[pspp.git] / src / data / attributes.h
blob6da0b0ef9cd71b362b45122bd93c1d8300e17620
1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2008, 2011, 2012, 2016 Free Software Foundation, Inc.
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.
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.
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/>. */
17 #ifndef DATA_ATTRIBUTES_H
18 #define DATA_ATTRIBUTES_H 1
20 #include "libpspp/hmapx.h"
22 /* This header supports custom attribute of the sort maintained
23 by the DATAFILE ATTRIBUTE and VARIABLE ATTRIBUTE commands.
25 Attributes have a name (the rules for which are the same as
26 those for PSPP variable names) and one or more values, each of
27 which is a string. An attribute may be part of one attribute
28 set.
30 An attribute set is an unordered collection of attributes
31 with names that are unique (case-insensitively). */
33 struct attribute *attribute_create (const char *name);
34 struct attribute *attribute_clone (const struct attribute *);
35 void attribute_destroy (struct attribute *);
37 const char *attribute_get_name (const struct attribute *);
38 const char *attribute_get_value (const struct attribute *, size_t index);
39 void attribute_add_value (struct attribute *, const char *);
40 void attribute_set_value (struct attribute *, size_t index, const char *);
41 void attribute_del_value (struct attribute *, size_t index);
42 size_t attribute_get_n_values (const struct attribute *);
44 struct attrset
46 struct hmap map;
48 #define ATTRSET_INITIALIZER(ATTRSET) { .map = HMAP_INITIALIZER((ATTRSET).map) }
50 void attrset_init (struct attrset *);
51 void attrset_clone (struct attrset *, const struct attrset *);
52 void attrset_destroy (struct attrset *);
54 size_t attrset_count (const struct attrset *);
56 struct attribute *attrset_lookup (const struct attrset *, const char *);
57 bool attrset_try_add (struct attrset *, struct attribute *);
58 void attrset_add (struct attrset *, struct attribute *);
59 void attrset_delete (struct attrset *, const char *);
60 void attrset_clear (struct attrset *);
62 struct attrset_iterator
64 struct hmap_node *node;
66 struct attribute *attrset_first (const struct attrset *,
67 struct attrset_iterator *);
68 struct attribute *attrset_next (const struct attrset *,
69 struct attrset_iterator *);
70 struct attribute **attrset_sorted (const struct attrset *);
72 #endif /* data/attributes.h */