gretl_string_table

gretl_string_table

Synopsis

gretl_string_table * gretl_string_table_new             (int *err);
gretl_string_table * string_table_new_from_cols_list    (int *list);
int                 gretl_string_table_index            (gretl_string_table *st,
                                                         const char *s,
                                                         int col,
                                                         int addcol,
                                                         PRN *prn);
int                 gretl_string_table_print            (gretl_string_table *st,
                                                         DATAINFO *pdinfo,
                                                         const char *fname,
                                                         PRN *prn);
void                gretl_string_table_destroy          (gretl_string_table *st);
void                gretl_string_table_add_extra        (gretl_string_table *st,
                                                         PRN *prn);
int                 gretl_string_table_reset_column_id  (gretl_string_table *st,
                                                         int oldid,
                                                         int newid);
void                gretl_insert_builtin_string         (const char *name,
                                                         const char *s);
int                 save_named_string                   (const char *name,
                                                         const char *s,
                                                         PRN *prn);
int                 add_string_as                       (const char *s,
                                                         const char *name);
char *              get_string_by_name                  (const char *name);
int                 process_string_command              (const char *line,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         PRN *prn);
int                 substitute_named_strings            (char *line,
                                                         int *subst);
int                 gretl_is_string                     (const char *sname);
int                 is_user_string                      (const char *sname);
void                saved_strings_cleanup               (void);
int                 delete_saved_string                 (const char *name,
                                                         PRN *prn);
void                destroy_user_strings                (void);
int                 destroy_saved_strings_at_level      (int d);
int                 is_codevar                          (const char *s);
int                 set_codevars                        (const char *s);
char *              gretl_getenv                        (const char *key,
                                                         int *defined,
                                                         int *err);
char *              retrieve_date_string                (int t,
                                                         const DATAINFO *pdinfo,
                                                         int *err);
char *              retrieve_file_content               (const char *fname,
                                                         int *err);
char *              gretl_backtick                      (const char *arg,
                                                         int *err);
                    gretl_string_table;

Description

Details

gretl_string_table_new ()

gretl_string_table * gretl_string_table_new             (int *err);

err :

location to receive error code.

Returns :

a pointer to a newly allocated string table.

string_table_new_from_cols_list ()

gretl_string_table * string_table_new_from_cols_list    (int *list);


gretl_string_table_index ()

int                 gretl_string_table_index            (gretl_string_table *st,
                                                         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).

st :

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 *st,
                                                         DATAINFO *pdinfo,
                                                         const char *fname,
                                                         PRN *prn);

Prints table st to a file called fname.

st :

gretl string table.

pdinfo :

dataset information (for names of variables).

fname :

name of file to which to print.

prn :

gretl printer (or NULL).

Returns :

0 on success, non-zero on error.

gretl_string_table_destroy ()

void                gretl_string_table_destroy          (gretl_string_table *st);

Frees all resources associated with st.

st :

gretl string table.

gretl_string_table_add_extra ()

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

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

st :

gretl string table.

prn :

gretl printer.

gretl_string_table_reset_column_id ()

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


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.

name :

the name of the string to be added or replaced.

s :

the value for this string variable.

save_named_string ()

int                 save_named_string                   (const char *name,
                                                         const char *s,
                                                         PRN *prn);


add_string_as ()

int                 add_string_as                       (const char *s,
                                                         const char *name);

Adds s to the saved array of string variables under the name name.

s :

string value to be added.

name :

the name of the string variable to add.

Returns :

0 on success, non-zero on failure.

get_string_by_name ()

char *              get_string_by_name                  (const char *name);

name :

the name of the string variable to access.

Returns :

the value of string variable name, or NULL if there is no such variable.

process_string_command ()

int                 process_string_command              (const char *line,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         PRN *prn);


substitute_named_strings ()

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


gretl_is_string ()

int                 gretl_is_string                     (const char *sname);

sname :

string to test.

Returns :

1 if sname os the name of a currently defined string variable, otherwise 0.

is_user_string ()

int                 is_user_string                      (const char *sname);


saved_strings_cleanup ()

void                saved_strings_cleanup               (void);


delete_saved_string ()

int                 delete_saved_string                 (const char *name,
                                                         PRN *prn);

Deletes the string variable called name.

name :

the name of the string variable to delete.

prn :

gretl printer (or NULL).

Returns :

0 on success, non-zero on failure (e.g. attempting to delete a built-in string variable).

destroy_user_strings ()

void                destroy_user_strings                (void);


destroy_saved_strings_at_level ()

int                 destroy_saved_strings_at_level      (int d);


is_codevar ()

int                 is_codevar                          (const char *s);


set_codevars ()

int                 set_codevars                        (const char *s);


gretl_getenv ()

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


retrieve_date_string ()

char *              retrieve_date_string                (int t,
                                                         const DATAINFO *pdinfo,
                                                         int *err);


retrieve_file_content ()

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


gretl_backtick ()

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


gretl_string_table

typedef struct _gretl_string_table gretl_string_table;