1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-24 21:33:51 +03:00

parser: Add getters for XML declaration to parser context

Access to struct members will be deprecated.
This commit is contained in:
Nick Wellnhofer 2024-06-26 02:22:04 +02:00
parent 598ee0d2c6
commit eca972e682
3 changed files with 49 additions and 0 deletions

View File

@ -1406,6 +1406,12 @@ XMLPUBFUN int
XMLPUBFUN int
xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
int options);
XMLPUBFUN const xmlChar *
xmlCtxtGetVersion (xmlParserCtxtPtr ctxt);
XMLPUBFUN const xmlChar *
xmlCtxtGetDeclaredEncoding(xmlParserCtxtPtr ctxt);
XMLPUBFUN int
xmlCtxtGetStandalone (xmlParserCtxtPtr ctxt);
XMLPUBFUN void
xmlCtxtSetErrorHandler (xmlParserCtxtPtr ctxt,
xmlStructuredErrorFunc handler,

View File

@ -10404,6 +10404,34 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
}
}
/**
* xmlCtxtGetVersion:
* ctxt: parser context
*
* Returns the version from the XML declaration.
*/
const xmlChar *
xmlCtxtGetVersion(xmlParserCtxtPtr ctxt) {
if (ctxt == NULL)
return(NULL);
return(ctxt->version);
}
/**
* xmlCtxtGetStandalone:
* ctxt: parser context
*
* Returns the value from the standalone document declaration.
*/
int
xmlCtxtGetStandalone(xmlParserCtxtPtr ctxt) {
if (ctxt == NULL)
return(0);
return(ctxt->standalone);
}
/**
* xmlParseMisc:
* @ctxt: an XML parser context

View File

@ -1520,6 +1520,21 @@ xmlSetDeclaredEncoding(xmlParserCtxtPtr ctxt, xmlChar *encoding) {
ctxt->encoding = encoding;
}
/**
* xmlCtxtGetDeclaredEncoding:
* ctxt: parser context
*
* Returns the encoding from the encoding declaration. This can differ
* from the actual encoding.
*/
const xmlChar *
xmlCtxtGetDeclaredEncoding(xmlParserCtxtPtr ctxt) {
if (ctxt == NULL)
return(NULL);
return(ctxt->encoding);
}
/**
* xmlGetActualEncoding:
* @ctxt: the parser context