CAEN Utility  2.0.2
Utilities for CAEN projects
XML parser

Wrapper functions to libxml. More...

Functions

c_xmlfile_tc_xml_newfile (const char *filename)
 
c_xmlfile_tc_xml_newfile_from_memory (const char *buffer, int size)
 
void c_xml_freefile (c_xmlfile_t *file)
 
xmlNode * c_xml_getrootnode (const c_xmlfile_t *file)
 
const char * c_xml_getpath (const c_xmlfile_t *file)
 
xmlNodeSet * c_xml_getnodeset (c_xmlfile_t *file, const xmlChar *query)
 
void c_xml_freenodeset (xmlNodeSet *nodeset)
 
const char * c_xml_getattributevalue (const xmlNode *node, const char *attribute, bool warnEnable)
 
xmlNode * c_xml_getfirstnodefromxpathquery (c_xmlfile_t *file, const xmlChar *query)
 
xmlNode * c_xml_getnextelementfromname (xmlNode *node, const char *nodename)
 
xmlNode * c_getfirstsiblingelementfromname (xmlNode *node, const char *nodename)
 
xmlNode * c_xml_getfirstchildrenelementfromname (xmlNode *node, const char *nodename)
 
xmlNode * c_xml_getfirstdescendantelementfromname (xmlNode *node, const char *nodename)
 
int32_t c_xml_getcodefromnodechild (const xmlNode *node, double *code)
 
int32_t c_xml_getcodefromnode (const xmlNode *node, double *code)
 
int32_t c_xml_getcodefromcodename (const c_xmlfile_t *file, const char *__restrict category, const char *__restrict codename, double *code)
 
const char * c_xml_getattributevaluefromcodename (const c_xmlfile_t *file, const char *__restrict category, const char *__restrict codename, const char *__restrict attrname)
 
c_fcnhandle_t c_xml_getfunctionpointerfromcodename (const c_xmlfile_t *file, const char *codename)
 
int c_xml_snprintf (xmlChar *buf, int len, const char *msg,...)
 
int c_xml_strlen (const xmlChar *str)
 
const char * c_xml_parserversion (void)
 
void c_xml_parsercleanup (void)
 

Detailed Description

Wrapper functions to libxml.

Function Documentation

◆ c_xml_newfile()

c_xmlfile_t* c_xml_newfile ( const char *  filename)

Create a new c_xmlfile_t struct given its filename, and call xmlReadFile().

Parameters
[in]filenamepath to XML file or URL
Returns
An initialized pointer. NULL in case of error.

Definition at line 54 of file CAENXMLParser.c.

Here is the call graph for this function:

◆ c_xml_newfile_from_memory()

c_xmlfile_t* c_xml_newfile_from_memory ( const char *  buffer,
int  size 
)

Create a new c_xmlfile_t struct given a buffer in memory, and call xmlReadMemory().

Parameters
[in]buffera pointer to a char array
[in]sizethe size of the array
Returns
An initialized pointer. NULL in case of error.

Definition at line 79 of file CAENXMLParser.c.

Here is the call graph for this function:

◆ c_xml_freefile()

void c_xml_freefile ( c_xmlfile_t file)

Free memory allocated by c_xml_newfile() of c_xml_newfile_from_buffer() and close the document.

Parameters
[in]filea pointer returned by c_xml_newfile() or c_xml_newfile_from_memory(). If NULL, no operation is performed.

Definition at line 106 of file CAENXMLParser.c.

Here is the call graph for this function:

◆ c_xml_getrootnode()

xmlNode* c_xml_getrootnode ( const c_xmlfile_t file)

Wrapper to xmlDocGetRootElement(file->doc).

Parameters
[in]filethe file
Returns
the xmlNode pointer for the root. NULL in case of error.

Definition at line 117 of file CAENXMLParser.c.

Here is the caller graph for this function:

◆ c_xml_getpath()

const char* c_xml_getpath ( const c_xmlfile_t file)

Get the complete path of the document.

Parameters
[in]filethe file
Returns
a pointer to the filename

Definition at line 238 of file CAENXMLParser.c.

◆ c_xml_getnodeset()

xmlNodeSet* c_xml_getnodeset ( c_xmlfile_t file,
const xmlChar *  query 
)

Uses 'query' expression to get a nodeset from 'file'.

Parameters
[in]filethe file
[in]querythe expression
Returns
a pointer to a xmlNodeSet, to be freed with c_xml_freenodeset(). NULL in case of error.

Definition at line 121 of file CAENXMLParser.c.

Here is the caller graph for this function:

◆ c_xml_freenodeset()

void c_xml_freenodeset ( xmlNodeSet *  nodeset)

Wrapper to xmlXPathFreeNodeSet(nodeset).

Parameters
[in]nodeseta pointer returned by c_xml_getnodeset(). If NULL, no operation is performed.

Definition at line 146 of file CAENXMLParser.c.

Here is the caller graph for this function:

◆ c_xml_getattributevalue()

const char* c_xml_getattributevalue ( const xmlNode *  node,
const char *  attribute,
bool  warnEnable 
)

Parses an xmlNode to get the value of the one named 'attr'.

Parameters
[in]nodea node
[in]attributethe name of the attribute to get
[in]warnEnableif true, print a message to the log in case of error
Returns
a pointer the value of the attribute. NULL in case of error.

Definition at line 151 of file CAENXMLParser.c.

Here is the caller graph for this function:

◆ c_xml_getfirstnodefromxpathquery()

xmlNode* c_xml_getfirstnodefromxpathquery ( c_xmlfile_t file,
const xmlChar *  query 
)

Returns the first random-ordered node which matches the query. To be used only for queries which produce for sure a single result.

Parameters
[in]filethe file
[in]querythe query
Returns
a pointer the node. NULL in case number of results is not 1 (0 or more than 1).

Definition at line 162 of file CAENXMLParser.c.

Here is the call graph for this function:

◆ c_xml_getnextelementfromname()

xmlNode* c_xml_getnextelementfromname ( xmlNode *  node,
const char *  nodename 
)

Parses an xmlNode to get the first one called 'nodename'.

Parameters
[in]nodea node
[in]nodenamethe name
Returns
a pointer the node. If 'node' itself matches 'nodename', 'node' is returned. NULL in case of error.

Definition at line 176 of file CAENXMLParser.c.

Here is the caller graph for this function:

◆ c_getfirstsiblingelementfromname()

xmlNode* c_getfirstsiblingelementfromname ( xmlNode *  node,
const char *  nodename 
)

Parses an xmlNode siblings to get the first one called 'nodename'.

Parameters
[in]nodea node
[in]nodenamethe name
Returns
a pointer the node. NULL in case of error.

Definition at line 188 of file CAENXMLParser.c.

Here is the call graph for this function:

◆ c_xml_getfirstchildrenelementfromname()

xmlNode* c_xml_getfirstchildrenelementfromname ( xmlNode *  node,
const char *  nodename 
)

Parses an xmlNode children to get the first one called 'nodename'.

Parameters
[in]nodea node
[in]nodenamethe name
Returns
a pointer the node. NULL in case of error.

Definition at line 197 of file CAENXMLParser.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_xml_getfirstdescendantelementfromname()

xmlNode* c_xml_getfirstdescendantelementfromname ( xmlNode *  node,
const char *  nodename 
)

Parses an xmlNode descendants to get the first one whose hierachy is 'nodename'.

Parameters
[in]nodea node
[in]nodenamethe name
Returns
a pointer the node. NULL in case of error.

Definition at line 207 of file CAENXMLParser.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_xml_getcodefromnodechild()

int32_t c_xml_getcodefromnodechild ( const xmlNode *  node,
double *  code 
)

Get value in 'node' first child, taking into account possible double or hexadecimal representation.

Parameters
[in]nodea node
[out]codethe value
Returns
c_xml_RetCode_Success (0) in case of success. Error codes specified in c_xml_RetCode_t.

Definition at line 244 of file CAENXMLParser.c.

Here is the caller graph for this function:

◆ c_xml_getcodefromnode()

int32_t c_xml_getcodefromnode ( const xmlNode *  node,
double *  code 
)

Get value in 'node[/code]', taking into account possible double or hexadecimal representation.

Parameters
[in]nodea node
[out]codethe returned value
Returns
c_xml_RetCode_Success (0) in case of success. Error codes specified in c_xml_RetCode_t.

Definition at line 270 of file CAENXMLParser.c.

Here is the call graph for this function:

◆ c_xml_getcodefromcodename()

int32_t c_xml_getcodefromcodename ( const c_xmlfile_t file,
const char *__restrict  category,
const char *__restrict  codename,
double *  code 
)

Looks for a node called '/Definitions/${category}/${codename}' to get its value converted to double. Both double and hexadecimal integer parsing are supported.

Parameters
[in]filethe file
[in]categorythe category name
[in]codenamethe codename
[out]codethe returned value
Returns
c_xml_RetCode_Success (0) in case of success. Error codes specified in c_xml_RetCode_t.

Definition at line 293 of file CAENXMLParser.c.

Here is the call graph for this function:

◆ c_xml_getattributevaluefromcodename()

const char* c_xml_getattributevaluefromcodename ( const c_xmlfile_t file,
const char *__restrict  category,
const char *__restrict  codename,
const char *__restrict  attrname 
)

Looks for a node called '/Definitions/${category}/${codename}' to get the attribute named 'attrname'.

Parameters
[in]filethe file
[in]categorythe category name
[in]codenamethe codename
[in]attrnamethe atribute
Returns
a pointer the value of the attribute. NULL in case of error.

Definition at line 320 of file CAENXMLParser.c.

Here is the call graph for this function:

◆ c_xml_getfunctionpointerfromcodename()

c_fcnhandle_t c_xml_getfunctionpointerfromcodename ( const c_xmlfile_t file,
const char *  codename 
)

Looks for a node called '/Definitions/XMLFunctions/${codename}' to dynamically load a function with name 'codename' from library specified by node's 'libname' attribute.

Parameters
[in]filethe file
[in]codenamethe codename
Returns
a pointer to that function. NULL in case of error.

Definition at line 349 of file CAENXMLParser.c.

Here is the call graph for this function:

◆ c_xml_snprintf()

int c_xml_snprintf ( xmlChar *  buf,
int  len,
const char *  msg,
  ... 
)

Wrapper to xmlStrPrintf().

Parameters
[out]bufthe result buffer
[in]lenthe result buffer length
[in]msgthe message with printf formatting
[in]...extra parameters for the message
Returns
the number of characters written to buf or -1 if an error occurs

Definition at line 401 of file CAENXMLParser.c.

◆ c_xml_strlen()

int c_xml_strlen ( const xmlChar *  str)

Length of a xmlChar's string. Wrapper to xmlStrlen().

Parameters
[in]strthe xmlChar array
Returns
the number of xmlChar contained in the the xmlChar array

Definition at line 416 of file CAENXMLParser.c.

◆ c_xml_parserversion()

const char* c_xml_parserversion ( void  )

Version of LibXML parser. Wrapper to xmlParserVersion.

Returns
the version.

Definition at line 420 of file CAENXMLParser.c.

◆ c_xml_parsercleanup()

void c_xml_parsercleanup ( void  )

Cleanup of allocated resources. To be used when the module will not be used anymore. Wrapper to xmlCleanupParser(). Also close the libray, if some calls to c_xml_getfunctionpointerfromcodename() occurred.

Definition at line 388 of file CAENXMLParser.c.

Here is the call graph for this function:
Here is the caller graph for this function: