gretl_xml

gretl_xml —

Synopsis




#define     XUC
void        gretl_xml_header                (FILE *fp);
int         gretl_xml_open_doc_root         (const char *fname,
                                             const char *rootname,
                                             xmlDocPtr *pdoc,
                                             xmlNodePtr *pnode);
void        gretl_xml_put_double            (const char *tag,
                                             double x,
                                             FILE *fp);
void        gretl_xml_put_double_array      (const char *tag,
                                             double *x,
                                             int n,
                                             FILE *fp);
void        gretl_xml_put_strings_array     (const char *tag,
                                             const char **strs,
                                             int n,
                                             FILE *fp);
void        gretl_xml_put_named_list        (const char *name,
                                             const int *list,
                                             FILE *fp);
void        gretl_xml_put_tagged_list       (const char *tag,
                                             const int *list,
                                             FILE *fp);
int         gretl_xml_put_tagged_string     (const char *tag,
                                             const char *str,
                                             FILE *fp);
int         gretl_xml_put_raw_string        (const char *str,
                                             FILE *fp);
void        gretl_xml_put_matrix            (const gretl_matrix *m,
                                             const char *name,
                                             FILE *fp);
int         gretl_xml_get_prop_as_int       (xmlNodePtr node,
                                             const char *tag,
                                             int *i);
int         gretl_xml_get_prop_as_char      (xmlNodePtr node,
                                             const char *tag,
                                             char *c);
int         gretl_xml_get_prop_as_uchar     (xmlNodePtr node,
                                             const char *tag,
                                             unsigned char *u);
int         gretl_xml_get_prop_as_double    (xmlNodePtr node,
                                             const char *tag,
                                             double *x);
int         gretl_xml_get_prop_as_string    (xmlNodePtr node,
                                             const char *tag,
                                             char **pstr);
int         gretl_xml_get_prop_as_bool      (xmlNodePtr node,
                                             const char *tag);
int         gretl_xml_node_get_int          (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *i);
int         gretl_xml_node_get_double       (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             double *x);
int*        gretl_xml_node_get_list         (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *err);
int         gretl_xml_node_get_string       (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             char **pstr);
int         gretl_xml_node_get_trimmed_string
                                            (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             char **pstr);
int*        gretl_xml_get_int_array         (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *nelem,
                                             int *err);
double*     gretl_xml_get_double_array      (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *nelem,
                                             int *err);
cmplx*      gretl_xml_get_cmplx_array       (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *nelem,
                                             int *err);
char**      gretl_xml_get_strings_array     (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *nelem,
                                             int *err);
gretl_matrix* gretl_xml_get_matrix          (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *err);
int         gretl_xml_get_submask           (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             char **pmask,
                                             int *pmode);
int         gretl_write_matrix_as_gdt       (const char *fname,
                                             const gretl_matrix *X,
                                             const char **varnames,
                                             const char **labels);
int         gretl_write_gdt                 (const char *fname,
                                             const int *list,
                                             const double **Z,
                                             const DATAINFO *pdinfo,
                                             GretlDataFormat fmt,
                                             PATHS *ppaths);
int         gretl_read_gdt                  (double ***pZ,
                                             DATAINFO **ppdinfo,
                                             char *fname,
                                             PATHS *ppaths,
                                             DataOpenCode ocode,
                                             PRN *prn,
                                             int gui);
char*       gretl_get_gdt_description       (const char *fname);
int         load_user_matrix_file           (const char *fname);
int         load_user_XML_file              (const char *fname);

Description

Details

XUC

#define XUC const xmlChar *


gretl_xml_header ()

void        gretl_xml_header                (FILE *fp);

fp :

gretl_xml_open_doc_root ()

int         gretl_xml_open_doc_root         (const char *fname,
                                             const char *rootname,
                                             xmlDocPtr *pdoc,
                                             xmlNodePtr *pnode);

fname :
rootname :
pdoc :
pnode :
Returns :

gretl_xml_put_double ()

void        gretl_xml_put_double            (const char *tag,
                                             double x,
                                             FILE *fp);

Writes to fp a string of the form "s=%.15g" if the value of x is valid, otherwise "s=NA".

tag : name to give value.
x : value to put.
fp : file to which to write.

gretl_xml_put_double_array ()

void        gretl_xml_put_double_array      (const char *tag,
                                             double *x,
                                             int n,
                                             FILE *fp);

tag : name to give array.
x : values to put.
n : number of values in x.
fp : file to which to write.

gretl_xml_put_strings_array ()

void        gretl_xml_put_strings_array     (const char *tag,
                                             const char **strs,
                                             int n,
                                             FILE *fp);

tag : name to give array.
strs : array of strings to put.
n : number of strings in strs.
fp : file to which to write.

gretl_xml_put_named_list ()

void        gretl_xml_put_named_list        (const char *name,
                                             const int *list,
                                             FILE *fp);

name : name to give list.
list : list of integers to be written.
fp : file to which to write.

gretl_xml_put_tagged_list ()

void        gretl_xml_put_tagged_list       (const char *tag,
                                             const int *list,
                                             FILE *fp);

tag : tag in which list should be wrapped.
list : list of integers to be written.
fp : file to which to write.

gretl_xml_put_tagged_string ()

int         gretl_xml_put_tagged_string     (const char *tag,
                                             const char *str,
                                             FILE *fp);

Write str to fp, enclosed in simple starting and ending tags specified by tag. If str needs to have XML-special characters escaped, this will be done automatically. If str is NULL, this is considered a no-op.

tag : name to give string.
str : string to put.
fp : file to which to write.
Returns : 0 on success, non-zero error code on failure.

gretl_xml_put_raw_string ()

int         gretl_xml_put_raw_string        (const char *str,
                                             FILE *fp);

Write str to fp. If str needs to have XML-special characters escaped, this will be done automatically. If str is NULL, this is considered a no-op.

str : string to put.
fp : file to which to write.
Returns : 0 on success, non-zero error code on failure.

gretl_xml_put_matrix ()

void        gretl_xml_put_matrix            (const gretl_matrix *m,
                                             const char *name,
                                             FILE *fp);

m : matrix to be written.
name : name for matrix.
fp : file to which to write.

gretl_xml_get_prop_as_int ()

int         gretl_xml_get_prop_as_int       (xmlNodePtr node,
                                             const char *tag,
                                             int *i);

node : XML node pointer.
tag : name by which integer property is known.
i : location to write int value.
Returns : 1 if an int is found and read successfully, 0 otherwise.

gretl_xml_get_prop_as_char ()

int         gretl_xml_get_prop_as_char      (xmlNodePtr node,
                                             const char *tag,
                                             char *c);

node : XML node pointer.
tag : name by which character property is known.
c : location to write value.
Returns : 1 if a char is found and read successfully, 0 otherwise.

gretl_xml_get_prop_as_uchar ()

int         gretl_xml_get_prop_as_uchar     (xmlNodePtr node,
                                             const char *tag,
                                             unsigned char *u);

node : XML node pointer.
tag : name by which unsigned character property is known.
u : location to write value.
Returns : 1 if an unsigned char is found and read successfully, 0 otherwise.

gretl_xml_get_prop_as_double ()

int         gretl_xml_get_prop_as_double    (xmlNodePtr node,
                                             const char *tag,
                                             double *x);

node : XML node pointer.
tag : name by which floating-point property is known.
x : location to write double value.
Returns : 1 if a double is found and read successfully, 0 otherwise.

gretl_xml_get_prop_as_string ()

int         gretl_xml_get_prop_as_string    (xmlNodePtr node,
                                             const char *tag,
                                             char **pstr);

node : XML node pointer.
tag : name by which string property is known.
pstr : location to assign string.
Returns : 1 if a string is found and read successfully, 0 otherwise.

gretl_xml_get_prop_as_bool ()

int         gretl_xml_get_prop_as_bool      (xmlNodePtr node,
                                             const char *tag);

node : XML node pointer.
tag : name by which property is known.
Returns : 1 if the named property is found and has value true, else 0.

gretl_xml_node_get_int ()

int         gretl_xml_node_get_int          (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *i);

node : XML node pointer.
doc : XML document pointer.
i : location to receive integer.
Returns : 1 if an int is found and read successfully, 0 otherwise.

gretl_xml_node_get_double ()

int         gretl_xml_node_get_double       (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             double *x);

node : XML node pointer.
doc : XML document pointer.
x : location to receive double.
Returns : 1 if a double is found and read successfully, 0 otherwise.

gretl_xml_node_get_list ()

int*        gretl_xml_node_get_list         (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *err);

node : XML node pointer.
doc : XML document pointer.
err : location to receive error code.
Returns : allocated list read from node, or NULL on failure.

gretl_xml_node_get_string ()

int         gretl_xml_node_get_string       (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             char **pstr);

node : XML node pointer.
doc : XML document pointer.
pstr : location to receive string.
Returns : 1 if a string is found and read successfully, 0 otherwise.

gretl_xml_node_get_trimmed_string ()

int         gretl_xml_node_get_trimmed_string
                                            (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             char **pstr);

Reads a string from node and trims both leading and trailing whit space.

node : XML node pointer.
doc : XML document pointer.
pstr : location to receive string.
Returns : 1 if a string is found and read successfully, 0 otherwise.

gretl_xml_get_int_array ()

int*        gretl_xml_get_int_array         (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *nelem,
                                             int *err);

node : XML node pointer.
doc : XML document pointer.
nelem : location to receive number of elements in array.
err : location to receive error code.
Returns : allocated array of integers read from node, or NULL on failure.

gretl_xml_get_double_array ()

double*     gretl_xml_get_double_array      (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *nelem,
                                             int *err);

node : XML node pointer.
doc : XML document pointer.
nelem : location to receive number of elements in array.
err : location to receive error code.
Returns : allocated array of doubles read from node, or NULL on failure.

gretl_xml_get_cmplx_array ()

cmplx*      gretl_xml_get_cmplx_array       (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *nelem,
                                             int *err);

node : XML node pointer.
doc : XML document pointer.
nelem : location to receive number of elements in array.
err : location to receive error code.
Returns : allocated array of cmplx (complex numbers) read from node, or NULL on failure.

gretl_xml_get_strings_array ()

char**      gretl_xml_get_strings_array     (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *nelem,
                                             int *err);

node : XML node pointer.
doc : XML document pointer.
nelem : location to receive number of elements in array.
err : location to receive error code.
Returns : allocated array of cmplx (complex numbers) read from node, or NULL on failure.

gretl_xml_get_matrix ()

gretl_matrix* gretl_xml_get_matrix          (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             int *err);

node : XML node pointer.
doc : XML document pointer.
err : location to receive error code.
Returns : allocated gretl matrix read from node, or NULL on failure.

gretl_xml_get_submask ()

int         gretl_xml_get_submask           (xmlNodePtr node,
                                             xmlDocPtr doc,
                                             char **pmask,
                                             int *pmode);

node : XML node pointer.
doc : XML document pointer.
pmask : location to receive allocated mask.
pmode : location to receive sub-sampling mode (or NULL).
Returns : 0 on success, non-zero on failure.

gretl_write_matrix_as_gdt ()

int         gretl_write_matrix_as_gdt       (const char *fname,
                                             const gretl_matrix *X,
                                             const char **varnames,
                                             const char **labels);

Write out a .gdt data file containing the elements of of the given matrix.

fname : name of file to write.
X : matrix, variable in columns.
varnames : column names.
labels : descriptive labels for the variables, or NULL.
Returns : 0 on successful completion, non-zero on error.

gretl_write_gdt ()

int         gretl_write_gdt                 (const char *fname,
                                             const int *list,
                                             const double **Z,
                                             const DATAINFO *pdinfo,
                                             GretlDataFormat fmt,
                                             PATHS *ppaths);

Write out in xml a data file containing the values of the given set of variables.

fname : name of file to write.
list : list of variables to write (or NULL to write all).
Z : data matrix.
pdinfo : data information struct.
fmt : if GRETL_DATA_GZIPPED write gzipped data, else uncompressed.
ppaths : pointer to paths information (or NULL).
Returns : 0 on successful completion, non-zero on error.

gretl_read_gdt ()

int         gretl_read_gdt                  (double ***pZ,
                                             DATAINFO **ppdinfo,
                                             char *fname,
                                             PATHS *ppaths,
                                             DataOpenCode ocode,
                                             PRN *prn,
                                             int gui);

Read data from file into gretl's work space, allocating space as required.

pZ : pointer to data set.
ppdinfo : pointer to data information struct.
fname : name of file to try.
ppaths : path information struct.
ocode : DATA_NONE: no datafile currently open; DATA_CLEAR: datafile is open, should be cleared; DATA_APPEND: add to current dataset.
prn : where messages should be written.
gui : should = 1 if the function is launched from the GUI, else 0.
Returns : 0 on successful completion, non-zero otherwise.

gretl_get_gdt_description ()

char*       gretl_get_gdt_description       (const char *fname);

Read data description for gretl xml (.gdt) data file.

fname : name of file to try.
Returns : buffer containing description, or NULL on failure.

load_user_matrix_file ()

int         load_user_matrix_file           (const char *fname);

fname :
Returns :

load_user_XML_file ()

int         load_user_XML_file              (const char *fname);

fname :
Returns :