Patch #5244.
[pspp-builds.git] / src / data / format.h
index edf7f64860fb04dcba27b5213dca347a875f3229..e9d5e5e3f5d8be9cc36e8bfc12377bf936c9ec15 100644 (file)
@@ -39,10 +39,14 @@ enum
   };
 #undef DEFFMT
 
+/* Length of longest format specifier name,
+   not including terminating null. */
+#define FMT_TYPE_LEN_MAX 8
+
 /* Describes one of the display formats above. */
 struct fmt_desc
   {
-    char name[9];              /* `DATETIME' is the longest name. */
+    char name[FMT_TYPE_LEN_MAX + 1]; /* Name, in all caps. */
     int n_args;                        /* 1=width; 2=width.decimals. */
     int Imin_w, Imax_w;                /* Bounds on input width. */
     int Omin_w, Omax_w;                /* Bounds on output width. */
@@ -76,7 +80,8 @@ enum alignment
   {
     ALIGN_LEFT = 0,
     ALIGN_RIGHT = 1,
-    ALIGN_CENTRE = 2
+    ALIGN_CENTRE = 2, 
+    n_ALIGN
   };
 
 
@@ -84,9 +89,12 @@ enum measure
   {
     MEASURE_NOMINAL=1,
     MEASURE_ORDINAL=2,
-    MEASURE_SCALE=3
+    MEASURE_SCALE=3,
+    n_MEASURES
   };
 
+bool measure_is_valid(enum measure m);
+bool alignment_is_valid(enum alignment a);
 
 
 /* Descriptions of all the display formats above. */
@@ -97,18 +105,9 @@ union value;
 /* Maximum length of formatted value, in characters. */
 #define MAX_FORMATTED_LEN 256
 
-/* Flags for parsing formats. */
-enum fmt_parse_flags
-  {
-    FMTP_ALLOW_XT = 001,                /* 1=Allow X and T formats. */
-    FMTP_SUPPRESS_ERRORS = 002          /* 1=Do not emit error messages. */
-  };
-
 /* Common formats. */
 extern const struct fmt_spec f8_2;      /* F8.2. */
 
-int parse_format_specifier (struct fmt_spec *input, enum fmt_parse_flags);
-int parse_format_specifier_name (const char **cp, enum fmt_parse_flags);
 int check_input_specifier (const struct fmt_spec *spec, int emit_error);
 int check_output_specifier (const struct fmt_spec *spec, int emit_error);
 bool check_specifier_type (const struct fmt_spec *, int type, bool emit_error);
@@ -120,6 +119,7 @@ int parse_string_as_format (const char *s, int len, const struct fmt_spec *fp,
                            int fc, union value *v);
 int translate_fmt (int spss);
 bool data_out (char *s, const struct fmt_spec *fp, const union value *v);
+bool fmt_type_from_string (const char *name, int *type);
 char *fmt_to_string (const struct fmt_spec *);
 void num_to_string (double v, char *s, int w, int d);
 struct fmt_spec make_input_format (int type, int w, int d);