Qt 4.8
Public Functions | Public Variables | Private Types | List of all members
QXmlSerializerPrivate Class Reference

#include <qxmlserializer_p.h>

Inheritance diagram for QXmlSerializerPrivate:
QAbstractXmlReceiverPrivate QXmlFormatterPrivate

Public Functions

 QXmlSerializerPrivate (const QXmlQuery &q, QIODevice *outputDevice)
 
void write (const char c)
 
- Public Functions inherited from QAbstractXmlReceiverPrivate
virtual ~QAbstractXmlReceiverPrivate ()
 

Public Variables

const QTextCodeccodec
 
QTextCodec::ConverterState converterState
 
QIODevicedevice
 
QStack< QPair< QXmlName, bool > > hasClosedElement
 
bool isPreviousAtomic
 
QHash< QXmlName::Code, QByteArraynameCache
 
QStack< QVector< QXmlName > > namespaces
 
const QPatternist::NamePool::Ptr np
 
const QXmlQuery query
 
QXmlSerializer::State state
 

Private Types

enum  Constants { EstimatedTreeDepth = 10, EstimatedNameCount = 60 }
 

Detailed Description

Definition at line 69 of file qxmlserializer_p.h.

Enumerations

◆ Constants

Enumerator
EstimatedTreeDepth 
EstimatedNameCount 

We use a high count to avoid rehashing. We can afford it since we only allocate one hash for this.

Definition at line 111 of file qxmlserializer_p.h.

Constructors and Destructors

◆ QXmlSerializerPrivate()

QXmlSerializerPrivate::QXmlSerializerPrivate ( const QXmlQuery q,
QIODevice outputDevice 
)

Definition at line 53 of file qxmlserializer.cpp.

55  : isPreviousAtomic(false),
57  np(query.namePool().d),
58  device(outputDevice),
59  codec(QTextCodec::codecForMib(106)), /* UTF-8 */
60  query(query)
61 {
65 
67 
68  /*
69  We push the empty namespace such that first of all
70  namespaceBinding() won't assert on an empty QStack,
71  and such that the empty namespace is in-scope and
72  that the code doesn't attempt to declare it.
73 
74  We push the XML namespace. Although we won't receive
75  declarations for it, we may output attributes by that
76  name.
77  */
78  QVector<QXmlName> defNss;
79  defNss.resize(2);
80  defNss[0] = QXmlName(StandardNamespaces::empty,
81  StandardLocalNames::empty,
82  StandardPrefixes::empty);
83  defNss[1] = QXmlName(StandardNamespaces::xml,
84  StandardLocalNames::empty,
85  StandardPrefixes::xml);
86 
87  namespaces.push(defNss);
88 
89  /* If we don't set this flag, QTextCodec will generate a BOM. */
91 }
QXmlSerializer::State state
QTextCodec::ConverterState converterState
void reserve(int size)
Ensures that the QHash&#39;s internal hash table consists of at least size buckets.
Definition: qhash.h:846
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
const QTextCodec * codec
QExplicitlySharedDataPointer< QPatternist::NamePool > d
Definition: qxmlnamepool.h:88
static QTextCodec * codecForMib(int mib)
Returns the QTextCodec which matches the MIBenum mib.
QStack< QPair< QXmlName, bool > > hasClosedElement
void push(const T &t)
Adds element t to the top of the stack.
Definition: qstack.h:60
ConversionFlags flags
Definition: qtextcodec.h:106
QHash< QXmlName::Code, QByteArray > nameCache
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
QXmlNamePool namePool() const
Returns the name pool used by this QXmlQuery for constructing QXmlName {names}.
Definition: qxmlquery.cpp:933
void reserve(int size)
Attempts to allocate memory for at least size elements.
Definition: qvector.h:339
const QPatternist::NamePool::Ptr np
QStack< QVector< QXmlName > > namespaces

Functions

◆ write()

void QXmlSerializerPrivate::write ( const char  c)
inline

Definition at line 123 of file qxmlserializer_p.h.

124 {
125  device->putChar(c);
126 }
unsigned char c[8]
Definition: qnumeric_p.h:62
bool putChar(char c)
Writes the character c to the device.
Definition: qiodevice.cpp:1486

Properties

◆ codec

const QTextCodec* QXmlSerializerPrivate::codec

Definition at line 90 of file qxmlserializer_p.h.

◆ converterState

QTextCodec::ConverterState QXmlSerializerPrivate::converterState

Definition at line 91 of file qxmlserializer_p.h.

Referenced by QXmlSerializerPrivate().

◆ device

QIODevice* QXmlSerializerPrivate::device

Definition at line 89 of file qxmlserializer_p.h.

Referenced by write().

◆ hasClosedElement

QStack<QPair<QXmlName, bool> > QXmlSerializerPrivate::hasClosedElement

Definition at line 75 of file qxmlserializer_p.h.

Referenced by QXmlSerializerPrivate().

◆ isPreviousAtomic

bool QXmlSerializerPrivate::isPreviousAtomic

Definition at line 76 of file qxmlserializer_p.h.

◆ nameCache

QHash<QXmlName::Code, QByteArray> QXmlSerializerPrivate::nameCache

Name cache. Since encoding QStrings are rather expensive operations to do, and we on top of that would have to do it each time a name appears, we here map names to their encoded equivalents.

This means that when writing out large documents, the serialization of names after a while is reduced to a hash lookup and passing an existing byte array.

We use QXmlName::Code as key as opposed to merely QName, because the prefix is of significance.

Definition at line 105 of file qxmlserializer_p.h.

Referenced by QXmlSerializerPrivate().

◆ namespaces

QStack<QVector<QXmlName> > QXmlSerializerPrivate::namespaces

This member worries me a bit. We never use it but nevertheless it is pushed and pops linear to startElement() and endElement(). An optimization would be to at least merge it with hasClosedElement, but even better to push it on demand. That is, namespaceBinding() pushes it up to the tree depth first when it is needed.

Definition at line 87 of file qxmlserializer_p.h.

Referenced by QXmlSerializerPrivate().

◆ np

const QPatternist::NamePool::Ptr QXmlSerializerPrivate::np

Definition at line 78 of file qxmlserializer_p.h.

◆ query

const QXmlQuery QXmlSerializerPrivate::query

Definition at line 106 of file qxmlserializer_p.h.

◆ state

QXmlSerializer::State QXmlSerializerPrivate::state

Definition at line 77 of file qxmlserializer_p.h.


The documentation for this class was generated from the following files: