gretl_string_table

gretl_string_table

Functions

Types and Values

Object Hierarchy


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_print ()

int
gretl_string_table_print (gretl_string_table *gst,
                          DATASET *dset,
                          const char *fname,
                          PRN *prn);

Prints table gst to a file named string_table.txt in the user's working directory.

Parameters

gst

gretl string table.

 

dset

dataset information (for names of variables).

 

fname

name of the datafile to which the table pertains.

 

prn

gretl printer (or NULL).

 

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_print().

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);

Returns


series_table_new ()

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

Returns


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_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.


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);

Returns


builtin_strings_cleanup ()

void
builtin_strings_cleanup (void);


process_string_command ()

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

Returns


substitute_named_strings ()

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

Returns


gretl_getenv ()

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

Returns


retrieve_date_string ()

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

Returns


retrieve_file_content ()

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

Returns


gretl_backtick ()

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

Returns

Types and Values

gretl_string_table

typedef struct _gretl_string_table gretl_string_table;