34c9b912e6f467e5bc16b1f6b750312612ab9907
[pspp-builds.git] / src / libpspp / getl.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000, 2006 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 GETL_H
21 #define GETL_H 1
22
23 #include <stdbool.h>
24 #include <libpspp/ll.h>
25
26 struct string; 
27
28 struct getl_source;
29
30
31 /* An abstract base class for objects which act as line buffers for the 
32    PSPP.  Ie anything which might contain content for the lexer */
33 struct getl_interface 
34   {
35     /* Returns true, if the interface is interactive */
36     bool  (*interactive) (const struct getl_interface *); 
37
38     /* Read a line from the interface */
39     bool  (*read)  (struct getl_interface *, struct string *);
40
41     /* Close and destroy the interface */
42     void  (*close) (struct getl_interface *);
43
44     /* Filter for current and all included sources.  May be NULL */
45     void  (*filter) (struct getl_interface *, struct string *line);
46
47     /* Returns the name of the source */
48     const char * (*name) (const struct getl_interface *);
49
50     /* Returns the current location within the source */
51     int (*location) (const struct getl_interface *);
52   };
53
54 void getl_initialize (void);
55 void getl_uninitialize (void);
56
57 void getl_clear_include_path (void);
58 void getl_add_include_dir (const char *);
59 const char * getl_include_path (void);
60
61 void getl_abort_noninteractive (void);
62 bool getl_is_interactive (void);
63
64 bool getl_read_line (bool *interactive);
65
66 bool do_read_line (struct string *line, bool *interactive);
67
68 void getl_append_source (struct getl_interface *s) ;
69 void getl_include_source (struct getl_interface *s) ;
70
71 const char * getl_source_name (void);
72 int getl_source_location (void);
73
74 #endif /* line-buffer.h */