gretl_xml

gretl_xml

Functions

Types and Values

#define XUC

Object Hierarchy


Description

Functions

gretl_xml_header ()

void
gretl_xml_header (FILE *fp);


gretl_xml_open_doc_root ()

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

Returns


gretl_xml_put_int ()

void
gretl_xml_put_int (const char *tag,
                   int i,
                   FILE *fp);

Writes to fp a string of the form "%s=%d".

Parameters

tag

name to give value.

 

i

value to put (as attribute)

 

fp

file to which to write.

 

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

Parameters

tag

name to give value.

 

x

value to put (as attribute)

 

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

Parameters

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

Parameters

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

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

Parameters

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

Parameters

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

Parameters

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.

Parameters

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.

Parameters

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

Parameters

m

matrix to be written.

 

name

name for matrix.

 

fp

file to which to write.

 

gretl_xml_put_matrix_to_prn ()

void
gretl_xml_put_matrix_to_prn (const gretl_matrix *m,
                             const char *name,
                             PRN *prn);

Parameters

m

matrix to be written.

 

name

name for matrix.

 

prn

gretl printer.

 

gretl_xml_get_prop_as_int ()

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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 white space.

Parameters

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

int
gretl_xml_child_get_string (xmlNodePtr node,
                            xmlDocPtr doc,
                            const char *name,
                            char **pstr);

Parameters

node

XML node pointer.

 

doc

XML document pointer.

 

name

name of child node.

 

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

Parameters

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

Parameters

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

Parameters

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 slop,
                             int *err);

Parameters

node

XML node pointer.

 

doc

XML document pointer.

 

nelem

location to receive number of elements in array.

 

slop

if non-zero, allow the number of strings to fall short of the recorded string count by one.

 

err

location to receive error code.

 

Returns

allocated array of strings read from node , or NULL on failure.


gretl_xml_child_get_strings_array ()

int
gretl_xml_child_get_strings_array (xmlNodePtr node,
                                   xmlDocPtr doc,
                                   const char *name,
                                   char ***pstrs,
                                   int *nstrs);

Parameters

node

XML node pointer.

 

doc

XML document pointer.

 

name

name of child node.

 

pstrs

location to receive strings array.

 

nstrs

location to receive number of strings.

 

Returns

1 if an array of strings is found and read successfully, 0 otherwise.


gretl_xml_get_matrix ()

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

Parameters

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.


xml_get_user_matrix ()

gretl_matrix *
xml_get_user_matrix (xmlNodePtr node,
                     xmlDocPtr doc,
                     char **colnames,
                     char **rownames,
                     int *err);

Parameters

node

XML node pointer.

 

doc

XML document pointer.

 

colnames

location to receive column labels, if present.

 

rownames

location to receive row labels, if present.

 

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

Parameters

node

XML node pointer.

 

doc

XML document pointer.

 

pmask

location to receive allocated mask.

 

Returns

0 on success, non-zero on failure.


gretl_xml_serialize_matrix ()

char *
gretl_xml_serialize_matrix (const gretl_matrix *m,
                            const char *name);

Parameters

m

matrix to be written.

 

name

name for matrix (or NULL).

 

Returns

allocated string containing the serialized matrix as XML.


gretl_xml_deserialize_matrix ()

gretl_matrix *
gretl_xml_deserialize_matrix (const char *buf,
                              int size,
                              int *err);

Parameters

buf

character buffer containing serialization of a gretl matrix.

 

size

size of buf , or -1 to use full length of a NUL-terminated buffer.

 

err

location to receive error code.

 

Returns

allocated gretl_matrix, or NULL 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.

Parameters

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 DATASET *dset,
                 gretlopt opt,
                 int progress);

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

Parameters

fname

name of file to write.

 

list

list of variables to write (or NULL to write all).

 

dset

dataset struct.

 

opt

if OPT_Z write gzipped data, else uncompressed.

 

progress

may be 1 when called from gui to display progress bar in case of a large data write; generally should be 0.

 

Returns

0 on successful completion, non-zero on error.


gretl_read_gdt ()

int
gretl_read_gdt (const char *fname,
                DATASET *dset,
                gretlopt opt,
                PRN *prn);

Read data from native file into gretl's workspace.

Parameters

fname

name of file to open for reading.

 

dset

dataset struct.

 

opt

use OPT_B to display gui progress bar; may also use OPT_T when appending to panel data (see the "append" command in the gretl manual). Otherwise use OPT_NONE.

 

prn

where any messages should be written.

 

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 native data file.

Parameters

fname

name of file to try.

 

Returns

buffer containing description, or NULL on failure.


load_user_XML_file ()

int
load_user_XML_file (const char *fname,
                    PRN *prn);

Returns

Types and Values

XUC

#define XUC const xmlChar *