Redo VFM interface. Get rid of compaction_necessary, compaction_nval,
[pspp-builds.git] / src / var.h
index c587f7a23d5ab5aaac0e039c42ea3fc42c7e9ec4..6d5cad7938ea2589cb6047b55ac6a3d8b21af14c 100644 (file)
--- a/src/var.h
+++ b/src/var.h
 #include <stddef.h>
 #include "format.h"
 #include "t-test.h"
+#include "val.h"
 
-/* Values. */
-
-/* Definition of the max length of a short string value, generally
-   eight characters.  */
-#define MAX_SHORT_STRING ((SIZEOF_DOUBLE)>=8 ? ((SIZEOF_DOUBLE)+1)/2*2 : 8)
-#define MIN_LONG_STRING (MAX_SHORT_STRING+1)
-
-/* FYI: It is a bad situation if sizeof(flt64) < MAX_SHORT_STRING:
-   then short string missing values can be truncated in system files
-   because there's only room for as many characters as can fit in a
-   flt64. */
-#if MAX_SHORT_STRING > 8
-#error MAX_SHORT_STRING must be less than 8.
-#endif
-
-/* Special values. */
-#define SYSMIS (-DBL_MAX)
-#define LOWEST second_lowest_value
-#define HIGHEST DBL_MAX
-
-/* Describes one value, which is either a floating-point number or a
-   short string. */
-union value
-  {
-    /* A numeric value. */
-    double f;
-
-    /* A short-string value. */
-    unsigned char s[MAX_SHORT_STRING];
-
-    /* This member is used by data-in.c to return a string result,
-       since it may need to return a long string.  As currently
-       implemented, it's a pointer to a static internal buffer in
-       data-in.c.
-
-       Also used by evaluate_expression() to return a string result.
-       As currently implemented, it's a pointer to a dynamic buffer in
-       the appropriate expression.
-
-       Also used by the AGGREGATE procedure in handling string
-       values. */
-    unsigned char *c;
-
-    /* Sometimes we insert value's in a hash table. */
-    unsigned long hash[SIZEOF_DOUBLE / SIZEOF_LONG];
-  };
-\f
 /* Frequency tables. */
 
 /* Frequency table entry. */
@@ -197,19 +151,6 @@ struct get_proc
     int fv, nv;                        /* First, # of values. */
   };
 
-/* Sort order. */
-enum
-  {
-    SRT_ASCEND,                        /* A, B, C, ..., X, Y, Z. */
-    SRT_DESCEND                        /* Z, Y, X, ..., C, B, A. */
-  };
-
-/* SORT CASES private data. */
-struct sort_cases_proc
-  {
-    int order;                 /* SRT_ASCEND or SRT_DESCEND. */
-  };
-
 /* MEANS private data. */
 struct means_proc
   {
@@ -273,18 +214,13 @@ enum
     MISSING_COUNT
   };
 
-/* A variable's dictionary entry.  Note: don't reorder name[] from the
-   first element; a pointer to `variable' should be a pointer to
-   member `name'.  FIXME: is this comment still accurate? */
+/* A variable's dictionary entry.  */
 struct variable
   {
-    /* Required by parse_variables() to be in this order.  */
     char name[9];              /* As a string. */
     int index;                 /* Index into its dictionary's var[]. */
     int type;                   /* NUMERIC or ALPHA. */
 
-    /* Also important but parse_variables() doesn't need it.  Still,
-       check before reordering. */
     int width;                 /* Size of string variables in chars. */
     int fv, nv;                        /* Index into `value's, number of values. */
     unsigned init : 1;          /* 1=VFM must init and possibly reinit. */
@@ -312,7 +248,6 @@ struct variable
        struct frequencies_proc frq;
        struct list_proc lst;
        struct means_proc mns;
-       struct sort_cases_proc srt;
        struct matrix_data_proc mxd;
        struct match_files_proc mtf;
        struct t_test_proc t_t;
@@ -351,6 +286,13 @@ struct ccase
   {
     union value data[1];
   };
+
+/* Linked list of cases. */
+struct case_list 
+  {
+    struct case_list *next;
+    struct ccase c;
+  };
 \f
 /* Dictionary. */ 
 
@@ -399,8 +341,12 @@ void dict_set_filter (struct dictionary *, struct variable *);
 int dict_get_case_limit (const struct dictionary *);
 void dict_set_case_limit (struct dictionary *, int);
 
-int dict_get_value_cnt (const struct dictionary *);
+int dict_get_next_value_idx (const struct dictionary *);
+size_t dict_get_case_size (const struct dictionary *);
+
 void dict_compact_values (struct dictionary *);
+size_t dict_get_compacted_value_cnt (const struct dictionary *);
+int *dict_get_compacted_idx_to_fv (const struct dictionary *);
 
 struct variable *const *dict_get_split_vars (const struct dictionary *);
 size_t dict_get_split_cnt (const struct dictionary *);
@@ -460,6 +406,7 @@ void cancel_temporary (void);
 /* Functions. */
 
 void dump_split_vars (const struct ccase *);
+typedef int (* is_missing_func )(const union value *, const struct variable *);
 
 int is_num_user_missing (double, const struct variable *);
 int is_str_user_missing (const unsigned char[], const struct variable *);
@@ -470,17 +417,16 @@ void copy_missing_values (struct variable *dest, const struct variable *src);
 \f
 /* Transformations. */
 
+struct trns_header;
+typedef int trns_proc_func (struct trns_header *, struct ccase *, int);
+typedef void trns_free_func (struct trns_header *);
+
 /* Header for all transformations. */
 struct trns_header
   {
-    /* Index into t_trns[]. */
-    int index;
-
-    /* Transformation proc. */
-    int (*proc) (struct trns_header *, struct ccase *);
-
-    /* Garbage collector proc. */
-    void (*free) (struct trns_header *);
+    int index;                  /* Index into t_trns[]. */
+    trns_proc_func *proc;       /* Transformation proc. */
+    trns_free_func *free;       /* Garbage collector proc. */
   };
 
 /* Array of transformations */
@@ -505,7 +451,6 @@ size_t var_set_get_cnt (struct var_set *vs);
 struct variable *var_set_get_var (struct var_set *vs, size_t idx);
 struct variable *var_set_lookup_var (struct var_set *vs, const char *name);
 void var_set_destroy (struct var_set *vs);
-
 \f
 /* Variable parsers. */