b4f22348ec45536d95dad563adc5f194cf063908
[pspp-builds.git] / src / language / lexer / subcommand-list.h
1 #ifndef SUBCLIST_H
2 #define SUBCLIST_H
3
4 /* subclist - lists for PSPP subcommands
5
6    Copyright (C) 2004 Free Software Foundation, Inc.
7
8
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2 of the
13    License, or (at your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA. */
24
25
26
27 #include <sys/types.h>
28
29 /* This module provides a rudimentary list class
30    It is intended for use by the command line parser for list subcommands
31 */
32
33
34 struct subc_list_double {
35   double *data ;
36   size_t sz;
37   int n_data;
38 };
39
40 struct subc_list_int {
41   int *data ;
42   size_t sz;
43   int n_data;
44 };
45
46
47 typedef struct subc_list_double subc_list_double ;
48 typedef struct subc_list_int subc_list_int ;
49
50 /* Create a  list */
51 void subc_list_double_create(subc_list_double *l) ;
52 void subc_list_int_create(subc_list_int *l) ;
53
54 /* Push a value onto the list */
55 void subc_list_double_push(subc_list_double *l, double d) ;
56 void subc_list_int_push(subc_list_int *l, int i) ;
57
58 /* Index into the list */
59 double subc_list_double_at(const subc_list_double *l, int idx);
60 int subc_list_int_at(const subc_list_int *l, int idx);
61
62 /* Return the number of values in the list */
63 int subc_list_double_count(const subc_list_double *l);
64 int subc_list_int_count(const subc_list_int *l);
65
66 /* Destroy the list */
67 void subc_list_double_destroy(subc_list_double *l) ;
68 void subc_list_int_destroy(subc_list_int *l) ;
69
70
71 #endif