LibreOffice Module sax (master) 1
|
Receives notification of sax document events to write into an XOutputStream. More...
#include <fastserializer.hxx>
Classes | |
class | ForMerge |
class | ForSort |
Public Member Functions | |
FastSaxSerializer (const css::uno::Reference< css::io::XOutputStream > &xOutputStream) | |
~FastSaxSerializer () | |
css::uno::Reference< css::io::XOutputStream > const & | getOutputStream () const |
TokenValueList & | getTokenValueList () |
called by FSHelper to put data in for writeTokenValueList More... | |
void | startDocument () |
called by the parser when parsing of an XML stream is started. More... | |
void | endDocument () |
called by the parser after the last XML element of a stream is processed. More... | |
void | startFastElement (::sal_Int32 Element, FastAttributeList const *pAttrList=nullptr) |
receives notification of the beginning of an element. More... | |
void | endFastElement (::sal_Int32 Element) |
receives notification of the end of a known element. More... | |
void | singleFastElement (::sal_Int32 Element, FastAttributeList const *pAttrList=nullptr) |
receives notification of the beginning of a single element. More... | |
void | writeId (::sal_Int32 Element) |
OString | getId (::sal_Int32 Element) |
void | write (double value) |
void | write (std::u16string_view s, bool bEscape=false) |
void | write (std::string_view s, bool bEscape=false) |
void | write (const char *pStr, sal_Int32 nLen, bool bEscape=false) |
void | setAllowXEscape (bool bSet) |
void | mark (sal_Int32 nTag, const Int32Sequence &rOrder) |
From now on, don't write directly to the stream, but to top of a stack. More... | |
void | mergeTopMarks (sal_Int32 nTag, sax_fastparser::MergeMarks eMergeType) |
Merge 2 topmost marks. More... | |
Private Types | |
typedef css::uno::Sequence< ::sal_Int8 > | Int8Sequence |
typedef css::uno::Sequence< ::sal_Int32 > | Int32Sequence |
Private Member Functions | |
void | writeTokenValueList () |
void | writeFastAttributeList (FastAttributeList const &rAttrList) |
void | writeBytes (const css::uno::Sequence< ::sal_Int8 > &aData) |
Forward the call to the output stream, or write to the stack. More... | |
void | writeBytes (const char *pStr, size_t nLen) |
Private Attributes | |
CachedOutputStream | maCachedOutputStream |
Helper class to cache data and write in chunks to XOutputStream or ForMerge::append. More... | |
css::uno::Reference< css::xml::sax::XFastTokenHandler > | mxFastTokenHandler |
std::stack< std::shared_ptr< ForMerge > > | maMarkStack |
bool | mbMarkStackEmpty |
rtl_String * | mpDoubleStr |
sal_Int32 | mnDoubleStrCapacity |
TokenValueList | maTokenValues |
bool | mbXescape |
whether to escape invalid XML characters as xHHHH in write(const char*,sal_Int32,true) More... | |
std::stack< sal_Int32 > | m_DebugStartedElements |
Receives notification of sax document events to write into an XOutputStream.
Definition at line 46 of file fastserializer.hxx.
|
private |
Definition at line 49 of file fastserializer.hxx.
|
private |
Definition at line 48 of file fastserializer.hxx.
|
explicit |
Definition at line 60 of file fastserializer.cxx.
References maCachedOutputStream, mnDoubleStrCapacity, mpDoubleStr, mxFastTokenHandler, and sax_fastparser::CachedOutputStream::setOutputStream().
sax_fastparser::FastSaxSerializer::~FastSaxSerializer | ( | ) |
Definition at line 73 of file fastserializer.cxx.
References mpDoubleStr.
void sax_fastparser::FastSaxSerializer::endDocument | ( | ) |
called by the parser after the last XML element of a stream is processed.
Definition at line 310 of file fastserializer.cxx.
References sax_fastparser::CachedOutputStream::flush(), maCachedOutputStream, maMarkStack, and mbMarkStackEmpty.
void sax_fastparser::FastSaxSerializer::endFastElement | ( | ::sal_Int32 | Element | ) |
receives notification of the end of a known element.
Definition at line 380 of file fastserializer.cxx.
References m_DebugStartedElements, maMarkStack, mbMarkStackEmpty, N_CHARS, sClosingBracket, sOpeningBracketAndSlash, writeBytes(), and writeId().
OString sax_fastparser::FastSaxSerializer::getId | ( | ::sal_Int32 | Element | ) |
Definition at line 334 of file fastserializer.cxx.
References HAS_NAMESPACE, mxFastTokenHandler, name, NAMESPACE, ns, sColon, and TOKEN.
Referenced by writeFastAttributeList(), and writeTokenValueList().
css::uno::Reference< css::io::XOutputStream > const & sax_fastparser::FastSaxSerializer::getOutputStream | ( | ) | const |
Definition at line 435 of file fastserializer.cxx.
References sax_fastparser::CachedOutputStream::getOutputStream(), and maCachedOutputStream.
|
inline |
called by FSHelper to put data in for writeTokenValueList
Definition at line 57 of file fastserializer.hxx.
References maTokenValues.
void sax_fastparser::FastSaxSerializer::mark | ( | sal_Int32 | nTag, |
const Int32Sequence & | rOrder | ||
) |
From now on, don't write directly to the stream, but to top of a stack.
This is to be able to change the order of the data being written. If you need to write eg. p, r, rPr, [something], /rPr, t, [text], /t, /r, /p, but get it in order p, r, t, [text], /t, rPr, [something], /rPr, /r, /p, simply do p, r, mark(), t, [text], /t, mark(), rPr, [something], /rPr, mergeTopMarks( MergeMarks::PREPEND ), mergeTopMarks( MergeMarks::APPEND ), /r, /p and you are done.
nTag | debugging aid to ensure mark and merge match in LIFO order |
Definition at line 506 of file fastserializer.cxx.
References maCachedOutputStream, maMarkStack, mbMarkStackEmpty, and sax_fastparser::CachedOutputStream::setOutput().
void sax_fastparser::FastSaxSerializer::mergeTopMarks | ( | sal_Int32 | nTag, |
sax_fastparser::MergeMarks | eMergeType | ||
) |
Merge 2 topmost marks.
The possibilities: prepend the top before the second top-most mark, append it, append it later or ignore; prepending brings the possibility to switch parts of the output, appending later allows to write some output in advance.
Writes the result to the output stream if the mark stack becomes empty by the operation.
When the MergeMarks::POSTPONE is specified, the merge happens just before the next merge.
nTag | debugging aid to ensure mark and merge match in LIFO order |
Definition at line 577 of file fastserializer.cxx.
References sax_fastparser::APPEND, aSeq, sax_fastparser::CachedOutputStream::flush(), sax_fastparser::lcl_DebugMergeAppend(), sax_fastparser::lcl_DebugMergePrepend(), m_DebugStartedElements, maCachedOutputStream, maMarkStack, mbMarkStackEmpty, sax_fastparser::POSTPONE, sax_fastparser::PREPEND, sax_fastparser::CachedOutputStream::resetOutputToStream(), SAL_WARN_IF, sax_fastparser::CachedOutputStream::setOutput(), and sax_fastparser::CachedOutputStream::writeBytes().
|
inline |
Definition at line 120 of file fastserializer.hxx.
References mbXescape.
void sax_fastparser::FastSaxSerializer::singleFastElement | ( | ::sal_Int32 | Element, |
FastAttributeList const * | pAttrList = nullptr |
||
) |
receives notification of the beginning of a single element.
Element | contains the integer token from the <type>XFastTokenHandler</type> registered at the <type>XFastParser</type>. |
If the element has a namespace that was registered with the <type>XFastParser</type>, Element
contains the integer token of the elements local name from the <type>XFastTokenHandler</type> and the integer token of the namespace combined with an arithmetic or operation.
pAttrList | Contains a <type>FastAttributeList</type> to access the attributes from the element. |
Definition at line 416 of file fastserializer.cxx.
References sax_fastparser::CachedOutputStream::flush(), maCachedOutputStream, maMarkStack, mbMarkStackEmpty, N_CHARS, sOpeningBracket, sSlashAndClosingBracket, writeBytes(), writeFastAttributeList(), writeId(), and writeTokenValueList().
void sax_fastparser::FastSaxSerializer::startDocument | ( | ) |
called by the parser when parsing of an XML stream is started.
Definition at line 78 of file fastserializer.cxx.
References N_CHARS, sXmlHeader, and writeBytes().
void sax_fastparser::FastSaxSerializer::startFastElement | ( | ::sal_Int32 | Element, |
FastAttributeList const * | pAttrList = nullptr |
||
) |
receives notification of the beginning of an element.
Element | contains the integer token from the <type>XFastTokenHandler</type> registered at the <type>XFastParser</type>. |
If the element has a namespace that was registered with the <type>XFastParser</type>, Element
contains the integer token of the elements local name from the <type>XFastTokenHandler</type> and the integer token of the namespace combined with an arithmetic or operation.
pAttrList | Contains a <type>FastAttributeList</type> to access the attributes from the element. |
Definition at line 354 of file fastserializer.cxx.
References sax_fastparser::CachedOutputStream::flush(), m_DebugStartedElements, maCachedOutputStream, maMarkStack, mbMarkStackEmpty, N_CHARS, sClosingBracket, sOpeningBracket, writeBytes(), writeFastAttributeList(), writeId(), and writeTokenValueList().
void sax_fastparser::FastSaxSerializer::write | ( | const char * | pStr, |
sal_Int32 | nLen, | ||
bool | bEscape = false |
||
) |
Definition at line 155 of file fastserializer.cxx.
References i, sax_fastparser::invalidChar(), sax_fastparser::isHexDigit(), mbXescape, SAL_WARN_IF, and writeBytes().
void sax_fastparser::FastSaxSerializer::write | ( | double | value | ) |
Definition at line 83 of file fastserializer.cxx.
References mnDoubleStrCapacity, mpDoubleStr, value, and write().
Referenced by write(), writeFastAttributeList(), and writeTokenValueList().
void sax_fastparser::FastSaxSerializer::write | ( | std::string_view | s, |
bool | bEscape = false |
||
) |
Definition at line 102 of file fastserializer.cxx.
References write().
void sax_fastparser::FastSaxSerializer::write | ( | std::u16string_view | s, |
bool | bEscape = false |
||
) |
Definition at line 96 of file fastserializer.cxx.
References OUStringToOString(), and write().
|
private |
Definition at line 693 of file fastserializer.cxx.
References i, sax_fastparser::invalidChar(), maCachedOutputStream, SAL_WARN, SAL_WARN_IF, and sax_fastparser::CachedOutputStream::writeBytes().
|
private |
Forward the call to the output stream, or write to the stack.
The latter in the case that we are inside a mark().
Referenced by endFastElement(), singleFastElement(), startDocument(), startFastElement(), write(), writeFastAttributeList(), writeId(), and writeTokenValueList().
|
private |
Definition at line 468 of file fastserializer.cxx.
References sax_fastparser::FastAttributeList::AttributeValueLength(), sax_fastparser::FastAttributeList::getFastAttributeTokens(), sax_fastparser::FastAttributeList::getFastAttributeValue(), getId(), N_CHARS, nToken, SAL_WARN_IF, sEqualSignAndQuote, sQuote, sSpace, write(), writeBytes(), and writeId().
Referenced by singleFastElement(), and startFastElement().
void sax_fastparser::FastSaxSerializer::writeId | ( | ::sal_Int32 | Element | ) |
Definition at line 316 of file fastserializer.cxx.
References HAS_NAMESPACE, mxFastTokenHandler, NAMESPACE, sColon, TOKEN, and writeBytes().
Referenced by endFastElement(), singleFastElement(), startFastElement(), writeFastAttributeList(), and writeTokenValueList().
|
private |
Definition at line 440 of file fastserializer.cxx.
References getId(), maTokenValues, N_CHARS, nToken, sEqualSignAndQuote, sQuote, sSpace, write(), writeBytes(), and writeId().
Referenced by singleFastElement(), and startFastElement().
|
private |
Definition at line 239 of file fastserializer.hxx.
Referenced by endFastElement(), mergeTopMarks(), and startFastElement().
|
private |
Helper class to cache data and write in chunks to XOutputStream or ForMerge::append.
Its flush method needs to be called before touching maMarkStack to ensure correct order of ForSort methods.
Definition at line 164 of file fastserializer.hxx.
Referenced by endDocument(), FastSaxSerializer(), getOutputStream(), mark(), mergeTopMarks(), singleFastElement(), startFastElement(), and writeBytes().
|
private |
Definition at line 228 of file fastserializer.hxx.
Referenced by endDocument(), endFastElement(), mark(), mergeTopMarks(), singleFastElement(), and startFastElement().
|
private |
Definition at line 234 of file fastserializer.hxx.
Referenced by getTokenValueList(), and writeTokenValueList().
|
private |
Definition at line 229 of file fastserializer.hxx.
Referenced by endDocument(), endFastElement(), mark(), mergeTopMarks(), singleFastElement(), and startFastElement().
|
private |
whether to escape invalid XML characters as xHHHH in write(const char*,sal_Int32,true)
Definition at line 235 of file fastserializer.hxx.
Referenced by setAllowXEscape(), and write().
|
private |
Definition at line 233 of file fastserializer.hxx.
Referenced by FastSaxSerializer(), and write().
|
private |
Definition at line 232 of file fastserializer.hxx.
Referenced by FastSaxSerializer(), write(), and ~FastSaxSerializer().
|
private |
Definition at line 165 of file fastserializer.hxx.
Referenced by FastSaxSerializer(), getId(), and writeId().