1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2017 Free Software Foundation
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 __PSPPIRE_TEXT_FILE_H__
18 #define __PSPPIRE_TEXT_FILE_H__
20 #include "libpspp/str.h"
22 #include <glib-object.h>
28 #define PSPPIRE_TYPE_TEXT_FILE (psppire_text_file_get_type ())
30 #define PSPPIRE_TEXT_FILE(obj) \
31 (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
32 PSPPIRE_TYPE_TEXT_FILE, PsppireTextFile))
34 #define PSPPIRE_TEXT_FILE_CLASS(klass) \
35 (G_TYPE_CHECK_CLASS_CAST ((klass), \
36 PSPPIRE_TYPE_TEXT_FILE, \
37 PsppireTextFileClass))
40 #define PSPPIRE_IS_TEXT_FILE(obj) \
41 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_TEXT_FILE))
43 #define PSPPIRE_IS_TEXT_FILE_CLASS(klass) \
44 (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_TEXT_FILE))
46 #define PSPPIRE_TEXT_FILE_GET_CLASS(obj) \
47 (G_TYPE_INSTANCE_GET_CLASS ((obj), \
48 PSPPIRE_TYPE_TEXT_FILE, \
49 PsppireTextFileClass))
51 enum { MAX_PREVIEW_LINES = 1000 }; /* Max number of lines to read. */
53 struct _PsppireTextFile
62 /* The first several lines of the file. These copies which are UTF8 encoded,
63 regardless of the file encoding. */
64 struct substring lines[MAX_PREVIEW_LINES];
67 gulong total_lines; /* Number of lines in file. */
68 gboolean total_is_exact; /* Is total_lines exact (or an estimate)? */
71 gboolean dispose_has_run ;
75 struct _PsppireTextFileClass
77 GObjectClass parent_class;
81 typedef struct _PsppireTextFile PsppireTextFile;
82 typedef struct _PsppireTextFileClass PsppireTextFileClass;
84 GType psppire_text_file_get_type (void) G_GNUC_CONST;
85 PsppireTextFile *psppire_text_file_new (const gchar *file_name, const gchar *encoding);
87 gboolean psppire_text_file_get_total_exact (PsppireTextFile *tf);
88 gulong psppire_text_file_get_n_lines (PsppireTextFile *tf);
92 #endif /* __PSPPIRE_TEXT_FILE_H__ */