gui: Honor quotes in the text data import dialog.
[pspp] / src / ui / gui / psppire-delimited-text.h
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2017  Free Software Foundation
3
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.
8
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.
13
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/>. */
16
17 #ifndef __PSPPIRE_DELIMITED_TEXT_H__
18 #define __PSPPIRE_DELIMITED_TEXT_H__
19
20 #include "libpspp/str.h"
21
22 #include <glib-object.h>
23 #include <gtk/gtk.h>
24
25 G_BEGIN_DECLS
26
27
28
29 #define PSPPIRE_TYPE_DELIMITED_TEXT            (psppire_delimited_text_get_type ())
30
31 #define PSPPIRE_DELIMITED_TEXT(obj)     \
32   (G_TYPE_CHECK_INSTANCE_CAST ((obj),                                   \
33                                PSPPIRE_TYPE_DELIMITED_TEXT, PsppireDelimitedText))
34
35 #define PSPPIRE_DELIMITED_TEXT_CLASS(klass) \
36   (G_TYPE_CHECK_CLASS_CAST ((klass),                                    \
37                             PSPPIRE_TYPE_DELIMITED_TEXT,                    \
38                             PsppireDelimitedTextClass))
39
40
41 #define PSPPIRE_IS_DELIMITED_TEXT(obj) \
42   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DELIMITED_TEXT))
43
44 #define PSPPIRE_IS_DELIMITED_TEXT_CLASS(klass) \
45   (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DELIMITED_TEXT))
46
47 #define PSPPIRE_DELIMITED_TEXT_GET_CLASS(obj) \
48   (G_TYPE_INSTANCE_GET_CLASS ((obj),                                    \
49                               PSPPIRE_TYPE_DELIMITED_TEXT,                  \
50                               PsppireDelimitedTextClass))
51
52 struct _PsppireDelimitedText
53 {
54   GObject parent;
55
56   GtkTreeModel *child;
57
58   /* The first line of the file to be modelled */
59   gint first_line;
60
61   GSList *delimiters;
62   gint max_delimiters;
63
64   gunichar quotes[2];
65
66   /*< private >*/
67   gboolean dispose_has_run ;
68   gint stamp;
69
70   /* caching */
71   const char *cache_starts[512];
72   struct substring const_cache;
73   int cache_row;
74 };
75
76 struct _PsppireDelimitedTextClass
77 {
78   GObjectClass parent_class;
79 };
80
81
82 typedef struct _PsppireDelimitedText       PsppireDelimitedText;
83 typedef struct _PsppireDelimitedTextClass  PsppireDelimitedTextClass;
84
85 GType psppire_delimited_text_get_type (void) G_GNUC_CONST;
86 PsppireDelimitedText *psppire_delimited_text_new (GtkTreeModel *);
87
88 const gchar *psppire_delimited_text_get_header_title (PsppireDelimitedText *file, gint column);
89
90
91 G_END_DECLS
92
93 #endif /* __PSPPIRE_DELIMITED_TEXT_H__ */