Beginning of VFM cleanup.
[pspp-builds.git] / src / var.h
index 71c645387b0c8bc8aa45f3211f265722b741d912..bf2e4d5082c7c27af2151508e8d3553f68956366 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. */
@@ -129,32 +84,6 @@ struct crosstab_proc
   };
 
 
-/* T-TEST private data */
-struct t_test_proc
-  {
-    double mean;
-
-    double std_dev;
-    
-    /* count */
-    double n;
-
-    double sum;
-
-    /* Sum of squares */
-    double ssq;
-
-    /* Std Err of Mean */
-    double se_mean;
-
-    /* Sum of differnces */
-    double sum_diff;
-
-    /* Mean of differences */
-    double mean_diff ;
-  };
-
-
 /* FREQUENCIES private data. */
 enum
   {
@@ -222,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
   {
@@ -298,21 +214,19 @@ 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'.*/
+/* 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. */
+    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. */
-    int left;                  /* 0=reinitialize each case, 1=don't. */
+    unsigned init : 1;          /* 1=VFM must init and possibly reinit. */
+    unsigned reinit : 1;        /* Cases are: 1=reinitialized; 0=left. */
 
     /* Missing values. */
     int miss_type;             /* One of the MISSING_* constants. */
@@ -336,7 +250,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;
@@ -375,6 +288,13 @@ struct ccase
   {
     union value data[1];
   };
+
+/* Linked list of cases. */
+struct case_list 
+  {
+    struct case_list *next;
+    struct ccase c;
+  };
 \f
 /* Dictionary. */ 
 
@@ -394,11 +314,15 @@ void dict_get_vars (const struct dictionary *,
 
 struct variable *dict_create_var (struct dictionary *, const char *,
                                   int width);
+struct variable *dict_create_var_assert (struct dictionary *, const char *,
+                                  int width);
 struct variable *dict_clone_var (struct dictionary *, const struct variable *,
                                  const char *);
 void dict_rename_var (struct dictionary *, struct variable *, const char *);
 
 struct variable *dict_lookup_var (const struct dictionary *, const char *);
+struct variable *dict_lookup_var_assert (const struct dictionary *,
+                                         const char *);
 int dict_contains_var (const struct dictionary *, const struct variable *);
 void dict_delete_var (struct dictionary *, struct variable *);
 void dict_delete_vars (struct dictionary *,
@@ -419,7 +343,8 @@ 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 *);
 
 struct variable *const *dict_get_split_vars (const struct dictionary *);
@@ -487,20 +412,6 @@ int is_missing (const union value *, const struct variable *);
 int is_system_missing (const union value *, const struct variable *);
 int is_user_missing (const union value *, const struct variable *);
 void copy_missing_values (struct variable *dest, const struct variable *src);
-
-#if GLOBAL_DEBUGGING
-struct variable *force_create_variable (struct dictionary *, const char *name,
-                                       int type, int width);
-struct variable *force_dup_variable (struct dictionary *,
-                                    const struct variable *src,
-                                    const char *name);
-#else
-#define force_create_variable(A, B, C, D)      \
-       create_variable (A, B, C, D)
-#define force_dup_variable(A, B, C)            \
-       dup_variable (A, B, C)
-#endif
-
 \f
 /* Transformations. */