Implemented long variable names a la spss V12.
[pspp-builds.git] / src / var.h
index 0bca760ed44aa3f5ce67559704b55a0d3924dae5..f13606be9f546ebf8b14c143d6b0c5ab0de317aa 100644 (file)
--- a/src/var.h
+++ b/src/var.h
 #if !var_h
 #define var_h 1
 
+
 #include <stddef.h>
+#include "config.h"
+#include "bool.h"
 #include "format.h"
 #include "val.h"
 
+
+
 /* Script variables. */
 
 /* Variable type. */
@@ -53,10 +58,12 @@ enum
     MISSING_COUNT
   };
 
+
 /* A variable's dictionary entry.  */
 struct variable
   {
-    char name[9];              /* As a string. */
+    char name[SHORT_NAME_LEN + 1];             /* As a string. */
+    char *longname;             /* Pointer to entry in dictionary's table  */
     int index;                 /* Index into its dictionary's var[]. */
     int type;                   /* NUMERIC or ALPHA. */
 
@@ -77,13 +84,36 @@ struct variable
     struct val_labs *val_labs;  /* Value labels. */
     char *label;               /* Variable label. */
 
+
+    /* GUI display parameters */
+    enum measure measure;       /* Nominal ordinal or continuous */
+    int display_width;          /* Width of data editor column */
+    enum alignment alignment;   /* Alignment of data in gui */
+
     /* Per-command info. */
     void *aux;
     void (*aux_dtor) (struct variable *);
   };
 
-int compare_variables (const void *, const void *, void *);
-unsigned hash_variable (const void *, void *);
+
+/* A tuple containing short names and longnames */
+struct name_table_entry
+{
+  char *longname;
+  char *name;
+};
+
+bool var_is_valid_name (const char *, bool issue_error);
+int compare_var_names (const void *, const void *, void *);
+unsigned hash_var_name (const void *, void *);
+
+
+unsigned hash_long_name (const void *e_, void *aux UNUSED) ;
+int compare_long_names(const void *a_, const void *b_, void *aux);
+
+
+int compare_var_ptr_names (const void *, const void *, void *);
+unsigned hash_var_ptr_name (const void *, void *);
 
 void *var_attach_aux (struct variable *,
                       void *aux, void (*aux_dtor) (struct variable *));
@@ -106,7 +136,7 @@ const char *dict_class_to_name (enum dict_class dict_class);
 struct vector
   {
     int idx;                    /* Index for dict_get_vector(). */
-    char name[9];              /* Name. */
+    char name[SHORT_NAME_LEN + 1];     /* Name. */
     struct variable **var;     /* Vector of variables. */
     int cnt;                   /* Number of variables. */
   };
@@ -196,6 +226,7 @@ size_t var_set_get_cnt (const struct var_set *vs);
 struct variable *var_set_get_var (const struct var_set *vs, size_t idx);
 struct variable *var_set_lookup_var (const struct var_set *vs,
                                      const char *name);
+int var_set_lookup_var_idx (const struct var_set *vs, const char *name);
 void var_set_destroy (struct var_set *vs);
 \f
 /* Variable parsers. */