Automatically infer variables' measurement level from format and data.
[pspp] / src / data / settings.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2015 Free Software Foundation, Inc.
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 #if !settings_h
18 #define settings_h 1
19
20 #include <stdbool.h>
21 #include <stddef.h>
22
23 #include "data/format.h"
24 #include "libpspp/compiler.h"
25 #include "libpspp/float-format.h"
26 #include "libpspp/integer-format.h"
27 #include "libpspp/message.h"
28
29 struct caseproto;
30 struct settings;
31
32 void settings_init (void);
33 void settings_done (void);
34
35 struct settings *settings_get (void);
36 void settings_set (const struct settings *);
37 void settings_destroy (struct settings *);
38
39 enum float_format settings_get_input_float_format (void);
40 void settings_set_input_float_format (enum float_format);
41
42 /* Returns the integer format used for IB and PIB input. */
43 enum integer_format settings_get_input_integer_format (void);
44
45 /* Sets the integer format used for IB and PIB input to
46    FORMAT. */
47 void settings_set_input_integer_format (enum integer_format);
48
49
50 /* Returns the current output integer format. */
51 enum integer_format settings_get_output_integer_format (void);
52
53 /* Sets the output integer format to INTEGER_FORMAT. */
54 void settings_set_output_integer_format (enum integer_format integer_format);
55
56 /* Returns the current output float format. */
57 enum float_format settings_get_output_float_format (void);
58
59 /* Sets the output float format to FLOAT_FORMAT. */
60 void settings_set_output_float_format (enum float_format float_format);
61
62
63
64 int settings_get_viewlength (void);
65 void settings_set_viewlength (int);
66
67 int settings_get_viewwidth (void);
68 void settings_set_viewwidth (int);
69
70 bool settings_get_safer_mode (void);
71 void settings_set_safer_mode (void);
72
73 bool settings_get_include (void);
74 void settings_set_include (bool);
75
76 int settings_get_epoch (void);
77 void settings_set_epoch (int);
78
79 bool settings_get_scompression (void);
80 void settings_set_scompression (bool);
81
82 bool settings_get_undefined (void);
83 void settings_set_undefined (bool);
84 double settings_get_blanks (void);
85 void settings_set_blanks (double);
86
87 int settings_get_max_messages (enum msg_severity);
88 void settings_set_max_messages (enum msg_severity, int max);
89
90 /* Macro settings. */
91 bool settings_get_mexpand (void);
92 void settings_set_mexpand (bool);
93
94 bool settings_get_mprint (void);
95 void settings_set_mprint (bool);
96
97 int settings_get_miterate (void);
98 void settings_set_miterate (int);
99
100 int settings_get_mnest (void);
101 void settings_set_mnest (int);
102
103 int settings_get_mxloops (void);
104 void settings_set_mxloops (int);
105
106 size_t settings_get_workspace (void);
107 size_t settings_get_workspace_cases (const struct caseproto *);
108 void settings_set_workspace (size_t);
109
110 const struct fmt_spec *settings_get_format (void);
111 void settings_set_format (const struct fmt_spec *);
112
113 bool settings_get_testing_mode (void);
114 void settings_set_testing_mode (bool);
115
116 int settings_get_fuzzbits (void);
117 void settings_set_fuzzbits (int);
118
119 int settings_get_scalemin (void);
120 void settings_set_scalemin (int);
121
122 /* Whether to show variable or value labels or the underlying value or variable
123    name. */
124 enum ATTRIBUTE ((packed)) settings_value_show
125   {
126     /* Use higher-level default.
127        In a pivot_value, the default is taken from the pivot_table.
128        In a pivot_table, the default is a global default.
129        As a global default, this is invalid. */
130     SETTINGS_VALUE_SHOW_DEFAULT = 0,
131
132     SETTINGS_VALUE_SHOW_VALUE = 1, /* Show value or variable name only. */
133     SETTINGS_VALUE_SHOW_LABEL = 2, /* Show label only. */
134     SETTINGS_VALUE_SHOW_BOTH = 3,  /* Show both value/name and label. */
135   };
136
137 enum settings_value_show settings_get_show_values (void);
138 enum settings_value_show settings_get_show_variables (void);
139
140 void settings_set_show_values (enum settings_value_show);
141 void settings_set_show_variables (enum settings_value_show);
142
143
144 enum behavior_mode {
145   ENHANCED,             /* Use improved PSPP behavior. */
146   COMPATIBLE            /* Be as compatible as possible. */
147 };
148
149 enum behavior_mode settings_get_algorithm (void);
150 void settings_set_algorithm (enum behavior_mode);
151 enum behavior_mode settings_get_syntax (void);
152 void settings_set_syntax (enum behavior_mode);
153
154 void settings_set_cmd_algorithm (enum behavior_mode);
155 void unset_cmd_algorithm (void);
156
157 enum fmt_type;
158 bool settings_set_cc (const char *cc_string, enum fmt_type type);
159
160 void settings_set_decimal_char (char decimal);
161 void settings_set_include_leading_zero (bool include_leading_zero);
162
163 const struct fmt_settings *settings_get_fmt_settings (void);
164
165 double settings_get_small (void);
166 void settings_set_small (double);
167
168 char * settings_dollar_template (const struct fmt_spec *fmt);
169
170 /* Routing of different kinds of output. */
171 enum settings_output_devices
172   {
173     SETTINGS_DEVICE_LISTING = 1 << 0,  /* File or device. */
174     SETTINGS_DEVICE_TERMINAL = 1 << 1, /* Screen. */
175     SETTINGS_DEVICE_UNFILTERED = 1 << 2 /* Gets all output, no filtering. */
176   };
177
178 enum settings_output_type
179   {
180     SETTINGS_OUTPUT_ERROR,      /* Errors and warnings. */
181     SETTINGS_OUTPUT_NOTE,       /* Notes. */
182     SETTINGS_OUTPUT_SYNTAX,     /* Syntax. */
183     SETTINGS_OUTPUT_RESULT,     /* Everything else. */
184     SETTINGS_N_OUTPUT_TYPES
185   };
186
187
188
189 void settings_set_output_routing (enum settings_output_type,
190                                   enum settings_output_devices);
191 enum settings_output_devices settings_get_output_routing (
192   enum settings_output_type);
193
194 enum settings_mdisplay
195   {
196     SETTINGS_MDISPLAY_TEXT,
197     SETTINGS_MDISPLAY_TABLES
198   };
199
200 enum settings_mdisplay settings_get_mdisplay (void);
201 void settings_set_mdisplay (enum settings_mdisplay);
202
203 #endif /* !settings_h */