mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-21 14:53:44 +03:00
Provide new accessors for xmlOutputBuffer
To avoid digging into buf->buffer insternal strcuture the two new entry points xmlOutputBufferGetContent() and xmlOutputBufferGetSize() should make the ode cleaner. * include/libxml/xmlIO.h: add two new functions * xmlIO.c: impement the 2 functions based on the new buffer entry points
This commit is contained in:
@@ -245,6 +245,12 @@ XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
|||||||
void *ioctx,
|
void *ioctx,
|
||||||
xmlCharEncodingHandlerPtr encoder);
|
xmlCharEncodingHandlerPtr encoder);
|
||||||
|
|
||||||
|
/* Couple of APIs to get the output without digging into the buffers */
|
||||||
|
XMLPUBFUN const xmlChar * XMLCALL
|
||||||
|
xmlOutputBufferGetContent (xmlOutputBufferPtr out);
|
||||||
|
XMLPUBFUN size_t XMLCALL
|
||||||
|
xmlOutputBufferGetSize (xmlOutputBufferPtr out);
|
||||||
|
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlOutputBufferWrite (xmlOutputBufferPtr out,
|
xmlOutputBufferWrite (xmlOutputBufferPtr out,
|
||||||
int len,
|
int len,
|
||||||
|
33
xmlIO.c
33
xmlIO.c
@@ -2922,6 +2922,39 @@ xmlOutputBufferCreateBuffer(xmlBufferPtr buffer,
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlOutputBufferGetContent:
|
||||||
|
* @out: an xmlOutputBufferPtr
|
||||||
|
*
|
||||||
|
* Gives a pointer to the data currently held in the output buffer
|
||||||
|
*
|
||||||
|
* Returns a pointer to the data or NULL in case of error
|
||||||
|
*/
|
||||||
|
const xmlChar *
|
||||||
|
xmlOutputBufferGetContent(xmlOutputBufferPtr out) {
|
||||||
|
if ((out == NULL) || (out->buffer == NULL))
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
|
return(xmlBufContent(out->buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlOutputBufferGetSize:
|
||||||
|
* @out: an xmlOutputBufferPtr
|
||||||
|
*
|
||||||
|
* Gives the length of the data currently held in the output buffer
|
||||||
|
*
|
||||||
|
* Returns 0 in case or error or no data is held, the size otherwise
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
xmlOutputBufferGetSize(xmlOutputBufferPtr out) {
|
||||||
|
if ((out == NULL) || (out->buffer == NULL))
|
||||||
|
return(0);
|
||||||
|
|
||||||
|
return(xmlBufUse(out->buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user