X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvar.h;h=1d36467b09534ef7a30221cfcbb823534cda000f;hb=6d7e2826ba9c863f6261e9718e0e822e0ca60aa0;hp=46a0efc5fc0a061d83f315ec9f6cacb93741efa9;hpb=b321086267ad1014dc5d09886396cde30f094437;p=pspp diff --git a/src/var.h b/src/var.h index 46a0efc5fc..1d36467b09 100644 --- a/src/var.h +++ b/src/var.h @@ -14,65 +14,29 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #if !var_h #define var_h 1 + #include +#include "config.h" +#include "bool.h" #include "format.h" #include "val.h" -/* Frequency tables. */ - -/* Frequency table entry. */ -struct freq - { - union value v; /* The value. */ - double c; /* The number of occurrences of the value. */ - }; - -/* Types of frequency tables. */ -enum - { - FRQM_GENERAL, - FRQM_INTEGER - }; - -/* Entire frequency table. */ -struct freq_tab - { - int mode; /* FRQM_GENERAL or FRQM_INTEGER. */ - - /* General mode. */ - struct hsh_table *data; /* Undifferentiated data. */ - - /* Integer mode. */ - double *vector; /* Frequencies proper. */ - int min, max; /* The boundaries of the table. */ - double out_of_range; /* Sum of weights of out-of-range values. */ - double sysmis; /* Sum of weights of SYSMIS values. */ - /* All modes. */ - struct freq *valid; /* Valid freqs. */ - int n_valid; /* Number of total freqs. */ - struct freq *missing; /* Missing freqs. */ - int n_missing; /* Number of missing freqs. */ - - /* Statistics. */ - double total_cases; /* Sum of weights of all cases. */ - double valid_cases; /* Sum of weights of valid cases. */ - }; - /* Script variables. */ /* Variable type. */ enum { NUMERIC, /* A numeric variable. */ - ALPHA /* A string variable. (STRING is pre-empted by lexer.h) */ + ALPHA /* A string variable. + (STRING is pre-empted by lexer.h.) */ }; /* Types of missing values. Order is significant, see @@ -95,18 +59,21 @@ enum MISSING_COUNT }; + /* A variable's dictionary entry. */ struct variable { - char name[9]; /* As a string. */ - int index; /* Index into its dictionary's var[]. */ + /* Basic information. */ + char name[LONG_NAME_LEN + 1]; /* Variable name. Mixed case. */ int type; /* NUMERIC or ALPHA. */ - 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. */ unsigned reinit : 1; /* Cases are: 1=reinitialized; 0=left. */ + /* Data for use by containing dictionary. */ + int index; /* Dictionary index. */ + /* Missing values. */ int miss_type; /* One of the MISSING_* constants. */ union value missing[3]; /* User-missing value. */ @@ -119,14 +86,38 @@ 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 */ + + /* Short name, used only for system and portable file input + and output. Upper case only. There is no index for short + names. Short names are not necessarily unique. Any + variable may have no short name, indicated by an empty + string. */ + char short_name[SHORT_NAME_LEN + 1]; + /* Per-command info. */ void *aux; void (*aux_dtor) (struct variable *); }; -int compare_variables (const void *, const void *, void *); -unsigned hash_variable (const void *, void *); +/* Variable names. */ +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 *); + +/* Short names. */ +void var_set_short_name (struct variable *, const char *); +void var_set_short_name_suffix (struct variable *, const char *, int suffix); +void var_clear_short_name (struct variable *); +/* Pointers to `struct variable', by name. */ +int compare_var_ptr_names (const void *, const void *, void *); +unsigned hash_var_ptr_name (const void *, void *); + +/* Variable auxiliary data. */ void *var_attach_aux (struct variable *, void *aux, void (*aux_dtor) (struct variable *)); void var_clear_aux (struct variable *); @@ -148,12 +139,11 @@ 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[LONG_NAME_LEN + 1]; /* Name. */ struct variable **var; /* Vector of variables. */ int cnt; /* Number of variables. */ }; - void discard_variables (void); /* This is the active file dictionary. */ @@ -238,6 +228,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); /* Variable parsers. */