gui: For text data import, use the same parser for preview as for import.
[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 #include "libpspp/string-array.h"
22
23 #include <glib-object.h>
24 #include <gtk/gtk.h>
25
26 G_BEGIN_DECLS
27
28
29
30 #define PSPPIRE_TYPE_DELIMITED_TEXT            (psppire_delimited_text_get_type ())
31
32 #define PSPPIRE_DELIMITED_TEXT(obj)     \
33   (G_TYPE_CHECK_INSTANCE_CAST ((obj),                                   \
34                                PSPPIRE_TYPE_DELIMITED_TEXT, PsppireDelimitedText))
35
36 #define PSPPIRE_DELIMITED_TEXT_CLASS(klass) \
37   (G_TYPE_CHECK_CLASS_CAST ((klass),                                    \
38                             PSPPIRE_TYPE_DELIMITED_TEXT,                    \
39                             PsppireDelimitedTextClass))
40
41
42 #define PSPPIRE_IS_DELIMITED_TEXT(obj) \
43   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DELIMITED_TEXT))
44
45 #define PSPPIRE_IS_DELIMITED_TEXT_CLASS(klass) \
46   (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DELIMITED_TEXT))
47
48 #define PSPPIRE_DELIMITED_TEXT_GET_CLASS(obj) \
49   (G_TYPE_INSTANCE_GET_CLASS ((obj),                                    \
50                               PSPPIRE_TYPE_DELIMITED_TEXT,                  \
51                               PsppireDelimitedTextClass))
52
53 struct _PsppireDelimitedText
54 {
55   GObject parent;
56
57   GtkTreeModel *child;
58
59   /* The first line of the file to be modelled */
60   gint first_line;
61
62   GSList *delimiters;
63   gint max_fields;
64
65   gunichar quote;
66
67   /*< private >*/
68   gboolean dispose_has_run ;
69   gint stamp;
70
71   /* caching */
72   int cache_row;
73   struct string_array cache;
74   struct data_parser *parser;
75 };
76
77 struct _PsppireDelimitedTextClass
78 {
79   GObjectClass parent_class;
80 };
81
82
83 typedef struct _PsppireDelimitedText       PsppireDelimitedText;
84 typedef struct _PsppireDelimitedTextClass  PsppireDelimitedTextClass;
85
86 GType psppire_delimited_text_get_type (void) G_GNUC_CONST;
87 PsppireDelimitedText *psppire_delimited_text_new (GtkTreeModel *);
88
89 const gchar *psppire_delimited_text_get_header_title (PsppireDelimitedText *file, gint column);
90
91
92 G_END_DECLS
93
94 #endif /* __PSPPIRE_DELIMITED_TEXT_H__ */