Quellcode-Bibliothek fastserializer.hxx
Sprache: C
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
/// Receives notification of sax document events to write into an XOutputStream. class FastSaxSerializer
{ typedef css::uno::Sequence< ::sal_Int32 > Int32Sequence;
css::uno::Reference< css::io::XOutputStream > const & getOutputStream() const; /// called by FSHelper to put data in for writeTokenValueList
TokenValueList& getTokenValueList() { return maTokenValues; }
/** called by the parser when parsing of an XML stream is started.
*/ void startDocument();
/** called by the parser after the last XML element of a stream is processed.
*/ void endDocument();
/** receives notification of the beginning of an element.
@param Element contains the integer token from the <type>XFastTokenHandler</type> registered at the <type>XFastParser</type>.<br>
If the element has a namespace that was registered with the <type>XFastParser</type>, <param>Element</param> 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 <b>or</b> operation.
@param pAttrList Contains a <type>FastAttributeList</type> to access the attributes from the element.
/** receives notification of the end of a known element. @see startFastElement
*/ void endFastElement( ::sal_Int32 Element );
/** receives notification of the beginning of a single element.
@param Element contains the integer token from the <type>XFastTokenHandler</type> registered at the <type>XFastParser</type>.<br>
If the element has a namespace that was registered with the <type>XFastParser</type>, <param>Element</param> 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 <b>or</b> operation.
@param pAttrList Contains a <type>FastAttributeList</type> to access the attributes from the element.
// strings with _xHHHH_ are escaped with _x005F unless this is disabled void setAllowXEscape(bool bSet) { mbXescape = bSet; }
public: /** 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.
@param nTag debugging aid to ensure mark and merge match in LIFO order
*/ void mark(sal_Int32 nTag, const Int32Sequence& rOrder);
/** 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.
@param nTag debugging aid to ensure mark and merge match in LIFO order
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.
*/
CachedOutputStream maCachedOutputStream;
css::uno::Reference< css::xml::sax::XFastTokenHandler > mxFastTokenHandler;
class ForMerge : public ForMergeBase
{
Int8Sequence maData;
std::vector<sal_Int8> maPostponed;
public:
sal_Int32 const m_Tag; #ifdef DBG_UTIL // pending close tags, followed by pending open tags
std::deque<sal_Int32> m_DebugEndedElements;
std::deque<sal_Int32> m_DebugStartedElements; // ... and another buffer for maPostponed ...
std::deque<sal_Int32> m_DebugPostponedEndedElements;
std::deque<sal_Int32> m_DebugPostponedStartedElements; #endif
std::stack< std::shared_ptr< ForMerge > > maMarkStack; bool mbMarkStackEmpty; // Would be better to use OStringBuffer instead of these two // but then we couldn't get the rtl_String* member :-(
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)
/** Forward the call to the output stream, or write to the stack.
The latter in the case that we are inside a mark().
*/ void writeBytes( const css::uno::Sequence< ::sal_Int8 >& aData ); void writeBytes( constchar* pStr, size_t nLen );
};
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.