treewide: Replace <name>_cnt by n_<name>s and <name>_cap by allocated_<name>.
[pspp] / src / ui / gui / psppire-text-file.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_TEXT_FILE_H__
18 #define __PSPPIRE_TEXT_FILE_H__
19
20 #include "libpspp/str.h"
21
22 #include <glib-object.h>
23
24 G_BEGIN_DECLS
25
26
27
28 #define PSPPIRE_TYPE_TEXT_FILE         (psppire_text_file_get_type ())
29
30 #define PSPPIRE_TEXT_FILE(obj)  \
31   (G_TYPE_CHECK_INSTANCE_CAST ((obj),                                   \
32                                PSPPIRE_TYPE_TEXT_FILE, PsppireTextFile))
33
34 #define PSPPIRE_TEXT_FILE_CLASS(klass) \
35   (G_TYPE_CHECK_CLASS_CAST ((klass),                                    \
36                             PSPPIRE_TYPE_TEXT_FILE,                    \
37                             PsppireTextFileClass))
38
39
40 #define PSPPIRE_IS_TEXT_FILE(obj) \
41   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_TEXT_FILE))
42
43 #define PSPPIRE_IS_TEXT_FILE_CLASS(klass) \
44   (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_TEXT_FILE))
45
46 #define PSPPIRE_TEXT_FILE_GET_CLASS(obj) \
47   (G_TYPE_INSTANCE_GET_CLASS ((obj),                                    \
48                               PSPPIRE_TYPE_TEXT_FILE,                  \
49                               PsppireTextFileClass))
50
51 enum { MAX_PREVIEW_LINES = 1000 }; /* Max number of lines to read. */
52
53 struct _PsppireTextFile
54 {
55   GObject parent;
56
57   gchar *file_name;
58   gchar *encoding;
59
60   gint maximum_lines;
61
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];
65   size_t n_lines;
66
67   gulong total_lines; /* Number of lines in file. */
68   gboolean total_is_exact;    /* Is total_lines exact (or an estimate)? */
69
70   /*< private >*/
71   gboolean dispose_has_run ;
72   gint stamp;
73 };
74
75 struct _PsppireTextFileClass
76 {
77   GObjectClass parent_class;
78 };
79
80
81 typedef struct _PsppireTextFile       PsppireTextFile;
82 typedef struct _PsppireTextFileClass  PsppireTextFileClass;
83
84 GType psppire_text_file_get_type (void) G_GNUC_CONST;
85 PsppireTextFile *psppire_text_file_new (const gchar *file_name, const gchar *encoding);
86
87 gboolean psppire_text_file_get_total_exact (PsppireTextFile *tf);
88 gulong psppire_text_file_get_n_lines (PsppireTextFile *tf);
89
90 G_END_DECLS
91
92 #endif /* __PSPPIRE_TEXT_FILE_H__ */