Qt 4.8
Classes | Public Functions | Private Types | Private Functions | Properties | Static Private Attributes | Friends | List of all members
QXmlSimpleReaderPrivate Class Reference

Classes

struct  ExternEntity
 
struct  ExternParameterEntity
 
struct  ParseState
 
struct  XmlRef
 

Public Functions

 ~QXmlSimpleReaderPrivate ()
 

Private Types

enum  EntityRecognitionContext { InContent, InAttributeValue, InEntityValue, InDTD }
 
typedef bool(QXmlSimpleReaderPrivate::* ParseFunction) ()
 
enum  Standalone { Yes, No, Unknown }
 

Private Functions

bool atEnd ()
 
bool eat_ws ()
 
bool entityExist (const QString &) const
 
void init (const QXmlInputSource *i)
 
void initData ()
 
void initIncrementalParsing ()
 
bool insertXmlRef (const QString &, const QString &, bool)
 
bool isExpandedEntityValueTooLarge (QString *errorMessage)
 
const QStringname ()
 
void nameAddC (QChar)
 
void nameAddC ()
 
void nameClear ()
 
void QT_FASTCALL next ()
 
bool next_eat_ws ()
 
bool parseAttlistDecl ()
 
bool parseAttribute ()
 
bool parseAttType ()
 
bool parseAttValue ()
 
bool parseBeginOrContinue (int state, bool incremental)
 
bool parseChoiceSeq ()
 
bool parseComment ()
 
bool parseContent ()
 
bool parseDoctype ()
 
bool parseElement ()
 
bool parseElementDecl ()
 
bool parseEntityDecl ()
 
bool parseEntityValue ()
 
bool parseExternalID ()
 
void parseFailed (ParseFunction where, int state)
 
bool parseMarkupdecl ()
 
bool parseMisc ()
 
bool parseName ()
 
bool parseNmtoken ()
 
bool parseNotationDecl ()
 
bool parsePEReference ()
 
bool parsePI ()
 
bool parseProlog ()
 
bool parseReference ()
 
bool parseString ()
 
bool processElementAttribute ()
 
bool processElementEmptyTag ()
 
bool processElementETagBegin2 ()
 
bool processReference ()
 
void pushParseState (ParseFunction function, int state)
 
 QXmlSimpleReaderPrivate (QXmlSimpleReader *reader)
 
const QStringref ()
 
void refAddC (QChar)
 
void refAddC ()
 
void refClear ()
 
bool reportEndEntities ()
 
void reportParseError (const QString &error)
 
const QStringstring ()
 
void stringAddC (QChar)
 
void stringAddC ()
 
void stringClear ()
 
void unexpectedEof (ParseFunction where, int state)
 

Properties

QString attDeclAName
 
QString attDeclEName
 
QXmlAttributes attList
 
QChar c
 
int columnNr
 
bool contentCharDataRead
 
QXmlContentHandlercontentHnd
 
QXmlDeclHandlerdeclHnd
 
QString doctype
 
bool doctype_read
 
signed char Done
 
QXmlDTDHandlerdtdHnd
 
QString emptyStr
 
QString encoding
 
QMap< QString, QStringentities
 
QXmlEntityResolverentityRes
 
QString error
 
QXmlErrorHandlererrorHnd
 
QHash< QString, int > expandedSizes
 
QMap< QString, ExternEntityexternEntities
 
QMap< QString, ExternParameterEntityexternParameterEntities
 
QXmlInputSourceinputSource
 
QXmlLexicalHandlerlexicalHnd
 
int lineNr
 
QHash< QString, int > literalEntitySizes
 
QScopedPointer< QXmlLocatorlocator
 
QChar nameArray [256]
 
int nameArrayPos
 
QXmlNamespaceSupport namespaceSupport
 
QString nameValue
 
int nameValueLen
 
QMap< QString, QStringparameterEntities
 
bool parseExternalID_allowPublicID
 
bool parseName_useRef
 
EntityRecognitionContext parsePEReference_context
 
bool parsePI_xmldecl
 
bool parseReference_charDataRead
 
EntityRecognitionContext parseReference_context
 
QStack< ParseState > * parseStack
 
QString parseString_s
 
QString publicId
 
QXmlSimpleReaderq_ptr
 
QChar refArray [256]
 
int refArrayPos
 
QHash< QString, QHash< QString, int > > referencesToOtherEntities
 
QString refValue
 
int refValueLen
 
bool reportEntities
 
bool reportWhitespaceCharData
 
Standalone standalone
 
bool startDTDwasReported
 
QChar stringArray [256]
 
int stringArrayPos
 
QString stringValue
 
int stringValueLen
 
QString systemId
 
QStack< QStringtags
 
QString thisPublicId
 
QString thisSystemId
 
bool useNamespacePrefixes
 
bool useNamespaces
 
bool xmldecl_possible
 
QStack< XmlRefxmlRefStack
 
QString xmlVersion
 

Static Private Attributes

static const int dtdRecursionLimit = 2
 
static const int entityCharacterLimit = 1024
 

Friends

class QXmlSimpleReaderLocator
 

Detailed Description

Definition at line 274 of file qxml.cpp.

Typedefs

◆ ParseFunction

typedef bool(QXmlSimpleReaderPrivate::* QXmlSimpleReaderPrivate::ParseFunction) ()
private

Definition at line 502 of file qxml.cpp.

Enumerations

◆ EntityRecognitionContext

Enumerator
InContent 
InAttributeValue 
InEntityValue 
InDTD 

Definition at line 287 of file qxml.cpp.

◆ Standalone

Enumerator
Yes 
No 
Unknown 

Definition at line 330 of file qxml.cpp.

Constructors and Destructors

◆ ~QXmlSimpleReaderPrivate()

QXmlSimpleReaderPrivate::~QXmlSimpleReaderPrivate ( )

Definition at line 3049 of file qxml.cpp.

3050 {
3051  delete parseStack;
3052 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387

◆ QXmlSimpleReaderPrivate()

QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate ( QXmlSimpleReader reader)
private

Definition at line 3029 of file qxml.cpp.

3030 {
3031  q_ptr = reader;
3032  parseStack = 0;
3033 
3034  locator.reset(new QXmlSimpleReaderLocator(reader));
3035  entityRes = 0;
3036  dtdHnd = 0;
3037  contentHnd = 0;
3038  errorHnd = 0;
3039  lexicalHnd = 0;
3040  declHnd = 0;
3041 
3042  // default feature settings
3043  useNamespaces = true;
3044  useNamespacePrefixes = false;
3045  reportWhitespaceCharData = true;
3046  reportEntities = false;
3047 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
QXmlLexicalHandler * lexicalHnd
Definition: qxml.cpp:405
bool reportWhitespaceCharData
Definition: qxml.cpp:354
QXmlDeclHandler * declHnd
Definition: qxml.cpp:406
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
QXmlEntityResolver * entityRes
Definition: qxml.cpp:404
QXmlErrorHandler * errorHnd
Definition: qxml.cpp:402
QXmlDTDHandler * dtdHnd
Definition: qxml.cpp:403
QXmlSimpleReader * q_ptr
Definition: qxml.cpp:509
QScopedPointer< QXmlLocator > locator
Definition: qxml.cpp:365
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401
friend class QXmlSimpleReaderLocator
Definition: qxml.cpp:511

Functions

◆ atEnd()

bool QXmlSimpleReaderPrivate::atEnd ( )
inlineprivate

Definition at line 3010 of file qxml.cpp.

3011 {
3012  return (c.unicode()|0x0001) == 0xffff;
3013 }
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251

◆ eat_ws()

bool QXmlSimpleReaderPrivate::eat_ws ( )
private

Definition at line 8343 of file qxml.cpp.

Referenced by parseAttlistDecl(), parseAttribute(), parseAttType(), parseAttValue(), parseChoiceSeq(), parseComment(), parseContent(), parseDoctype(), parseElement(), parseElementDecl(), parseEntityDecl(), parseEntityValue(), parseExternalID(), parseMarkupdecl(), parseMisc(), parseName(), parseNmtoken(), parseNotationDecl(), parsePEReference(), parsePI(), parseProlog(), parseReference(), and parseString().

8344 {
8345  while (!atEnd()) {
8346  if (!is_S(c)) {
8347  return true;
8348  }
8349  next();
8350  }
8351  if (parseStack != 0) {
8353  return false;
8354  }
8355  return true;
8356 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
void QT_FASTCALL next()
Definition: qxml.cpp:8300
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
static bool is_S(QChar ch)
Definition: qxml.cpp:3380

◆ entityExist()

bool QXmlSimpleReaderPrivate::entityExist ( const QString e) const
private

Definition at line 8405 of file qxml.cpp.

8406 {
8409  externEntities.find(e) == externEntities.end() &&
8410  entities.find(e) == entities.end()) {
8411  return false;
8412  } else {
8413  return true;
8414  }
8415 }
QMap< QString, QString > entities
Definition: qxml.cpp:313
iterator find(const Key &key)
Returns an iterator pointing to the item with key key in the map.
Definition: qmap.h:618
QMap< QString, ExternParameterEntity > externParameterEntities
Definition: qxml.cpp:310
QMap< QString, QString > parameterEntities
Definition: qxml.cpp:311
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
QMap< QString, ExternEntity > externEntities
Definition: qxml.cpp:312

◆ init()

void QXmlSimpleReaderPrivate::init ( const QXmlInputSource i)
private

Definition at line 8369 of file qxml.cpp.

8370 {
8371  lineNr = 0;
8372  columnNr = -1;
8373  inputSource = const_cast<QXmlInputSource *>(i);
8374  initData();
8375 
8376  externParameterEntities.clear();
8378  externEntities.clear();
8379  entities.clear();
8380 
8381  tags.clear();
8382 
8383  doctype.clear();
8384  xmlVersion.clear();
8385  encoding.clear();
8387  error.clear();
8388 }
QMap< QString, QString > entities
Definition: qxml.cpp:313
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
Standalone standalone
Definition: qxml.cpp:335
QMap< QString, ExternParameterEntity > externParameterEntities
Definition: qxml.cpp:310
QMap< QString, QString > parameterEntities
Definition: qxml.cpp:311
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
The QXmlInputSource class provides the input data for the QXmlReader subclasses.
Definition: qxml.h:158
QXmlInputSource * inputSource
Definition: qxml.cpp:408
QMap< QString, ExternEntity > externEntities
Definition: qxml.cpp:312
QStack< QString > tags
Definition: qxml.cpp:284
void clear()
Removes all items from the map.
Definition: qmap.h:444

◆ initData()

void QXmlSimpleReaderPrivate::initData ( )
private

Definition at line 8394 of file qxml.cpp.

8395 {
8397  xmlRefStack.clear();
8398  next();
8399 }
static const ushort EndOfData
Definition: qxml.h:172
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QStack< XmlRef > xmlRefStack
Definition: qxml.cpp:327

◆ initIncrementalParsing()

void QXmlSimpleReaderPrivate::initIncrementalParsing ( )
private

Definition at line 3054 of file qxml.cpp.

3055 {
3056  if(parseStack)
3057  parseStack->clear();
3058  else
3060 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
The QStack class is a template class that provides a stack.
Definition: qcontainerfwd.h:63

◆ insertXmlRef()

bool QXmlSimpleReaderPrivate::insertXmlRef ( const QString data,
const QString name,
bool  inLiteral 
)
private

Definition at line 8273 of file qxml.cpp.

8274 {
8275  if (inLiteral) {
8276  QString tmp = data;
8277  xmlRefStack.push(XmlRef(name, tmp.replace(QLatin1Char('\"'),
8278  QLatin1String("&quot;")).replace(QLatin1Char('\''), QLatin1String("&apos;"))));
8279  } else {
8280  xmlRefStack.push(XmlRef(name, data));
8281  }
8282  int n = qMax(parameterEntities.count(), entities.count());
8283  if (xmlRefStack.count() > n+1) {
8284  // recursive entities
8286  return false;
8287  }
8288  if (reportEntities && lexicalHnd) {
8289  if (!lexicalHnd->startEntity(name)) {
8291  return false;
8292  }
8293  }
8294  return true;
8295 }
QMap< QString, QString > entities
Definition: qxml.cpp:313
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
int count(const Key &key) const
Returns the number of items associated with key key.
Definition: qmap.h:539
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QXmlLexicalHandler * lexicalHnd
Definition: qxml.cpp:405
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QStack< XmlRef > xmlRefStack
Definition: qxml.cpp:327
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
static const char * data(const QByteArray &arr)
#define XMLERR_RECURSIVEENTITIES
Definition: qxml.cpp:80
virtual bool startEntity(const QString &name)=0
The reader calls this function to report the start of an entity called name.
QMap< QString, QString > parameterEntities
Definition: qxml.cpp:311
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ isExpandedEntityValueTooLarge()

bool QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge ( QString errorMessage)
private

Definition at line 6945 of file qxml.cpp.

6946 {
6947  QString entityNameBuffer;
6948 
6949  // For every entity, check how many times all entity names were referenced in its value.
6951  toSearchIt != entities.constEnd();
6952  ++toSearchIt) {
6953  const QString &toSearch = toSearchIt.key();
6954 
6955  // Don't check the same entities twice.
6956  if (!literalEntitySizes.contains(toSearch)) {
6957  // The amount of characters that weren't entity names, but literals, like 'X'.
6958  QString leftOvers = entities.value(toSearch);
6959  // How many times was entityName referenced by toSearch?
6961  referencedIt != entities.constEnd();
6962  ++referencedIt) {
6963  const QString &entityName = referencedIt.key();
6964 
6965  for (int i = 0; i < leftOvers.size() && i != -1; ) {
6966  entityNameBuffer = QLatin1Char('&') + entityName + QLatin1Char(';');
6967 
6968  i = leftOvers.indexOf(entityNameBuffer, i);
6969  if (i != -1) {
6970  leftOvers.remove(i, entityName.size() + 2);
6971  // The entityName we're currently trying to find was matched in this string; increase our count.
6972  ++referencesToOtherEntities[toSearch][entityName];
6973  }
6974  }
6975  }
6976  literalEntitySizes[toSearch] = leftOvers.size();
6977  }
6978  }
6979 
6980  for (QHash<QString, QHash<QString, int> >::const_iterator entityIt = referencesToOtherEntities.constBegin();
6981  entityIt != referencesToOtherEntities.constEnd();
6982  ++entityIt) {
6983  const QString &entity = entityIt.key();
6984 
6985  QHash<QString, int>::iterator expandedIt = expandedSizes.find(entity);
6986  if (expandedIt == expandedSizes.end()) {
6987  expandedIt = expandedSizes.insert(entity, literalEntitySizes.value(entity));
6988  for (QHash<QString, int>::const_iterator referenceIt = entityIt->constBegin();
6989  referenceIt != entityIt->constEnd();
6990  ++referenceIt) {
6991  const QString &referenceTo = referenceIt.key();
6992  const int references = referencesToOtherEntities.value(entity).value(referenceTo);
6993  // The total size of an entity's value is the expanded size of all of its referenced entities, plus its literal size.
6994  *expandedIt += expandedSizes.value(referenceTo) * references + literalEntitySizes.value(referenceTo) * references;
6995  }
6996 
6997  if (*expandedIt > entityCharacterLimit) {
6998  if (errorMessage) {
6999  *errorMessage = QString::fromLatin1("The XML entity \"%1\" expands to a string that is too large to process (%2 characters > %3).")
7000  .arg(entity, *expandedIt, entityCharacterLimit);
7001  }
7002  return true;
7003  }
7004  }
7005  }
7006  return false;
7007 }
QMap< QString, QString > entities
Definition: qxml.cpp:313
static const int entityCharacterLimit
Definition: qxml.cpp:436
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
Definition: qmap.h:374
QHash< QString, int > expandedSizes
Definition: qxml.cpp:431
QHash< QString, int > literalEntitySizes
Definition: qxml.cpp:428
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:380
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QHash< QString, QHash< QString, int > > referencesToOtherEntities
Definition: qxml.cpp:430
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67

◆ name()

const QString & QXmlSimpleReaderPrivate::name ( )
private

Definition at line 8495 of file qxml.cpp.

Referenced by processElementAttribute(), and processElementETagBegin2().

8496 {
8498  return nameValue;
8499 }
QChar nameArray[256]
Definition: qxml.cpp:414
static void updateValue(QString &value, const QChar *array, int &arrayPos, int &valueLen)
Definition: qxml.cpp:8481

◆ nameAddC() [1/2]

void QXmlSimpleReaderPrivate::nameAddC ( QChar  ch)
private

Definition at line 8512 of file qxml.cpp.

8513 {
8514  if (nameArrayPos == 256)
8516  nameArray[nameArrayPos++] = ch;
8517 }
QChar nameArray[256]
Definition: qxml.cpp:414
static void updateValue(QString &value, const QChar *array, int &arrayPos, int &valueLen)
Definition: qxml.cpp:8481

◆ nameAddC() [2/2]

void QXmlSimpleReaderPrivate::nameAddC ( )
inlineprivate

Definition at line 445 of file qxml.cpp.

Referenced by nameAddC().

◆ nameClear()

void QXmlSimpleReaderPrivate::nameClear ( )
inlineprivate

Definition at line 3019 of file qxml.cpp.

3020 {
3021  nameValueLen = 0; nameArrayPos = 0;
3022 }

◆ next()

void QXmlSimpleReaderPrivate::next ( )
private

Definition at line 8300 of file qxml.cpp.

8301 {
8302  int count = xmlRefStack.size();
8303  while (count != 0) {
8304  if (xmlRefStack.top().isEmpty()) {
8305  xmlRefStack.pop_back();
8306  count--;
8307  } else {
8308  c = xmlRefStack.top().next();
8309  return;
8310  }
8311  }
8312 
8313  // the following could be written nicer, but since it is a time-critical
8314  // function, rather optimize for speed
8315  ushort uc = c.unicode();
8316  c = inputSource->next();
8317  // If we are not incremental parsing, we just skip over EndOfData chars to give the
8318  // parser an uninterrupted stream of document chars.
8319  if (c == QXmlInputSource::EndOfData && parseStack == 0)
8320  c = inputSource->next();
8321  if (uc == '\n') {
8322  lineNr++;
8323  columnNr = -1;
8324  } else if (uc == '\r') {
8325  if (c != QLatin1Char('\n')) {
8326  lineNr++;
8327  columnNr = -1;
8328  }
8329  }
8330  ++columnNr;
8331 }
static const ushort EndOfData
Definition: qxml.h:172
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
QStack< XmlRef > xmlRefStack
Definition: qxml.cpp:327
unsigned short ushort
Definition: qglobal.h:995
QXmlInputSource * inputSource
Definition: qxml.cpp:408
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
virtual QChar next()
Returns the next character of the input source.
Definition: qxml.cpp:1444

◆ next_eat_ws()

bool QXmlSimpleReaderPrivate::next_eat_ws ( )
private

Definition at line 8358 of file qxml.cpp.

8359 {
8360  next();
8361  return eat_ws();
8362 }
void QT_FASTCALL next()
Definition: qxml.cpp:8300

◆ parseAttlistDecl()

bool QXmlSimpleReaderPrivate::parseAttlistDecl ( )
private

Definition at line 5867 of file qxml.cpp.

5868 {
5869  const signed char Init = 0;
5870  const signed char Attlist = 1; // parse the string "ATTLIST"
5871  const signed char Ws = 2; // whitespace read
5872  const signed char Name = 3; // parse name
5873  const signed char Ws1 = 4; // whitespace read
5874  const signed char Attdef = 5; // parse the AttDef
5875  const signed char Ws2 = 6; // whitespace read
5876  const signed char Atttype = 7; // parse the AttType
5877  const signed char Ws3 = 8; // whitespace read
5878  const signed char DDecH = 9; // DefaultDecl with #
5879  const signed char DefReq = 10; // parse the string "REQUIRED"
5880  const signed char DefImp = 11; // parse the string "IMPLIED"
5881  const signed char DefFix = 12; // parse the string "FIXED"
5882  const signed char Attval = 13; // parse the AttValue
5883  const signed char Ws4 = 14; // whitespace read
5884  const signed char Done = 15;
5885 
5886  const signed char InpWs = 0; // white space
5887  const signed char InpGt = 1; // >
5888  const signed char InpHash = 2; // #
5889  const signed char InpA = 3; // A
5890  const signed char InpI = 4; // I
5891  const signed char InpF = 5; // F
5892  const signed char InpR = 6; // R
5893  const signed char InpUnknown = 7;
5894 
5895  static const signed char table[15][8] = {
5896  /* InpWs InpGt InpHash InpA InpI InpF InpR InpUnknown */
5897  { -1, -1, -1, Attlist, -1, -1, -1, -1 }, // Init
5898  { Ws, -1, -1, -1, -1, -1, -1, -1 }, // Attlist
5899  { -1, -1, -1, Name, Name, Name, Name, Name }, // Ws
5900  { Ws1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef }, // Name
5901  { -1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef }, // Ws1
5902  { Ws2, -1, -1, -1, -1, -1, -1, -1 }, // Attdef
5903  { -1, Atttype, Atttype, Atttype, Atttype, Atttype, Atttype, Atttype }, // Ws2
5904  { Ws3, -1, -1, -1, -1, -1, -1, -1 }, // Attype
5905  { -1, Attval, DDecH, Attval, Attval, Attval, Attval, Attval }, // Ws3
5906  { -1, -1, -1, -1, DefImp, DefFix, DefReq, -1 }, // DDecH
5907  { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, // DefReq
5908  { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, // DefImp
5909  { Ws3, -1, -1, -1, -1, -1, -1, -1 }, // DefFix
5910  { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, // Attval
5911  { -1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef } // Ws4
5912  };
5913  signed char state;
5914  signed char input;
5915 
5916  if (parseStack==0 || parseStack->isEmpty()) {
5917  state = Init;
5918  } else {
5919  state = parseStack->pop().state;
5920 #if defined(QT_QXML_DEBUG)
5921  qDebug("QXmlSimpleReader: parseAttlistDecl (cont) in state %d", state);
5922 #endif
5923  if (!parseStack->isEmpty()) {
5924  ParseFunction function = parseStack->top().function;
5925  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
5926  parseStack->pop();
5927 #if defined(QT_QXML_DEBUG)
5928  qDebug("QXmlSimpleReader: eat_ws (cont)");
5929 #endif
5930  }
5931  if (!(this->*function)()) {
5933  return false;
5934  }
5935  }
5936  }
5937 
5938  for (;;) {
5939  switch (state) {
5940  case Name:
5941  attDeclEName = name();
5942  break;
5943  case Attdef:
5944  attDeclAName = name();
5945  break;
5946  case Done:
5947  return true;
5948  case -1:
5949  // Error
5951  return false;
5952  }
5953 
5954  if (atEnd()) {
5956  return false;
5957  }
5958  if (is_S(c)) {
5959  input = InpWs;
5960  } else if (c == QLatin1Char('>')) {
5961  input = InpGt;
5962  } else if (c == QLatin1Char('#')) {
5963  input = InpHash;
5964  } else if (c == QLatin1Char('A')) {
5965  input = InpA;
5966  } else if (c == QLatin1Char('I')) {
5967  input = InpI;
5968  } else if (c == QLatin1Char('F')) {
5969  input = InpF;
5970  } else if (c == QLatin1Char('R')) {
5971  input = InpR;
5972  } else {
5973  input = InpUnknown;
5974  }
5975  state = table[state][input];
5976 
5977  switch (state) {
5978  case Attlist:
5979  parseString_s = QLatin1String("ATTLIST");
5980  if (!parseString()) {
5982  return false;
5983  }
5984  break;
5985  case Ws:
5986  case Ws1:
5987  case Ws2:
5988  case Ws3:
5989  if (!eat_ws()) {
5991  return false;
5992  }
5993  break;
5994  case Name:
5995  parseName_useRef = false;
5996  if (!parseName()) {
5998  return false;
5999  }
6000  break;
6001  case Attdef:
6002  parseName_useRef = false;
6003  if (!parseName()) {
6005  return false;
6006  }
6007  break;
6008  case Atttype:
6009  if (!parseAttType()) {
6011  return false;
6012  }
6013  break;
6014  case DDecH:
6015  next();
6016  break;
6017  case DefReq:
6018  parseString_s = QLatin1String("REQUIRED");
6019  if (!parseString()) {
6021  return false;
6022  }
6023  break;
6024  case DefImp:
6025  parseString_s = QLatin1String("IMPLIED");
6026  if (!parseString()) {
6028  return false;
6029  }
6030  break;
6031  case DefFix:
6032  parseString_s = QLatin1String("FIXED");
6033  if (!parseString()) {
6035  return false;
6036  }
6037  break;
6038  case Attval:
6039  if (!parseAttValue()) {
6041  return false;
6042  }
6043  break;
6044  case Ws4:
6045  if (declHnd) {
6046  // ### not all values are computed yet...
6049  return false;
6050  }
6051  }
6052  if (!eat_ws()) {
6054  return false;
6055  }
6056  break;
6057  case Done:
6058  next();
6059  break;
6060  }
6061  }
6062  return false;
6063 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:73
virtual bool attributeDecl(const QString &eName, const QString &aName, const QString &type, const QString &valueDefault, const QString &value)=0
The reader calls this function to report an attribute type declaration.
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QXmlDeclHandler * declHnd
Definition: qxml.cpp:406
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
const QString & name()
Definition: qxml.cpp:8495
signed char Done
Definition: qxml.cpp:397
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseAttribute()

bool QXmlSimpleReaderPrivate::parseAttribute ( )
private

Definition at line 7559 of file qxml.cpp.

7560 {
7561  const int Init = 0;
7562  const int PName = 1; // parse name
7563  const int Ws = 2; // eat ws
7564  const int Eq = 3; // the '=' was read
7565  const int Quotes = 4; // " or ' were read
7566 
7567  const int InpNameBe = 0;
7568  const int InpEq = 1; // =
7569  const int InpDq = 2; // "
7570  const int InpSq = 3; // '
7571  const int InpUnknown = 4;
7572 
7573  static const int table[4][5] = {
7574  /* InpNameBe InpEq InpDq InpSq InpUnknown */
7575  { PName, -1, -1, -1, -1 }, // Init
7576  { -1, Eq, -1, -1, Ws }, // PName
7577  { -1, Eq, -1, -1, -1 }, // Ws
7578  { -1, -1, Quotes, Quotes, -1 } // Eq
7579  };
7580  int state;
7581  int input;
7582 
7583  if (parseStack==0 || parseStack->isEmpty()) {
7584  state = Init;
7585  } else {
7586  state = parseStack->pop().state;
7587 #if defined(QT_QXML_DEBUG)
7588  qDebug("QXmlSimpleReader: parseAttribute (cont) in state %d", state);
7589 #endif
7590  if (!parseStack->isEmpty()) {
7591  ParseFunction function = parseStack->top().function;
7592  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
7593  parseStack->pop();
7594 #if defined(QT_QXML_DEBUG)
7595  qDebug("QXmlSimpleReader: eat_ws (cont)");
7596 #endif
7597  }
7598  if (!(this->*function)()) {
7600  return false;
7601  }
7602  }
7603  }
7604 
7605  for (;;) {
7606  switch (state) {
7607  case Quotes:
7608  // Done
7609  return true;
7610  case -1:
7611  // Error
7613  return false;
7614  }
7615 
7616  if (atEnd()) {
7618  return false;
7619  }
7620  if (determineNameChar(c) == NameBeginning) {
7621  input = InpNameBe;
7622  } else if (c == QLatin1Char('=')) {
7623  input = InpEq;
7624  } else if (c == QLatin1Char('"')) {
7625  input = InpDq;
7626  } else if (c == QLatin1Char('\'')) {
7627  input = InpSq;
7628  } else {
7629  input = InpUnknown;
7630  }
7631  state = table[state][input];
7632 
7633  switch (state) {
7634  case PName:
7635  parseName_useRef = false;
7636  if (!parseName()) {
7638  return false;
7639  }
7640  break;
7641  case Ws:
7642  if (!eat_ws()) {
7644  return false;
7645  }
7646  break;
7647  case Eq:
7648  if (!next_eat_ws()) {
7650  return false;
7651  }
7652  break;
7653  case Quotes:
7654  if (!parseAttValue()) {
7656  return false;
7657  }
7658  break;
7659  }
7660  }
7661  return false;
7662 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
static NameChar determineNameChar(QChar ch)
Definition: qxml.cpp:3437
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:66
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseAttType()

bool QXmlSimpleReaderPrivate::parseAttType ( )
private

Definition at line 6068 of file qxml.cpp.

6069 {
6070  const signed char Init = 0;
6071  const signed char ST = 1; // StringType
6072  const signed char TTI = 2; // TokenizedType starting with 'I'
6073  const signed char TTI2 = 3; // TokenizedType helpstate
6074  const signed char TTI3 = 4; // TokenizedType helpstate
6075  const signed char TTE = 5; // TokenizedType starting with 'E'
6076  const signed char TTEY = 6; // TokenizedType starting with 'ENTITY'
6077  const signed char TTEI = 7; // TokenizedType starting with 'ENTITI'
6078  const signed char N = 8; // N read (TokenizedType or Notation)
6079  const signed char TTNM = 9; // TokenizedType starting with 'NM'
6080  const signed char TTNM2 = 10; // TokenizedType helpstate
6081  const signed char NO = 11; // Notation
6082  const signed char NO2 = 12; // Notation helpstate
6083  const signed char NO3 = 13; // Notation helpstate
6084  const signed char NOName = 14; // Notation, read name
6085  const signed char NO4 = 15; // Notation helpstate
6086  const signed char EN = 16; // Enumeration
6087  const signed char ENNmt = 17; // Enumeration, read Nmtoken
6088  const signed char EN2 = 18; // Enumeration helpstate
6089  const signed char ADone = 19; // almost done (make next and accept)
6090  const signed char Done = 20;
6091 
6092  const signed char InpWs = 0; // whitespace
6093  const signed char InpOp = 1; // (
6094  const signed char InpCp = 2; //)
6095  const signed char InpPipe = 3; // |
6096  const signed char InpC = 4; // C
6097  const signed char InpE = 5; // E
6098  const signed char InpI = 6; // I
6099  const signed char InpM = 7; // M
6100  const signed char InpN = 8; // N
6101  const signed char InpO = 9; // O
6102  const signed char InpR = 10; // R
6103  const signed char InpS = 11; // S
6104  const signed char InpY = 12; // Y
6105  const signed char InpUnknown = 13;
6106 
6107  static const signed char table[19][14] = {
6108  /* InpWs InpOp InpCp InpPipe InpC InpE InpI InpM InpN InpO InpR InpS InpY InpUnknown */
6109  { -1, EN, -1, -1, ST, TTE, TTI, -1, N, -1, -1, -1, -1, -1 }, // Init
6110  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // ST
6111  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTI2, Done, Done, Done }, // TTI
6112  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTI3, Done, Done }, // TTI2
6113  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTI3
6114  { -1, -1, -1, -1, -1, -1, TTEI, -1, -1, -1, -1, -1, TTEY, -1 }, // TTE
6115  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTEY
6116  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTEI
6117  { -1, -1, -1, -1, -1, -1, -1, TTNM, -1, NO, -1, -1, -1, -1 }, // N
6118  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTNM2, Done, Done }, // TTNM
6119  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTNM2
6120  { NO2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NO
6121  { -1, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NO2
6122  { NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName }, // NO3
6123  { NO4, -1, ADone, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NOName
6124  { -1, -1, ADone, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NO4
6125  { -1, -1, ENNmt, -1, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt }, // EN
6126  { EN2, -1, ADone, EN, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // ENNmt
6127  { -1, -1, ADone, EN, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } // EN2
6128  };
6129  signed char state;
6130  signed char input;
6131 
6132  if (parseStack==0 || parseStack->isEmpty()) {
6133  state = Init;
6134  } else {
6135  state = parseStack->pop().state;
6136 #if defined(QT_QXML_DEBUG)
6137  qDebug("QXmlSimpleReader: parseAttType (cont) in state %d", state);
6138 #endif
6139  if (!parseStack->isEmpty()) {
6140  ParseFunction function = parseStack->top().function;
6141  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
6142  parseStack->pop();
6143 #if defined(QT_QXML_DEBUG)
6144  qDebug("QXmlSimpleReader: eat_ws (cont)");
6145 #endif
6146  }
6147  if (!(this->*function)()) {
6149  return false;
6150  }
6151  }
6152  }
6153 
6154  for (;;) {
6155  switch (state) {
6156  case ADone:
6157  return true;
6158  case Done:
6159  return true;
6160  case -1:
6161  // Error
6163  return false;
6164  }
6165 
6166  if (atEnd()) {
6168  return false;
6169  }
6170  if (is_S(c)) {
6171  input = InpWs;
6172  } else if (c == QLatin1Char('(')) {
6173  input = InpOp;
6174  } else if (c == QLatin1Char(')')) {
6175  input = InpCp;
6176  } else if (c == QLatin1Char('|')) {
6177  input = InpPipe;
6178  } else if (c == QLatin1Char('C')) {
6179  input = InpC;
6180  } else if (c == QLatin1Char('E')) {
6181  input = InpE;
6182  } else if (c == QLatin1Char('I')) {
6183  input = InpI;
6184  } else if (c == QLatin1Char('M')) {
6185  input = InpM;
6186  } else if (c == QLatin1Char('N')) {
6187  input = InpN;
6188  } else if (c == QLatin1Char('O')) {
6189  input = InpO;
6190  } else if (c == QLatin1Char('R')) {
6191  input = InpR;
6192  } else if (c == QLatin1Char('S')) {
6193  input = InpS;
6194  } else if (c == QLatin1Char('Y')) {
6195  input = InpY;
6196  } else {
6197  input = InpUnknown;
6198  }
6199  state = table[state][input];
6200 
6201  switch (state) {
6202  case ST:
6203  parseString_s = QLatin1String("CDATA");
6204  if (!parseString()) {
6206  return false;
6207  }
6208  break;
6209  case TTI:
6210  parseString_s = QLatin1String("ID");
6211  if (!parseString()) {
6213  return false;
6214  }
6215  break;
6216  case TTI2:
6217  parseString_s = QLatin1String("REF");
6218  if (!parseString()) {
6220  return false;
6221  }
6222  break;
6223  case TTI3:
6224  next(); // S
6225  break;
6226  case TTE:
6227  parseString_s = QLatin1String("ENTIT");
6228  if (!parseString()) {
6230  return false;
6231  }
6232  break;
6233  case TTEY:
6234  next(); // Y
6235  break;
6236  case TTEI:
6237  parseString_s = QLatin1String("IES");
6238  if (!parseString()) {
6240  return false;
6241  }
6242  break;
6243  case N:
6244  next(); // N
6245  break;
6246  case TTNM:
6247  parseString_s = QLatin1String("MTOKEN");
6248  if (!parseString()) {
6250  return false;
6251  }
6252  break;
6253  case TTNM2:
6254  next(); // S
6255  break;
6256  case NO:
6257  parseString_s = QLatin1String("OTATION");
6258  if (!parseString()) {
6260  return false;
6261  }
6262  break;
6263  case NO2:
6264  if (!eat_ws()) {
6266  return false;
6267  }
6268  break;
6269  case NO3:
6270  if (!next_eat_ws()) {
6272  return false;
6273  }
6274  break;
6275  case NOName:
6276  parseName_useRef = false;
6277  if (!parseName()) {
6279  return false;
6280  }
6281  break;
6282  case NO4:
6283  if (!eat_ws()) {
6285  return false;
6286  }
6287  break;
6288  case EN:
6289  if (!next_eat_ws()) {
6291  return false;
6292  }
6293  break;
6294  case ENNmt:
6295  if (!parseNmtoken()) {
6297  return false;
6298  }
6299  break;
6300  case EN2:
6301  if (!eat_ws()) {
6303  return false;
6304  }
6305  break;
6306  case ADone:
6307  next();
6308  break;
6309  }
6310  }
6311  return false;
6312 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:73
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
signed char Done
Definition: qxml.cpp:397
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseAttValue()

bool QXmlSimpleReaderPrivate::parseAttValue ( )
private

Definition at line 6323 of file qxml.cpp.

6324 {
6325  const signed char Init = 0;
6326  const signed char Dq = 1; // double quotes were read
6327  const signed char DqRef = 2; // read references in double quotes
6328  const signed char DqC = 3; // signed character read in double quotes
6329  const signed char Sq = 4; // single quotes were read
6330  const signed char SqRef = 5; // read references in single quotes
6331  const signed char SqC = 6; // signed character read in single quotes
6332  const signed char Done = 7;
6333 
6334  const signed char InpDq = 0; // "
6335  const signed char InpSq = 1; // '
6336  const signed char InpAmp = 2; // &
6337  const signed char InpLt = 3; // <
6338  const signed char InpUnknown = 4;
6339 
6340  static const signed char table[7][5] = {
6341  /* InpDq InpSq InpAmp InpLt InpUnknown */
6342  { Dq, Sq, -1, -1, -1 }, // Init
6343  { Done, DqC, DqRef, -1, DqC }, // Dq
6344  { Done, DqC, DqRef, -1, DqC }, // DqRef
6345  { Done, DqC, DqRef, -1, DqC }, // DqC
6346  { SqC, Done, SqRef, -1, SqC }, // Sq
6347  { SqC, Done, SqRef, -1, SqC }, // SqRef
6348  { SqC, Done, SqRef, -1, SqC } // SqRef
6349  };
6350  signed char state;
6351  signed char input;
6352 
6353  if (parseStack==0 || parseStack->isEmpty()) {
6354  state = Init;
6355  } else {
6356  state = parseStack->pop().state;
6357 #if defined(QT_QXML_DEBUG)
6358  qDebug("QXmlSimpleReader: parseAttValue (cont) in state %d", state);
6359 #endif
6360  if (!parseStack->isEmpty()) {
6361  ParseFunction function = parseStack->top().function;
6362  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
6363  parseStack->pop();
6364 #if defined(QT_QXML_DEBUG)
6365  qDebug("QXmlSimpleReader: eat_ws (cont)");
6366 #endif
6367  }
6368  if (!(this->*function)()) {
6370  return false;
6371  }
6372  }
6373  }
6374 
6375  for (;;) {
6376  switch (state) {
6377  case Done:
6378  return true;
6379  case -1:
6380  // Error
6382  return false;
6383  }
6384 
6385  if (atEnd()) {
6387  return false;
6388  }
6389  if (c == QLatin1Char('"')) {
6390  input = InpDq;
6391  } else if (c == QLatin1Char('\'')) {
6392  input = InpSq;
6393  } else if (c == QLatin1Char('&')) {
6394  input = InpAmp;
6395  } else if (c == QLatin1Char('<')) {
6396  input = InpLt;
6397  } else {
6398  input = InpUnknown;
6399  }
6400  state = table[state][input];
6401 
6402  switch (state) {
6403  case Dq:
6404  case Sq:
6405  stringClear();
6406  next();
6407  break;
6408  case DqRef:
6409  case SqRef:
6411  if (!parseReference()) {
6413  return false;
6414  }
6415  break;
6416  case DqC:
6417  case SqC:
6418  stringAddC();
6419  next();
6420  break;
6421  case Done:
6422  next();
6423  break;
6424  }
6425  }
6426  return false;
6427 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:66
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
EntityRecognitionContext parseReference_context
Definition: qxml.cpp:376
signed char Done
Definition: qxml.cpp:397
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseBeginOrContinue()

bool QXmlSimpleReaderPrivate::parseBeginOrContinue ( int  state,
bool  incremental 
)
private

Definition at line 3791 of file qxml.cpp.

3792 {
3793  bool atEndOrig = atEnd();
3794 
3795  if (state==0) {
3796  if (!parseProlog()) {
3797  if (incremental && error.isNull()) {
3798  pushParseState(0, 0);
3799  return true;
3800  } else {
3801  tags.clear();
3802  return false;
3803  }
3804  }
3805  state = 1;
3806  }
3807  if (state==1) {
3808  if (!parseElement()) {
3809  if (incremental && error.isNull()) {
3810  pushParseState(0, 1);
3811  return true;
3812  } else {
3813  tags.clear();
3814  return false;
3815  }
3816  }
3817  state = 2;
3818  }
3819  // parse Misc*
3820  while (!atEnd()) {
3821  if (!parseMisc()) {
3822  if (incremental && error.isNull()) {
3823  pushParseState(0, 2);
3824  return true;
3825  } else {
3826  tags.clear();
3827  return false;
3828  }
3829  }
3830  }
3831  if (!atEndOrig && incremental) {
3832  // we parsed something at all, so be prepared to come back later
3833  pushParseState(0, 2);
3834  return true;
3835  }
3836  // is stack empty?
3837  if (!tags.isEmpty() && !error.isNull()) {
3839  tags.clear();
3840  return false;
3841  }
3842  // call the handler
3843  if (contentHnd) {
3844  delete parseStack;
3845  parseStack = 0;
3846  if (!contentHnd->endDocument()) {
3848  return false;
3849  }
3850  }
3851  return true;
3852 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void pushParseState(ParseFunction function, int state)
Definition: qxml.cpp:8473
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
virtual bool endDocument()=0
The reader calls this function after it has finished parsing.
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:61
QStack< QString > tags
Definition: qxml.cpp:284
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401

◆ parseChoiceSeq()

bool QXmlSimpleReaderPrivate::parseChoiceSeq ( )
private

Definition at line 6816 of file qxml.cpp.

6817 {
6818  const signed char Init = 0;
6819  const signed char Ws1 = 1; // eat whitespace
6820  const signed char CoS = 2; // choice or set
6821  const signed char Ws2 = 3; // eat whitespace
6822  const signed char More = 4; // more cp to read
6823  const signed char Name = 5; // read name
6824  const signed char Done = 6; //
6825 
6826  const signed char InpWs = 0; // S
6827  const signed char InpOp = 1; // (
6828  const signed char InpCp = 2; //)
6829  const signed char InpQm = 3; // ?
6830  const signed char InpAst = 4; // *
6831  const signed char InpPlus = 5; // +
6832  const signed char InpPipe = 6; // |
6833  const signed char InpComm = 7; // ,
6834  const signed char InpUnknown = 8;
6835 
6836  static const signed char table[6][9] = {
6837  /* InpWs InpOp InpCp InpQm InpAst InpPlus InpPipe InpComm InpUnknown */
6838  { -1, Ws1, -1, -1, -1, -1, -1, -1, Name }, // Init
6839  { -1, CoS, -1, -1, -1, -1, -1, -1, CoS }, // Ws1
6840  { Ws2, -1, Done, Ws2, Ws2, Ws2, More, More, -1 }, // CS
6841  { -1, -1, Done, -1, -1, -1, More, More, -1 }, // Ws2
6842  { -1, Ws1, -1, -1, -1, -1, -1, -1, Name }, // More (same as Init)
6843  { Ws2, -1, Done, Ws2, Ws2, Ws2, More, More, -1 } // Name (same as CS)
6844  };
6845  signed char state;
6846  signed char input;
6847 
6848  if (parseStack==0 || parseStack->isEmpty()) {
6849  state = Init;
6850  } else {
6851  state = parseStack->pop().state;
6852 #if defined(QT_QXML_DEBUG)
6853  qDebug("QXmlSimpleReader: parseChoiceSeq (cont) in state %d", state);
6854 #endif
6855  if (!parseStack->isEmpty()) {
6856  ParseFunction function = parseStack->top().function;
6857  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
6858  parseStack->pop();
6859 #if defined(QT_QXML_DEBUG)
6860  qDebug("QXmlSimpleReader: eat_ws (cont)");
6861 #endif
6862  }
6863  if (!(this->*function)()) {
6865  return false;
6866  }
6867  }
6868  }
6869 
6870  for (;;) {
6871  switch (state) {
6872  case Done:
6873  return true;
6874  case -1:
6875  // Error
6877  return false;
6878  }
6879 
6880  if (atEnd()) {
6882  return false;
6883  }
6884  if (is_S(c)) {
6885  input = InpWs;
6886  } else if (c == QLatin1Char('(')) {
6887  input = InpOp;
6888  } else if (c == QLatin1Char(')')) {
6889  input = InpCp;
6890  } else if (c == QLatin1Char('?')) {
6891  input = InpQm;
6892  } else if (c == QLatin1Char('*')) {
6893  input = InpAst;
6894  } else if (c == QLatin1Char('+')) {
6895  input = InpPlus;
6896  } else if (c == QLatin1Char('|')) {
6897  input = InpPipe;
6898  } else if (c == QLatin1Char(',')) {
6899  input = InpComm;
6900  } else {
6901  input = InpUnknown;
6902  }
6903  state = table[state][input];
6904 
6905  switch (state) {
6906  case Ws1:
6907  if (!next_eat_ws()) {
6909  return false;
6910  }
6911  break;
6912  case CoS:
6913  if (!parseChoiceSeq()) {
6915  return false;
6916  }
6917  break;
6918  case Ws2:
6919  if (!next_eat_ws()) {
6921  return false;
6922  }
6923  break;
6924  case More:
6925  if (!next_eat_ws()) {
6927  return false;
6928  }
6929  break;
6930  case Name:
6931  parseName_useRef = false;
6932  if (!parseName()) {
6934  return false;
6935  }
6936  break;
6937  case Done:
6938  next();
6939  break;
6940  }
6941  }
6942  return false;
6943 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:66
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
signed char Done
Definition: qxml.cpp:397
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseComment()

bool QXmlSimpleReaderPrivate::parseComment ( )
private

Definition at line 7445 of file qxml.cpp.

7446 {
7447  const signed char Init = 0;
7448  const signed char Dash1 = 1; // the first dash was read
7449  const signed char Dash2 = 2; // the second dash was read
7450  const signed char Com = 3; // read comment
7451  const signed char Com2 = 4; // read comment (help state)
7452  const signed char ComE = 5; // finished reading comment
7453  const signed char Done = 6;
7454 
7455  const signed char InpDash = 0; // -
7456  const signed char InpGt = 1; // >
7457  const signed char InpUnknown = 2;
7458 
7459  static const signed char table[6][3] = {
7460  /* InpDash InpGt InpUnknown */
7461  { Dash1, -1, -1 }, // Init
7462  { Dash2, -1, -1 }, // Dash1
7463  { Com2, Com, Com }, // Dash2
7464  { Com2, Com, Com }, // Com
7465  { ComE, Com, Com }, // Com2
7466  { -1, Done, -1 } // ComE
7467  };
7468  signed char state;
7469  signed char input;
7470 
7471  if (parseStack==0 || parseStack->isEmpty()) {
7472  state = Init;
7473  } else {
7474  state = parseStack->pop().state;
7475 #if defined(QT_QXML_DEBUG)
7476  qDebug("QXmlSimpleReader: parseComment (cont) in state %d", state);
7477 #endif
7478  if (!parseStack->isEmpty()) {
7479  ParseFunction function = parseStack->top().function;
7480  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
7481  parseStack->pop();
7482 #if defined(QT_QXML_DEBUG)
7483  qDebug("QXmlSimpleReader: eat_ws (cont)");
7484 #endif
7485  }
7486  if (!(this->*function)()) {
7488  return false;
7489  }
7490  }
7491  }
7492 
7493  for (;;) {
7494  switch (state) {
7495  case Dash2:
7496  stringClear();
7497  break;
7498  case Com2:
7499  // if next character is not a dash than don't skip it
7500  if (!atEnd() && c != QLatin1Char('-'))
7501  stringAddC(QLatin1Char('-'));
7502  break;
7503  case Done:
7504  return true;
7505  case -1:
7506  // Error
7508  return false;
7509  }
7510 
7511  if (atEnd()) {
7513  return false;
7514  }
7515  if (c == QLatin1Char('-')) {
7516  input = InpDash;
7517  } else if (c == QLatin1Char('>')) {
7518  input = InpGt;
7519  } else {
7520  input = InpUnknown;
7521  }
7522  state = table[state][input];
7523 
7524  switch (state) {
7525  case Dash1:
7526  next();
7527  break;
7528  case Dash2:
7529  next();
7530  break;
7531  case Com:
7532  stringAddC();
7533  next();
7534  break;
7535  case Com2:
7536  next();
7537  break;
7538  case ComE:
7539  next();
7540  break;
7541  case Done:
7542  next();
7543  break;
7544  }
7545  }
7546  return false;
7547 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
#define XMLERR_ERRORPARSINGCOMMENT
Definition: qxml.cpp:74
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
signed char Done
Definition: qxml.cpp:397
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseContent()

bool QXmlSimpleReaderPrivate::parseContent ( )
private

Definition at line 4454 of file qxml.cpp.

4455 {
4456  const signed char Init = 0;
4457  const signed char ChD = 1; // CharData
4458  const signed char ChD1 = 2; // CharData help state
4459  const signed char ChD2 = 3; // CharData help state
4460  const signed char Ref = 4; // Reference
4461  const signed char Lt = 5; // '<' read
4462  const signed char PInstr = 6; // PI
4463  const signed char PInstrR = 7; // same as PInstr, but already reported
4464  const signed char Elem = 8; // Element
4465  const signed char Em = 9; // '!' read
4466  const signed char Com = 10; // Comment
4467  const signed char ComR = 11; // same as Com, but already reported
4468  const signed char CDS = 12; // CDSect
4469  const signed char CDS1 = 13; // read a CDSect
4470  const signed char CDS2 = 14; // read a CDSect (help state)
4471  const signed char CDS3 = 15; // read a CDSect (help state)
4472  const signed char Done = 16; // finished reading content
4473 
4474  const signed char InpLt = 0; // <
4475  const signed char InpGt = 1; // >
4476  const signed char InpSlash = 2; // /
4477  const signed char InpQMark = 3; // ?
4478  const signed char InpEMark = 4; // !
4479  const signed char InpAmp = 5; // &
4480  const signed char InpDash = 6; // -
4481  const signed char InpOpenB = 7; // [
4482  const signed char InpCloseB = 8; //]
4483  const signed char InpUnknown = 9;
4484 
4485  static const signed char mapCLT2FSMChar[] = {
4486  InpUnknown, // white space
4487  InpUnknown, // %
4488  InpAmp, // &
4489  InpGt, // >
4490  InpLt, // <
4491  InpSlash, // /
4492  InpQMark, // ?
4493  InpEMark, // !
4494  InpDash, // -
4495  InpCloseB, //]
4496  InpOpenB, // [
4497  InpUnknown, // =
4498  InpUnknown, // "
4499  InpUnknown, // '
4500  InpUnknown // unknown
4501  };
4502 
4503  static const signed char table[16][10] = {
4504  /* InpLt InpGt InpSlash InpQMark InpEMark InpAmp InpDash InpOpenB InpCloseB InpUnknown */
4505  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD1, ChD }, // Init
4506  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD1, ChD }, // ChD
4507  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD2, ChD }, // ChD1
4508  { Lt, -1, ChD, ChD, ChD, Ref, ChD, ChD, ChD2, ChD }, // ChD2
4509  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // Ref (same as Init)
4510  { -1, -1, Done, PInstr, Em, -1, -1, -1, -1, Elem }, // Lt
4511  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // PInstr (same as Init)
4512  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // PInstrR
4513  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // Elem (same as Init)
4514  { -1, -1, -1, -1, -1, -1, Com, CDS, -1, -1 }, // Em
4515  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // Com (same as Init)
4516  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // ComR
4517  { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS2, CDS1 }, // CDS
4518  { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS2, CDS1 }, // CDS1
4519  { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS3, CDS1 }, // CDS2
4520  { CDS1, Init, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS3, CDS1 } // CDS3
4521  };
4522  signed char state;
4523  signed char input;
4524 
4525  if (parseStack == 0 || parseStack->isEmpty()) {
4526  contentCharDataRead = false;
4527  state = Init;
4528  } else {
4529  state = parseStack->pop().state;
4530 #if defined(QT_QXML_DEBUG)
4531  qDebug("QXmlSimpleReader: parseContent (cont) in state %d", state);
4532 #endif
4533  if (!parseStack->isEmpty()) {
4534  ParseFunction function = parseStack->top().function;
4535  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
4536  parseStack->pop();
4537 #if defined(QT_QXML_DEBUG)
4538  qDebug("QXmlSimpleReader: eat_ws (cont)");
4539 #endif
4540  }
4541  if (!(this->*function)()) {
4543  return false;
4544  }
4545  }
4546  }
4547 
4548  for (;;) {
4549  switch (state) {
4550  case Ref:
4551  if (!contentCharDataRead)
4553  break;
4554  case PInstr:
4555  if (contentHnd) {
4556  if (!contentHnd->processingInstruction(name(),string())) {
4558  return false;
4559  }
4560  }
4561  state = PInstrR;
4562  break;
4563  case Com:
4564  if (lexicalHnd) {
4565  if (!lexicalHnd->comment(string())) {
4567  return false;
4568  }
4569  }
4570  state = ComR;
4571  break;
4572  case CDS:
4573  stringClear();
4574  break;
4575  case CDS2:
4576  if (!atEnd() && c != QLatin1Char(']'))
4577  stringAddC(QLatin1Char(']'));
4578  break;
4579  case CDS3:
4580  // test if this skipping was legal
4581  if (!atEnd()) {
4582  if (c == QLatin1Char('>')) {
4583  // the end of the CDSect
4584  if (lexicalHnd) {
4585  if (!lexicalHnd->startCDATA()) {
4587  return false;
4588  }
4589  }
4590  if (contentHnd) {
4591  if (!contentHnd->characters(string())) {
4593  return false;
4594  }
4595  }
4596  if (lexicalHnd) {
4597  if (!lexicalHnd->endCDATA()) {
4599  return false;
4600  }
4601  }
4602  } else if (c == QLatin1Char(']')) {
4603  // three or more ']'
4604  stringAddC(QLatin1Char(']'));
4605  } else {
4606  // after ']]' comes another character
4607  stringAddC(QLatin1Char(']'));
4608  stringAddC(QLatin1Char(']'));
4609  }
4610  }
4611  break;
4612  case Done:
4613  // call the handler for CharData
4614  if (contentHnd) {
4615  if (contentCharDataRead) {
4616  if (reportWhitespaceCharData || !string().simplified().isEmpty()) {
4617  if (!contentHnd->characters(string())) {
4619  return false;
4620  }
4621  }
4622  }
4623  }
4624  // Done
4625  return true;
4626  case -1:
4627  // Error
4629  return false;
4630  }
4631 
4632  // get input (use lookup-table instead of nested ifs for performance
4633  // reasons)
4634  if (atEnd()) {
4636  return false;
4637  }
4638  if (c.row()) {
4639  input = InpUnknown;
4640  } else {
4641  input = mapCLT2FSMChar[charLookupTable[c.cell()]];
4642  }
4643  state = table[state][input];
4644 
4645  switch (state) {
4646  case Init:
4647  // skip the ending '>' of a CDATASection
4648  next();
4649  break;
4650  case ChD:
4651  // on first call: clear string
4652  if (!contentCharDataRead) {
4653  contentCharDataRead = true;
4654  stringClear();
4655  }
4656  stringAddC();
4657  if (reportEntities) {
4658  if (!reportEndEntities())
4659  return false;
4660  }
4661  next();
4662  break;
4663  case ChD1:
4664  // on first call: clear string
4665  if (!contentCharDataRead) {
4666  contentCharDataRead = true;
4667  stringClear();
4668  }
4669  stringAddC();
4670  if (reportEntities) {
4671  if (!reportEndEntities())
4672  return false;
4673  }
4674  next();
4675  break;
4676  case ChD2:
4677  stringAddC();
4678  if (reportEntities) {
4679  if (!reportEndEntities())
4680  return false;
4681  }
4682  next();
4683  break;
4684  case Ref:
4685  if (!contentCharDataRead) {
4686  // reference may be CharData; so clear string to be safe
4687  stringClear();
4689  if (!parseReference()) {
4691  return false;
4692  }
4693  } else {
4694  if (reportEntities) {
4695  // report character data in chunks
4696  if (contentHnd) {
4697  if (reportWhitespaceCharData || !string().simplified().isEmpty()) {
4698  if (!contentHnd->characters(string())) {
4700  return false;
4701  }
4702  }
4703  }
4704  stringClear();
4705  }
4707  if (!parseReference()) {
4709  return false;
4710  }
4711  }
4712  break;
4713  case Lt:
4714  // call the handler for CharData
4715  if (contentHnd) {
4716  if (contentCharDataRead) {
4717  if (reportWhitespaceCharData || !string().simplified().isEmpty()) {
4718  if (!contentHnd->characters(string())) {
4720  return false;
4721  }
4722  }
4723  }
4724  }
4725  contentCharDataRead = false;
4726  next();
4727  break;
4728  case PInstr:
4729  case PInstrR:
4730  parsePI_xmldecl = false;
4731  if (!parsePI()) {
4733  return false;
4734  }
4735  break;
4736  case Elem:
4737  if (!parseElement()) {
4739  return false;
4740  }
4741  break;
4742  case Em:
4743  next();
4744  break;
4745  case Com:
4746  case ComR:
4747  if (!parseComment()) {
4749  return false;
4750  }
4751  break;
4752  case CDS:
4753  parseString_s = QLatin1String("[CDATA[");
4754  if (!parseString()) {
4756  return false;
4757  }
4758  break;
4759  case CDS1:
4760  stringAddC();
4761  next();
4762  break;
4763  case CDS2:
4764  // skip ']'
4765  next();
4766  break;
4767  case CDS3:
4768  // skip ']'...
4769  next();
4770  break;
4771  }
4772  }
4773  return false;
4774 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QXmlLexicalHandler * lexicalHnd
Definition: qxml.cpp:405
bool reportWhitespaceCharData
Definition: qxml.cpp:354
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
static bool isEmpty(const char *str)
#define XMLERR_ERRORPARSINGCONTENT
Definition: qxml.cpp:65
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
virtual bool comment(const QString &ch)=0
The reader calls this function to report an XML comment anywhere in the document. ...
bool parseReference_charDataRead
Definition: qxml.cpp:375
virtual bool processingInstruction(const QString &target, const QString &data)=0
The reader calls this function when it has parsed a processing instruction.
virtual bool startCDATA()=0
The reader calls this function to report the start of a CDATA section.
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
EntityRecognitionContext parseReference_context
Definition: qxml.cpp:376
const QString & name()
Definition: qxml.cpp:8495
virtual bool characters(const QString &ch)=0
The reader calls this function when it has parsed a chunk of character data (either normal character ...
virtual bool endCDATA()=0
The reader calls this function to report the end of a CDATA section.
uchar cell() const
Returns the cell (least significant byte) of the Unicode character.
Definition: qchar.h:283
signed char Done
Definition: qxml.cpp:397
static const signed char charLookupTable[256]
Definition: qxml.cpp:107
uchar row() const
Returns the row (most significant byte) of the Unicode character.
Definition: qchar.h:284
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401

◆ parseDoctype()

bool QXmlSimpleReaderPrivate::parseDoctype ( )
private

Definition at line 5165 of file qxml.cpp.

5166 {
5167  const signed char Init = 0;
5168  const signed char Doctype = 1; // read the doctype
5169  const signed char Ws1 = 2; // eat_ws
5170  const signed char Doctype2 = 3; // read the doctype, part 2
5171  const signed char Ws2 = 4; // eat_ws
5172  const signed char Sys = 5; // read SYSTEM or PUBLIC
5173  const signed char Ws3 = 6; // eat_ws
5174  const signed char MP = 7; // markupdecl or PEReference
5175  const signed char MPR = 8; // same as MP, but already reported
5176  const signed char PER = 9; // PERReference
5177  const signed char Mup = 10; // markupdecl
5178  const signed char Ws4 = 11; // eat_ws
5179  const signed char MPE = 12; // end of markupdecl or PEReference
5180  const signed char Done = 13;
5181 
5182  const signed char InpWs = 0;
5183  const signed char InpD = 1; // 'D'
5184  const signed char InpS = 2; // 'S' or 'P'
5185  const signed char InpOB = 3; // [
5186  const signed char InpCB = 4; //]
5187  const signed char InpPer = 5; // %
5188  const signed char InpGt = 6; // >
5189  const signed char InpUnknown = 7;
5190 
5191  static const signed char table[13][8] = {
5192  /* InpWs, InpD InpS InpOB InpCB InpPer InpGt InpUnknown */
5193  { -1, Doctype, -1, -1, -1, -1, -1, -1 }, // Init
5194  { Ws1, -1, -1, -1, -1, -1, -1, -1 }, // Doctype
5195  { -1, Doctype2, Doctype2, -1, -1, -1, -1, Doctype2 }, // Ws1
5196  { Ws2, -1, Sys, MP, -1, -1, Done, -1 }, // Doctype2
5197  { -1, -1, Sys, MP, -1, -1, Done, -1 }, // Ws2
5198  { Ws3, -1, -1, MP, -1, -1, Done, -1 }, // Sys
5199  { -1, -1, -1, MP, -1, -1, Done, -1 }, // Ws3
5200  { -1, -1, -1, -1, MPE, PER, -1, Mup }, // MP
5201  { -1, -1, -1, -1, MPE, PER, -1, Mup }, // MPR
5202  { Ws4, -1, -1, -1, MPE, PER, -1, Mup }, // PER
5203  { Ws4, -1, -1, -1, MPE, PER, -1, Mup }, // Mup
5204  { -1, -1, -1, -1, MPE, PER, -1, Mup }, // Ws4
5205  { -1, -1, -1, -1, -1, -1, Done, -1 } // MPE
5206  };
5207  signed char state;
5208  signed char input;
5209 
5210  if (parseStack==0 || parseStack->isEmpty()) {
5211  startDTDwasReported = false;
5212  systemId.clear();
5213  publicId.clear();
5214  state = Init;
5215  } else {
5216  state = parseStack->pop().state;
5217 #if defined(QT_QXML_DEBUG)
5218  qDebug("QXmlSimpleReader: parseDoctype (cont) in state %d", state);
5219 #endif
5220  if (!parseStack->isEmpty()) {
5221  ParseFunction function = parseStack->top().function;
5222  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
5223  parseStack->pop();
5224 #if defined(QT_QXML_DEBUG)
5225  qDebug("QXmlSimpleReader: eat_ws (cont)");
5226 #endif
5227  }
5228  if (!(this->*function)()) {
5230  return false;
5231  }
5232  }
5233  }
5234 
5235  for (;;) {
5236  switch (state) {
5237  case Doctype2:
5238  doctype = name();
5239  break;
5240  case MP:
5241  if (!startDTDwasReported && lexicalHnd ) {
5242  startDTDwasReported = true;
5245  return false;
5246  }
5247  }
5248  state = MPR;
5249  break;
5250  case Done:
5251  return true;
5252  case -1:
5253  // Error
5255  return false;
5256  }
5257 
5258  if (atEnd()) {
5260  return false;
5261  }
5262  if (is_S(c)) {
5263  input = InpWs;
5264  } else if (c == QLatin1Char('D')) {
5265  input = InpD;
5266  } else if (c == QLatin1Char('S')) {
5267  input = InpS;
5268  } else if (c == QLatin1Char('P')) {
5269  input = InpS;
5270  } else if (c == QLatin1Char('[')) {
5271  input = InpOB;
5272  } else if (c == QLatin1Char(']')) {
5273  input = InpCB;
5274  } else if (c == QLatin1Char('%')) {
5275  input = InpPer;
5276  } else if (c == QLatin1Char('>')) {
5277  input = InpGt;
5278  } else {
5279  input = InpUnknown;
5280  }
5281  state = table[state][input];
5282 
5283  switch (state) {
5284  case Doctype:
5285  parseString_s = QLatin1String("DOCTYPE");
5286  if (!parseString()) {
5288  return false;
5289  }
5290  break;
5291  case Ws1:
5292  case Ws2:
5293  case Ws3:
5294  case Ws4:
5295  if (!eat_ws()) {
5297  return false;
5298  }
5299  break;
5300  case Doctype2:
5301  parseName_useRef = false;
5302  if (!parseName()) {
5304  return false;
5305  }
5306  break;
5307  case Sys:
5309  if (!parseExternalID()) {
5311  return false;
5312  }
5315  break;
5316  case MP:
5317  case MPR:
5318  if (!next_eat_ws()) {
5320  return false;
5321  }
5322  break;
5323  case PER:
5325  if (!parsePEReference()) {
5327  return false;
5328  }
5329  break;
5330  case Mup:
5333  "DTD parsing exceeded recursion limit of %1.").arg(dtdRecursionLimit));
5334  return false;
5335  }
5336  if (!parseMarkupdecl()) {
5338  return false;
5339  }
5340  break;
5341  case MPE:
5342  if (!next_eat_ws()) {
5344  return false;
5345  }
5346  break;
5347  case Done:
5348  if (lexicalHnd) {
5349  if (!startDTDwasReported) {
5350  startDTDwasReported = true;
5353  return false;
5354  }
5355  }
5356  if (!lexicalHnd->endDTD()) {
5358  return false;
5359  }
5360  }
5361  next();
5362  break;
5363  }
5364  }
5365  return false;
5366 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
void QT_FASTCALL next()
Definition: qxml.cpp:8300
#define XMLERR_ERRORPARSINGDOCTYPE
Definition: qxml.cpp:72
int size() const
Returns the number of (key, value) pairs in the map.
Definition: qmap.h:201
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static const int dtdRecursionLimit
Definition: qxml.cpp:434
QXmlLexicalHandler * lexicalHnd
Definition: qxml.cpp:405
virtual bool startDTD(const QString &name, const QString &publicId, const QString &systemId)=0
The reader calls this function to report the start of a DTD declaration, if any.
bool parseExternalID_allowPublicID
Definition: qxml.cpp:377
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
QMap< QString, QString > parameterEntities
Definition: qxml.cpp:311
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
const QString & name()
Definition: qxml.cpp:8495
EntityRecognitionContext parsePEReference_context
Definition: qxml.cpp:378
signed char Done
Definition: qxml.cpp:397
virtual bool endDTD()=0
The reader calls this function to report the end of a DTD declaration, if any.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseElement()

bool QXmlSimpleReaderPrivate::parseElement ( )
private

Definition at line 4121 of file qxml.cpp.

4122 {
4123  const int Init = 0;
4124  const int ReadName = 1;
4125  const int Ws1 = 2;
4126  const int STagEnd = 3;
4127  const int STagEnd2 = 4;
4128  const int ETagBegin = 5;
4129  const int ETagBegin2 = 6;
4130  const int Ws2 = 7;
4131  const int EmptyTag = 8;
4132  const int Attrib = 9;
4133  const int AttribPro = 10; // like Attrib, but processAttribute was already called
4134  const int Ws3 = 11;
4135  const int Done = 12;
4136 
4137  const int InpWs = 0; // whitespace
4138  const int InpNameBe = 1; // NameBeginning
4139  const int InpGt = 2; // >
4140  const int InpSlash = 3; // /
4141  const int InpUnknown = 4;
4142 
4143  static const int table[12][5] = {
4144  /* InpWs InpNameBe InpGt InpSlash InpUnknown */
4145  { -1, ReadName, -1, -1, -1 }, // Init
4146  { Ws1, Attrib, STagEnd, EmptyTag, -1 }, // ReadName
4147  { -1, Attrib, STagEnd, EmptyTag, -1 }, // Ws1
4148  { STagEnd2, STagEnd2, STagEnd2, STagEnd2, STagEnd2 }, // STagEnd
4149  { -1, -1, -1, ETagBegin, -1 }, // STagEnd2
4150  { -1, ETagBegin2, -1, -1, -1 }, // ETagBegin
4151  { Ws2, -1, Done, -1, -1 }, // ETagBegin2
4152  { -1, -1, Done, -1, -1 }, // Ws2
4153  { -1, -1, Done, -1, -1 }, // EmptyTag
4154  { Ws3, Attrib, STagEnd, EmptyTag, -1 }, // Attrib
4155  { Ws3, Attrib, STagEnd, EmptyTag, -1 }, // AttribPro
4156  { -1, Attrib, STagEnd, EmptyTag, -1 } // Ws3
4157  };
4158  int state;
4159  int input;
4160 
4161  if (parseStack == 0 || parseStack->isEmpty()) {
4162  state = Init;
4163  } else {
4164  state = parseStack->pop().state;
4165 #if defined(QT_QXML_DEBUG)
4166  qDebug("QXmlSimpleReader: parseElement (cont) in state %d", state);
4167 #endif
4168  if (!parseStack->isEmpty()) {
4169  ParseFunction function = parseStack->top().function;
4170  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
4171  parseStack->pop();
4172 #if defined(QT_QXML_DEBUG)
4173  qDebug("QXmlSimpleReader: eat_ws (cont)");
4174 #endif
4175  }
4176  if (!(this->*function)()) {
4178  return false;
4179  }
4180  }
4181  }
4182 
4183  for (;;) {
4184  switch (state) {
4185  case ReadName:
4186  // store it on the stack
4187  tags.push(name());
4188  // empty the attributes
4189  attList.clear();
4190  if (useNamespaces)
4192  break;
4193  case ETagBegin2:
4194  if (!processElementETagBegin2())
4195  return false;
4196  break;
4197  case Attrib:
4198  if (!processElementAttribute())
4199  return false;
4200  state = AttribPro;
4201  break;
4202  case Done:
4203  return true;
4204  case -1:
4206  return false;
4207  }
4208 
4209  if (atEnd()) {
4211  return false;
4212  }
4214  input = InpNameBe;
4215  } else if (c == QLatin1Char('>')) {
4216  input = InpGt;
4217  } else if (is_S(c)) {
4218  input = InpWs;
4219  } else if (c == QLatin1Char('/')) {
4220  input = InpSlash;
4221  } else {
4222  input = InpUnknown;
4223  }
4224  state = table[state][input];
4225 
4226  switch (state) {
4227  case ReadName:
4228  parseName_useRef = false;
4229  if (!parseName()) {
4231  return false;
4232  }
4233  break;
4234  case Ws1:
4235  case Ws2:
4236  case Ws3:
4237  if (!eat_ws()) {
4239  return false;
4240  }
4241  break;
4242  case STagEnd:
4243  // call the handler
4244  if (contentHnd) {
4245  const QString &tagsTop = tags.top();
4246  if (useNamespaces) {
4247  QString uri, lname;
4248  namespaceSupport.processName(tagsTop, false, uri, lname);
4249  if (!contentHnd->startElement(uri, lname, tagsTop, attList)) {
4251  return false;
4252  }
4253  } else {
4254  if (!contentHnd->startElement(QString(), QString(), tagsTop, attList)) {
4256  return false;
4257  }
4258  }
4259  }
4260  next();
4261  break;
4262  case STagEnd2:
4263  if (!parseContent()) {
4265  return false;
4266  }
4267  break;
4268  case ETagBegin:
4269  next();
4270  break;
4271  case ETagBegin2:
4272  // get the name of the tag
4273  parseName_useRef = false;
4274  if (!parseName()) {
4276  return false;
4277  }
4278  break;
4279  case EmptyTag:
4280  if (tags.isEmpty()) {
4282  return false;
4283  }
4284  if (!processElementEmptyTag())
4285  return false;
4286  next();
4287  break;
4288  case Attrib:
4289  case AttribPro:
4290  // get name and value of attribute
4291  if (!parseAttribute()) {
4293  return false;
4294  }
4295  break;
4296  case Done:
4297  next();
4298  break;
4299  }
4300  }
4301  return false;
4302 }
void processName(const QString &, bool, QString &, QString &) const
Processes a raw XML 1.0 name in the current context by removing the prefix and looking it up among th...
Definition: qxml.cpp:864
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
bool processElementAttribute()
Definition: qxml.cpp:4410
bool processElementEmptyTag()
Definition: qxml.cpp:4308
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QXmlAttributes attList
Definition: qxml.cpp:358
#define XMLERR_TAGMISMATCH
Definition: qxml.cpp:64
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define XMLERR_ERRORPARSINGELEMENT
Definition: qxml.cpp:63
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)=0
The reader calls this function when it has parsed a start element tag.
The QString class provides a Unicode character string.
Definition: qstring.h:83
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
void push(const T &t)
Adds element t to the top of the stack.
Definition: qstack.h:60
QXmlNamespaceSupport namespaceSupport
Definition: qxml.cpp:366
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
const QString & name()
Definition: qxml.cpp:8495
signed char Done
Definition: qxml.cpp:397
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
static NameChar fastDetermineNameChar(QChar ch)
Definition: qxml.cpp:3420
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QStack< QString > tags
Definition: qxml.cpp:284
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401
T & top()
Returns a reference to the stack&#39;s top item.
Definition: qstack.h:72
void clear()
Clears the list of attributes.
Definition: qxml.cpp:1260
bool processElementETagBegin2()
Definition: qxml.cpp:4363
void pushContext()
Starts a new namespace context.
Definition: qxml.cpp:954

◆ parseElementDecl()

bool QXmlSimpleReaderPrivate::parseElementDecl ( )
private

Definition at line 6435 of file qxml.cpp.

6436 {
6437  const signed char Init = 0;
6438  const signed char Elem = 1; // parse the beginning string
6439  const signed char Ws1 = 2; // whitespace required
6440  const signed char Nam = 3; // parse Name
6441  const signed char Ws2 = 4; // whitespace required
6442  const signed char Empty = 5; // read EMPTY
6443  const signed char Any = 6; // read ANY
6444  const signed char Cont = 7; // read contentspec (except ANY or EMPTY)
6445  const signed char Mix = 8; // read Mixed
6446  const signed char Mix2 = 9; //
6447  const signed char Mix3 = 10; //
6448  const signed char MixN1 = 11; //
6449  const signed char MixN2 = 12; //
6450  const signed char MixN3 = 13; //
6451  const signed char MixN4 = 14; //
6452  const signed char Cp = 15; // parse cp
6453  const signed char Cp2 = 16; //
6454  const signed char WsD = 17; // eat whitespace before Done
6455  const signed char Done = 18;
6456 
6457  const signed char InpWs = 0;
6458  const signed char InpGt = 1; // >
6459  const signed char InpPipe = 2; // |
6460  const signed char InpOp = 3; // (
6461  const signed char InpCp = 4; //)
6462  const signed char InpHash = 5; // #
6463  const signed char InpQm = 6; // ?
6464  const signed char InpAst = 7; // *
6465  const signed char InpPlus = 8; // +
6466  const signed char InpA = 9; // A
6467  const signed char InpE = 10; // E
6468  const signed char InpL = 11; // L
6469  const signed char InpUnknown = 12;
6470 
6471  static const signed char table[18][13] = {
6472  /* InpWs InpGt InpPipe InpOp InpCp InpHash InpQm InpAst InpPlus InpA InpE InpL InpUnknown */
6473  { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, Elem, -1 }, // Init
6474  { Ws1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Elem
6475  { -1, -1, -1, -1, -1, -1, -1, -1, -1, Nam, Nam, Nam, Nam }, // Ws1
6476  { Ws2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Nam
6477  { -1, -1, -1, Cont, -1, -1, -1, -1, -1, Any, Empty, -1, -1 }, // Ws2
6478  { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Empty
6479  { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Any
6480  { -1, -1, -1, Cp, Cp, Mix, -1, -1, -1, Cp, Cp, Cp, Cp }, // Cont
6481  { Mix2, -1, MixN1, -1, Mix3, -1, -1, -1, -1, -1, -1, -1, -1 }, // Mix
6482  { -1, -1, MixN1, -1, Mix3, -1, -1, -1, -1, -1, -1, -1, -1 }, // Mix2
6483  { WsD, Done, -1, -1, -1, -1, -1, WsD, -1, -1, -1, -1, -1 }, // Mix3
6484  { -1, -1, -1, -1, -1, -1, -1, -1, -1, MixN2, MixN2, MixN2, MixN2 }, // MixN1
6485  { MixN3, -1, MixN1, -1, MixN4, -1, -1, -1, -1, -1, -1, -1, -1 }, // MixN2
6486  { -1, -1, MixN1, -1, MixN4, -1, -1, -1, -1, -1, -1, -1, -1 }, // MixN3
6487  { -1, -1, -1, -1, -1, -1, -1, WsD, -1, -1, -1, -1, -1 }, // MixN4
6488  { WsD, Done, -1, -1, -1, -1, Cp2, Cp2, Cp2, -1, -1, -1, -1 }, // Cp
6489  { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Cp2
6490  { -1, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } // WsD
6491  };
6492  signed char state;
6493  signed char input;
6494 
6495  if (parseStack==0 || parseStack->isEmpty()) {
6496  state = Init;
6497  } else {
6498  state = parseStack->pop().state;
6499 #if defined(QT_QXML_DEBUG)
6500  qDebug("QXmlSimpleReader: parseElementDecl (cont) in state %d", state);
6501 #endif
6502  if (!parseStack->isEmpty()) {
6503  ParseFunction function = parseStack->top().function;
6504  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
6505  parseStack->pop();
6506 #if defined(QT_QXML_DEBUG)
6507  qDebug("QXmlSimpleReader: eat_ws (cont)");
6508 #endif
6509  }
6510  if (!(this->*function)()) {
6512  return false;
6513  }
6514  }
6515  }
6516 
6517  for (;;) {
6518  switch (state) {
6519  case Done:
6520  return true;
6521  case -1:
6523  return false;
6524  }
6525 
6526  if (atEnd()) {
6528  return false;
6529  }
6530  if (is_S(c)) {
6531  input = InpWs;
6532  } else if (c == QLatin1Char('>')) {
6533  input = InpGt;
6534  } else if (c == QLatin1Char('|')) {
6535  input = InpPipe;
6536  } else if (c == QLatin1Char('(')) {
6537  input = InpOp;
6538  } else if (c == QLatin1Char(')')) {
6539  input = InpCp;
6540  } else if (c == QLatin1Char('#')) {
6541  input = InpHash;
6542  } else if (c == QLatin1Char('?')) {
6543  input = InpQm;
6544  } else if (c == QLatin1Char('*')) {
6545  input = InpAst;
6546  } else if (c == QLatin1Char('+')) {
6547  input = InpPlus;
6548  } else if (c == QLatin1Char('A')) {
6549  input = InpA;
6550  } else if (c == QLatin1Char('E')) {
6551  input = InpE;
6552  } else if (c == QLatin1Char('L')) {
6553  input = InpL;
6554  } else {
6555  input = InpUnknown;
6556  }
6557  state = table[state][input];
6558 
6559  switch (state) {
6560  case Elem:
6561  parseString_s = QLatin1String("LEMENT");
6562  if (!parseString()) {
6564  return false;
6565  }
6566  break;
6567  case Ws1:
6568  if (!eat_ws()) {
6570  return false;
6571  }
6572  break;
6573  case Nam:
6574  parseName_useRef = false;
6575  if (!parseName()) {
6577  return false;
6578  }
6579  break;
6580  case Ws2:
6581  if (!eat_ws()) {
6583  return false;
6584  }
6585  break;
6586  case Empty:
6587  parseString_s = QLatin1String("EMPTY");
6588  if (!parseString()) {
6590  return false;
6591  }
6592  break;
6593  case Any:
6594  parseString_s = QLatin1String("ANY");
6595  if (!parseString()) {
6597  return false;
6598  }
6599  break;
6600  case Cont:
6601  if (!next_eat_ws()) {
6603  return false;
6604  }
6605  break;
6606  case Mix:
6607  parseString_s = QLatin1String("#PCDATA");
6608  if (!parseString()) {
6610  return false;
6611  }
6612  break;
6613  case Mix2:
6614  if (!eat_ws()) {
6616  return false;
6617  }
6618  break;
6619  case Mix3:
6620  next();
6621  break;
6622  case MixN1:
6623  if (!next_eat_ws()) {
6625  return false;
6626  }
6627  break;
6628  case MixN2:
6629  parseName_useRef = false;
6630  if (!parseName()) {
6632  return false;
6633  }
6634  break;
6635  case MixN3:
6636  if (!eat_ws()) {
6638  return false;
6639  }
6640  break;
6641  case MixN4:
6642  next();
6643  break;
6644  case Cp:
6645  if (!parseChoiceSeq()) {
6647  return false;
6648  }
6649  break;
6650  case Cp2:
6651  next();
6652  break;
6653  case WsD:
6654  if (!next_eat_ws()) {
6656  return false;
6657  }
6658  break;
6659  case Done:
6660  next();
6661  break;
6662  }
6663  }
6664  return false;
6665 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:66
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
signed char Done
Definition: qxml.cpp:397
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseEntityDecl()

bool QXmlSimpleReaderPrivate::parseEntityDecl ( )
private

Definition at line 7015 of file qxml.cpp.

7016 {
7017  const signed char Init = 0;
7018  const signed char Ent = 1; // parse "ENTITY"
7019  const signed char Ws1 = 2; // white space read
7020  const signed char Name = 3; // parse name
7021  const signed char Ws2 = 4; // white space read
7022  const signed char EValue = 5; // parse entity value
7023  const signed char EValueR = 6; // same as EValue, but already reported
7024  const signed char ExtID = 7; // parse ExternalID
7025  const signed char Ws3 = 8; // white space read
7026  const signed char Ndata = 9; // parse "NDATA"
7027  const signed char Ws4 = 10; // white space read
7028  const signed char NNam = 11; // parse name
7029  const signed char NNamR = 12; // same as NNam, but already reported
7030  const signed char PEDec = 13; // parse PEDecl
7031  const signed char Ws6 = 14; // white space read
7032  const signed char PENam = 15; // parse name
7033  const signed char Ws7 = 16; // white space read
7034  const signed char PEVal = 17; // parse entity value
7035  const signed char PEValR = 18; // same as PEVal, but already reported
7036  const signed char PEEID = 19; // parse ExternalID
7037  const signed char PEEIDR = 20; // same as PEEID, but already reported
7038  const signed char WsE = 21; // white space read
7039  const signed char Done = 22;
7040  const signed char EDDone = 23; // done, but also report an external, unparsed entity decl
7041 
7042  const signed char InpWs = 0; // white space
7043  const signed char InpPer = 1; // %
7044  const signed char InpQuot = 2; // " or '
7045  const signed char InpGt = 3; // >
7046  const signed char InpN = 4; // N
7047  const signed char InpUnknown = 5;
7048 
7049  static const signed char table[22][6] = {
7050  /* InpWs InpPer InpQuot InpGt InpN InpUnknown */
7051  { -1, -1, -1, -1, Ent, -1 }, // Init
7052  { Ws1, -1, -1, -1, -1, -1 }, // Ent
7053  { -1, PEDec, -1, -1, Name, Name }, // Ws1
7054  { Ws2, -1, -1, -1, -1, -1 }, // Name
7055  { -1, -1, EValue, -1, -1, ExtID }, // Ws2
7056  { WsE, -1, -1, Done, -1, -1 }, // EValue
7057  { WsE, -1, -1, Done, -1, -1 }, // EValueR
7058  { Ws3, -1, -1, EDDone,-1, -1 }, // ExtID
7059  { -1, -1, -1, EDDone,Ndata, -1 }, // Ws3
7060  { Ws4, -1, -1, -1, -1, -1 }, // Ndata
7061  { -1, -1, -1, -1, NNam, NNam }, // Ws4
7062  { WsE, -1, -1, Done, -1, -1 }, // NNam
7063  { WsE, -1, -1, Done, -1, -1 }, // NNamR
7064  { Ws6, -1, -1, -1, -1, -1 }, // PEDec
7065  { -1, -1, -1, -1, PENam, PENam }, // Ws6
7066  { Ws7, -1, -1, -1, -1, -1 }, // PENam
7067  { -1, -1, PEVal, -1, -1, PEEID }, // Ws7
7068  { WsE, -1, -1, Done, -1, -1 }, // PEVal
7069  { WsE, -1, -1, Done, -1, -1 }, // PEValR
7070  { WsE, -1, -1, Done, -1, -1 }, // PEEID
7071  { WsE, -1, -1, Done, -1, -1 }, // PEEIDR
7072  { -1, -1, -1, Done, -1, -1 } // WsE
7073  };
7074  signed char state;
7075  signed char input;
7076 
7077  if (parseStack==0 || parseStack->isEmpty()) {
7078  state = Init;
7079  } else {
7080  state = parseStack->pop().state;
7081 #if defined(QT_QXML_DEBUG)
7082  qDebug("QXmlSimpleReader: parseEntityDecl (cont) in state %d", state);
7083 #endif
7084  if (!parseStack->isEmpty()) {
7085  ParseFunction function = parseStack->top().function;
7086  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
7087  parseStack->pop();
7088 #if defined(QT_QXML_DEBUG)
7089  qDebug("QXmlSimpleReader: eat_ws (cont)");
7090 #endif
7091  }
7092  if (!(this->*function)()) {
7094  return false;
7095  }
7096  }
7097  }
7098 
7099  for (;;) {
7100  switch (state) {
7101  case EValue:
7102  if ( !entityExist(name())) {
7103  QString errorMessage;
7104  if (isExpandedEntityValueTooLarge(&errorMessage)) {
7105  reportParseError(errorMessage);
7106  return false;
7107  }
7108 
7109  entities.insert(name(), string());
7110  if (declHnd) {
7111  if (!declHnd->internalEntityDecl(name(), string())) {
7113  return false;
7114  }
7115  }
7116  }
7117  state = EValueR;
7118  break;
7119  case NNam:
7120  if ( !entityExist(name())) {
7122  if (dtdHnd) {
7125  return false;
7126  }
7127  }
7128  }
7129  state = NNamR;
7130  break;
7131  case PEVal:
7132  if ( !entityExist(name())) {
7133  parameterEntities.insert(name(), string());
7134  if (declHnd) {
7135  if (!declHnd->internalEntityDecl(QLatin1Char('%') + name(), string())) {
7137  return false;
7138  }
7139  }
7140  }
7141  state = PEValR;
7142  break;
7143  case PEEID:
7144  if ( !entityExist(name())) {
7146  if (declHnd) {
7149  return false;
7150  }
7151  }
7152  }
7153  state = PEEIDR;
7154  break;
7155  case EDDone:
7156  if ( !entityExist(name())) {
7158  if (declHnd) {
7161  return false;
7162  }
7163  }
7164  }
7165  return true;
7166  case Done:
7167  return true;
7168  case -1:
7169  // Error
7171  return false;
7172  }
7173 
7174  if (atEnd()) {
7176  return false;
7177  }
7178  if (is_S(c)) {
7179  input = InpWs;
7180  } else if (c == QLatin1Char('%')) {
7181  input = InpPer;
7182  } else if (c == QLatin1Char('"') || c == QLatin1Char('\'')) {
7183  input = InpQuot;
7184  } else if (c == QLatin1Char('>')) {
7185  input = InpGt;
7186  } else if (c == QLatin1Char('N')) {
7187  input = InpN;
7188  } else {
7189  input = InpUnknown;
7190  }
7191  state = table[state][input];
7192 
7193  switch (state) {
7194  case Ent:
7195  parseString_s = QLatin1String("NTITY");
7196  if (!parseString()) {
7198  return false;
7199  }
7200  break;
7201  case Ws1:
7202  if (!eat_ws()) {
7204  return false;
7205  }
7206  break;
7207  case Name:
7208  parseName_useRef = false;
7209  if (!parseName()) {
7211  return false;
7212  }
7213  break;
7214  case Ws2:
7215  if (!eat_ws()) {
7217  return false;
7218  }
7219  break;
7220  case EValue:
7221  case EValueR:
7222  if (!parseEntityValue()) {
7224  return false;
7225  }
7226  break;
7227  case ExtID:
7229  if (!parseExternalID()) {
7231  return false;
7232  }
7233  break;
7234  case Ws3:
7235  if (!eat_ws()) {
7237  return false;
7238  }
7239  break;
7240  case Ndata:
7241  parseString_s = QLatin1String("NDATA");
7242  if (!parseString()) {
7244  return false;
7245  }
7246  break;
7247  case Ws4:
7248  if (!eat_ws()) {
7250  return false;
7251  }
7252  break;
7253  case NNam:
7254  case NNamR:
7255  parseName_useRef = true;
7256  if (!parseName()) {
7258  return false;
7259  }
7260  break;
7261  case PEDec:
7262  next();
7263  break;
7264  case Ws6:
7265  if (!eat_ws()) {
7267  return false;
7268  }
7269  break;
7270  case PENam:
7271  parseName_useRef = false;
7272  if (!parseName()) {
7274  return false;
7275  }
7276  break;
7277  case Ws7:
7278  if (!eat_ws()) {
7280  return false;
7281  }
7282  break;
7283  case PEVal:
7284  case PEValR:
7285  if (!parseEntityValue()) {
7287  return false;
7288  }
7289  break;
7290  case PEEID:
7291  case PEEIDR:
7293  if (!parseExternalID()) {
7295  return false;
7296  }
7297  break;
7298  case WsE:
7299  if (!eat_ws()) {
7301  return false;
7302  }
7303  break;
7304  case EDDone:
7305  next();
7306  break;
7307  case Done:
7308  next();
7309  break;
7310  }
7311  }
7312  return false;
7313 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
QMap< QString, QString > entities
Definition: qxml.cpp:313
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool parseExternalID_allowPublicID
Definition: qxml.cpp:377
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:73
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
virtual bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString &notationName)=0
The reader calls this function when it finds an unparsed entity declaration.
bool entityExist(const QString &) const
Definition: qxml.cpp:8405
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
QMap< QString, ExternParameterEntity > externParameterEntities
Definition: qxml.cpp:310
QXmlDeclHandler * declHnd
Definition: qxml.cpp:406
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
bool isExpandedEntityValueTooLarge(QString *errorMessage)
Definition: qxml.cpp:6945
QMap< QString, QString > parameterEntities
Definition: qxml.cpp:311
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
const QString & name()
Definition: qxml.cpp:8495
signed char Done
Definition: qxml.cpp:397
QXmlDTDHandler * dtdHnd
Definition: qxml.cpp:403
const QString & ref()
Definition: qxml.cpp:8500
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
virtual bool internalEntityDecl(const QString &name, const QString &value)=0
The reader calls this function to report an internal entity declaration.
QMap< QString, ExternEntity > externEntities
Definition: qxml.cpp:312
virtual bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId)=0
The reader calls this function to report a parsed external entity declaration.

◆ parseEntityValue()

bool QXmlSimpleReaderPrivate::parseEntityValue ( )
private

Definition at line 7318 of file qxml.cpp.

7319 {
7320  const signed char Init = 0;
7321  const signed char Dq = 1; // EntityValue is double quoted
7322  const signed char DqC = 2; // signed character
7323  const signed char DqPER = 3; // PERefence
7324  const signed char DqRef = 4; // Reference
7325  const signed char Sq = 5; // EntityValue is double quoted
7326  const signed char SqC = 6; // signed character
7327  const signed char SqPER = 7; // PERefence
7328  const signed char SqRef = 8; // Reference
7329  const signed char Done = 9;
7330 
7331  const signed char InpDq = 0; // "
7332  const signed char InpSq = 1; // '
7333  const signed char InpAmp = 2; // &
7334  const signed char InpPer = 3; // %
7335  const signed char InpUnknown = 4;
7336 
7337  static const signed char table[9][5] = {
7338  /* InpDq InpSq InpAmp InpPer InpUnknown */
7339  { Dq, Sq, -1, -1, -1 }, // Init
7340  { Done, DqC, DqRef, DqPER, DqC }, // Dq
7341  { Done, DqC, DqRef, DqPER, DqC }, // DqC
7342  { Done, DqC, DqRef, DqPER, DqC }, // DqPER
7343  { Done, DqC, DqRef, DqPER, DqC }, // DqRef
7344  { SqC, Done, SqRef, SqPER, SqC }, // Sq
7345  { SqC, Done, SqRef, SqPER, SqC }, // SqC
7346  { SqC, Done, SqRef, SqPER, SqC }, // SqPER
7347  { SqC, Done, SqRef, SqPER, SqC } // SqRef
7348  };
7349  signed char state;
7350  signed char input;
7351 
7352  if (parseStack==0 || parseStack->isEmpty()) {
7353  state = Init;
7354  } else {
7355  state = parseStack->pop().state;
7356 #if defined(QT_QXML_DEBUG)
7357  qDebug("QXmlSimpleReader: parseEntityValue (cont) in state %d", state);
7358 #endif
7359  if (!parseStack->isEmpty()) {
7360  ParseFunction function = parseStack->top().function;
7361  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
7362  parseStack->pop();
7363 #if defined(QT_QXML_DEBUG)
7364  qDebug("QXmlSimpleReader: eat_ws (cont)");
7365 #endif
7366  }
7367  if (!(this->*function)()) {
7369  return false;
7370  }
7371  }
7372  }
7373 
7374  for (;;) {
7375  switch (state) {
7376  case Done:
7377  return true;
7378  case -1:
7379  // Error
7381  return false;
7382  }
7383 
7384  if (atEnd()) {
7386  return false;
7387  }
7388  if (c == QLatin1Char('"')) {
7389  input = InpDq;
7390  } else if (c == QLatin1Char('\'')) {
7391  input = InpSq;
7392  } else if (c == QLatin1Char('&')) {
7393  input = InpAmp;
7394  } else if (c == QLatin1Char('%')) {
7395  input = InpPer;
7396  } else {
7397  input = InpUnknown;
7398  }
7399  state = table[state][input];
7400 
7401  switch (state) {
7402  case Dq:
7403  case Sq:
7404  stringClear();
7405  next();
7406  break;
7407  case DqC:
7408  case SqC:
7409  stringAddC();
7410  next();
7411  break;
7412  case DqPER:
7413  case SqPER:
7415  if (!parsePEReference()) {
7417  return false;
7418  }
7419  break;
7420  case DqRef:
7421  case SqRef:
7423  if (!parseReference()) {
7425  return false;
7426  }
7427  break;
7428  case Done:
7429  next();
7430  break;
7431  }
7432  }
7433  return false;
7434 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:73
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
EntityRecognitionContext parseReference_context
Definition: qxml.cpp:376
EntityRecognitionContext parsePEReference_context
Definition: qxml.cpp:378
signed char Done
Definition: qxml.cpp:397
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseExternalID()

bool QXmlSimpleReaderPrivate::parseExternalID ( )
private

Definition at line 5373 of file qxml.cpp.

5374 {
5375  const signed char Init = 0;
5376  const signed char Sys = 1; // parse 'SYSTEM'
5377  const signed char SysWS = 2; // parse the whitespace after 'SYSTEM'
5378  const signed char SysSQ = 3; // parse SystemLiteral with '
5379  const signed char SysSQ2 = 4; // parse SystemLiteral with '
5380  const signed char SysDQ = 5; // parse SystemLiteral with "
5381  const signed char SysDQ2 = 6; // parse SystemLiteral with "
5382  const signed char Pub = 7; // parse 'PUBLIC'
5383  const signed char PubWS = 8; // parse the whitespace after 'PUBLIC'
5384  const signed char PubSQ = 9; // parse PubidLiteral with '
5385  const signed char PubSQ2 = 10; // parse PubidLiteral with '
5386  const signed char PubDQ = 11; // parse PubidLiteral with "
5387  const signed char PubDQ2 = 12; // parse PubidLiteral with "
5388  const signed char PubE = 13; // finished parsing the PubidLiteral
5389  const signed char PubWS2 = 14; // parse the whitespace after the PubidLiteral
5390  const signed char PDone = 15; // done if allowPublicID is true
5391  const signed char Done = 16;
5392 
5393  const signed char InpSQ = 0; // '
5394  const signed char InpDQ = 1; // "
5395  const signed char InpS = 2; // S
5396  const signed char InpP = 3; // P
5397  const signed char InpWs = 4; // white space
5398  const signed char InpUnknown = 5;
5399 
5400  static const signed char table[15][6] = {
5401  /* InpSQ InpDQ InpS InpP InpWs InpUnknown */
5402  { -1, -1, Sys, Pub, -1, -1 }, // Init
5403  { -1, -1, -1, -1, SysWS, -1 }, // Sys
5404  { SysSQ, SysDQ, -1, -1, -1, -1 }, // SysWS
5405  { Done, SysSQ2, SysSQ2, SysSQ2, SysSQ2, SysSQ2 }, // SysSQ
5406  { Done, SysSQ2, SysSQ2, SysSQ2, SysSQ2, SysSQ2 }, // SysSQ2
5407  { SysDQ2, Done, SysDQ2, SysDQ2, SysDQ2, SysDQ2 }, // SysDQ
5408  { SysDQ2, Done, SysDQ2, SysDQ2, SysDQ2, SysDQ2 }, // SysDQ2
5409  { -1, -1, -1, -1, PubWS, -1 }, // Pub
5410  { PubSQ, PubDQ, -1, -1, -1, -1 }, // PubWS
5411  { PubE, -1, PubSQ2, PubSQ2, PubSQ2, PubSQ2 }, // PubSQ
5412  { PubE, -1, PubSQ2, PubSQ2, PubSQ2, PubSQ2 }, // PubSQ2
5413  { -1, PubE, PubDQ2, PubDQ2, PubDQ2, PubDQ2 }, // PubDQ
5414  { -1, PubE, PubDQ2, PubDQ2, PubDQ2, PubDQ2 }, // PubDQ2
5415  { PDone, PDone, PDone, PDone, PubWS2, PDone }, // PubE
5416  { SysSQ, SysDQ, PDone, PDone, PDone, PDone } // PubWS2
5417  };
5418  signed char state;
5419  signed char input;
5420 
5421  if (parseStack==0 || parseStack->isEmpty()) {
5422  systemId.clear();
5423  publicId.clear();
5424  state = Init;
5425  } else {
5426  state = parseStack->pop().state;
5427 #if defined(QT_QXML_DEBUG)
5428  qDebug("QXmlSimpleReader: parseExternalID (cont) in state %d", state);
5429 #endif
5430  if (!parseStack->isEmpty()) {
5431  ParseFunction function = parseStack->top().function;
5432  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
5433  parseStack->pop();
5434 #if defined(QT_QXML_DEBUG)
5435  qDebug("QXmlSimpleReader: eat_ws (cont)");
5436 #endif
5437  }
5438  if (!(this->*function)()) {
5440  return false;
5441  }
5442  }
5443  }
5444 
5445  for (;;) {
5446  switch (state) {
5447  case PDone:
5449  publicId = string();
5450  return true;
5451  } else {
5453  return false;
5454  }
5455  case Done:
5456  return true;
5457  case -1:
5458  // Error
5460  return false;
5461  }
5462 
5463  if (atEnd()) {
5465  return false;
5466  }
5467  if (is_S(c)) {
5468  input = InpWs;
5469  } else if (c == QLatin1Char('\'')) {
5470  input = InpSQ;
5471  } else if (c == QLatin1Char('"')) {
5472  input = InpDQ;
5473  } else if (c == QLatin1Char('S')) {
5474  input = InpS;
5475  } else if (c == QLatin1Char('P')) {
5476  input = InpP;
5477  } else {
5478  input = InpUnknown;
5479  }
5480  state = table[state][input];
5481 
5482  switch (state) {
5483  case Sys:
5484  parseString_s = QLatin1String("SYSTEM");
5485  if (!parseString()) {
5487  return false;
5488  }
5489  break;
5490  case SysWS:
5491  if (!eat_ws()) {
5493  return false;
5494  }
5495  break;
5496  case SysSQ:
5497  case SysDQ:
5498  stringClear();
5499  next();
5500  break;
5501  case SysSQ2:
5502  case SysDQ2:
5503  stringAddC();
5504  next();
5505  break;
5506  case Pub:
5507  parseString_s = QLatin1String("PUBLIC");
5508  if (!parseString()) {
5510  return false;
5511  }
5512  break;
5513  case PubWS:
5514  if (!eat_ws()) {
5516  return false;
5517  }
5518  break;
5519  case PubSQ:
5520  case PubDQ:
5521  stringClear();
5522  next();
5523  break;
5524  case PubSQ2:
5525  case PubDQ2:
5526  stringAddC();
5527  next();
5528  break;
5529  case PubE:
5530  next();
5531  break;
5532  case PubWS2:
5533  publicId = string();
5534  if (!eat_ws()) {
5536  return false;
5537  }
5538  break;
5539  case Done:
5540  systemId = string();
5541  next();
5542  break;
5543  }
5544  }
5545  return false;
5546 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:66
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool parseExternalID_allowPublicID
Definition: qxml.cpp:377
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
signed char Done
Definition: qxml.cpp:397
const QString & string()
Definition: qxml.cpp:8490
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseFailed()

void QXmlSimpleReaderPrivate::parseFailed ( ParseFunction  where,
int  state 
)
private

Definition at line 8459 of file qxml.cpp.

8460 {
8461  if (parseStack!=0 && error.isNull()) {
8462  pushParseState(where, state);
8463  }
8464 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
void pushParseState(ParseFunction function, int state)
Definition: qxml.cpp:8473
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505

◆ parseMarkupdecl()

bool QXmlSimpleReaderPrivate::parseMarkupdecl ( )
private

Definition at line 5551 of file qxml.cpp.

5552 {
5553  const signed char Init = 0;
5554  const signed char Lt = 1; // < was read
5555  const signed char Em = 2; // ! was read
5556  const signed char CE = 3; // E was read
5557  const signed char Qm = 4; // ? was read
5558  const signed char Dash = 5; // - was read
5559  const signed char CA = 6; // A was read
5560  const signed char CEL = 7; // EL was read
5561  const signed char CEN = 8; // EN was read
5562  const signed char CN = 9; // N was read
5563  const signed char Done = 10;
5564 
5565  const signed char InpLt = 0; // <
5566  const signed char InpQm = 1; // ?
5567  const signed char InpEm = 2; // !
5568  const signed char InpDash = 3; // -
5569  const signed char InpA = 4; // A
5570  const signed char InpE = 5; // E
5571  const signed char InpL = 6; // L
5572  const signed char InpN = 7; // N
5573  const signed char InpUnknown = 8;
5574 
5575  static const signed char table[4][9] = {
5576  /* InpLt InpQm InpEm InpDash InpA InpE InpL InpN InpUnknown */
5577  { Lt, -1, -1, -1, -1, -1, -1, -1, -1 }, // Init
5578  { -1, Qm, Em, -1, -1, -1, -1, -1, -1 }, // Lt
5579  { -1, -1, -1, Dash, CA, CE, -1, CN, -1 }, // Em
5580  { -1, -1, -1, -1, -1, -1, CEL, CEN, -1 } // CE
5581  };
5582  signed char state;
5583  signed char input;
5584 
5585  if (parseStack==0 || parseStack->isEmpty()) {
5586  state = Init;
5587  } else {
5588  state = parseStack->pop().state;
5589 #if defined(QT_QXML_DEBUG)
5590  qDebug("QXmlSimpleReader: parseMarkupdecl (cont) in state %d", state);
5591 #endif
5592  if (!parseStack->isEmpty()) {
5593  ParseFunction function = parseStack->top().function;
5594  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
5595  parseStack->pop();
5596 #if defined(QT_QXML_DEBUG)
5597  qDebug("QXmlSimpleReader: eat_ws (cont)");
5598 #endif
5599  }
5600  if (!(this->*function)()) {
5602  return false;
5603  }
5604  }
5605  }
5606 
5607  for (;;) {
5608  switch (state) {
5609  case Qm:
5610  if (contentHnd) {
5611  if (!contentHnd->processingInstruction(name(),string())) {
5613  return false;
5614  }
5615  }
5616  return true;
5617  case Dash:
5618  if (lexicalHnd) {
5619  if (!lexicalHnd->comment(string())) {
5621  return false;
5622  }
5623  }
5624  return true;
5625  case CA:
5626  return true;
5627  case CEL:
5628  return true;
5629  case CEN:
5630  return true;
5631  case CN:
5632  return true;
5633  case Done:
5634  return true;
5635  case -1:
5636  // Error
5638  return false;
5639  }
5640 
5641  if (atEnd()) {
5643  return false;
5644  }
5645  if (c == QLatin1Char('<')) {
5646  input = InpLt;
5647  } else if (c == QLatin1Char('?')) {
5648  input = InpQm;
5649  } else if (c == QLatin1Char('!')) {
5650  input = InpEm;
5651  } else if (c == QLatin1Char('-')) {
5652  input = InpDash;
5653  } else if (c == QLatin1Char('A')) {
5654  input = InpA;
5655  } else if (c == QLatin1Char('E')) {
5656  input = InpE;
5657  } else if (c == QLatin1Char('L')) {
5658  input = InpL;
5659  } else if (c == QLatin1Char('N')) {
5660  input = InpN;
5661  } else {
5662  input = InpUnknown;
5663  }
5664  state = table[state][input];
5665 
5666  switch (state) {
5667  case Lt:
5668  next();
5669  break;
5670  case Em:
5671  next();
5672  break;
5673  case CE:
5674  next();
5675  break;
5676  case Qm:
5677  parsePI_xmldecl = false;
5678  if (!parsePI()) {
5680  return false;
5681  }
5682  break;
5683  case Dash:
5684  if (!parseComment()) {
5686  return false;
5687  }
5688  break;
5689  case CA:
5690  if (!parseAttlistDecl()) {
5692  return false;
5693  }
5694  break;
5695  case CEL:
5696  if (!parseElementDecl()) {
5698  return false;
5699  }
5700  break;
5701  case CEN:
5702  if (!parseEntityDecl()) {
5704  return false;
5705  }
5706  break;
5707  case CN:
5708  if (!parseNotationDecl()) {
5710  return false;
5711  }
5712  break;
5713  }
5714  }
5715  return false;
5716 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QXmlLexicalHandler * lexicalHnd
Definition: qxml.cpp:405
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:73
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
virtual bool comment(const QString &ch)=0
The reader calls this function to report an XML comment anywhere in the document. ...
virtual bool processingInstruction(const QString &target, const QString &data)=0
The reader calls this function when it has parsed a processing instruction.
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
const QString & name()
Definition: qxml.cpp:8495
signed char Done
Definition: qxml.cpp:397
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401

◆ parseMisc()

bool QXmlSimpleReaderPrivate::parseMisc ( )
private

Definition at line 4804 of file qxml.cpp.

4805 {
4806  const signed char Init = 0;
4807  const signed char Lt = 1; // '<' was read
4808  const signed char Comment = 2; // read comment
4809  const signed char eatWS = 3; // eat whitespaces
4810  const signed char PInstr = 4; // read PI
4811  const signed char Comment2 = 5; // read comment
4812 
4813  const signed char InpWs = 0; // S
4814  const signed char InpLt = 1; // <
4815  const signed char InpQm = 2; // ?
4816  const signed char InpEm = 3; // !
4817  const signed char InpUnknown = 4;
4818 
4819  static const signed char table[3][5] = {
4820  /* InpWs InpLt InpQm InpEm InpUnknown */
4821  { eatWS, Lt, -1, -1, -1 }, // Init
4822  { -1, -1, PInstr,Comment, -1 }, // Lt
4823  { -1, -1, -1, -1, Comment2 } // Comment
4824  };
4825  signed char state;
4826  signed char input;
4827 
4828  if (parseStack==0 || parseStack->isEmpty()) {
4829  state = Init;
4830  } else {
4831  state = parseStack->pop().state;
4832 #if defined(QT_QXML_DEBUG)
4833  qDebug("QXmlSimpleReader: parseMisc (cont) in state %d", state);
4834 #endif
4835  if (!parseStack->isEmpty()) {
4836  ParseFunction function = parseStack->top().function;
4837  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
4838  parseStack->pop();
4839 #if defined(QT_QXML_DEBUG)
4840  qDebug("QXmlSimpleReader: eat_ws (cont)");
4841 #endif
4842  }
4843  if (!(this->*function)()) {
4845  return false;
4846  }
4847  }
4848  }
4849 
4850  for (;;) {
4851  switch (state) {
4852  case eatWS:
4853  return true;
4854  case PInstr:
4855  if (contentHnd) {
4856  if (!contentHnd->processingInstruction(name(),string())) {
4858  return false;
4859  }
4860  }
4861  return true;
4862  case Comment2:
4863  if (lexicalHnd) {
4864  if (!lexicalHnd->comment(string())) {
4866  return false;
4867  }
4868  }
4869  return true;
4870  case -1:
4871  // Error
4873  return false;
4874  }
4875 
4876  if (atEnd()) {
4878  return false;
4879  }
4880  if (is_S(c)) {
4881  input = InpWs;
4882  } else if (c == QLatin1Char('<')) {
4883  input = InpLt;
4884  } else if (c == QLatin1Char('?')) {
4885  input = InpQm;
4886  } else if (c == QLatin1Char('!')) {
4887  input = InpEm;
4888  } else {
4889  input = InpUnknown;
4890  }
4891  state = table[state][input];
4892 
4893  switch (state) {
4894  case eatWS:
4895  if (!eat_ws()) {
4897  return false;
4898  }
4899  break;
4900  case Lt:
4901  next();
4902  break;
4903  case PInstr:
4904  parsePI_xmldecl = false;
4905  if (!parsePI()) {
4907  return false;
4908  }
4909  break;
4910  case Comment:
4911  next();
4912  break;
4913  case Comment2:
4914  if (!parseComment()) {
4916  return false;
4917  }
4918  break;
4919  }
4920  }
4921  return false;
4922 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:66
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QXmlLexicalHandler * lexicalHnd
Definition: qxml.cpp:405
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
virtual bool comment(const QString &ch)=0
The reader calls this function to report an XML comment anywhere in the document. ...
virtual bool processingInstruction(const QString &target, const QString &data)=0
The reader calls this function when it has parsed a processing instruction.
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
const QString & name()
Definition: qxml.cpp:8495
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401

◆ parseName()

bool QXmlSimpleReaderPrivate::parseName ( )
private

Definition at line 7667 of file qxml.cpp.

7668 {
7669  const int Init = 0;
7670  const int Name1 = 1; // parse first character of the name
7671  const int Name = 2; // parse name
7672  const int Done = 3;
7673 
7674  static const int table[3][3] = {
7675  /* InpNameBe InpNameCh InpUnknown */
7676  { Name1, -1, -1 }, // Init
7677  { Name, Name, Done }, // Name1
7678  { Name, Name, Done } // Name
7679  };
7680  int state;
7681 
7682  if (parseStack==0 || parseStack->isEmpty()) {
7683  state = Init;
7684  } else {
7685  state = parseStack->pop().state;
7686 #if defined(QT_QXML_DEBUG)
7687  qDebug("QXmlSimpleReader: parseName (cont) in state %d", state);
7688 #endif
7689  if (!parseStack->isEmpty()) {
7690  ParseFunction function = parseStack->top().function;
7691  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
7692  parseStack->pop();
7693 #if defined(QT_QXML_DEBUG)
7694  qDebug("QXmlSimpleReader: eat_ws (cont)");
7695 #endif
7696  }
7697  if (!(this->*function)()) {
7699  return false;
7700  }
7701  }
7702  }
7703 
7704  for (;;) {
7705  switch (state) {
7706  case Done:
7707  return true;
7708  case -1:
7709  // Error
7711  return false;
7712  }
7713 
7714  if (atEnd()) {
7716  return false;
7717  }
7718 
7719  // we can safely do the (int) cast thanks to the Q_ASSERTs earlier in this function
7720  state = table[state][(int)fastDetermineNameChar(c)];
7721 
7722  switch (state) {
7723  case Name1:
7724  if (parseName_useRef) {
7725  refClear();
7726  refAddC();
7727  } else {
7728  nameClear();
7729  nameAddC();
7730  }
7731  next();
7732  break;
7733  case Name:
7734  if (parseName_useRef) {
7735  refAddC();
7736  } else {
7737  nameAddC();
7738  }
7739  next();
7740  break;
7741  }
7742  }
7743  return false;
7744 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:73
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
signed char Done
Definition: qxml.cpp:397
static NameChar fastDetermineNameChar(QChar ch)
Definition: qxml.cpp:3420

◆ parseNmtoken()

bool QXmlSimpleReaderPrivate::parseNmtoken ( )
private

Definition at line 7749 of file qxml.cpp.

7750 {
7751  const signed char Init = 0;
7752  const signed char NameF = 1;
7753  const signed char Name = 2;
7754  const signed char Done = 3;
7755 
7756  const signed char InpNameCh = 0; // NameChar without InpNameBe
7757  const signed char InpUnknown = 1;
7758 
7759  static const signed char table[3][2] = {
7760  /* InpNameCh InpUnknown */
7761  { NameF, -1 }, // Init
7762  { Name, Done }, // NameF
7763  { Name, Done } // Name
7764  };
7765  signed char state;
7766  signed char input;
7767 
7768  if (parseStack==0 || parseStack->isEmpty()) {
7769  state = Init;
7770  } else {
7771  state = parseStack->pop().state;
7772 #if defined(QT_QXML_DEBUG)
7773  qDebug("QXmlSimpleReader: parseNmtoken (cont) in state %d", state);
7774 #endif
7775  if (!parseStack->isEmpty()) {
7776  ParseFunction function = parseStack->top().function;
7777  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
7778  parseStack->pop();
7779 #if defined(QT_QXML_DEBUG)
7780  qDebug("QXmlSimpleReader: eat_ws (cont)");
7781 #endif
7782  }
7783  if (!(this->*function)()) {
7785  return false;
7786  }
7787  }
7788  }
7789 
7790  for (;;) {
7791  switch (state) {
7792  case Done:
7793  return true;
7794  case -1:
7795  // Error
7797  return false;
7798  }
7799 
7800  if (atEnd()) {
7802  return false;
7803  }
7804  if (determineNameChar(c) == NotName) {
7805  input = InpUnknown;
7806  } else {
7807  input = InpNameCh;
7808  }
7809  state = table[state][input];
7810 
7811  switch (state) {
7812  case NameF:
7813  nameClear();
7814  nameAddC();
7815  next();
7816  break;
7817  case Name:
7818  nameAddC();
7819  next();
7820  break;
7821  }
7822  }
7823  return false;
7824 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
static NameChar determineNameChar(QChar ch)
Definition: qxml.cpp:3437
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:73
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
signed char Done
Definition: qxml.cpp:397

◆ parseNotationDecl()

bool QXmlSimpleReaderPrivate::parseNotationDecl ( )
private

Definition at line 6673 of file qxml.cpp.

6674 {
6675  const signed char Init = 0;
6676  const signed char Not = 1; // read NOTATION
6677  const signed char Ws1 = 2; // eat whitespaces
6678  const signed char Nam = 3; // read Name
6679  const signed char Ws2 = 4; // eat whitespaces
6680  const signed char ExtID = 5; // parse ExternalID
6681  const signed char ExtIDR = 6; // same as ExtID, but already reported
6682  const signed char Ws3 = 7; // eat whitespaces
6683  const signed char Done = 8;
6684 
6685  const signed char InpWs = 0;
6686  const signed char InpGt = 1; // >
6687  const signed char InpN = 2; // N
6688  const signed char InpUnknown = 3;
6689 
6690  static const signed char table[8][4] = {
6691  /* InpWs InpGt InpN InpUnknown */
6692  { -1, -1, Not, -1 }, // Init
6693  { Ws1, -1, -1, -1 }, // Not
6694  { -1, -1, Nam, Nam }, // Ws1
6695  { Ws2, Done, -1, -1 }, // Nam
6696  { -1, Done, ExtID, ExtID }, // Ws2
6697  { Ws3, Done, -1, -1 }, // ExtID
6698  { Ws3, Done, -1, -1 }, // ExtIDR
6699  { -1, Done, -1, -1 } // Ws3
6700  };
6701  signed char state;
6702  signed char input;
6703 
6704  if (parseStack==0 || parseStack->isEmpty()) {
6705  state = Init;
6706  } else {
6707  state = parseStack->pop().state;
6708 #if defined(QT_QXML_DEBUG)
6709  qDebug("QXmlSimpleReader: parseNotationDecl (cont) in state %d", state);
6710 #endif
6711  if (!parseStack->isEmpty()) {
6712  ParseFunction function = parseStack->top().function;
6713  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
6714  parseStack->pop();
6715 #if defined(QT_QXML_DEBUG)
6716  qDebug("QXmlSimpleReader: eat_ws (cont)");
6717 #endif
6718  }
6719  if (!(this->*function)()) {
6721  return false;
6722  }
6723  }
6724  }
6725 
6726  for (;;) {
6727  switch (state) {
6728  case ExtID:
6729  // call the handler
6730  if (dtdHnd) {
6731  if (!dtdHnd->notationDecl(name(), publicId, systemId)) {
6733  return false;
6734  }
6735  }
6736  state = ExtIDR;
6737  break;
6738  case Done:
6739  return true;
6740  case -1:
6741  // Error
6743  return false;
6744  }
6745 
6746  if (atEnd()) {
6748  return false;
6749  }
6750  if (is_S(c)) {
6751  input = InpWs;
6752  } else if (c == QLatin1Char('>')) {
6753  input = InpGt;
6754  } else if (c == QLatin1Char('N')) {
6755  input = InpN;
6756  } else {
6757  input = InpUnknown;
6758  }
6759  state = table[state][input];
6760 
6761  switch (state) {
6762  case Not:
6763  parseString_s = QLatin1String("NOTATION");
6764  if (!parseString()) {
6766  return false;
6767  }
6768  break;
6769  case Ws1:
6770  if (!eat_ws()) {
6772  return false;
6773  }
6774  break;
6775  case Nam:
6776  parseName_useRef = false;
6777  if (!parseName()) {
6779  return false;
6780  }
6781  break;
6782  case Ws2:
6783  if (!eat_ws()) {
6785  return false;
6786  }
6787  break;
6788  case ExtID:
6789  case ExtIDR:
6791  if (!parseExternalID()) {
6793  return false;
6794  }
6795  break;
6796  case Ws3:
6797  if (!eat_ws()) {
6799  return false;
6800  }
6801  break;
6802  case Done:
6803  next();
6804  break;
6805  }
6806  }
6807  return false;
6808 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:66
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool parseExternalID_allowPublicID
Definition: qxml.cpp:377
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
virtual bool notationDecl(const QString &name, const QString &publicId, const QString &systemId)=0
The reader calls this function when it has parsed a notation declaration.
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
const QString & name()
Definition: qxml.cpp:8495
signed char Done
Definition: qxml.cpp:397
QXmlDTDHandler * dtdHnd
Definition: qxml.cpp:403
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parsePEReference()

bool QXmlSimpleReaderPrivate::parsePEReference ( )
private

Definition at line 5721 of file qxml.cpp.

5722 {
5723  const signed char Init = 0;
5724  const signed char Next = 1;
5725  const signed char Name = 2;
5726  const signed char NameR = 3; // same as Name, but already reported
5727  const signed char Done = 4;
5728 
5729  const signed char InpSemi = 0; // ;
5730  const signed char InpPer = 1; // %
5731  const signed char InpUnknown = 2;
5732 
5733  static const signed char table[4][3] = {
5734  /* InpSemi InpPer InpUnknown */
5735  { -1, Next, -1 }, // Init
5736  { -1, -1, Name }, // Next
5737  { Done, -1, -1 }, // Name
5738  { Done, -1, -1 } // NameR
5739  };
5740  signed char state;
5741  signed char input;
5742 
5743  if (parseStack==0 || parseStack->isEmpty()) {
5744  state = Init;
5745  } else {
5746  state = parseStack->pop().state;
5747 #if defined(QT_QXML_DEBUG)
5748  qDebug("QXmlSimpleReader: parsePEReference (cont) in state %d", state);
5749 #endif
5750  if (!parseStack->isEmpty()) {
5751  ParseFunction function = parseStack->top().function;
5752  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
5753  parseStack->pop();
5754 #if defined(QT_QXML_DEBUG)
5755  qDebug("QXmlSimpleReader: eat_ws (cont)");
5756 #endif
5757  }
5758  if (!(this->*function)()) {
5760  return false;
5761  }
5762  }
5763  }
5764 
5765  for (;;) {
5766  switch (state) {
5767  case Name:
5768  {
5769  bool skipIt = true;
5770  QString xmlRefString;
5771 
5773  it = parameterEntities.find(ref());
5774  if (it != parameterEntities.end()) {
5775  skipIt = false;
5776  xmlRefString = *it;
5777  } else if (entityRes) {
5779  it2 = externParameterEntities.find(ref());
5780  QXmlInputSource *ret = 0;
5781  if (it2 != externParameterEntities.end()) {
5782  if (!entityRes->resolveEntity((*it2).publicId, (*it2).systemId, ret)) {
5783  delete ret;
5785  return false;
5786  }
5787  if (ret) {
5788  xmlRefString = ret->data();
5789  delete ret;
5790  if (!stripTextDecl(xmlRefString)) {
5792  return false;
5793  }
5794  skipIt = false;
5795  }
5796  }
5797  }
5798 
5799  if (skipIt) {
5800  if (contentHnd) {
5801  if (!contentHnd->skippedEntity(QLatin1Char('%') + ref())) {
5803  return false;
5804  }
5805  }
5806  } else {
5808  // Included in literal
5809  if (!insertXmlRef(xmlRefString, ref(), true))
5810  return false;
5811  } else if (parsePEReference_context == InDTD) {
5812  // Included as PE
5813  if (!insertXmlRef(QLatin1Char(' ') + xmlRefString + QLatin1Char(' '), ref(), false))
5814  return false;
5815  }
5816  }
5817  }
5818  state = NameR;
5819  break;
5820  case Done:
5821  return true;
5822  case -1:
5823  // Error
5825  return false;
5826  }
5827 
5828  if (atEnd()) {
5830  return false;
5831  }
5832  if (c == QLatin1Char(';')) {
5833  input = InpSemi;
5834  } else if (c == QLatin1Char('%')) {
5835  input = InpPer;
5836  } else {
5837  input = InpUnknown;
5838  }
5839  state = table[state][input];
5840 
5841  switch (state) {
5842  case Next:
5843  next();
5844  break;
5845  case Name:
5846  case NameR:
5847  parseName_useRef = true;
5848  if (!parseName()) {
5850  return false;
5851  }
5852  break;
5853  case Done:
5854  next();
5855  break;
5856  }
5857  }
5858  return false;
5859 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
static bool stripTextDecl(QString &str)
Definition: qxml.cpp:189
virtual bool skippedEntity(const QString &name)=0
Some readers may skip entities if they have not seen the declarations (e.
#define it(className, varName)
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
iterator find(const Key &key)
Returns an iterator pointing to the item with key key in the map.
Definition: qmap.h:618
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool insertXmlRef(const QString &, const QString &, bool)
Definition: qxml.cpp:8273
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:73
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
#define XMLERR_ERRORINTEXTDECL
Definition: qxml.cpp:81
QMap< QString, ExternParameterEntity > externParameterEntities
Definition: qxml.cpp:310
virtual QString data() const
Returns the data the input source contains or an empty string if the input source does not contain an...
Definition: qxml.cpp:1491
QXmlEntityResolver * entityRes
Definition: qxml.cpp:404
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
QMap< QString, QString > parameterEntities
Definition: qxml.cpp:311
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
EntityRecognitionContext parsePEReference_context
Definition: qxml.cpp:378
signed char Done
Definition: qxml.cpp:397
const QString & ref()
Definition: qxml.cpp:8500
virtual bool resolveEntity(const QString &publicId, const QString &systemId, QXmlInputSource *&ret)=0
The reader calls this function before it opens any external entity, except the top-level document ent...
The QXmlInputSource class provides the input data for the QXmlReader subclasses.
Definition: qxml.h:158
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67

◆ parsePI()

bool QXmlSimpleReaderPrivate::parsePI ( )
private

Definition at line 4935 of file qxml.cpp.

4936 {
4937  const signed char Init = 0;
4938  const signed char QmI = 1; // ? was read
4939  const signed char Name = 2; // read Name
4940  const signed char XMLDecl = 3; // read XMLDecl
4941  const signed char Ws1 = 4; // eat ws after "xml" of XMLDecl
4942  const signed char PInstr = 5; // read PI
4943  const signed char Ws2 = 6; // eat ws after Name of PI
4944  const signed char Version = 7; // read versionInfo
4945  const signed char Ws3 = 8; // eat ws after versionInfo
4946  const signed char EorSD = 9; // read EDecl or SDDecl
4947  const signed char Ws4 = 10; // eat ws after EDecl or SDDecl
4948  const signed char SD = 11; // read SDDecl
4949  const signed char Ws5 = 12; // eat ws after SDDecl
4950  const signed char ADone = 13; // almost done
4951  const signed char Char = 14; // Char was read
4952  const signed char Qm = 15; // Qm was read
4953  const signed char Done = 16; // finished reading content
4954 
4955  const signed char InpWs = 0; // whitespace
4956  const signed char InpNameBe = 1; // NameBeginning
4957  const signed char InpGt = 2; // >
4958  const signed char InpQm = 3; // ?
4959  const signed char InpUnknown = 4;
4960 
4961  static const signed char table[16][5] = {
4962  /* InpWs, InpNameBe InpGt InpQm InpUnknown */
4963  { -1, -1, -1, QmI, -1 }, // Init
4964  { -1, Name, -1, -1, -1 }, // QmI
4965  { -1, -1, -1, -1, -1 }, // Name (this state is left not through input)
4966  { Ws1, -1, -1, -1, -1 }, // XMLDecl
4967  { -1, Version, -1, -1, -1 }, // Ws1
4968  { Ws2, -1, -1, Qm, -1 }, // PInstr
4969  { Char, Char, Char, Qm, Char }, // Ws2
4970  { Ws3, -1, -1, ADone, -1 }, // Version
4971  { -1, EorSD, -1, ADone, -1 }, // Ws3
4972  { Ws4, -1, -1, ADone, -1 }, // EorSD
4973  { -1, SD, -1, ADone, -1 }, // Ws4
4974  { Ws5, -1, -1, ADone, -1 }, // SD
4975  { -1, -1, -1, ADone, -1 }, // Ws5
4976  { -1, -1, Done, -1, -1 }, // ADone
4977  { Char, Char, Char, Qm, Char }, // Char
4978  { Char, Char, Done, Qm, Char }, // Qm
4979  };
4980  signed char state;
4981  signed char input;
4982 
4983  if (parseStack==0 || parseStack->isEmpty()) {
4984  state = Init;
4985  } else {
4986  state = parseStack->pop().state;
4987 #if defined(QT_QXML_DEBUG)
4988  qDebug("QXmlSimpleReader: parsePI (cont) in state %d", state);
4989 #endif
4990  if (!parseStack->isEmpty()) {
4991  ParseFunction function = parseStack->top().function;
4992  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
4993  parseStack->pop();
4994 #if defined(QT_QXML_DEBUG)
4995  qDebug("QXmlSimpleReader: eat_ws (cont)");
4996 #endif
4997  }
4998  if (!(this->*function)()) {
5000  return false;
5001  }
5002  }
5003  }
5004 
5005  for (;;) {
5006  switch (state) {
5007  case Name:
5008  // test what name was read and determine the next state
5009  // (not very beautiful, I admit)
5010  if (name().toLower() == QLatin1String("xml")) {
5011  if (parsePI_xmldecl && name() == QLatin1String("xml")) {
5012  state = XMLDecl;
5013  } else {
5015  return false;
5016  }
5017  } else {
5018  state = PInstr;
5019  stringClear();
5020  }
5021  break;
5022  case Version:
5023  // get version (syntax like an attribute)
5024  if (name() != QLatin1String("version")) {
5026  return false;
5027  }
5028  xmlVersion = string();
5029  break;
5030  case EorSD:
5031  // get the EDecl or SDDecl (syntax like an attribute)
5032  if (name() == QLatin1String("standalone")) {
5033  if (string()== QLatin1String("yes")) {
5035  } else if (string() == QLatin1String("no")) {
5037  } else {
5039  return false;
5040  }
5041  } else if (name() == QLatin1String("encoding")) {
5042  encoding = string();
5043  } else {
5045  return false;
5046  }
5047  break;
5048  case SD:
5049  if (name() != QLatin1String("standalone")) {
5051  return false;
5052  }
5053  if (string() == QLatin1String("yes")) {
5055  } else if (string() == QLatin1String("no")) {
5057  } else {
5059  return false;
5060  }
5061  break;
5062  case Qm:
5063  // test if the skipping was legal
5064  if (!atEnd() && c != QLatin1Char('>'))
5065  stringAddC(QLatin1Char('?'));
5066  break;
5067  case Done:
5068  return true;
5069  case -1:
5070  // Error
5072  return false;
5073  }
5074 
5075  if (atEnd()) {
5077  return false;
5078  }
5079  if (is_S(c)) {
5080  input = InpWs;
5081  } else if (determineNameChar(c) == NameBeginning) {
5082  input = InpNameBe;
5083  } else if (c == QLatin1Char('>')) {
5084  input = InpGt;
5085  } else if (c == QLatin1Char('?')) {
5086  input = InpQm;
5087  } else {
5088  input = InpUnknown;
5089  }
5090  state = table[state][input];
5091 
5092  switch (state) {
5093  case QmI:
5094  next();
5095  break;
5096  case Name:
5097  parseName_useRef = false;
5098  if (!parseName()) {
5100  return false;
5101  }
5102  break;
5103  case Ws1:
5104  case Ws2:
5105  case Ws3:
5106  case Ws4:
5107  case Ws5:
5108  if (!eat_ws()) {
5110  return false;
5111  }
5112  break;
5113  case Version:
5114  if (!parseAttribute()) {
5116  return false;
5117  }
5118  break;
5119  case EorSD:
5120  if (!parseAttribute()) {
5122  return false;
5123  }
5124  break;
5125  case SD:
5126  // get the SDDecl (syntax like an attribute)
5128  // already parsed the standalone declaration
5130  return false;
5131  }
5132  if (!parseAttribute()) {
5134  return false;
5135  }
5136  break;
5137  case ADone:
5138  next();
5139  break;
5140  case Char:
5141  stringAddC();
5142  next();
5143  break;
5144  case Qm:
5145  // skip the '?'
5146  next();
5147  break;
5148  case Done:
5149  next();
5150  break;
5151  }
5152  }
5153  return false;
5154 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
static NameChar determineNameChar(QChar ch)
Definition: qxml.cpp:3437
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:66
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define XMLERR_VERSIONEXPECTED
Definition: qxml.cpp:68
#define XMLERR_SDDECLEXPECTED
Definition: qxml.cpp:71
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
Standalone standalone
Definition: qxml.cpp:335
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
#define XMLERR_INVALIDNAMEFORPI
Definition: qxml.cpp:67
ushort Char
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
const QString & name()
Definition: qxml.cpp:8495
signed char Done
Definition: qxml.cpp:397
#define XMLERR_WRONGVALUEFORSDECL
Definition: qxml.cpp:69
const QString & string()
Definition: qxml.cpp:8490
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
#define XMLERR_EDECLORSDDECLEXPECTED
Definition: qxml.cpp:70

◆ parseProlog()

bool QXmlSimpleReaderPrivate::parseProlog ( )
private

Definition at line 3934 of file qxml.cpp.

3935 {
3936  const signed char Init = 0;
3937  const signed char EatWS = 1; // eat white spaces
3938  const signed char Lt = 2; // '<' read
3939  const signed char Em = 3; // '!' read
3940  const signed char DocType = 4; // read doctype
3941  const signed char Comment = 5; // read comment
3942  const signed char CommentR = 6; // same as Comment, but already reported
3943  const signed char PInstr = 7; // read PI
3944  const signed char PInstrR = 8; // same as PInstr, but already reported
3945  const signed char Done = 9;
3946 
3947  const signed char InpWs = 0;
3948  const signed char InpLt = 1; // <
3949  const signed char InpQm = 2; // ?
3950  const signed char InpEm = 3; // !
3951  const signed char InpD = 4; // D
3952  const signed char InpDash = 5; // -
3953  const signed char InpUnknown = 6;
3954 
3955  static const signed char table[9][7] = {
3956  /* InpWs InpLt InpQm InpEm InpD InpDash InpUnknown */
3957  { EatWS, Lt, -1, -1, -1, -1, -1 }, // Init
3958  { -1, Lt, -1, -1, -1, -1, -1 }, // EatWS
3959  { -1, -1, PInstr,Em, Done, -1, Done }, // Lt
3960  { -1, -1, -1, -1, DocType, Comment, -1 }, // Em
3961  { EatWS, Lt, -1, -1, -1, -1, -1 }, // DocType
3962  { EatWS, Lt, -1, -1, -1, -1, -1 }, // Comment
3963  { EatWS, Lt, -1, -1, -1, -1, -1 }, // CommentR
3964  { EatWS, Lt, -1, -1, -1, -1, -1 }, // PInstr
3965  { EatWS, Lt, -1, -1, -1, -1, -1 } // PInstrR
3966  };
3967  signed char state;
3968  signed char input;
3969 
3970  if (parseStack == 0 || parseStack->isEmpty()) {
3971  xmldecl_possible = true;
3972  doctype_read = false;
3973  state = Init;
3974  } else {
3975  state = parseStack->pop().state;
3976 #if defined(QT_QXML_DEBUG)
3977  qDebug("QXmlSimpleReader: parseProlog (cont) in state %d", state);
3978 #endif
3979  if (!parseStack->isEmpty()) {
3980  ParseFunction function = parseStack->top().function;
3981  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
3982  parseStack->pop();
3983 #if defined(QT_QXML_DEBUG)
3984  qDebug("QXmlSimpleReader: eat_ws (cont)");
3985 #endif
3986  }
3987  if (!(this->*function)()) {
3989  return false;
3990  }
3991  }
3992  }
3993 
3994  for (;;) {
3995  switch (state) {
3996  case DocType:
3997  if (doctype_read) {
3999  return false;
4000  } else {
4001  doctype_read = false;
4002  }
4003  break;
4004  case Comment:
4005  if (lexicalHnd) {
4006  if (!lexicalHnd->comment(string())) {
4008  return false;
4009  }
4010  }
4011  state = CommentR;
4012  break;
4013  case PInstr:
4014  // call the handler
4015  if (contentHnd) {
4016  if (xmldecl_possible && !xmlVersion.isEmpty()) {
4017  QString value(QLatin1String("version='"));
4018  value += xmlVersion;
4019  value += QLatin1Char('\'');
4020  if (!encoding.isEmpty()) {
4021  value += QLatin1String(" encoding='");
4022  value += encoding;
4023  value += QLatin1Char('\'');
4024  }
4026  value += QLatin1String(" standalone='yes'");
4027  } else if (standalone == QXmlSimpleReaderPrivate::No) {
4028  value += QLatin1String(" standalone='no'");
4029  }
4030  if (!contentHnd->processingInstruction(QLatin1String("xml"), value)) {
4032  return false;
4033  }
4034  } else {
4035  if (!contentHnd->processingInstruction(name(), string())) {
4037  return false;
4038  }
4039  }
4040  }
4041  // XML declaration only on first position possible
4042  xmldecl_possible = false;
4043  state = PInstrR;
4044  break;
4045  case Done:
4046  return true;
4047  case -1:
4049  return false;
4050  }
4051 
4052  if (atEnd()) {
4054  return false;
4055  }
4056  if (is_S(c)) {
4057  input = InpWs;
4058  } else if (c == QLatin1Char('<')) {
4059  input = InpLt;
4060  } else if (c == QLatin1Char('?')) {
4061  input = InpQm;
4062  } else if (c == QLatin1Char('!')) {
4063  input = InpEm;
4064  } else if (c == QLatin1Char('D')) {
4065  input = InpD;
4066  } else if (c == QLatin1Char('-')) {
4067  input = InpDash;
4068  } else {
4069  input = InpUnknown;
4070  }
4071  state = table[state][input];
4072 
4073  switch (state) {
4074  case EatWS:
4075  // XML declaration only on first position possible
4076  xmldecl_possible = false;
4077  if (!eat_ws()) {
4079  return false;
4080  }
4081  break;
4082  case Lt:
4083  next();
4084  break;
4085  case Em:
4086  // XML declaration only on first position possible
4087  xmldecl_possible = false;
4088  next();
4089  break;
4090  case DocType:
4091  if (!parseDoctype()) {
4093  return false;
4094  }
4095  break;
4096  case Comment:
4097  case CommentR:
4098  if (!parseComment()) {
4100  return false;
4101  }
4102  break;
4103  case PInstr:
4104  case PInstrR:
4106  if (!parsePI()) {
4108  return false;
4109  }
4110  break;
4111  }
4112  }
4113  return false;
4114 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define XMLERR_ERRORPARSINGELEMENT
Definition: qxml.cpp:63
QXmlLexicalHandler * lexicalHnd
Definition: qxml.cpp:405
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define XMLERR_MORETHANONEDOCTYPE
Definition: qxml.cpp:62
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
static bool is_S(QChar ch)
Definition: qxml.cpp:3380
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Standalone standalone
Definition: qxml.cpp:335
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
virtual bool comment(const QString &ch)=0
The reader calls this function to report an XML comment anywhere in the document. ...
virtual bool processingInstruction(const QString &target, const QString &data)=0
The reader calls this function when it has parsed a processing instruction.
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
const QString & name()
Definition: qxml.cpp:8495
signed char Done
Definition: qxml.cpp:397
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401

◆ parseReference()

bool QXmlSimpleReaderPrivate::parseReference ( )
private

Definition at line 7837 of file qxml.cpp.

7838 {
7839  // temporary variables (only used in very local context, so they don't
7840  // interfere with incremental parsing)
7841  uint tmp;
7842  bool ok;
7843 
7844  const signed char Init = 0;
7845  const signed char SRef = 1; // start of a reference
7846  const signed char ChRef = 2; // parse CharRef
7847  const signed char ChDec = 3; // parse CharRef decimal
7848  const signed char ChHexS = 4; // start CharRef hexadecimal
7849  const signed char ChHex = 5; // parse CharRef hexadecimal
7850  const signed char Name = 6; // parse name
7851  const signed char DoneD = 7; // done CharRef decimal
7852  const signed char DoneH = 8; // done CharRef hexadecimal
7853  const signed char DoneN = 9; // done EntityRef
7854 
7855  const signed char InpAmp = 0; // &
7856  const signed char InpSemi = 1; // ;
7857  const signed char InpHash = 2; // #
7858  const signed char InpX = 3; // x
7859  const signed char InpNum = 4; // 0-9
7860  const signed char InpHex = 5; // a-f A-F
7861  const signed char InpUnknown = 6;
7862 
7863  static const signed char table[8][7] = {
7864  /* InpAmp InpSemi InpHash InpX InpNum InpHex InpUnknown */
7865  { SRef, -1, -1, -1, -1, -1, -1 }, // Init
7866  { -1, -1, ChRef, Name, Name, Name, Name }, // SRef
7867  { -1, -1, -1, ChHexS, ChDec, -1, -1 }, // ChRef
7868  { -1, DoneD, -1, -1, ChDec, -1, -1 }, // ChDec
7869  { -1, -1, -1, -1, ChHex, ChHex, -1 }, // ChHexS
7870  { -1, DoneH, -1, -1, ChHex, ChHex, -1 }, // ChHex
7871  { -1, DoneN, -1, -1, -1, -1, -1 } // Name
7872  };
7873  signed char state;
7874  signed char input;
7875 
7876  if (parseStack==0 || parseStack->isEmpty()) {
7878  state = Init;
7879  } else {
7880  state = parseStack->pop().state;
7881 #if defined(QT_QXML_DEBUG)
7882  qDebug("QXmlSimpleReader: parseReference (cont) in state %d", state);
7883 #endif
7884  if (!parseStack->isEmpty()) {
7885  ParseFunction function = parseStack->top().function;
7886  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
7887  parseStack->pop();
7888 #if defined(QT_QXML_DEBUG)
7889  qDebug("QXmlSimpleReader: eat_ws (cont)");
7890 #endif
7891  }
7892  if (!(this->*function)()) {
7894  return false;
7895  }
7896  }
7897  }
7898 
7899  for (;;) {
7900  switch (state) {
7901  case DoneD:
7902  return true;
7903  case DoneH:
7904  return true;
7905  case DoneN:
7906  return true;
7907  case -1:
7908  // Error
7910  return false;
7911  }
7912 
7913  if (atEnd()) {
7915  return false;
7916  }
7917  if (c.row()) {
7918  input = InpUnknown;
7919  } else if (c.cell() == '&') {
7920  input = InpAmp;
7921  } else if (c.cell() == ';') {
7922  input = InpSemi;
7923  } else if (c.cell() == '#') {
7924  input = InpHash;
7925  } else if (c.cell() == 'x') {
7926  input = InpX;
7927  } else if ('0' <= c.cell() && c.cell() <= '9') {
7928  input = InpNum;
7929  } else if ('a' <= c.cell() && c.cell() <= 'f') {
7930  input = InpHex;
7931  } else if ('A' <= c.cell() && c.cell() <= 'F') {
7932  input = InpHex;
7933  } else {
7934  input = InpUnknown;
7935  }
7936  state = table[state][input];
7937 
7938  switch (state) {
7939  case SRef:
7940  refClear();
7941  next();
7942  break;
7943  case ChRef:
7944  next();
7945  break;
7946  case ChDec:
7947  refAddC();
7948  next();
7949  break;
7950  case ChHexS:
7951  next();
7952  break;
7953  case ChHex:
7954  refAddC();
7955  next();
7956  break;
7957  case Name:
7958  // read the name into the ref
7959  parseName_useRef = true;
7960  if (!parseName()) {
7962  return false;
7963  }
7964  break;
7965  case DoneD:
7966  tmp = ref().toUInt(&ok, 10);
7967  if (ok) {
7968  stringAddC(QChar(tmp));
7969  } else {
7971  return false;
7972  }
7974  next();
7975  break;
7976  case DoneH:
7977  tmp = ref().toUInt(&ok, 16);
7978  if (ok) {
7979  stringAddC(QChar(tmp));
7980  } else {
7982  return false;
7983  }
7985  next();
7986  break;
7987  case DoneN:
7988  if (!processReference())
7989  return false;
7990  next();
7991  break;
7992  }
7993  }
7994  return false;
7995 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
void QT_FASTCALL next()
Definition: qxml.cpp:8300
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
#define XMLERR_ERRORPARSINGREFERENCE
Definition: qxml.cpp:75
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
unsigned int uint
Definition: qglobal.h:996
bool parseReference_charDataRead
Definition: qxml.cpp:375
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
uint toUInt(bool *ok=0, int base=10) const
Returns the string converted to an unsigned int using base base, which is 10 by default and must be b...
Definition: qstring.cpp:6120
uchar cell() const
Returns the cell (least significant byte) of the Unicode character.
Definition: qchar.h:283
const QString & ref()
Definition: qxml.cpp:8500
uchar row() const
Returns the row (most significant byte) of the Unicode character.
Definition: qchar.h:284

◆ parseString()

bool QXmlSimpleReaderPrivate::parseString ( )
private

Definition at line 8207 of file qxml.cpp.

8208 {
8209  const signed char InpCharExpected = 0; // the character that was expected
8210  const signed char InpUnknown = 1;
8211 
8212  signed char state; // state in this function is the position in the string s
8213  signed char input;
8214 
8215  if (parseStack==0 || parseStack->isEmpty()) {
8217  state = 0;
8218  } else {
8219  state = parseStack->pop().state;
8220 #if defined(QT_QXML_DEBUG)
8221  qDebug("QXmlSimpleReader: parseString (cont) in state %d", state);
8222 #endif
8223  if (!parseStack->isEmpty()) {
8224  ParseFunction function = parseStack->top().function;
8225  if (function == &QXmlSimpleReaderPrivate::eat_ws) {
8226  parseStack->pop();
8227 #if defined(QT_QXML_DEBUG)
8228  qDebug("QXmlSimpleReader: eat_ws (cont)");
8229 #endif
8230  }
8231  if (!(this->*function)()) {
8233  return false;
8234  }
8235  }
8236  }
8237 
8238  for (;;) {
8239  if (state == Done) {
8240  return true;
8241  }
8242 
8243  if (atEnd()) {
8245  return false;
8246  }
8247  if (c == parseString_s[(int)state]) {
8248  input = InpCharExpected;
8249  } else {
8250  input = InpUnknown;
8251  }
8252  if (input == InpCharExpected) {
8253  state++;
8254  } else {
8255  // Error
8257  return false;
8258  }
8259 
8260  next();
8261  }
8262  return false;
8263 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:66
void QT_FASTCALL next()
Definition: qxml.cpp:8300
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void unexpectedEof(ParseFunction where, int state)
Definition: qxml.cpp:8439
void parseFailed(ParseFunction where, int state)
Definition: qxml.cpp:8459
Q_CORE_EXPORT void qDebug(const char *,...)
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
bool(QXmlSimpleReaderPrivate::* ParseFunction)()
Definition: qxml.cpp:502
signed char Done
Definition: qxml.cpp:397

◆ processElementAttribute()

bool QXmlSimpleReaderPrivate::processElementAttribute ( )
private

Definition at line 4410 of file qxml.cpp.

4411 {
4412  QString uri, lname, prefix;
4414  const QString &string = QXmlSimpleReaderPrivate::string();
4415 
4416  // add the attribute to the list
4417  if (useNamespaces) {
4418  // is it a namespace declaration?
4419  namespaceSupport.splitName(name, prefix, lname);
4420  if (prefix == QLatin1String("xmlns")) {
4421  // namespace declaration
4422  namespaceSupport.setPrefix(lname, string);
4423  if (useNamespacePrefixes) {
4424  // according to http://www.w3.org/2000/xmlns/, the "prefix"
4425  // xmlns maps to the namespace name
4426  // http://www.w3.org/2000/xmlns/
4427  attList.append(name, QLatin1String("http://www.w3.org/2000/xmlns/"), lname, string);
4428  }
4429  // call the handler for prefix mapping
4430  if (contentHnd) {
4431  if (!contentHnd->startPrefixMapping(lname, string)) {
4433  return false;
4434  }
4435  }
4436  } else {
4437  // no namespace delcaration
4438  namespaceSupport.processName(name, true, uri, lname);
4439  attList.append(name, uri, lname, string);
4440  }
4441  } else {
4442  // no namespace support
4443  attList.append(name, uri, lname, string);
4444  }
4445  return true;
4446 }
void processName(const QString &, bool, QString &, QString &) const
Processes a raw XML 1.0 name in the current context by removing the prefix and looking it up among th...
Definition: qxml.cpp:864
QXmlAttributes attList
Definition: qxml.cpp:358
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
QXmlNamespaceSupport namespaceSupport
Definition: qxml.cpp:366
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
const QString & name()
Definition: qxml.cpp:8495
void splitName(const QString &, QString &, QString &) const
Splits the name qname at the &#39;:&#39; and returns the prefix in prefix and the local name in localname...
Definition: qxml.cpp:836
void setPrefix(const QString &, const QString &)
This function declares a prefix pre in the current namespace context to be the namespace URI uri...
Definition: qxml.cpp:790
void append(const QString &qName, const QString &uri, const QString &localPart, const QString &value)
Appends a new attribute entry to the list of attributes.
Definition: qxml.cpp:1273
const QString & string()
Definition: qxml.cpp:8490
virtual bool startPrefixMapping(const QString &prefix, const QString &uri)=0
The reader calls this function to signal the begin of a prefix-URI namespace mapping scope...
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401

◆ processElementEmptyTag()

bool QXmlSimpleReaderPrivate::processElementEmptyTag ( )
private

Definition at line 4308 of file qxml.cpp.

4309 {
4310  QString uri, lname;
4311  // pop the stack and call the handler
4312  if (contentHnd) {
4313  if (useNamespaces) {
4314  // report startElement first...
4315  namespaceSupport.processName(tags.top(), false, uri, lname);
4316  if (!contentHnd->startElement(uri, lname, tags.top(), attList)) {
4318  return false;
4319  }
4320  // ... followed by endElement...
4321  if (!contentHnd->endElement(uri, lname, tags.pop())) {
4323  return false;
4324  }
4325  // ... followed by endPrefixMapping
4326  QStringList prefixesBefore, prefixesAfter;
4327  if (contentHnd) {
4328  prefixesBefore = namespaceSupport.prefixes();
4329  }
4331  // call the handler for prefix mapping
4332  prefixesAfter = namespaceSupport.prefixes();
4333  for (QStringList::Iterator it = prefixesBefore.begin(); it != prefixesBefore.end(); ++it) {
4334  if (!prefixesAfter.contains(*it)) {
4335  if (!contentHnd->endPrefixMapping(*it)) {
4337  return false;
4338  }
4339  }
4340  }
4341  } else {
4342  // report startElement first...
4345  return false;
4346  }
4347  // ... followed by endElement
4348  if (!contentHnd->endElement(QString(), QString(), tags.pop())) {
4350  return false;
4351  }
4352  }
4353  } else {
4354  tags.pop_back();
4356  }
4357  return true;
4358 }
void processName(const QString &, bool, QString &, QString &) const
Processes a raw XML 1.0 name in the current context by removing the prefix and looking it up among th...
Definition: qxml.cpp:864
void popContext()
Reverts to the previous namespace context.
Definition: qxml.cpp:968
#define it(className, varName)
QXmlAttributes attList
Definition: qxml.cpp:358
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)=0
The reader calls this function when it has parsed a start element tag.
The QString class provides a Unicode character string.
Definition: qstring.h:83
QStringList prefixes() const
Returns a list of all the prefixes currently declared.
Definition: qxml.cpp:901
iterator Iterator
Qt-style synonym for QList::iterator.
Definition: qlist.h:278
T pop()
Removes the top item from the stack and returns it.
Definition: qstack.h:67
void pop_back()
This function is provided for STL compatibility.
Definition: qvector.h:283
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
QXmlNamespaceSupport namespaceSupport
Definition: qxml.cpp:366
virtual bool endPrefixMapping(const QString &prefix)=0
The reader calls this function to signal the end of a prefix mapping for the prefix prefix...
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
QStack< QString > tags
Definition: qxml.cpp:284
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401
T & top()
Returns a reference to the stack&#39;s top item.
Definition: qstack.h:72
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)=0
The reader calls this function when it has parsed an end element tag with the qualified name qName...

◆ processElementETagBegin2()

bool QXmlSimpleReaderPrivate::processElementETagBegin2 ( )
private

Definition at line 4363 of file qxml.cpp.

4364 {
4366 
4367  // pop the stack and compare it with the name
4368  if (tags.pop() != name) {
4370  return false;
4371  }
4372  // call the handler
4373  if (contentHnd) {
4374  QString uri, lname;
4375 
4376  if (useNamespaces)
4377  namespaceSupport.processName(name, false, uri, lname);
4378  if (!contentHnd->endElement(uri, lname, name)) {
4380  return false;
4381  }
4382  }
4383  if (useNamespaces) {
4384  NamespaceMap prefixesBefore, prefixesAfter;
4385  if (contentHnd)
4386  prefixesBefore = namespaceSupport.d->ns;
4387 
4389  // call the handler for prefix mapping
4390  if (contentHnd) {
4391  prefixesAfter = namespaceSupport.d->ns;
4392  if (prefixesBefore.size() != prefixesAfter.size()) {
4393  for (NamespaceMap::const_iterator it = prefixesBefore.constBegin(); it != prefixesBefore.constEnd(); ++it) {
4394  if (!it.key().isEmpty() && !prefixesAfter.contains(it.key())) {
4395  if (!contentHnd->endPrefixMapping(it.key())) {
4397  return false;
4398  }
4399  }
4400  }
4401  }
4402  }
4403  }
4404  return true;
4405 }
void processName(const QString &, bool, QString &, QString &) const
Processes a raw XML 1.0 name in the current context by removing the prefix and looking it up among th...
Definition: qxml.cpp:864
void popContext()
Reverts to the previous namespace context.
Definition: qxml.cpp:968
#define it(className, varName)
int size() const
Returns the number of (key, value) pairs in the map.
Definition: qmap.h:201
#define XMLERR_TAGMISMATCH
Definition: qxml.cpp:64
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
T pop()
Removes the top item from the stack and returns it.
Definition: qstack.h:67
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
Definition: qmap.h:374
QXmlNamespaceSupport namespaceSupport
Definition: qxml.cpp:366
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:380
virtual bool endPrefixMapping(const QString &prefix)=0
The reader calls this function to signal the end of a prefix mapping for the prefix prefix...
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
const QString & name()
Definition: qxml.cpp:8495
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
Definition: qmap.h:553
QStack< QString > tags
Definition: qxml.cpp:284
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401
QXmlNamespaceSupportPrivate * d
Definition: qxml.h:108
friend class const_iterator
Definition: qmap.h:369
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)=0
The reader calls this function when it has parsed an end element tag with the qualified name qName...

◆ processReference()

bool QXmlSimpleReaderPrivate::processReference ( )
private

Definition at line 8000 of file qxml.cpp.

8001 {
8002  QString reference = ref();
8003  if (reference == QLatin1String("amp")) {
8005  // Bypassed
8007  } else {
8008  // Included or Included in literal
8009  stringAddC(QLatin1Char('&'));
8010  }
8012  } else if (reference == QLatin1String("lt")) {
8014  // Bypassed
8016  } else {
8017  // Included or Included in literal
8018  stringAddC(QLatin1Char('<'));
8019  }
8021  } else if (reference == QLatin1String("gt")) {
8023  // Bypassed
8025  } else {
8026  // Included or Included in literal
8027  stringAddC(QLatin1Char('>'));
8028  }
8030  } else if (reference == QLatin1String("apos")) {
8032  // Bypassed
8034  } else {
8035  // Included or Included in literal
8036  stringAddC(QLatin1Char('\''));
8037  }
8039  } else if (reference == QLatin1String("quot")) {
8041  // Bypassed
8043  } else {
8044  // Included or Included in literal
8045  stringAddC(QLatin1Char('"'));
8046  }
8048  } else {
8050  it = entities.find(reference);
8051  if (it != entities.end()) {
8052  // "Internal General"
8053  switch (parseReference_context) {
8054  case InContent:
8055  // Included
8056  if (!insertXmlRef(*it, reference, false))
8057  return false;
8059  break;
8060  case InAttributeValue:
8061  // Included in literal
8062  if (!insertXmlRef(*it, reference, true))
8063  return false;
8065  break;
8066  case InEntityValue:
8067  {
8068  // Bypassed
8069  stringAddC(QLatin1Char('&'));
8070  for (int i=0; i<(int)reference.length(); i++) {
8071  stringAddC(reference[i]);
8072  }
8073  stringAddC(QLatin1Char(';'));
8075  }
8076  break;
8077  case InDTD:
8078  // Forbidden
8081  return false;
8082  }
8083  } else {
8085  itExtern = externEntities.find(reference);
8086  if (itExtern == externEntities.end()) {
8087  // entity not declared
8088  // ### check this case for conformance
8090  // Bypassed
8091  stringAddC(QLatin1Char('&'));
8092  for (int i=0; i<(int)reference.length(); i++) {
8093  stringAddC(reference[i]);
8094  }
8095  stringAddC(QLatin1Char(';'));
8097  } else {
8098  // if we have some char data read, report it now
8100  if (contentCharDataRead) {
8101  if (reportWhitespaceCharData || !string().simplified().isEmpty()) {
8102  if (contentHnd != 0 && !contentHnd->characters(string())) {
8104  return false;
8105  }
8106  }
8107  stringClear();
8108  contentCharDataRead = false;
8109  }
8110  }
8111 
8112  if (contentHnd) {
8114  if (!contentHnd->skippedEntity(reference)) {
8117  return false; // error
8118  }
8120  }
8121  }
8122  } else if ((*itExtern).notation.isNull()) {
8123  // "External Parsed General"
8124  switch (parseReference_context) {
8125  case InContent:
8126  {
8127  // Included if validating
8128  bool skipIt = true;
8129  if (entityRes) {
8130  QXmlInputSource *ret = 0;
8131  if (!entityRes->resolveEntity((*itExtern).publicId, (*itExtern).systemId, ret)) {
8132  delete ret;
8134  return false;
8135  }
8136  if (ret) {
8137  QString xmlRefString;
8138  QString buffer = ret->data();
8139  while (buffer.length()>0){
8140  xmlRefString += buffer;
8141  ret->fetchData();
8142  buffer = ret->data();
8143  }
8144  delete ret;
8145  if (!stripTextDecl(xmlRefString)) {
8147  return false;
8148  }
8149  if (!insertXmlRef(xmlRefString, reference, false))
8150  return false;
8151  skipIt = false;
8152  }
8153  }
8154  if (skipIt && contentHnd) {
8156  if (!contentHnd->skippedEntity(reference)) {
8159  return false; // error
8160  }
8162  }
8164  } break;
8165  case InAttributeValue:
8166  // Forbidden
8169  return false;
8170  case InEntityValue:
8171  {
8172  // Bypassed
8173  stringAddC(QLatin1Char('&'));
8174  for (int i=0; i<(int)reference.length(); i++) {
8175  stringAddC(reference[i]);
8176  }
8177  stringAddC(QLatin1Char(';'));
8179  }
8180  break;
8181  case InDTD:
8182  // Forbidden
8185  return false;
8186  }
8187  } else {
8188  // "Unparsed"
8189  // ### notify for "Occurs as Attribute Value" missing (but this is no refence, anyway)
8190  // Forbidden
8193  return false; // error
8194  }
8195  }
8196  }
8197  return true; // no error
8198 }
virtual void fetchData()
This function reads more data from the device that was set during construction.
Definition: qxml.cpp:1551
QMap< QString, QString > entities
Definition: qxml.cpp:313
static bool stripTextDecl(QString &str)
Definition: qxml.cpp:189
virtual bool skippedEntity(const QString &name)=0
Some readers may skip entities if they have not seen the declarations (e.
#define it(className, varName)
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
iterator find(const Key &key)
Returns an iterator pointing to the item with key key in the map.
Definition: qmap.h:618
#define XMLERR_INTERNALGENERALENTITYINDTD
Definition: qxml.cpp:76
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool reportWhitespaceCharData
Definition: qxml.cpp:354
#define XMLERR_UNPARSEDENTITYREFERENCE
Definition: qxml.cpp:79
bool insertXmlRef(const QString &, const QString &, bool)
Definition: qxml.cpp:8273
bool qt_xml_skipped_entity_in_content
Definition: qxml.cpp:104
static bool isEmpty(const char *str)
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
#define XMLERR_ERRORINTEXTDECL
Definition: qxml.cpp:81
bool parseReference_charDataRead
Definition: qxml.cpp:375
virtual QString data() const
Returns the data the input source contains or an empty string if the input source does not contain an...
Definition: qxml.cpp:1491
#define XMLERR_EXTERNALGENERALENTITYINDTD
Definition: qxml.cpp:78
QXmlEntityResolver * entityRes
Definition: qxml.cpp:404
#define XMLERR_EXTERNALGENERALENTITYINAV
Definition: qxml.cpp:77
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
EntityRecognitionContext parseReference_context
Definition: qxml.cpp:376
virtual bool characters(const QString &ch)=0
The reader calls this function when it has parsed a chunk of character data (either normal character ...
const QString & ref()
Definition: qxml.cpp:8500
virtual bool resolveEntity(const QString &publicId, const QString &systemId, QXmlInputSource *&ret)=0
The reader calls this function before it opens any external entity, except the top-level document ent...
The QXmlInputSource class provides the input data for the QXmlReader subclasses.
Definition: qxml.h:158
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QMap< QString, ExternEntity > externEntities
Definition: qxml.cpp:312
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67

◆ pushParseState()

void QXmlSimpleReaderPrivate::pushParseState ( ParseFunction  function,
int  state 
)
private

Definition at line 8473 of file qxml.cpp.

8474 {
8476  ps.function = function;
8477  ps.state = state;
8478  parseStack->push(ps);
8479 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387

◆ ref()

const QString & QXmlSimpleReaderPrivate::ref ( )
private

Definition at line 8500 of file qxml.cpp.

8501 {
8503  return refValue;
8504 }
static void updateValue(QString &value, const QChar *array, int &arrayPos, int &valueLen)
Definition: qxml.cpp:8481
QChar refArray[256]
Definition: qxml.cpp:418

◆ refAddC() [1/2]

void QXmlSimpleReaderPrivate::refAddC ( QChar  ch)
private

Definition at line 8518 of file qxml.cpp.

8519 {
8520  if (refArrayPos == 256)
8522  refArray[refArrayPos++] = ch;
8523 }
static void updateValue(QString &value, const QChar *array, int &arrayPos, int &valueLen)
Definition: qxml.cpp:8481
QChar refArray[256]
Definition: qxml.cpp:418

◆ refAddC() [2/2]

void QXmlSimpleReaderPrivate::refAddC ( )
inlineprivate

Definition at line 449 of file qxml.cpp.

Referenced by refAddC().

449 { refAddC(c); }

◆ refClear()

void QXmlSimpleReaderPrivate::refClear ( )
inlineprivate

Definition at line 3024 of file qxml.cpp.

3025 {
3026  refValueLen = 0; refArrayPos = 0;
3027 }

◆ reportEndEntities()

bool QXmlSimpleReaderPrivate::reportEndEntities ( )
private

Definition at line 4776 of file qxml.cpp.

4777 {
4778  int count = (int)xmlRefStack.count();
4779  while (count != 0 && xmlRefStack.top().isEmpty()) {
4780  if (contentHnd) {
4781  if (reportWhitespaceCharData || !string().simplified().isEmpty()) {
4782  if (!contentHnd->characters(string())) {
4784  return false;
4785  }
4786  }
4787  }
4788  stringClear();
4789  if (lexicalHnd) {
4790  if (!lexicalHnd->endEntity(xmlRefStack.top().name)) {
4792  return false;
4793  }
4794  }
4795  xmlRefStack.pop_back();
4796  count--;
4797  }
4798  return true;
4799 }
virtual QString errorString() const =0
The reader calls this function to get an error string if any of the handler functions returns false...
QXmlLexicalHandler * lexicalHnd
Definition: qxml.cpp:405
bool reportWhitespaceCharData
Definition: qxml.cpp:354
QStack< XmlRef > xmlRefStack
Definition: qxml.cpp:327
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
virtual bool endEntity(const QString &name)=0
The reader calls this function to report the end of an entity called name.
virtual QString errorString() const =0
The reader calls this function to get an error string, e.
virtual bool characters(const QString &ch)=0
The reader calls this function when it has parsed a chunk of character data (either normal character ...
QXmlContentHandler * contentHnd
Definition: qxml.cpp:401

◆ reportParseError()

void QXmlSimpleReaderPrivate::reportParseError ( const QString error)
private

Definition at line 8417 of file qxml.cpp.

8418 {
8419  this->error = error;
8420  if (errorHnd) {
8421  if (this->error.isNull()) {
8424  errorHnd->fatalError(ex);
8425  } else {
8426  const QXmlParseException ex(this->error, columnNr+1, lineNr+1,
8428  errorHnd->fatalError(ex);
8429  }
8430  }
8431 }
#define XMLERR_OK
Definition: qxml.cpp:59
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
QXmlErrorHandler * errorHnd
Definition: qxml.cpp:402
The QXmlParseException class is used to report errors with the QXmlErrorHandler interface.
Definition: qxml.h:192
virtual bool fatalError(const QXmlParseException &exception)=0
A reader must use this function to report a non-recoverable error.

◆ string()

const QString & QXmlSimpleReaderPrivate::string ( )
private

Definition at line 8490 of file qxml.cpp.

Referenced by processElementAttribute().

8491 {
8493  return stringValue;
8494 }
static void updateValue(QString &value, const QChar *array, int &arrayPos, int &valueLen)
Definition: qxml.cpp:8481
QChar stringArray[256]
Definition: qxml.cpp:422

◆ stringAddC() [1/2]

void QXmlSimpleReaderPrivate::stringAddC ( QChar  ch)
private

Definition at line 8506 of file qxml.cpp.

8507 {
8508  if (stringArrayPos == 256)
8510  stringArray[stringArrayPos++] = ch;
8511 }
static void updateValue(QString &value, const QChar *array, int &arrayPos, int &valueLen)
Definition: qxml.cpp:8481
QChar stringArray[256]
Definition: qxml.cpp:422

◆ stringAddC() [2/2]

void QXmlSimpleReaderPrivate::stringAddC ( )
inlineprivate

Definition at line 441 of file qxml.cpp.

Referenced by stringAddC().

◆ stringClear()

void QXmlSimpleReaderPrivate::stringClear ( )
inlineprivate

Definition at line 3015 of file qxml.cpp.

3016 {
3017  stringValueLen = 0; stringArrayPos = 0;
3018 }

◆ unexpectedEof()

void QXmlSimpleReaderPrivate::unexpectedEof ( ParseFunction  where,
int  state 
)
private

Definition at line 8439 of file qxml.cpp.

8440 {
8441  if (parseStack == 0) {
8443  } else {
8446  } else {
8447  pushParseState(where, state);
8448  }
8449  }
8450 }
QStack< ParseState > * parseStack
Definition: qxml.cpp:387
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void pushParseState(ParseFunction function, int state)
Definition: qxml.cpp:8473
void reportParseError(const QString &error)
Definition: qxml.cpp:8417
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:61
static const ushort EndOfDocument
Definition: qxml.h:173

Friends and Related Functions

◆ QXmlSimpleReaderLocator

Definition at line 511 of file qxml.cpp.

Properties

◆ attDeclAName

QString QXmlSimpleReaderPrivate::attDeclAName
private

Definition at line 349 of file qxml.cpp.

◆ attDeclEName

QString QXmlSimpleReaderPrivate::attDeclEName
private

Definition at line 348 of file qxml.cpp.

◆ attList

QXmlAttributes QXmlSimpleReaderPrivate::attList
private

Definition at line 358 of file qxml.cpp.

◆ c

QChar QXmlSimpleReaderPrivate::c
private

Definition at line 410 of file qxml.cpp.

◆ columnNr

int QXmlSimpleReaderPrivate::columnNr
private

Definition at line 412 of file qxml.cpp.

Referenced by QXmlSimpleReaderLocator::columnNumber().

◆ contentCharDataRead

bool QXmlSimpleReaderPrivate::contentCharDataRead
private

Definition at line 362 of file qxml.cpp.

◆ contentHnd

QXmlContentHandler* QXmlSimpleReaderPrivate::contentHnd
private

Definition at line 401 of file qxml.cpp.

Referenced by QXmlSimpleReader::contentHandler().

◆ declHnd

QXmlDeclHandler* QXmlSimpleReaderPrivate::declHnd
private

Definition at line 406 of file qxml.cpp.

Referenced by QXmlSimpleReader::declHandler().

◆ doctype

QString QXmlSimpleReaderPrivate::doctype
private

Definition at line 332 of file qxml.cpp.

◆ doctype_read

bool QXmlSimpleReaderPrivate::doctype_read
private

Definition at line 391 of file qxml.cpp.

◆ Done

signed char QXmlSimpleReaderPrivate::Done
private

Definition at line 397 of file qxml.cpp.

◆ dtdHnd

QXmlDTDHandler* QXmlSimpleReaderPrivate::dtdHnd
private

Definition at line 403 of file qxml.cpp.

Referenced by QXmlSimpleReader::DTDHandler().

◆ dtdRecursionLimit

const int QXmlSimpleReaderPrivate::dtdRecursionLimit = 2
staticprivate

Definition at line 434 of file qxml.cpp.

◆ emptyStr

QString QXmlSimpleReaderPrivate::emptyStr
private

Definition at line 426 of file qxml.cpp.

◆ encoding

QString QXmlSimpleReaderPrivate::encoding
private

Definition at line 334 of file qxml.cpp.

◆ entities

QMap<QString,QString> QXmlSimpleReaderPrivate::entities
private

Definition at line 313 of file qxml.cpp.

◆ entityCharacterLimit

const int QXmlSimpleReaderPrivate::entityCharacterLimit = 1024
staticprivate

Definition at line 436 of file qxml.cpp.

◆ entityRes

QXmlEntityResolver* QXmlSimpleReaderPrivate::entityRes
private

Definition at line 404 of file qxml.cpp.

Referenced by QXmlSimpleReader::entityResolver().

◆ error

QString QXmlSimpleReaderPrivate::error
private

Definition at line 369 of file qxml.cpp.

◆ errorHnd

QXmlErrorHandler* QXmlSimpleReaderPrivate::errorHnd
private

Definition at line 402 of file qxml.cpp.

Referenced by QXmlSimpleReader::errorHandler().

◆ expandedSizes

QHash<QString, int> QXmlSimpleReaderPrivate::expandedSizes
private

Definition at line 431 of file qxml.cpp.

◆ externEntities

QMap<QString,ExternEntity> QXmlSimpleReaderPrivate::externEntities
private

Definition at line 312 of file qxml.cpp.

◆ externParameterEntities

QMap<QString,ExternParameterEntity> QXmlSimpleReaderPrivate::externParameterEntities
private

Definition at line 310 of file qxml.cpp.

◆ inputSource

QXmlInputSource* QXmlSimpleReaderPrivate::inputSource
private

Definition at line 408 of file qxml.cpp.

◆ lexicalHnd

QXmlLexicalHandler* QXmlSimpleReaderPrivate::lexicalHnd
private

Definition at line 405 of file qxml.cpp.

Referenced by QXmlSimpleReader::lexicalHandler().

◆ lineNr

int QXmlSimpleReaderPrivate::lineNr
private

Definition at line 411 of file qxml.cpp.

Referenced by QXmlSimpleReaderLocator::lineNumber().

◆ literalEntitySizes

QHash<QString, int> QXmlSimpleReaderPrivate::literalEntitySizes
private

Definition at line 428 of file qxml.cpp.

◆ locator

QScopedPointer<QXmlLocator> QXmlSimpleReaderPrivate::locator
private

Definition at line 365 of file qxml.cpp.

◆ nameArray

QChar QXmlSimpleReaderPrivate::nameArray[256]
private

Definition at line 414 of file qxml.cpp.

◆ nameArrayPos

int QXmlSimpleReaderPrivate::nameArrayPos
private

Definition at line 416 of file qxml.cpp.

◆ namespaceSupport

QXmlNamespaceSupport QXmlSimpleReaderPrivate::namespaceSupport
private

Definition at line 366 of file qxml.cpp.

◆ nameValue

QString QXmlSimpleReaderPrivate::nameValue
private

Definition at line 415 of file qxml.cpp.

◆ nameValueLen

int QXmlSimpleReaderPrivate::nameValueLen
private

Definition at line 417 of file qxml.cpp.

◆ parameterEntities

QMap<QString,QString> QXmlSimpleReaderPrivate::parameterEntities
private

Definition at line 311 of file qxml.cpp.

◆ parseExternalID_allowPublicID

bool QXmlSimpleReaderPrivate::parseExternalID_allowPublicID
private

Definition at line 377 of file qxml.cpp.

◆ parseName_useRef

bool QXmlSimpleReaderPrivate::parseName_useRef
private

Definition at line 374 of file qxml.cpp.

◆ parsePEReference_context

EntityRecognitionContext QXmlSimpleReaderPrivate::parsePEReference_context
private

Definition at line 378 of file qxml.cpp.

◆ parsePI_xmldecl

bool QXmlSimpleReaderPrivate::parsePI_xmldecl
private

Definition at line 373 of file qxml.cpp.

◆ parseReference_charDataRead

bool QXmlSimpleReaderPrivate::parseReference_charDataRead
private

Definition at line 375 of file qxml.cpp.

◆ parseReference_context

EntityRecognitionContext QXmlSimpleReaderPrivate::parseReference_context
private

Definition at line 376 of file qxml.cpp.

◆ parseStack

QStack<ParseState>* QXmlSimpleReaderPrivate::parseStack
private

Definition at line 387 of file qxml.cpp.

◆ parseString_s

QString QXmlSimpleReaderPrivate::parseString_s
private

Definition at line 379 of file qxml.cpp.

◆ publicId

QString QXmlSimpleReaderPrivate::publicId
private

Definition at line 337 of file qxml.cpp.

◆ q_ptr

QXmlSimpleReader* QXmlSimpleReaderPrivate::q_ptr
private

Definition at line 509 of file qxml.cpp.

◆ refArray

QChar QXmlSimpleReaderPrivate::refArray[256]
private

Definition at line 418 of file qxml.cpp.

◆ refArrayPos

int QXmlSimpleReaderPrivate::refArrayPos
private

Definition at line 420 of file qxml.cpp.

◆ referencesToOtherEntities

QHash<QString, QHash<QString, int> > QXmlSimpleReaderPrivate::referencesToOtherEntities
private

Definition at line 430 of file qxml.cpp.

◆ refValue

QString QXmlSimpleReaderPrivate::refValue
private

Definition at line 419 of file qxml.cpp.

◆ refValueLen

int QXmlSimpleReaderPrivate::refValueLen
private

Definition at line 421 of file qxml.cpp.

◆ reportEntities

bool QXmlSimpleReaderPrivate::reportEntities
private

Definition at line 355 of file qxml.cpp.

Referenced by QXmlSimpleReader::feature().

◆ reportWhitespaceCharData

bool QXmlSimpleReaderPrivate::reportWhitespaceCharData
private

Definition at line 354 of file qxml.cpp.

Referenced by QXmlSimpleReader::feature().

◆ standalone

Standalone QXmlSimpleReaderPrivate::standalone
private

Definition at line 335 of file qxml.cpp.

◆ startDTDwasReported

bool QXmlSimpleReaderPrivate::startDTDwasReported
private

Definition at line 394 of file qxml.cpp.

◆ stringArray

QChar QXmlSimpleReaderPrivate::stringArray[256]
private

Definition at line 422 of file qxml.cpp.

◆ stringArrayPos

int QXmlSimpleReaderPrivate::stringArrayPos
private

Definition at line 424 of file qxml.cpp.

◆ stringValue

QString QXmlSimpleReaderPrivate::stringValue
private

Definition at line 423 of file qxml.cpp.

◆ stringValueLen

int QXmlSimpleReaderPrivate::stringValueLen
private

Definition at line 425 of file qxml.cpp.

◆ systemId

QString QXmlSimpleReaderPrivate::systemId
private

Definition at line 338 of file qxml.cpp.

◆ tags

QStack<QString> QXmlSimpleReaderPrivate::tags
private

Definition at line 284 of file qxml.cpp.

◆ thisPublicId

QString QXmlSimpleReaderPrivate::thisPublicId
private

Definition at line 345 of file qxml.cpp.

◆ thisSystemId

QString QXmlSimpleReaderPrivate::thisSystemId
private

Definition at line 346 of file qxml.cpp.

◆ useNamespacePrefixes

bool QXmlSimpleReaderPrivate::useNamespacePrefixes
private

Definition at line 353 of file qxml.cpp.

Referenced by QXmlSimpleReader::feature().

◆ useNamespaces

bool QXmlSimpleReaderPrivate::useNamespaces
private

Definition at line 352 of file qxml.cpp.

Referenced by QXmlSimpleReader::feature().

◆ xmldecl_possible

bool QXmlSimpleReaderPrivate::xmldecl_possible
private

Definition at line 390 of file qxml.cpp.

◆ xmlRefStack

QStack<XmlRef> QXmlSimpleReaderPrivate::xmlRefStack
private

Definition at line 327 of file qxml.cpp.

◆ xmlVersion

QString QXmlSimpleReaderPrivate::xmlVersion
private

Definition at line 333 of file qxml.cpp.


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