gretl_string_table

gretl_string_table

Functions

Description

Functions

gretl_string_table_new ()

gretl_string_table *
gretl_string_table_new (const int *list);

These values in list should correspond to the 0-based indices of the series in question within the dataset. For example, if strings are to be recorded for variables 2, 5 and 10 the list argument would be {3, 2, 5, 10}. If NULL is passed for list the return value is an initialized, empty string table.

Parameters

list

list of series IDs whose values are to be given a string representation, or NULL.

 

Returns

pointer to a newly allocated string table or NULL on failure.


gretl_string_table_index ()

int
gretl_string_table_index (gretl_string_table *gst,
                          const char *s,
                          int col,
                          int addcol,
                          PRN *prn);

This function has two main uses: for lookup in the context of a completed string table, or for constructing such a table (with addcol non-zero). The returned index reflects any additions to the table that may be required (if column col does not already exist, or if string s is not already stored for column col ).

Parameters

gst

a gretl string table.

 

s

the string to look up or add.

 

col

index of the column to be accessed or created.

 

addcol

non-zero to indicate that a column should be added if it's not already present.

 

prn

gretl printer (or NULL).

 

Returns

the 1-based index of s within the column of st that has index col , if available, otherwise 0.


gretl_string_table_finalize ()

int
gretl_string_table_finalize (gretl_string_table *gst,
                             DATASET *dset);

Attaches the string-value information in gst to the dataset dset . However, if one or more of the series referenced by gst are deemed to be integer codes or misclassified numeric data, their "series tables" are commuted into numeric form.

Parameters

gst

gretl string table.

 

dset

dataset.

 

Returns

the number of series tables actually attached.


gretl_string_table_validate ()

int
gretl_string_table_validate (gretl_string_table *gst,
                             gretlopt opt);

Checks that the "string values" in gst are not in fact undigested quasi-numerical values. We run this on imported CSV data to ensure we don't produce misleading results. In the spreadsheet case we're on the lookout for purely numerical data wrongly identified as strings; we don't treat that as fatal but mark the series table(s) for conversion to numeric.

Parameters

gst

gretl string table.

 

opt

may include OPT_S to indicate that the string table was constructed from a spreadsheet file, in which case certain cells may be explicitly marked as holding strings, which information may be not be reliable.

 

Returns

0 on success, non-zero on error.


gretl_string_table_save ()

int
gretl_string_table_save (gretl_string_table *gst,
                         DATASET *dset);

Attaches the content of gst to dset .

Parameters

gst

gretl string table.

 

dset

dataset information (for names of variables).

 

Returns

0 on success, non-zero on error.


gretl_string_table_destroy ()

void
gretl_string_table_destroy (gretl_string_table *gst);

Frees all resources associated with gst .

Parameters

gst

gretl string table.

 

gretl_string_table_add_extra ()

void
gretl_string_table_add_extra (gretl_string_table *gst,
                              PRN *prn);

Steals the printing buffer from prn and adds it to gst . The buffer will be appended when gst is printed via gretl_string_table_finalize().

Parameters

gst

gretl string table.

 

prn

gretl printer.

 

gretl_string_table_reset_column_id ()

int
gretl_string_table_reset_column_id (gretl_string_table *gst,
                                    int oldid,
                                    int newid);

gretl_string_table_detach_col ()

series_table *
gretl_string_table_detach_col (gretl_string_table *gst,
                               int col);

in_string_table ()

int
in_string_table (gretl_string_table *gst,
                 int id);

string_table_copy_list ()

int *
string_table_copy_list (gretl_string_table *gst);

string_table_replace_list ()

int
string_table_replace_list (gretl_string_table *gst,
                           int *newlist);

series_table_new ()

series_table *
series_table_new (char **strs,
                  int n_strs,
                  int *err);

series_table_copy ()

series_table *
series_table_copy (series_table *st);

series_table_destroy ()

void
series_table_destroy (series_table *st);

Frees all resources associated with st .

Parameters

st

series string table.

 

series_table_get_value ()

double
series_table_get_value (series_table *st,
                        const char *s);

Parameters

st

a gretl series table.

 

s

the string to look up.

 

Returns

the numerical value associated with s in the given series table, or NADBL in case there is no match.


series_table_get_string ()

const char *
series_table_get_string (series_table *st,
                         double val);

Parameters

st

a gretl series table.

 

val

the numerical value to look up.

 

Returns

the string associated with val in the given series table, or NULL in case there is no match.


series_table_add_string ()

int
series_table_add_string (series_table *st,
                         const char *s);

Parameters

st

a gretl series table.

 

s

new string to add.

 

Returns

the index of the new string within the table, or -1 on failure.


series_table_get_strings ()

char **
series_table_get_strings (series_table *st,
                          int *n_strs);

Parameters

st

a gretl series table.

 

n_strs

location to receive the number of strings.

 

Returns

the array of strings associated with st . These should not be modified in any way.


series_table_get_n_strings ()

int
series_table_get_n_strings (series_table *st);

series_table_map ()

int *
series_table_map (series_table *st_from,
                  series_table *st_to);

Constructs a mapping from the integer codes in st_from to those in st_to . For example, if the string "foo" has code 3 in st_from and code 12 in st_to , then element 3 in the mapping array will have value 12. For any strings in st_from that are not matched in st_to , the associated element of the map is set to -1.

Element 0 of the map holds the number of following elements, which is the same as the number of strings in st_from .

Parameters

st_from

gretl series table.

 

st_to

gretl series table.

 

Returns

allocated array of int or NULL in case of failure.


series_table_print ()

void
series_table_print (DATASET *dset,
                    int i,
                    PRN *prn);

gretl_insert_builtin_string ()

void
gretl_insert_builtin_string (const char *name,
                             const char *s);

Inserts value s for string name in gretl's table of built-in string variables.

Parameters

name

the name of the string to be added or replaced.

 

s

the value for this string variable.

 

get_built_in_string_by_name ()

char *
get_built_in_string_by_name (const char *name);

builtin_strings_cleanup ()

void
builtin_strings_cleanup (void);

process_string_command ()

int
process_string_command (const char *line,
                        double ***pZ,
                        DATASET *dset,
                        PRN *prn);

substitute_named_strings ()

int
substitute_named_strings (char *line,
                          int *subst);

gretl_getenv ()

char *
gretl_getenv (const char *key,
              int *defined,
              int *err);

retrieve_date_string ()

char *
retrieve_date_string (int t,
                      const DATASET *dset,
                      int *err);

retrieve_date_strings ()

gretl_array *
retrieve_date_strings (const gretl_vector *v,
                       const DATASET *dset,
                       int *err);

retrieve_file_content ()

char *
retrieve_file_content (const char *fname,
                       const char *codset,
                       int *err);

gretl_backtick ()

char *
gretl_backtick (const char *arg,
                int *err);