Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
QXmlSimpleReader Class Reference

The QXmlSimpleReader class provides an implementation of a simple XML reader (i.e. parser). More...

#include <qxml.h>

Inheritance diagram for QXmlSimpleReader:
QXmlReader

Public Member Functions

 QXmlSimpleReader ()
 
virtual ~QXmlSimpleReader ()
 
bool feature (const QString &name, bool *ok=0) const
 
void setFeature (const QString &name, bool value)
 
bool hasFeature (const QString &name) const
 
void * property (const QString &name, bool *ok=0) const
 
void setProperty (const QString &name, void *value)
 
bool hasProperty (const QString &name) const
 
void setEntityResolver (QXmlEntityResolver *handler)
 
QXmlEntityResolverentityResolver () const
 
void setDTDHandler (QXmlDTDHandler *handler)
 
QXmlDTDHandlerDTDHandler () const
 
void setContentHandler (QXmlContentHandler *handler)
 
QXmlContentHandlercontentHandler () const
 
void setErrorHandler (QXmlErrorHandler *handler)
 
QXmlErrorHandlererrorHandler () const
 
void setLexicalHandler (QXmlLexicalHandler *handler)
 
QXmlLexicalHandlerlexicalHandler () const
 
void setDeclHandler (QXmlDeclHandler *handler)
 
QXmlDeclHandlerdeclHandler () const
 
bool parse (const QXmlInputSource &input)
 
- Public Member Functions inherited from QXmlReader
virtual ~QXmlReader ()
 

Private Types

enum  EntityRecognitionContext { InContent, InAttributeValue, InEntityValue, InDTD }
 

Private Member Functions

virtual bool is_S (const QChar &)
 
virtual bool is_Letter (const QChar &)
 
virtual bool is_NameBeginning (const QChar &)
 
virtual bool is_Digit (const QChar &)
 
virtual bool is_CombiningChar (const QChar &)
 
virtual bool is_Extender (const QChar &)
 
virtual bool is_NameChar (const QChar &)
 
QStringstring ()
 
void stringClear ()
 
void stringAddC ()
 
void stringAddC (const QChar &)
 
QStringname ()
 
void nameClear ()
 
void nameAddC ()
 
void nameAddC (const QChar &)
 
QStringref ()
 
void refClear ()
 
void refAddC ()
 
void refAddC (const QChar &)
 
void eat_ws ()
 
void next_eat_ws ()
 
void next ()
 
bool atEnd ()
 
void init (const QXmlInputSource &i)
 
bool entityExist (const QString &) const
 
bool parseProlog ()
 
bool parseElement ()
 
bool parseElementEmptyTag (bool &t, QString &uri, QString &lname)
 
bool parseElementETagBegin2 (QString &uri, QString &lname)
 
bool parseElementAttribute (QString &prefix, QString &uri, QString &lname)
 
bool parseMisc ()
 
bool parseContent ()
 
bool parsePI (bool xmldecl=FALSE)
 
bool parseDoctype ()
 
bool parseComment ()
 
bool parseName (bool useRef=FALSE)
 
bool parseNmtoken ()
 
bool parseAttribute ()
 
bool parseReference (bool &charDataRead, EntityRecognitionContext context)
 
bool processReference (bool &charDataRead, EntityRecognitionContext context)
 
bool parseExternalID (bool allowPublicID=FALSE)
 
bool parsePEReference (EntityRecognitionContext context)
 
bool parseMarkupdecl ()
 
bool parseAttlistDecl ()
 
bool parseAttType ()
 
bool parseAttValue ()
 
bool parseElementDecl ()
 
bool parseNotationDecl ()
 
bool parseChoiceSeq ()
 
bool parseEntityDecl ()
 
bool parseEntityValue ()
 
bool parseString (const QString &s)
 
void reportParseError ()
 

Private Attributes

QXmlContentHandlercontentHnd
 
QXmlErrorHandlererrorHnd
 
QXmlDTDHandlerdtdHnd
 
QXmlEntityResolverentityRes
 
QXmlLexicalHandlerlexicalHnd
 
QXmlDeclHandlerdeclHnd
 
QChar c
 
int lineNr
 
int columnNr
 
int pos
 
int namePos
 
QChar nameArray [256]
 
QString nameValue
 
int refPos
 
QChar refArray [256]
 
QString refValue
 
int stringPos
 
QChar stringArray [256]
 
QString stringValue
 
QString xml
 
int xmlLength
 
QString xmlRef
 
QValueStack< QStringtags
 
QXmlSimpleReaderPrivated
 

Static Private Attributes

static const QChar QEOF = QChar((ushort)0xffff)
 

Friends

class QXmlSimpleReaderPrivate
 
class QXmlLocator
 

Detailed Description

The QXmlSimpleReader class provides an implementation of a simple XML reader (i.e. parser).

XML

This XML reader is sufficient for simple parsing tasks. Here is a short list of the properties of this reader:

For getting started see also the Quick start.

Definition at line 238 of file qxml.h.

Member Enumeration Documentation

Enumerator
InContent 
InAttributeValue 
InEntityValue 
InDTD 

Definition at line 324 of file qxml.h.

Constructor & Destructor Documentation

QXmlSimpleReader::QXmlSimpleReader ( )

Constructs a simple XML reader.

Definition at line 1904 of file qxml.cpp.

1905 {
1906  d = new QXmlSimpleReaderPrivate();
1907  d->locator = new QXmlLocator( this );
1908 
1909  entityRes = 0;
1910  dtdHnd = 0;
1911  contentHnd = 0;
1912  errorHnd = 0;
1913  lexicalHnd = 0;
1914  declHnd = 0;
1915 
1916  // default feature settings
1917  d->useNamespaces = TRUE;
1920 }
QXmlEntityResolver * entityRes
Definition: qxml.h:272
QXmlLexicalHandler * lexicalHnd
Definition: qxml.h:273
const bool FALSE
Definition: qglobal.h:370
QXmlContentHandler * contentHnd
Definition: qxml.h:269
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
QXmlDeclHandler * declHnd
Definition: qxml.h:274
friend class QXmlSimpleReaderPrivate
Definition: qxml.h:371
friend class QXmlLocator
Definition: qxml.h:372
QXmlDTDHandler * dtdHnd
Definition: qxml.h:271
QXmlLocator * locator
Definition: qxml.cpp:1674
const bool TRUE
Definition: qglobal.h:371
QXmlErrorHandler * errorHnd
Definition: qxml.h:270
QXmlSimpleReader::~QXmlSimpleReader ( )
virtual

Destroys a simple XML reader.

Definition at line 1925 of file qxml.cpp.

1926 {
1927  delete d->locator;
1928  delete d;
1929 }
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
QXmlLocator * locator
Definition: qxml.cpp:1674

Member Function Documentation

bool QXmlSimpleReader::atEnd ( )
inlineprivate

Definition at line 575 of file qxml.h.

576 { return c == QEOF; }
static const QChar QEOF
Definition: qxml.h:299
QXmlContentHandler * QXmlSimpleReader::contentHandler ( ) const
virtual

Implements QXmlReader.

Definition at line 2047 of file qxml.cpp.

2048 { return contentHnd; }
QXmlContentHandler * contentHnd
Definition: qxml.h:269
QXmlDeclHandler * QXmlSimpleReader::declHandler ( ) const
virtual

Implements QXmlReader.

Definition at line 2071 of file qxml.cpp.

2072 { return declHnd; }
QXmlDeclHandler * declHnd
Definition: qxml.h:274
QXmlDTDHandler * QXmlSimpleReader::DTDHandler ( ) const
virtual

Implements QXmlReader.

Definition at line 2039 of file qxml.cpp.

2040 { return dtdHnd; }
QXmlDTDHandler * dtdHnd
Definition: qxml.h:271
void QXmlSimpleReader::eat_ws ( )
inlineprivate

Definition at line 578 of file qxml.h.

579 { while ( !atEnd() && is_S(c) ) next(); }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
void next()
Definition: qxml.h:555
bool atEnd()
Definition: qxml.h:575
bool QXmlSimpleReader::entityExist ( const QString e) const
private

Returns TRUE if a entity with the name e exists, otherwise returns FALSE.

Definition at line 6045 of file qxml.cpp.

6046 {
6047  if ( d->parameterEntities.find(e) == d->parameterEntities.end() &&
6048  d->externParameterEntities.find(e) == d->externParameterEntities.end() ) {
6049  return FALSE;
6050  } else {
6051  return TRUE;
6052  }
6053 }
Iterator end()
Definition: qmap.h:523
const bool FALSE
Definition: qglobal.h:370
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
QMap< QString, ExternParameterEntity > externParameterEntities
Definition: qxml.cpp:1647
Iterator find(const Key &k)
Definition: qmap.h:527
QMap< QString, QString > parameterEntities
Definition: qxml.cpp:1648
const bool TRUE
Definition: qglobal.h:371
QXmlEntityResolver * QXmlSimpleReader::entityResolver ( ) const
virtual

Implements QXmlReader.

Definition at line 2031 of file qxml.cpp.

2032 { return entityRes; }
QXmlEntityResolver * entityRes
Definition: qxml.h:272
QXmlErrorHandler * QXmlSimpleReader::errorHandler ( ) const
virtual

Implements QXmlReader.

Definition at line 2055 of file qxml.cpp.

2056 { return errorHnd; }
QXmlErrorHandler * errorHnd
Definition: qxml.h:270
bool QXmlSimpleReader::feature ( const QString name,
bool ok = 0 
) const
virtual

Gets the state of a feature.

See also
setFeature() hasFeature()

Implements QXmlReader.

Definition at line 1936 of file qxml.cpp.

1937 {
1938  if ( ok != 0 )
1939  *ok = TRUE;
1940  if ( name == "http://xml.org/sax/features/namespaces" ) {
1941  return d->useNamespaces;
1942  } else if ( name == "http://xml.org/sax/features/namespace-prefixes" ) {
1943  return d->useNamespacePrefixes;
1944  } else if ( name == "http://trolltech.com/xml/features/report-whitespace-only-CharData" ) {
1945  return d->reportWhitespaceCharData;
1946  } else {
1947  qWarning( "Unknown feature %s", name.ascii() );
1948  if ( ok != 0 )
1949  *ok = FALSE;
1950  }
1951  return FALSE;
1952 }
const bool FALSE
Definition: qglobal.h:370
void qWarning(const char *msg,...)
Definition: qglobal.cpp:409
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
const char * ascii() const
Definition: qstring.cpp:14494
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::hasFeature ( const QString name) const
virtual

Returns TRUE if the class has a feature named feature, otherwise FALSE.

See also
setFeature() feature()

Implements QXmlReader.

Definition at line 1990 of file qxml.cpp.

1991 {
1992  if ( name == "http://xml.org/sax/features/namespaces" ||
1993  name == "http://xml.org/sax/features/namespace-prefixes" ||
1994  name == "http://trolltech.com/xml/features/report-whitespace-only-CharData" ) {
1995  return TRUE;
1996  } else {
1997  return FALSE;
1998  }
1999 }
const bool FALSE
Definition: qglobal.h:370
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::hasProperty ( const QString name) const
virtual

Returns FALSE since this class does not support any properties.

Implements QXmlReader.

Definition at line 2021 of file qxml.cpp.

2022 {
2023  return FALSE;
2024 }
const bool FALSE
Definition: qglobal.h:370
void QXmlSimpleReader::init ( const QXmlInputSource i)
private

Inits the data values.

Definition at line 6016 of file qxml.cpp.

6017 {
6018  xml = i.data();
6019  xmlLength = xml.length();
6020  xmlRef = "";
6021 
6022  d->externParameterEntities.clear();
6024  d->externEntities.clear();
6025  d->entities.clear();
6026 
6027  tags.clear();
6028 
6029  d->doctype = "";
6030  d->xmlVersion = "";
6031  d->encoding = "";
6033 
6034  lineNr = 0;
6035  columnNr = -1;
6036  pos = 0;
6037  next();
6038  d->error = XMLERR_OK;
6039 }
QString xml
Definition: qxml.h:291
QMap< QString, QString > entities
Definition: qxml.cpp:1650
#define XMLERR_OK
Definition: qxml.cpp:47
QValueStack< QString > tags
Definition: qxml.h:295
void clear()
Definition: qvaluelist.h:396
virtual const QString & data() const
Definition: qxml.cpp:717
int columnNr
Definition: qxml.h:278
void clear()
Definition: qmap.h:565
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
Standalone standalone
Definition: qxml.cpp:1658
void next()
Definition: qxml.h:555
uint length() const
Definition: qstring.h:679
QMap< QString, ExternParameterEntity > externParameterEntities
Definition: qxml.cpp:1647
QString xmlRef
Definition: qxml.h:293
int xmlLength
Definition: qxml.h:292
QMap< QString, QString > parameterEntities
Definition: qxml.cpp:1648
QMap< QString, ExternEntity > externEntities
Definition: qxml.cpp:1649
bool QXmlSimpleReader::is_CombiningChar ( const QChar )
inlineprivatevirtual

Definition at line 542 of file qxml.h.

543 { return FALSE; }
const bool FALSE
Definition: qglobal.h:370
bool QXmlSimpleReader::is_Digit ( const QChar ch)
inlineprivatevirtual

Definition at line 539 of file qxml.h.

540 { return ch.isDigit(); }
bool isDigit() const
Definition: qstring.cpp:11066
bool QXmlSimpleReader::is_Extender ( const QChar )
inlineprivatevirtual

Definition at line 545 of file qxml.h.

546 { return FALSE; }
const bool FALSE
Definition: qglobal.h:370
bool QXmlSimpleReader::is_Letter ( const QChar ch)
inlineprivatevirtual

Definition at line 533 of file qxml.h.

534 { return ch.isLetter(); }
bool isLetter() const
Definition: qstring.cpp:11035
bool QXmlSimpleReader::is_NameBeginning ( const QChar ch)
inlineprivatevirtual

Definition at line 536 of file qxml.h.

537 { return ch=='_' || ch==':' || ch.isLetter(); }
bool isLetter() const
Definition: qstring.cpp:11035
bool QXmlSimpleReader::is_NameChar ( const QChar ch)
inlineprivatevirtual

Definition at line 548 of file qxml.h.

549 {
550  return ch=='.' || ch=='-' || ch=='_' || ch==':' ||
551  is_Letter(ch) || is_Digit(ch) ||
552  is_CombiningChar(ch) || is_Extender(ch);
553 }
virtual bool is_CombiningChar(const QChar &)
Definition: qxml.h:542
virtual bool is_Extender(const QChar &)
Definition: qxml.h:545
virtual bool is_Letter(const QChar &)
Definition: qxml.h:533
virtual bool is_Digit(const QChar &)
Definition: qxml.h:539
bool QXmlSimpleReader::is_S ( const QChar ch)
inlineprivatevirtual

Definition at line 530 of file qxml.h.

531 { return ch==' ' || ch=='\t' || ch=='\n' || ch=='\r'; }
QXmlLexicalHandler * QXmlSimpleReader::lexicalHandler ( ) const
virtual

Implements QXmlReader.

Definition at line 2063 of file qxml.cpp.

2064 { return lexicalHnd; }
QXmlLexicalHandler * lexicalHnd
Definition: qxml.h:273
QString & QXmlSimpleReader::name ( )
inlineprivate

Definition at line 592 of file qxml.h.

593 {
595  namePos = 0;
596  return nameValue;
597 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QChar nameArray[256]
Definition: qxml.h:282
QString nameValue
Definition: qxml.h:283
void QXmlSimpleReader::nameAddC ( )
inlineprivate

Definition at line 620 of file qxml.h.

621 {
622  if ( namePos >= 256 ) {
624  namePos = 0;
625  }
626  nameArray[namePos++] = c;
627 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QChar nameArray[256]
Definition: qxml.h:282
QString nameValue
Definition: qxml.h:283
void QXmlSimpleReader::nameAddC ( const QChar ch)
inlineprivate

Definition at line 645 of file qxml.h.

646 {
647  if ( namePos >= 256 ) {
649  namePos = 0;
650  }
651  nameArray[namePos++] = ch;
652 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QChar nameArray[256]
Definition: qxml.h:282
QString nameValue
Definition: qxml.h:283
void QXmlSimpleReader::nameClear ( )
inlineprivate

Definition at line 607 of file qxml.h.

608 { nameValue = ""; namePos = 0; }
QString nameValue
Definition: qxml.h:283
void QXmlSimpleReader::next ( )
inlineprivate

Definition at line 555 of file qxml.h.

556 {
557  if ( !xmlRef.isEmpty() ) {
558  c = xmlRef[0];
559  xmlRef.remove( 0, 1 );
560  } else {
561  if ( c=='\n' || c=='\r' ) {
562  lineNr++;
563  columnNr = -1;
564  }
565  if ( pos >= xmlLength ) {
566  c = QEOF;
567  } else {
568  c = xml[pos];
569  columnNr++;
570  pos++;
571  }
572  }
573 }
QString xml
Definition: qxml.h:291
bool isEmpty() const
Definition: qstring.h:682
static const QChar QEOF
Definition: qxml.h:299
int columnNr
Definition: qxml.h:278
QString & remove(uint index, uint len)
Definition: qstring.cpp:13633
QString xmlRef
Definition: qxml.h:293
int xmlLength
Definition: qxml.h:292
void QXmlSimpleReader::next_eat_ws ( )
inlineprivate

Definition at line 581 of file qxml.h.

582 { next(); eat_ws(); }
void eat_ws()
Definition: qxml.h:578
void next()
Definition: qxml.h:555
bool QXmlSimpleReader::parse ( const QXmlInputSource input)
virtual

Implements QXmlReader.

Definition at line 2077 of file qxml.cpp.

2078 {
2079  init( input );
2080  // call the handler
2081  if ( contentHnd ) {
2083  if ( !contentHnd->startDocument() ) {
2084  d->error = contentHnd->errorString();
2085  goto parseError;
2086  }
2087  }
2088  // parse prolog
2089  if ( !parseProlog() ) {
2091  goto parseError;
2092  }
2093  // parse element
2094  if ( !parseElement() ) {
2096  goto parseError;
2097  }
2098  // parse Misc*
2099  while ( !atEnd() ) {
2100  if ( !parseMisc() ) {
2102  goto parseError;
2103  }
2104  }
2105  // is stack empty?
2106  if ( !tags.isEmpty() ) {
2108  goto parseError;
2109  }
2110  // call the handler
2111  if ( contentHnd ) {
2112  if ( !contentHnd->endDocument() ) {
2113  d->error = contentHnd->errorString();
2114  goto parseError;
2115  }
2116  }
2117 
2118  return TRUE;
2119 
2120  // error handling
2121 
2122 parseError:
2123  reportParseError();
2124  tags.clear();
2125  return FALSE;
2126 }
bool parseProlog()
Definition: qxml.cpp:2131
QValueStack< QString > tags
Definition: qxml.h:295
bool parseElement()
Definition: qxml.cpp:2303
virtual bool startDocument()=0
void clear()
Definition: qvaluelist.h:396
const bool FALSE
Definition: qglobal.h:370
#define XMLERR_ERRORPARSINGPROLOG
Definition: qxml.cpp:53
#define XMLERR_ERRORPARSINGMISC
Definition: qxml.cpp:59
QXmlContentHandler * contentHnd
Definition: qxml.h:269
#define XMLERR_ERRORPARSINGMAINELEMENT
Definition: qxml.cpp:54
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
virtual bool endDocument()=0
void reportParseError()
Definition: qxml.cpp:6055
QXmlLocator * locator
Definition: qxml.cpp:1674
bool parseMisc()
Definition: qxml.cpp:2922
virtual QString errorString()=0
void init(const QXmlInputSource &i)
Definition: qxml.cpp:6016
bool isEmpty() const
Definition: qvaluelist.h:368
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
virtual void setDocumentLocator(QXmlLocator *locator)=0
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseAttlistDecl ( )
private

Parse a AttlistDecl [52].

Precondition: the beginning '<!' is already read and the head stands on the 'A' of '<!ATTLIST'

Definition at line 3880 of file qxml.cpp.

3881 {
3882  const signed char Init = 0;
3883  const signed char Attlist = 1; // parse the string "ATTLIST"
3884  const signed char Ws = 2; // whitespace read
3885  const signed char Name = 3; // parse name
3886  const signed char Ws1 = 4; // whitespace read
3887  const signed char Attdef = 5; // parse the AttDef
3888  const signed char Ws2 = 6; // whitespace read
3889  const signed char Atttype = 7; // parse the AttType
3890  const signed char Ws3 = 8; // whitespace read
3891  const signed char DDecH = 9; // DefaultDecl with #
3892  const signed char DefReq = 10; // parse the string "REQUIRED"
3893  const signed char DefImp = 11; // parse the string "IMPLIED"
3894  const signed char DefFix = 12; // parse the string "FIXED"
3895  const signed char Attval = 13; // parse the AttValue
3896  const signed char Ws4 = 14; // whitespace read
3897  const signed char Done = 15;
3898 
3899  const signed char InpWs = 0; // white space
3900  const signed char InpGt = 1; // >
3901  const signed char InpHash = 2; // #
3902  const signed char InpA = 3; // A
3903  const signed char InpI = 4; // I
3904  const signed char InpF = 5; // F
3905  const signed char InpR = 6; // R
3906  const signed char InpUnknown = 7;
3907 
3908  // use some kind of state machine for parsing
3909  static signed char table[15][8] = {
3910  /* InpWs InpGt InpHash InpA InpI InpF InpR InpUnknown */
3911  { -1, -1, -1, Attlist, -1, -1, -1, -1 }, // Init
3912  { Ws, -1, -1, -1, -1, -1, -1, -1 }, // Attlist
3913  { -1, -1, -1, Name, Name, Name, Name, Name }, // Ws
3914  { Ws1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef }, // Name
3915  { -1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef }, // Ws1
3916  { Ws2, -1, -1, -1, -1, -1, -1, -1 }, // Attdef
3917  { -1, Atttype, Atttype, Atttype, Atttype, Atttype, Atttype, Atttype }, // Ws2
3918  { Ws3, -1, -1, -1, -1, -1, -1, -1 }, // Attype
3919  { -1, Attval, DDecH, Attval, Attval, Attval, Attval, Attval }, // Ws3
3920  { -1, -1, -1, -1, DefImp, DefFix, DefReq, -1 }, // DDecH
3921  { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, // DefReq
3922  { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, // DefImp
3923  { Ws3, -1, -1, -1, -1, -1, -1, -1 }, // DefFix
3924  { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, // Attval
3925  { -1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef } // Ws4
3926  };
3927  signed char state = Init;
3928  signed char input;
3929  bool parseOk = TRUE;
3930 
3931  while ( TRUE ) {
3932 
3933  // get input
3934  if ( atEnd() ) {
3936  goto parseError;
3937  }
3938  if ( is_S(c) ) {
3939  input = InpWs;
3940  } else if ( c == '>' ) {
3941  input = InpGt;
3942  } else if ( c == '#' ) {
3943  input = InpHash;
3944  } else if ( c == 'A' ) {
3945  input = InpA;
3946  } else if ( c == 'I' ) {
3947  input = InpI;
3948  } else if ( c == 'F' ) {
3949  input = InpF;
3950  } else if ( c == 'R' ) {
3951  input = InpR;
3952  } else {
3953  input = InpUnknown;
3954  }
3955 
3956  // set state according to input
3957  state = table[state][input];
3958 
3959  // do some actions according to state
3960  switch ( state ) {
3961  case Attlist:
3962  parseOk = parseString( "ATTLIST" );
3963  break;
3964  case Ws:
3965  case Ws1:
3966  case Ws2:
3967  case Ws3:
3968  eat_ws();
3969  break;
3970  case Name:
3971  parseOk = parseName();
3972  break;
3973  case Attdef:
3974  parseOk = parseName();
3975  break;
3976  case Atttype:
3977  parseOk = parseAttType();
3978  break;
3979  case DDecH:
3980  next();
3981  break;
3982  case DefReq:
3983  parseOk = parseString( "REQUIRED" );
3984  break;
3985  case DefImp:
3986  parseOk = parseString( "IMPLIED" );
3987  break;
3988  case DefFix:
3989  parseOk = parseString( "FIXED" );
3990  break;
3991  case Attval:
3992  parseOk = parseAttValue();
3993  break;
3994  case Ws4:
3995  if ( declHnd ) {
3996  // TODO: not all values are computed yet...
3997  if ( !declHnd->attributeDecl( d->attDeclEName, d->attDeclAName, "", "", "" ) ) {
3998  d->error = declHnd->errorString();
3999  goto parseError;
4000  }
4001  }
4002  eat_ws();
4003  break;
4004  case Done:
4005  next();
4006  break;
4007  }
4008  // no input is read after this
4009  switch ( state ) {
4010  case Attlist:
4011  if( !parseOk ) {
4013  goto parseError;
4014  }
4015  break;
4016  case Name:
4017  if ( !parseOk ) {
4019  goto parseError;
4020  }
4021  d->attDeclEName = name();
4022  break;
4023  case Attdef:
4024  if ( !parseOk ) {
4026  goto parseError;
4027  }
4028  d->attDeclAName = name();
4029  break;
4030  case Atttype:
4031  if ( !parseOk ) {
4033  goto parseError;
4034  }
4035  break;
4036  case DefReq:
4037  if( !parseOk ) {
4039  goto parseError;
4040  }
4041  break;
4042  case DefImp:
4043  if( !parseOk ) {
4045  goto parseError;
4046  }
4047  break;
4048  case DefFix:
4049  if( !parseOk ) {
4051  goto parseError;
4052  }
4053  break;
4054  case Attval:
4055  if ( !parseOk ) {
4057  goto parseError;
4058  }
4059  break;
4060  case Done:
4061  return TRUE;
4062  case -1:
4063  // Error
4065  goto parseError;
4066  }
4067 
4068  }
4069 
4070  return TRUE;
4071 
4072 parseError:
4073  reportParseError();
4074  return FALSE;
4075 }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
#define XMLERR_ERRORPARSINGATTTYPE
Definition: qxml.cpp:68
const bool FALSE
Definition: qglobal.h:370
ChannelGroupService::Name Name
bool parseAttValue()
Definition: qxml.cpp:4330
QString & name()
Definition: qxml.h:592
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
QXmlDeclHandler * declHnd
Definition: qxml.h:274
void eat_ws()
Definition: qxml.h:578
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:51
virtual bool attributeDecl(const QString &eName, const QString &aName, const QString &type, const QString &valueDefault, const QString &value)=0
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
#define XMLERR_ERRORPARSINGNAME
Definition: qxml.cpp:56
void Init(void)
Definition: gXSecComp.cxx:138
bool parseAttType()
Definition: qxml.cpp:4080
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
void reportParseError()
Definition: qxml.cpp:6055
bool parseString(const QString &s)
Definition: qxml.cpp:5964
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
virtual QString errorString()=0
const bool TRUE
Definition: qglobal.h:371
#define XMLERR_ERRORPARSINGATTVALUE
Definition: qxml.cpp:69
bool QXmlSimpleReader::parseAttribute ( )
private

Parse a Attribute [41].

Precondition: the head stands on the first character of the name of the attribute (i.e. all whitespaces are already parsed).

The head stand on the next character after the end quotes. The variable name contains the name of the attribute and the variable string contains the value of the attribute.

Definition at line 5402 of file qxml.cpp.

5403 {
5404  const signed char Init = 0;
5405  const signed char PName = 1; // parse name
5406  const signed char Ws = 2; // eat ws
5407  const signed char Eq = 3; // the '=' was read
5408  const signed char Quotes = 4; // " or ' were read
5409 
5410  const signed char InpNameBe = 0;
5411  const signed char InpEq = 1; // =
5412  const signed char InpDq = 2; // "
5413  const signed char InpSq = 3; // '
5414  const signed char InpUnknown = 4;
5415 
5416  // use some kind of state machine for parsing
5417  static signed char table[4][5] = {
5418  /* InpNameBe InpEq InpDq InpSq InpUnknown */
5419  { PName, -1, -1, -1, -1 }, // Init
5420  { -1, Eq, -1, -1, Ws }, // PName
5421  { -1, Eq, -1, -1, -1 }, // Ws
5422  { -1, -1, Quotes, Quotes, -1 } // Eq
5423  };
5424  signed char state = Init;
5425  signed char input;
5426  bool parseOk = TRUE;
5427 
5428  while ( TRUE ) {
5429 
5430  // get input
5431  if ( atEnd() ) {
5433  goto parseError;
5434  }
5435  if ( is_NameBeginning(c) ) {
5436  input = InpNameBe;
5437  } else if ( c == '=' ) {
5438  input = InpEq;
5439  } else if ( c == '"' ) {
5440  input = InpDq;
5441  } else if ( c == '\'' ) {
5442  input = InpSq;
5443  } else {
5444  input = InpUnknown;
5445  }
5446 
5447  // set state according to input
5448  state = table[state][input];
5449 
5450  // do some actions according to state
5451  switch ( state ) {
5452  case PName:
5453  parseOk = parseName();
5454  break;
5455  case Ws:
5456  eat_ws();
5457  break;
5458  case Eq:
5459  next_eat_ws();
5460  break;
5461  case Quotes:
5462  parseOk = parseAttValue();
5463  break;
5464  }
5465  // no input is read after this
5466  switch ( state ) {
5467  case PName:
5468  if ( !parseOk ) {
5470  goto parseError;
5471  }
5472  break;
5473  case Quotes:
5474  if ( !parseOk ) {
5476  goto parseError;
5477  }
5478  // Done
5479  return TRUE;
5480  case -1:
5481  // Error
5483  goto parseError;
5484  }
5485 
5486  }
5487 
5488  return TRUE;
5489 
5490 parseError:
5491  reportParseError();
5492  return FALSE;
5493 }
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
const bool FALSE
Definition: qglobal.h:370
bool parseAttValue()
Definition: qxml.cpp:4330
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
void eat_ws()
Definition: qxml.h:578
static int input(void)
Definition: code.cpp:15695
#define XMLERR_ERRORPARSINGNAME
Definition: qxml.cpp:56
void next_eat_ws()
Definition: qxml.h:581
void Init(void)
Definition: gXSecComp.cxx:138
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
void reportParseError()
Definition: qxml.cpp:6055
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
#define XMLERR_ERRORPARSINGATTVALUE
Definition: qxml.cpp:69
virtual bool is_NameBeginning(const QChar &)
Definition: qxml.h:536
bool QXmlSimpleReader::parseAttType ( )
private

Parse a AttType [54]

Definition at line 4080 of file qxml.cpp.

4081 {
4082  const signed char Init = 0;
4083  const signed char ST = 1; // StringType
4084  const signed char TTI = 2; // TokenizedType starting with 'I'
4085  const signed char TTI2 = 3; // TokenizedType helpstate
4086  const signed char TTI3 = 4; // TokenizedType helpstate
4087  const signed char TTE = 5; // TokenizedType starting with 'E'
4088  const signed char TTEY = 6; // TokenizedType starting with 'ENTITY'
4089  const signed char TTEI = 7; // TokenizedType starting with 'ENTITI'
4090  const signed char N = 8; // N read (TokenizedType or Notation)
4091  const signed char TTNM = 9; // TokenizedType starting with 'NM'
4092  const signed char TTNM2 = 10; // TokenizedType helpstate
4093  const signed char NO = 11; // Notation
4094  const signed char NO2 = 12; // Notation helpstate
4095  const signed char NO3 = 13; // Notation helpstate
4096  const signed char NOName = 14; // Notation, read name
4097  const signed char NO4 = 15; // Notation helpstate
4098  const signed char EN = 16; // Enumeration
4099  const signed char ENNmt = 17; // Enumeration, read Nmtoken
4100  const signed char EN2 = 18; // Enumeration helpstate
4101  const signed char ADone = 19; // almost done (make next and accept)
4102  const signed char Done = 20;
4103 
4104  const signed char InpWs = 0; // whitespace
4105  const signed char InpOp = 1; // (
4106  const signed char InpCp = 2; // )
4107  const signed char InpPipe = 3; // |
4108  const signed char InpC = 4; // C
4109  const signed char InpE = 5; // E
4110  const signed char InpI = 6; // I
4111  const signed char InpM = 7; // M
4112  const signed char InpN = 8; // N
4113  const signed char InpO = 9; // O
4114  const signed char InpR = 10; // R
4115  const signed char InpS = 11; // S
4116  const signed char InpY = 12; // Y
4117  const signed char InpUnknown = 13;
4118 
4119  // use some kind of state machine for parsing
4120  static signed char table[19][14] = {
4121  /* InpWs InpOp InpCp InpPipe InpC InpE InpI InpM InpN InpO InpR InpS InpY InpUnknown */
4122  { -1, EN, -1, -1, ST, TTE, TTI, -1, N, -1, -1, -1, -1, -1 }, // Init
4123  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // ST
4124  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTI2, Done, Done, Done }, // TTI
4125  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTI3, Done, Done }, // TTI2
4126  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTI3
4127  { -1, -1, -1, -1, -1, -1, TTEI, -1, -1, -1, -1, -1, TTEY, -1 }, // TTE
4128  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTEY
4129  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTEI
4130  { -1, -1, -1, -1, -1, -1, -1, TTNM, -1, NO, -1, -1, -1, -1 }, // N
4131  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTNM2, Done, Done }, // TTNM
4132  { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, // TTNM2
4133  { NO2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NO
4134  { -1, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NO2
4135  { NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName }, // NO3
4136  { NO4, -1, ADone, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NOName
4137  { -1, -1, ADone, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // NO4
4138  { -1, -1, ENNmt, -1, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt }, // EN
4139  { EN2, -1, ADone, EN, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // ENNmt
4140  { -1, -1, ADone, EN, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } // EN2
4141  };
4142  signed char state = Init;
4143  signed char input;
4144  bool parseOk = TRUE;
4145 
4146  while ( TRUE ) {
4147 
4148  // get input
4149  if ( atEnd() ) {
4151  goto parseError;
4152  }
4153  if ( is_S(c) ) {
4154  input = InpWs;
4155  } else if ( c == '(' ) {
4156  input = InpOp;
4157  } else if ( c == ')' ) {
4158  input = InpCp;
4159  } else if ( c == '|' ) {
4160  input = InpPipe;
4161  } else if ( c == 'C' ) {
4162  input = InpC;
4163  } else if ( c == 'E' ) {
4164  input = InpE;
4165  } else if ( c == 'I' ) {
4166  input = InpI;
4167  } else if ( c == 'M' ) {
4168  input = InpM;
4169  } else if ( c == 'N' ) {
4170  input = InpN;
4171  } else if ( c == 'O' ) {
4172  input = InpO;
4173  } else if ( c == 'R' ) {
4174  input = InpR;
4175  } else if ( c == 'S' ) {
4176  input = InpS;
4177  } else if ( c == 'Y' ) {
4178  input = InpY;
4179  } else {
4180  input = InpUnknown;
4181  }
4182 
4183  // set state according to input
4184  state = table[state][input];
4185 
4186  // do some actions according to state
4187  switch ( state ) {
4188  case ST:
4189  parseOk = parseString( "CDATA" );
4190  break;
4191  case TTI:
4192  parseOk = parseString( "ID" );
4193  break;
4194  case TTI2:
4195  parseOk = parseString( "REF" );
4196  break;
4197  case TTI3:
4198  next(); // S
4199  break;
4200  case TTE:
4201  parseOk = parseString( "ENTIT" );
4202  break;
4203  case TTEY:
4204  next(); // Y
4205  break;
4206  case TTEI:
4207  parseOk = parseString( "IES" );
4208  break;
4209  case N:
4210  next(); // N
4211  break;
4212  case TTNM:
4213  parseOk = parseString( "MTOKEN" );
4214  break;
4215  case TTNM2:
4216  next(); // S
4217  break;
4218  case NO:
4219  parseOk = parseString( "OTATION" );
4220  break;
4221  case NO2:
4222  eat_ws();
4223  break;
4224  case NO3:
4225  next_eat_ws();
4226  break;
4227  case NOName:
4228  parseOk = parseName();
4229  break;
4230  case NO4:
4231  eat_ws();
4232  break;
4233  case EN:
4234  next_eat_ws();
4235  break;
4236  case ENNmt:
4237  parseOk = parseNmtoken();
4238  break;
4239  case EN2:
4240  eat_ws();
4241  break;
4242  case ADone:
4243  next();
4244  break;
4245  }
4246  // no input is read after this
4247  switch ( state ) {
4248  case ST:
4249  if( !parseOk ) {
4251  goto parseError;
4252  }
4253  break;
4254  case TTI:
4255  if( !parseOk ) {
4257  goto parseError;
4258  }
4259  break;
4260  case TTI2:
4261  if( !parseOk ) {
4263  goto parseError;
4264  }
4265  break;
4266  case TTE:
4267  if( !parseOk ) {
4269  goto parseError;
4270  }
4271  break;
4272  case TTEI:
4273  if( !parseOk ) {
4275  goto parseError;
4276  }
4277  break;
4278  case TTNM:
4279  if( !parseOk ) {
4281  goto parseError;
4282  }
4283  break;
4284  case NO:
4285  if( !parseOk ) {
4287  goto parseError;
4288  }
4289  break;
4290  case NOName:
4291  if ( !parseOk ) {
4293  goto parseError;
4294  }
4295  break;
4296  case ENNmt:
4297  if ( !parseOk ) {
4299  goto parseError;
4300  }
4301  break;
4302  case ADone:
4303  return TRUE;
4304  case Done:
4305  return TRUE;
4306  case -1:
4307  // Error
4309  goto parseError;
4310  }
4311 
4312  }
4313 
4314  return TRUE;
4315 
4316 parseError:
4317  reportParseError();
4318  return FALSE;
4319 }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
const bool FALSE
Definition: qglobal.h:370
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
void eat_ws()
Definition: qxml.h:578
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:51
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
bool parseNmtoken()
Definition: qxml.cpp:5580
#define XMLERR_ERRORPARSINGNAME
Definition: qxml.cpp:56
void next_eat_ws()
Definition: qxml.h:581
void Init(void)
Definition: gXSecComp.cxx:138
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
void reportParseError()
Definition: qxml.cpp:6055
bool parseString(const QString &s)
Definition: qxml.cpp:5964
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
#define XMLERR_ERRORPARSINGNMTOKEN
Definition: qxml.cpp:57
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseAttValue ( )
private

Parse a AttValue [10]

Precondition: the head stands on the beginning " or '

If this function was successful, the head stands on the first character after the closing " or ' and the value of the attribute is in string().

Definition at line 4330 of file qxml.cpp.

4331 {
4332  bool tmp;
4333 
4334  const signed char Init = 0;
4335  const signed char Dq = 1; // double quotes were read
4336  const signed char DqRef = 2; // read references in double quotes
4337  const signed char DqC = 3; // signed character read in double quotes
4338  const signed char Sq = 4; // single quotes were read
4339  const signed char SqRef = 5; // read references in single quotes
4340  const signed char SqC = 6; // signed character read in single quotes
4341  const signed char Done = 7;
4342 
4343  const signed char InpDq = 0; // "
4344  const signed char InpSq = 1; // '
4345  const signed char InpAmp = 2; // &
4346  const signed char InpLt = 3; // <
4347  const signed char InpUnknown = 4;
4348 
4349  // use some kind of state machine for parsing
4350  static signed char table[7][5] = {
4351  /* InpDq InpSq InpAmp InpLt InpUnknown */
4352  { Dq, Sq, -1, -1, -1 }, // Init
4353  { Done, DqC, DqRef, -1, DqC }, // Dq
4354  { Done, DqC, DqRef, -1, DqC }, // DqRef
4355  { Done, DqC, DqRef, -1, DqC }, // DqC
4356  { SqC, Done, SqRef, -1, SqC }, // Sq
4357  { SqC, Done, SqRef, -1, SqC }, // SqRef
4358  { SqC, Done, SqRef, -1, SqC } // SqRef
4359  };
4360  signed char state = Init;
4361  signed char input;
4362  bool parseOk = TRUE;
4363 
4364  while ( TRUE ) {
4365 
4366  // get input
4367  if ( atEnd() ) {
4369  goto parseError;
4370  }
4371  if ( c == '"' ) {
4372  input = InpDq;
4373  } else if ( c == '\'' ) {
4374  input = InpSq;
4375  } else if ( c == '&' ) {
4376  input = InpAmp;
4377  } else if ( c == '<' ) {
4378  input = InpLt;
4379  } else {
4380  input = InpUnknown;
4381  }
4382 
4383  // set state according to input
4384  state = table[state][input];
4385 
4386  // do some actions according to state
4387  switch ( state ) {
4388  case Dq:
4389  case Sq:
4390  stringClear();
4391  next();
4392  break;
4393  case DqRef:
4394  case SqRef:
4395  parseOk = parseReference( tmp, InAttributeValue );
4396  break;
4397  case DqC:
4398  case SqC:
4399  stringAddC();
4400  next();
4401  break;
4402  case Done:
4403  next();
4404  break;
4405  }
4406  // no input is read after this
4407  switch ( state ) {
4408  case DqRef:
4409  case SqRef:
4410  if ( !parseOk ) {
4412  goto parseError;
4413  }
4414  break;
4415  case Done:
4416  return TRUE;
4417  case -1:
4418  // Error
4420  goto parseError;
4421  }
4422 
4423  }
4424 
4425  return TRUE;
4426 
4427 parseError:
4428  reportParseError();
4429  return FALSE;
4430 }
bool parseReference(bool &charDataRead, EntityRecognitionContext context)
Definition: qxml.cpp:5658
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
const bool FALSE
Definition: qglobal.h:370
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
void stringClear()
Definition: qxml.h:605
#define XMLERR_ERRORPARSINGREFERENCE
Definition: qxml.cpp:65
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
string tmp
Definition: languages.py:63
void Init(void)
Definition: gXSecComp.cxx:138
void stringAddC()
Definition: qxml.h:612
void reportParseError()
Definition: qxml.cpp:6055
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseChoiceSeq ( )
private

Parse choice [49] or seq [50].

Precondition: the beginning '('S? is already read and the head stands on the first non-whitespace character after it.

Definition at line 4786 of file qxml.cpp.

4787 {
4788  const signed char Init = 0;
4789  const signed char Ws1 = 1; // eat whitespace
4790  const signed char CS_ = 2; // choice or set
4791  const signed char Ws2 = 3; // eat whitespace
4792  const signed char More = 4; // more cp to read
4793  const signed char Name = 5; // read name
4794  const signed char Done = 6; //
4795 
4796  const signed char InpWs = 0; // S
4797  const signed char InpOp = 1; // (
4798  const signed char InpCp = 2; // )
4799  const signed char InpQm = 3; // ?
4800  const signed char InpAst = 4; // *
4801  const signed char InpPlus = 5; // +
4802  const signed char InpPipe = 6; // |
4803  const signed char InpComm = 7; // ,
4804  const signed char InpUnknown = 8;
4805 
4806  // use some kind of state machine for parsing
4807  static signed char table[6][9] = {
4808  /* InpWs InpOp InpCp InpQm InpAst InpPlus InpPipe InpComm InpUnknown */
4809  { -1, Ws1, -1, -1, -1, -1, -1, -1, Name }, // Init
4810  { -1, CS_, -1, -1, -1, -1, -1, -1, CS_ }, // Ws1
4811  { Ws2, -1, Done, Ws2, Ws2, Ws2, More, More, -1 }, // CS_
4812  { -1, -1, Done, -1, -1, -1, More, More, -1 }, // Ws2
4813  { -1, Ws1, -1, -1, -1, -1, -1, -1, Name }, // More (same as Init)
4814  { Ws2, -1, Done, Ws2, Ws2, Ws2, More, More, -1 } // Name (same as CS_)
4815  };
4816  signed char state = Init;
4817  signed char input;
4818  bool parseOk = TRUE;
4819 
4820  while ( TRUE ) {
4821 
4822  // get input
4823  if ( atEnd() ) {
4825  goto parseError;
4826  }
4827  if ( is_S(c) ) {
4828  input = InpWs;
4829  } else if ( c == '(' ) {
4830  input = InpOp;
4831  } else if ( c == ')' ) {
4832  input = InpCp;
4833  } else if ( c == '?' ) {
4834  input = InpQm;
4835  } else if ( c == '*' ) {
4836  input = InpAst;
4837  } else if ( c == '+' ) {
4838  input = InpPlus;
4839  } else if ( c == '|' ) {
4840  input = InpPipe;
4841  } else if ( c == ',' ) {
4842  input = InpComm;
4843  } else {
4844  input = InpUnknown;
4845  }
4846 
4847  // set state according to input
4848  state = table[state][input];
4849 
4850  // do some actions according to state
4851  switch ( state ) {
4852  case Ws1:
4853  next_eat_ws();
4854  break;
4855  case CS_:
4856  parseOk = parseChoiceSeq();
4857  break;
4858  case Ws2:
4859  next_eat_ws();
4860  break;
4861  case More:
4862  next_eat_ws();
4863  break;
4864  case Name:
4865  parseOk = parseName();
4866  break;
4867  case Done:
4868  next();
4869  break;
4870  }
4871  // no input is read after this
4872  switch ( state ) {
4873  case CS_:
4874  if ( !parseOk ) {
4876  goto parseError;
4877  }
4878  break;
4879  case Name:
4880  if ( !parseOk ) {
4882  goto parseError;
4883  }
4884  break;
4885  case Done:
4886  return TRUE;
4887  case -1:
4888  // Error
4890  goto parseError;
4891  }
4892 
4893  }
4894 
4895  return TRUE;
4896 
4897 parseError:
4898  reportParseError();
4899  return FALSE;
4900 }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
#define XMLERR_ERRORPARSINGCHOICE
Definition: qxml.cpp:60
const bool FALSE
Definition: qglobal.h:370
ChannelGroupService::Name Name
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
bool parseChoiceSeq()
Definition: qxml.cpp:4786
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
#define XMLERR_ERRORPARSINGNAME
Definition: qxml.cpp:56
void next_eat_ws()
Definition: qxml.h:581
void Init(void)
Definition: gXSecComp.cxx:138
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
void reportParseError()
Definition: qxml.cpp:6055
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseComment ( )
private

Parse a comment [15].

Precondition: the beginning '<!' of the comment is already read and the head stands on the first '-' of '

Definition at line 5297 of file qxml.cpp.

5298 {
5299  const signed char Init = 0;
5300  const signed char Dash1 = 1; // the first dash was read
5301  const signed char Dash2 = 2; // the second dash was read
5302  const signed char Com = 3; // read comment
5303  const signed char Com2 = 4; // read comment (help state)
5304  const signed char ComE = 5; // finished reading comment
5305  const signed char Done = 6;
5306 
5307  const signed char InpDash = 0; // -
5308  const signed char InpGt = 1; // >
5309  const signed char InpUnknown = 2;
5310 
5311  // use some kind of state machine for parsing
5312  static signed char table[6][3] = {
5313  /* InpDash InpGt InpUnknown */
5314  { Dash1, -1, -1 }, // Init
5315  { Dash2, -1, -1 }, // Dash1
5316  { Com2, Com, Com }, // Dash2
5317  { Com2, Com, Com }, // Com
5318  { ComE, Com, Com }, // Com2
5319  { -1, Done, -1 } // ComE
5320  };
5321  signed char state = Init;
5322  signed char input;
5323 
5324  while ( TRUE ) {
5325 
5326  // get input
5327  if ( atEnd() ) {
5329  goto parseError;
5330  }
5331  if ( c == '-' ) {
5332  input = InpDash;
5333  } else if ( c == '>' ) {
5334  input = InpGt;
5335  } else {
5336  input = InpUnknown;
5337  }
5338 
5339  // set state according to input
5340  state = table[state][input];
5341 
5342  // do some actions according to state
5343  switch ( state ) {
5344  case Dash1:
5345  next();
5346  break;
5347  case Dash2:
5348  next();
5349  break;
5350  case Com:
5351  stringAddC();
5352  next();
5353  break;
5354  case Com2:
5355  next();
5356  break;
5357  case ComE:
5358  next();
5359  break;
5360  case Done:
5361  next();
5362  break;
5363  }
5364  // no input is read after this
5365  switch ( state ) {
5366  case Dash2:
5367  stringClear();
5368  break;
5369  case Com2:
5370  // if next character is not a dash than don't skip it
5371  if ( c != '-' ) {
5372  stringAddC( '-' );
5373  }
5374  break;
5375  case Done:
5376  return TRUE;
5377  case -1:
5378  // Error
5380  goto parseError;
5381  }
5382 
5383  }
5384 
5385  return TRUE;
5386 
5387 parseError:
5388  reportParseError();
5389  return FALSE;
5390 }
const bool FALSE
Definition: qglobal.h:370
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
void stringClear()
Definition: qxml.h:605
#define XMLERR_ERRORPARSINGCOMMENT
Definition: qxml.cpp:74
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
void Init(void)
Definition: gXSecComp.cxx:138
void stringAddC()
Definition: qxml.h:612
void reportParseError()
Definition: qxml.cpp:6055
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseContent ( )
private

Parse a content [43].

A content is only used between tags. If a end tag is found the < is already read and the head stand on the '/' of the end tag '</name>'.

Definition at line 2635 of file qxml.cpp.

2636 {
2637  bool charDataRead = FALSE;
2638 
2639  const signed char Init = 0;
2640  const signed char ChD = 1; // CharData
2641  const signed char ChD1 = 2; // CharData help state
2642  const signed char ChD2 = 3; // CharData help state
2643  const signed char Ref = 4; // Reference
2644  const signed char Lt = 5; // '<' read
2645  const signed char PI = 6; // PI
2646  const signed char Elem = 7; // Element
2647  const signed char Em = 8; // '!' read
2648  const signed char Com = 9; // Comment
2649  const signed char CDS = 10; // CDSect
2650  const signed char CDS1 = 11; // read a CDSect
2651  const signed char CDS2 = 12; // read a CDSect (help state)
2652  const signed char CDS3 = 13; // read a CDSect (help state)
2653  const signed char Done = 14; // finished reading content
2654 
2655  const signed char InpLt = 0; // <
2656  const signed char InpGt = 1; // >
2657  const signed char InpSlash = 2; // /
2658  const signed char InpQMark = 3; // ?
2659  const signed char InpEMark = 4; // !
2660  const signed char InpAmp = 5; // &
2661  const signed char InpDash = 6; // -
2662  const signed char InpOpenB = 7; // [
2663  const signed char InpCloseB = 8; // ]
2664  const signed char InpUnknown = 9;
2665 
2666  static signed char mapCLT2FSMChar[] = {
2667  InpUnknown, // white space
2668  InpUnknown, // %
2669  InpAmp, // &
2670  InpGt, // >
2671  InpLt, // <
2672  InpSlash, // /
2673  InpQMark, // ?
2674  InpEMark, // !
2675  InpDash, // -
2676  InpCloseB, // ]
2677  InpOpenB, // [
2678  InpUnknown, // =
2679  InpUnknown, // "
2680  InpUnknown, // '
2681  InpUnknown // unknown
2682  };
2683 
2684  // use some kind of state machine for parsing
2685  static signed char const table[14][10] = {
2686  /* InpLt InpGt InpSlash InpQMark InpEMark InpAmp InpDash InpOpenB InpCloseB InpUnknown */
2687  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD1, ChD }, // Init
2688  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD1, ChD }, // ChD
2689  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD2, ChD }, // ChD1
2690  { Lt, -1, ChD, ChD, ChD, Ref, ChD, ChD, ChD2, ChD }, // ChD2
2691  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // Ref (same as Init)
2692  { -1, -1, Done, PI, Em, -1, -1, -1, -1, Elem }, // Lt
2693  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // PI (same as Init)
2694  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // Elem (same as Init)
2695  { -1, -1, -1, -1, -1, -1, Com, CDS, -1, -1 }, // Em
2696  { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, // Com (same as Init)
2697  { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS2, CDS1 }, // CDS
2698  { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS2, CDS1 }, // CDS1
2699  { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS3, CDS1 }, // CDS2
2700  { CDS1, Init, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS3, CDS1 } // CDS3
2701  };
2702  signed char state = Init;
2703  signed char input;
2704  bool parseOk = TRUE;
2705 
2706  while ( TRUE ) {
2707 
2708  // get input (use lookup-table instead of nested ifs for performance
2709  // reasons)
2710  if ( atEnd() ) {
2712  goto parseError;
2713  }
2714  if ( c.row() ) {
2715  input = InpUnknown;
2716  } else {
2717  input = mapCLT2FSMChar[ charLookupTable[ c.cell() ] ];
2718  }
2719 
2720  // set state according to input
2721  state = table[state][input];
2722 
2723  // do some actions according to state
2724  switch ( state ) {
2725  case Init:
2726  // next character
2727  next();
2728  break;
2729  case ChD:
2730  // on first call: clear string
2731  if ( !charDataRead ) {
2732  charDataRead = TRUE;
2733  stringClear();
2734  }
2735  stringAddC();
2736  next();
2737  break;
2738  case ChD1:
2739  // on first call: clear string
2740  if ( !charDataRead ) {
2741  charDataRead = TRUE;
2742  stringClear();
2743  }
2744  stringAddC();
2745  next();
2746  break;
2747  case ChD2:
2748  stringAddC();
2749  next();
2750  break;
2751  case Ref:
2752  if ( !charDataRead) {
2753  // reference may be CharData; so clear string to be safe
2754  stringClear();
2755  parseOk = parseReference( charDataRead, InContent );
2756  } else {
2757  bool tmp;
2758  parseOk = parseReference( tmp, InContent );
2759  }
2760  break;
2761  case Lt:
2762  // call the handler for CharData
2763  if ( contentHnd ) {
2764  if ( charDataRead ) {
2765  if ( d->reportWhitespaceCharData || !string().simplifyWhiteSpace().isEmpty() ) {
2766  if ( !contentHnd->characters( string() ) ) {
2767  d->error = contentHnd->errorString();
2768  goto parseError;
2769  }
2770  }
2771  }
2772  }
2773  charDataRead = FALSE;
2774  // next character
2775  next();
2776  break;
2777  case PI:
2778  parseOk = parsePI();
2779  break;
2780  case Elem:
2781  parseOk = parseElement();
2782  break;
2783  case Em:
2784  // next character
2785  next();
2786  break;
2787  case Com:
2788  parseOk = parseComment();
2789  break;
2790  case CDS:
2791  parseOk = parseString( "[CDATA[" );
2792  break;
2793  case CDS1:
2794  // read one character and add it
2795  stringAddC();
2796  next();
2797  break;
2798  case CDS2:
2799  // skip ']'
2800  next();
2801  break;
2802  case CDS3:
2803  // skip ']'...
2804  next();
2805  break;
2806  }
2807  // no input is read after this
2808  switch ( state ) {
2809  case Ref:
2810  if ( !parseOk ) {
2812  goto parseError;
2813  }
2814  break;
2815  case PI:
2816  if ( !parseOk ) {
2818  goto parseError;
2819  }
2820  // call the handler
2821  if ( contentHnd ) {
2822  if ( !contentHnd->processingInstruction(name(),string()) ) {
2823  d->error = contentHnd->errorString();
2824  goto parseError;
2825  }
2826  }
2827  break;
2828  case Elem:
2829  if ( !parseOk ) {
2831  goto parseError;
2832  }
2833  break;
2834  case Com:
2835  if ( !parseOk ) {
2837  goto parseError;
2838  }
2839  if ( lexicalHnd ) {
2840  if ( !lexicalHnd->comment( string() ) ) {
2841  d->error = lexicalHnd->errorString();
2842  goto parseError;
2843  }
2844  }
2845  break;
2846  case CDS:
2847  if( !parseOk ) {
2849  goto parseError;
2850  }
2851  // empty string
2852  stringClear();
2853  break;
2854  case CDS2:
2855  if (c != ']') {
2856  stringAddC( ']' );
2857  }
2858  break;
2859  case CDS3:
2860  // test if this skipping was legal
2861  if ( c == '>' ) {
2862  // the end of the CDSect
2863  if ( lexicalHnd ) {
2864  if ( !lexicalHnd->startCDATA() ) {
2865  d->error = lexicalHnd->errorString();
2866  goto parseError;
2867  }
2868  }
2869  if ( contentHnd ) {
2870  if ( !contentHnd->characters( string() ) ) {
2871  d->error = contentHnd->errorString();
2872  goto parseError;
2873  }
2874  }
2875  if ( lexicalHnd ) {
2876  if ( !lexicalHnd->endCDATA() ) {
2877  d->error = lexicalHnd->errorString();
2878  goto parseError;
2879  }
2880  }
2881  } else if (c == ']') {
2882  // three or more ']'
2883  stringAddC( ']' );
2884  } else {
2885  // after ']]' comes another character
2886  stringAddC( ']' );
2887  stringAddC( ']' );
2888  }
2889  break;
2890  case Done:
2891  // call the handler for CharData
2892  if ( contentHnd ) {
2893  if ( charDataRead ) {
2894  if ( d->reportWhitespaceCharData || !string().simplifyWhiteSpace().isEmpty() ) {
2895  if ( !contentHnd->characters( string() ) ) {
2896  d->error = contentHnd->errorString();
2897  goto parseError;
2898  }
2899  }
2900  }
2901  }
2902  // Done
2903  return TRUE;
2904  case -1:
2905  // Error
2907  goto parseError;
2908  }
2909 
2910  }
2911 
2912  return TRUE;
2913 
2914 parseError:
2915  reportParseError();
2916  return FALSE;
2917 }
bool parseReference(bool &charDataRead, EntityRecognitionContext context)
Definition: qxml.cpp:5658
QXmlLexicalHandler * lexicalHnd
Definition: qxml.h:273
bool parseElement()
Definition: qxml.cpp:2303
const bool FALSE
Definition: qglobal.h:370
#define XMLERR_ERRORPARSINGELEMENT
Definition: qxml.cpp:52
#define XMLERR_CDSECTHEADEREXPECTED
Definition: qxml.cpp:76
QString & name()
Definition: qxml.h:592
QXmlContentHandler * contentHnd
Definition: qxml.h:269
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
constexpr double PI
void stringClear()
Definition: qxml.h:605
uchar & cell()
Definition: qstring.h:167
#define XMLERR_ERRORPARSINGREFERENCE
Definition: qxml.cpp:65
#define XMLERR_ERRORPARSINGCOMMENT
Definition: qxml.cpp:74
static int input(void)
Definition: code.cpp:15695
#define XMLERR_ERRORPARSINGCONTENT
Definition: qxml.cpp:55
void next()
Definition: qxml.h:555
virtual bool comment(const QString &ch)=0
string tmp
Definition: languages.py:63
virtual bool processingInstruction(const QString &target, const QString &data)=0
bool parseComment()
Definition: qxml.cpp:5297
virtual bool startCDATA()=0
void Init(void)
Definition: gXSecComp.cxx:138
void stringAddC()
Definition: qxml.h:612
void reportParseError()
Definition: qxml.cpp:6055
virtual bool characters(const QString &ch)=0
virtual bool endCDATA()=0
virtual QString errorString()=0
bool parseString(const QString &s)
Definition: qxml.cpp:5964
uchar & row()
Definition: qstring.h:168
virtual QString errorString()=0
static const signed char charLookupTable[256]
Definition: qxml.cpp:108
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
#define XMLERR_ERRORPARSINGPI
Definition: qxml.cpp:66
bool parsePI(bool xmldecl=FALSE)
Definition: qxml.cpp:3042
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseDoctype ( )
private

Parse a document type definition (doctypedecl [28]).

Precondition: the beginning '<!' of the doctype is already read the head stands on the 'D' of '<!DOCTYPE'.

If this funktion was successful, the head-position is on the first character after the document type definition.

Definition at line 3264 of file qxml.cpp.

3265 {
3266  // some init-stuff
3269 
3270  const signed char Init = 0;
3271  const signed char Doctype = 1; // read the doctype
3272  const signed char Ws1 = 2; // eat_ws
3273  const signed char Doctype2 = 3; // read the doctype, part 2
3274  const signed char Ws2 = 4; // eat_ws
3275  const signed char Sys = 5; // read SYSTEM
3276  const signed char Ws3 = 6; // eat_ws
3277  const signed char MP = 7; // markupdecl or PEReference
3278  const signed char PER = 8; // PERReference
3279  const signed char Mup = 9; // markupdecl
3280  const signed char Ws4 = 10; // eat_ws
3281  const signed char MPE = 11; // end of markupdecl or PEReference
3282  const signed char Done = 12;
3283 
3284  const signed char InpWs = 0;
3285  const signed char InpD = 1; // 'D'
3286  const signed char InpS = 2; // 'S' or 'P'
3287  const signed char InpOB = 3; // [
3288  const signed char InpCB = 4; // ]
3289  const signed char InpPer = 5; // %
3290  const signed char InpGt = 6; // >
3291  const signed char InpUnknown = 7;
3292 
3293  // use some kind of state machine for parsing
3294  static signed char table[12][8] = {
3295  /* InpWs, InpD InpS InpOB InpCB InpPer InpGt InpUnknown */
3296  { -1, Doctype, -1, -1, -1, -1, -1, -1 }, // Init
3297  { Ws1, Doctype2, Doctype2, -1, -1, -1, -1, Doctype2 }, // Doctype
3298  { -1, Doctype2, Doctype2, -1, -1, -1, -1, Doctype2 }, // Ws1
3299  { Ws2, -1, Sys, MP, -1, -1, Done, -1 }, // Doctype2
3300  { -1, -1, Sys, MP, -1, -1, Done, -1 }, // Ws2
3301  { Ws3, -1, -1, MP, -1, -1, Done, -1 }, // Sys
3302  { -1, -1, -1, MP, -1, -1, Done, -1 }, // Ws3
3303  { -1, -1, -1, -1, MPE, PER, -1, Mup }, // MP
3304  { Ws4, -1, -1, -1, MPE, PER, -1, Mup }, // PER
3305  { Ws4, -1, -1, -1, MPE, PER, -1, Mup }, // Mup
3306  { -1, -1, -1, -1, MPE, PER, -1, Mup }, // Ws4
3307  { -1, -1, -1, -1, -1, -1, Done, -1 } // MPE
3308  };
3309  signed char state = Init;
3310  signed char input;
3311  bool parseOk = TRUE;
3312 
3313  while ( TRUE ) {
3314 
3315  // get input
3316  if ( atEnd() ) {
3318  goto parseError;
3319  }
3320  if ( is_S(c) ) {
3321  input = InpWs;
3322  } else if ( c == 'D' ) {
3323  input = InpD;
3324  } else if ( c == 'S' ) {
3325  input = InpS;
3326  } else if ( c == 'P' ) {
3327  input = InpS;
3328  } else if ( c == '[' ) {
3329  input = InpOB;
3330  } else if ( c == ']' ) {
3331  input = InpCB;
3332  } else if ( c == '%' ) {
3333  input = InpPer;
3334  } else if ( c == '>' ) {
3335  input = InpGt;
3336  } else {
3337  input = InpUnknown;
3338  }
3339 
3340  // set state according to input
3341  state = table[state][input];
3342 
3343  // do some actions according to state
3344  switch ( state ) {
3345  case Doctype:
3346  parseOk = parseString( "DOCTYPE" );
3347  break;
3348  case Ws1:
3349  case Ws2:
3350  case Ws3:
3351  case Ws4:
3352  eat_ws();
3353  break;
3354  case Doctype2:
3355  parseName();
3356  break;
3357  case Sys:
3358  parseOk = parseExternalID();
3359  break;
3360  case MP:
3361  next_eat_ws();
3362  break;
3363  case PER:
3364  parseOk = parsePEReference( InDTD );
3365  break;
3366  case Mup:
3367  parseOk = parseMarkupdecl();
3368  break;
3369  case MPE:
3370  next_eat_ws();
3371  break;
3372  case Done:
3373  if ( lexicalHnd ) {
3374  if ( !lexicalHnd->endDTD() ) {
3375  d->error = lexicalHnd->errorString();
3376  goto parseError;
3377  }
3378  }
3379  next();
3380  break;
3381  }
3382  // no input is read after this
3383  switch ( state ) {
3384  case Doctype:
3385  if ( !parseOk ) {
3387  goto parseError;
3388  }
3389  if ( !is_S(c) ) {
3391  goto parseError;
3392  }
3393  break;
3394  case Doctype2:
3395  d->doctype = name();
3396  if ( lexicalHnd ) {
3397  if ( !lexicalHnd->startDTD( d->doctype, d->publicId, d->systemId ) ) {
3398  d->error = lexicalHnd->errorString();
3399  goto parseError;
3400  }
3401  }
3402  break;
3403  case Sys:
3404  if ( !parseOk ) {
3406  goto parseError;
3407  }
3408  break;
3409  case PER:
3410  if ( !parseOk ) {
3412  goto parseError;
3413  }
3414  break;
3415  case Mup:
3416  if ( !parseOk ) {
3418  goto parseError;
3419  }
3420  break;
3421  case Done:
3422  return TRUE;
3423  case -1:
3424  // Error
3426  goto parseError;
3427  }
3428 
3429  }
3430 
3431  return TRUE;
3432 
3433 parseError:
3434  reportParseError();
3435  return FALSE;
3436 }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
QXmlLexicalHandler * lexicalHnd
Definition: qxml.h:273
#define XMLERR_ERRORPARSINGDOCTYPE
Definition: qxml.cpp:78
bool parseExternalID(bool allowPublicID=FALSE)
Definition: qxml.cpp:3443
const bool FALSE
Definition: qglobal.h:370
virtual bool startDTD(const QString &name, const QString &publicId, const QString &systemId)=0
QString & name()
Definition: qxml.h:592
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
void eat_ws()
Definition: qxml.h:578
bool parsePEReference(EntityRecognitionContext context)
Definition: qxml.cpp:3776
bool parseMarkupdecl()
Definition: qxml.cpp:3610
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
void next_eat_ws()
Definition: qxml.h:581
void Init(void)
Definition: gXSecComp.cxx:138
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
void reportParseError()
Definition: qxml.cpp:6055
virtual QString errorString()=0
bool parseString(const QString &s)
Definition: qxml.cpp:5964
virtual bool endDTD()=0
static const Null null
Definition: qstring.h:376
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseElement ( )
private

Parse an element [39].

Precondition: the opening '<' is already read.

Definition at line 2303 of file qxml.cpp.

2304 {
2305  static QString uri, lname, prefix;
2306  static bool t;
2307 
2308  const signed char Init = 0;
2309  const signed char ReadName = 1;
2310  const signed char Ws1 = 2;
2311  const signed char STagEnd = 3;
2312  const signed char STagEnd2 = 4;
2313  const signed char ETagBegin = 5;
2314  const signed char ETagBegin2 = 6;
2315  const signed char Ws2 = 7;
2316  const signed char EmptyTag = 8;
2317  const signed char Attribute = 9;
2318  const signed char Ws3 = 10;
2319  const signed char Done = 11;
2320 
2321  const signed char InpWs = 0; // whitespace
2322  const signed char InpNameBe = 1; // is_NameBeginning()
2323  const signed char InpGt = 2; // >
2324  const signed char InpSlash = 3; // /
2325  const signed char InpUnknown = 4;
2326 
2327  // use some kind of state machine for parsing
2328  static signed char table[11][5] = {
2329  /* InpWs InpNameBe InpGt InpSlash InpUnknown */
2330  { -1, ReadName, -1, -1, -1 }, // Init
2331  { Ws1, Attribute, STagEnd, EmptyTag, -1 }, // ReadName
2332  { -1, Attribute, STagEnd, EmptyTag, -1 }, // Ws1
2333  { STagEnd2, STagEnd2, STagEnd2, STagEnd2, STagEnd2 }, // STagEnd
2334  { -1, -1, -1, ETagBegin, -1 }, // STagEnd2
2335  { -1, ETagBegin2, -1, -1, -1 }, // ETagBegin
2336  { Ws2, -1, Done, -1, -1 }, // ETagBegin2
2337  { -1, -1, Done, -1, -1 }, // Ws2
2338  { -1, -1, Done, -1, -1 }, // EmptyTag
2339  { Ws3, Attribute, STagEnd, EmptyTag, -1 }, // Attribute
2340  { -1, Attribute, STagEnd, EmptyTag, -1 } // Ws3
2341  };
2342  signed char state = Init;
2343  signed char input;
2344  bool parseOk = TRUE;
2345 
2346  while ( TRUE ) {
2347 
2348  // read input
2349  if ( atEnd() ) {
2351  goto parseError;
2352  }
2353  if ( is_S(c) ) {
2354  input = InpWs;
2355  } else if ( is_NameBeginning(c) ) {
2356  input = InpNameBe;
2357  } else if ( c == '>' ) {
2358  input = InpGt;
2359  } else if ( c == '/' ) {
2360  input = InpSlash;
2361  } else {
2362  input = InpUnknown;
2363  }
2364  // get new state
2365 //qDebug( "%d -%d(%c)-> %d", state, input, c.latin1(), table[state][input] );
2366  state = table[state][input];
2367 
2368  // in some cases do special actions depending on state
2369  switch ( state ) {
2370  case ReadName:
2371  parseOk = parseName();
2372  break;
2373  case Ws1:
2374  case Ws2:
2375  case Ws3:
2376  eat_ws();
2377  break;
2378  case STagEnd:
2379  // call the handler
2380  if ( contentHnd ) {
2381  if ( d->useNamespaces ) {
2382  d->namespaceSupport.processName( tags.top(), FALSE, uri, lname );
2383  t = contentHnd->startElement( uri, lname, tags.top(), d->attList );
2384  } else {
2385  t = contentHnd->startElement( "", "", tags.top(), d->attList );
2386  }
2387  if ( !t ) {
2388  d->error = contentHnd->errorString();
2389  goto parseError;
2390  }
2391  }
2392  next();
2393  break;
2394  case STagEnd2:
2395  parseOk = parseContent();
2396  break;
2397  case ETagBegin:
2398  next();
2399  break;
2400  case ETagBegin2:
2401  // get the name of the tag
2402  parseOk = parseName();
2403  break;
2404  case EmptyTag:
2405  if ( tags.isEmpty() ) {
2407  goto parseError;
2408  }
2409  if ( !parseElementEmptyTag( t, uri, lname ) )
2410  goto parseError;
2411  // next character
2412  next();
2413  break;
2414  case Attribute:
2415  // get name and value of attribute
2416  parseOk = parseAttribute();
2417  break;
2418  case Done:
2419  next();
2420  break;
2421  }
2422  // no input is read after this
2423  switch ( state ) {
2424  case ReadName:
2425  if ( !parseOk ) {
2427  goto parseError;
2428  }
2429  // store it on the stack
2430  tags.push( name() );
2431  // empty the attributes
2432  d->attList.qnameList.clear();
2433  d->attList.uriList.clear();
2435  d->attList.valueList.clear();
2436  // namespace support?
2437  if ( d->useNamespaces ) {
2439  }
2440  break;
2441  case STagEnd2:
2442  if ( !parseOk ) {
2444  goto parseError;
2445  }
2446  break;
2447  case ETagBegin2:
2448  if ( !parseOk ) {
2450  goto parseError;
2451  }
2452  if ( !parseElementETagBegin2( uri, lname ) )
2453  goto parseError;
2454  break;
2455  case Attribute:
2456  if ( !parseOk ) {
2458  goto parseError;
2459  }
2460  if ( !parseElementAttribute( prefix, uri, lname ) )
2461  goto parseError;
2462  break;
2463  case Done:
2464  return TRUE;
2465  case -1:
2467  goto parseError;
2468  }
2469 
2470  }
2471 
2472  return TRUE;
2473 
2474 parseError:
2475  reportParseError();
2476  return FALSE;
2477 }
QStringList localnameList
Definition: qxml.h:150
virtual bool is_S(const QChar &)
Definition: qxml.h:530
QValueStack< QString > tags
Definition: qxml.h:295
QStringList uriList
Definition: qxml.h:149
QXmlAttributes attList
Definition: qxml.cpp:1671
void processName(const QString &, bool, QString &, QString &) const
Definition: qxml.cpp:421
bool parseElementETagBegin2(QString &uri, QString &lname)
Definition: qxml.cpp:2539
void clear()
Definition: qvaluelist.h:396
const bool FALSE
Definition: qglobal.h:370
#define XMLERR_TAGMISMATCH
Definition: qxml.cpp:48
#define XMLERR_ERRORPARSINGELEMENT
Definition: qxml.cpp:52
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)=0
bool parseAttribute()
Definition: qxml.cpp:5402
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QString & name()
Definition: qxml.h:592
QXmlContentHandler * contentHnd
Definition: qxml.h:269
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
void eat_ws()
Definition: qxml.h:578
void push(const T &d)
Definition: qvaluestack.h:52
#define XMLERR_ERRORPARSINGATTRIBUTE
Definition: qxml.cpp:58
bool parseElementAttribute(QString &prefix, QString &uri, QString &lname)
Definition: qxml.cpp:2589
static int input(void)
Definition: code.cpp:15695
#define XMLERR_ERRORPARSINGCONTENT
Definition: qxml.cpp:55
void next()
Definition: qxml.h:555
QStringList qnameList
Definition: qxml.h:148
#define XMLERR_ERRORPARSINGNAME
Definition: qxml.cpp:56
void Init(void)
Definition: gXSecComp.cxx:138
QXmlNamespaceSupport namespaceSupport
Definition: qxml.cpp:1675
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
void reportParseError()
Definition: qxml.cpp:6055
virtual QString errorString()=0
bool isEmpty() const
Definition: qvaluelist.h:368
bool parseContent()
Definition: qxml.cpp:2635
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool parseElementEmptyTag(bool &t, QString &uri, QString &lname)
Definition: qxml.cpp:2482
virtual bool is_NameBeginning(const QChar &)
Definition: qxml.h:536
QStringList valueList
Definition: qxml.h:151
void pushContext()
Definition: qxml.cpp:498
bool QXmlSimpleReader::parseElementAttribute ( QString prefix,
QString uri,
QString lname 
)
private

Helper to break down the size of the code in the case statement. Return FALSE on error, otherwise TRUE.

Definition at line 2589 of file qxml.cpp.

2590 {
2591  // add the attribute to the list
2592  if ( d->useNamespaces ) {
2593  // is it a namespace declaration?
2594  d->namespaceSupport.splitName( name(), prefix, lname );
2595  if ( prefix == "xmlns" ) {
2596  // namespace declaration
2597  d->namespaceSupport.setPrefix( lname, string() );
2598  if ( d->useNamespacePrefixes ) {
2599  d->attList.qnameList.append( name() );
2600  d->attList.uriList.append( "" );
2601  d->attList.localnameList.append( "" );
2602  d->attList.valueList.append( string() );
2603  }
2604  // call the handler for prefix mapping
2605  if ( contentHnd ) {
2606  if ( !contentHnd->startPrefixMapping( lname, string() ) ) {
2607  d->error = contentHnd->errorString();
2608  return FALSE;
2609  }
2610  }
2611  } else {
2612  // no namespace delcaration
2613  d->namespaceSupport.processName( name(), TRUE, uri, lname );
2614  d->attList.qnameList.append( name() );
2615  d->attList.uriList.append( uri );
2616  d->attList.localnameList.append( lname );
2617  d->attList.valueList.append( string() );
2618  }
2619  } else {
2620  // no namespace support
2621  d->attList.qnameList.append( name() );
2622  d->attList.uriList.append( "" );
2623  d->attList.localnameList.append( "" );
2624  d->attList.valueList.append( string() );
2625  }
2626  return TRUE;
2627 }
QStringList localnameList
Definition: qxml.h:150
Iterator append(const T &x)
Definition: qvaluelist.h:372
QStringList uriList
Definition: qxml.h:149
QXmlAttributes attList
Definition: qxml.cpp:1671
void processName(const QString &, bool, QString &, QString &) const
Definition: qxml.cpp:421
const bool FALSE
Definition: qglobal.h:370
QString & name()
Definition: qxml.h:592
QXmlContentHandler * contentHnd
Definition: qxml.h:269
void splitName(const QString &, QString &, QString &) const
Definition: qxml.cpp:387
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
QStringList qnameList
Definition: qxml.h:148
QXmlNamespaceSupport namespaceSupport
Definition: qxml.cpp:1675
virtual QString errorString()=0
void setPrefix(const QString &, const QString &)
Definition: qxml.cpp:344
virtual bool startPrefixMapping(const QString &prefix, const QString &uri)=0
const bool TRUE
Definition: qglobal.h:371
QStringList valueList
Definition: qxml.h:151
bool QXmlSimpleReader::parseElementDecl ( )
private

Parse a elementdecl [45].

Precondition: the beginning '<!E' is already read and the head stands on the 'L' of '<!ELEMENT'

Definition at line 4438 of file qxml.cpp.

4439 {
4440  const signed char Init = 0;
4441  const signed char Elem = 1; // parse the beginning string
4442  const signed char Ws1 = 2; // whitespace required
4443  const signed char Nam = 3; // parse Name
4444  const signed char Ws2 = 4; // whitespace required
4445  const signed char Empty = 5; // read EMPTY
4446  const signed char Any = 6; // read ANY
4447  const signed char Cont = 7; // read contentspec (except ANY or EMPTY)
4448  const signed char Mix = 8; // read Mixed
4449  const signed char Mix2 = 9; //
4450  const signed char Mix3 = 10; //
4451  const signed char MixN1 = 11; //
4452  const signed char MixN2 = 12; //
4453  const signed char MixN3 = 13; //
4454  const signed char MixN4 = 14; //
4455  const signed char Cp = 15; // parse cp
4456  const signed char Cp2 = 16; //
4457  const signed char WsD = 17; // eat whitespace before Done
4458  const signed char Done = 18;
4459 
4460  const signed char InpWs = 0;
4461  const signed char InpGt = 1; // >
4462  const signed char InpPipe = 2; // |
4463  const signed char InpOp = 3; // (
4464  const signed char InpCp = 4; // )
4465  const signed char InpHash = 5; // #
4466  const signed char InpQm = 6; // ?
4467  const signed char InpAst = 7; // *
4468  const signed char InpPlus = 8; // +
4469  const signed char InpA = 9; // A
4470  const signed char InpE = 10; // E
4471  const signed char InpL = 11; // L
4472  const signed char InpUnknown = 12;
4473 
4474  // use some kind of state machine for parsing
4475  static signed char table[18][13] = {
4476  /* InpWs InpGt InpPipe InpOp InpCp InpHash InpQm InpAst InpPlus InpA InpE InpL InpUnknown */
4477  { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, Elem, -1 }, // Init
4478  { Ws1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Elem
4479  { -1, -1, -1, -1, -1, -1, -1, -1, -1, Nam, Nam, Nam, Nam }, // Ws1
4480  { Ws2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Nam
4481  { -1, -1, -1, Cont, -1, -1, -1, -1, -1, Any, Empty, -1, -1 }, // Ws2
4482  { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Empty
4483  { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Any
4484  { -1, -1, -1, Cp, Cp, Mix, -1, -1, -1, Cp, Cp, Cp, Cp }, // Cont
4485  { Mix2, -1, MixN1, -1, Mix3, -1, -1, -1, -1, -1, -1, -1, -1 }, // Mix
4486  { -1, -1, MixN1, -1, Mix3, -1, -1, -1, -1, -1, -1, -1, -1 }, // Mix2
4487  { WsD, Done, -1, -1, -1, -1, -1, WsD, -1, -1, -1, -1, -1 }, // Mix3
4488  { -1, -1, -1, -1, -1, -1, -1, -1, -1, MixN2, MixN2, MixN2, MixN2 }, // MixN1
4489  { MixN3, -1, MixN1, -1, MixN4, -1, -1, -1, -1, -1, -1, -1, -1 }, // MixN2
4490  { -1, -1, MixN1, -1, MixN4, -1, -1, -1, -1, -1, -1, -1, -1 }, // MixN3
4491  { -1, -1, -1, -1, -1, -1, -1, WsD, -1, -1, -1, -1, -1 }, // MixN4
4492  { WsD, Done, -1, -1, -1, -1, Cp2, Cp2, Cp2, -1, -1, -1, -1 }, // Cp
4493  { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, // Cp2
4494  { -1, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } // WsD
4495  };
4496  signed char state = Init;
4497  signed char input;
4498  bool parseOk = TRUE;
4499 
4500  while ( TRUE ) {
4501 
4502  // read input
4503  if ( atEnd() ) {
4505  goto parseError;
4506  }
4507  if ( is_S(c) ) {
4508  input = InpWs;
4509  } else if ( c == '>' ) {
4510  input = InpGt;
4511  } else if ( c == '|' ) {
4512  input = InpPipe;
4513  } else if ( c == '(' ) {
4514  input = InpOp;
4515  } else if ( c == ')' ) {
4516  input = InpCp;
4517  } else if ( c == '#' ) {
4518  input = InpHash;
4519  } else if ( c == '?' ) {
4520  input = InpQm;
4521  } else if ( c == '*' ) {
4522  input = InpAst;
4523  } else if ( c == '+' ) {
4524  input = InpPlus;
4525  } else if ( c == 'A' ) {
4526  input = InpA;
4527  } else if ( c == 'E' ) {
4528  input = InpE;
4529  } else if ( c == 'L' ) {
4530  input = InpL;
4531  } else {
4532  input = InpUnknown;
4533  }
4534  // get new state
4535 //qDebug( "%d -%d(%c)-> %d", state, input, c.latin1(), table[state][input] );
4536  state = table[state][input];
4537 
4538  // in some cases do special actions depending on state
4539  switch ( state ) {
4540  case Elem:
4541  parseOk = parseString( "LEMENT" );
4542  break;
4543  case Ws1:
4544  eat_ws();
4545  break;
4546  case Nam:
4547  parseOk = parseName();
4548  break;
4549  case Ws2:
4550  eat_ws();
4551  break;
4552  case Empty:
4553  parseOk = parseString( "EMPTY" );
4554  break;
4555  case Any:
4556  parseOk = parseString( "ANY" );
4557  break;
4558  case Cont:
4559  next_eat_ws();
4560  break;
4561  case Mix:
4562  parseOk = parseString( "#PCDATA" );
4563  break;
4564  case Mix2:
4565  eat_ws();
4566  break;
4567  case Mix3:
4568  next();
4569  break;
4570  case MixN1:
4571  next_eat_ws();
4572  break;
4573  case MixN2:
4574  parseOk = parseName();
4575  break;
4576  case MixN3:
4577  eat_ws();
4578  break;
4579  case MixN4:
4580  next();
4581  break;
4582  case Cp:
4583  parseOk = parseChoiceSeq();
4584  break;
4585  case Cp2:
4586  next();
4587  break;
4588  case WsD:
4589  next_eat_ws();
4590  break;
4591  case Done:
4592  next();
4593  break;
4594  }
4595  // no input is read after this
4596  switch ( state ) {
4597  case Elem:
4598  if( !parseOk ) {
4600  goto parseError;
4601  }
4602  break;
4603  case Nam:
4604  if ( !parseOk ) {
4606  goto parseError;
4607  }
4608  break;
4609  case Empty:
4610  if( !parseOk ) {
4612  goto parseError;
4613  }
4614  break;
4615  case Any:
4616  if( !parseOk ) {
4618  goto parseError;
4619  }
4620  break;
4621  case Mix:
4622  if( !parseOk ) {
4624  goto parseError;
4625  }
4626  break;
4627  case MixN2:
4628  if ( !parseOk ) {
4630  goto parseError;
4631  }
4632  break;
4633  case Cp:
4634  if ( !parseOk ) {
4636  goto parseError;
4637  }
4638  break;
4639  case Done:
4640  return TRUE;
4641  case -1:
4643  goto parseError;
4644  }
4645 
4646  }
4647 
4648  return TRUE;
4649 
4650 parseError:
4651  reportParseError();
4652  return FALSE;
4653 }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
#define XMLERR_ERRORPARSINGCHOICE
Definition: qxml.cpp:60
const bool FALSE
Definition: qglobal.h:370
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
bool parseChoiceSeq()
Definition: qxml.cpp:4786
void eat_ws()
Definition: qxml.h:578
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
#define XMLERR_ERRORPARSINGNAME
Definition: qxml.cpp:56
void next_eat_ws()
Definition: qxml.h:581
void Init(void)
Definition: gXSecComp.cxx:138
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
void reportParseError()
Definition: qxml.cpp:6055
bool parseString(const QString &s)
Definition: qxml.cpp:5964
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseElementEmptyTag ( bool t,
QString uri,
QString lname 
)
private

Helper to break down the size of the code in the case statement. Return FALSE on error, otherwise TRUE.

Definition at line 2482 of file qxml.cpp.

2483 {
2484  // pop the stack and call the handler
2485  if ( contentHnd ) {
2486  // report startElement first...
2487  if ( d->useNamespaces ) {
2488  d->namespaceSupport.processName( tags.top(), FALSE, uri, lname );
2489  t = contentHnd->startElement( uri, lname, tags.top(), d->attList );
2490  } else {
2491  t = contentHnd->startElement( "", "", tags.top(), d->attList );
2492  }
2493  if ( !t ) {
2494  d->error = contentHnd->errorString();
2495  return FALSE;
2496  }
2497  // ... followed by endElement
2498  if ( d->useNamespaces ) {
2499  if ( !contentHnd->endElement( uri, lname,tags.pop() ) ) {
2500  d->error = contentHnd->errorString();
2501  return FALSE;
2502  }
2503  }
2504  else {
2505  if ( !contentHnd->endElement( "","",tags.pop() ) ) {
2506  d->error = contentHnd->errorString();
2507  return FALSE;
2508  }
2509  }
2510  // namespace support?
2511  if ( d->useNamespaces ) {
2512  QStringList prefixesBefore, prefixesAfter;
2513  if ( contentHnd ) {
2514  prefixesBefore = d->namespaceSupport.prefixes();
2515  }
2517  // call the handler for prefix mapping
2518  if ( contentHnd ) {
2519  prefixesAfter = d->namespaceSupport.prefixes();
2520  for ( QStringList::Iterator it = prefixesBefore.begin(); it != prefixesBefore.end(); ++it ) {
2521  if ( prefixesAfter.contains(*it) == 0 ) {
2522  if ( !contentHnd->endPrefixMapping( *it ) ) {
2523  d->error = contentHnd->errorString();
2524  return FALSE;
2525  }
2526  }
2527  }
2528  }
2529  }
2530  } else {
2531  tags.pop();
2532  }
2533  return TRUE;
2534 }
QValueStack< QString > tags
Definition: qxml.h:295
Iterator end()
Definition: qvaluelist.h:363
QXmlAttributes attList
Definition: qxml.cpp:1671
void processName(const QString &, bool, QString &, QString &) const
Definition: qxml.cpp:421
const bool FALSE
Definition: qglobal.h:370
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)=0
QXmlContentHandler * contentHnd
Definition: qxml.h:269
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
A list of strings.
Definition: qstringlist.h:51
QStringList prefixes() const
Definition: qxml.cpp:453
QXmlNamespaceSupport namespaceSupport
Definition: qxml.cpp:1675
uint contains(const T &x) const
Definition: qvaluelist.h:392
virtual bool endPrefixMapping(const QString &prefix)=0
Iterator begin()
Definition: qvaluelist.h:361
virtual QString errorString()=0
const bool TRUE
Definition: qglobal.h:371
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)=0
bool QXmlSimpleReader::parseElementETagBegin2 ( QString uri,
QString lname 
)
private

Helper to break down the size of the code in the case statement. Return FALSE on error, otherwise TRUE.

Definition at line 2539 of file qxml.cpp.

2540 {
2541 
2542  // pop the stack and compare it with the name
2543  if ( tags.pop() != name() ) {
2545  return FALSE;
2546  }
2547  // call the handler
2548  if ( contentHnd ) {
2549  if ( d->useNamespaces ) {
2550  d->namespaceSupport.processName( name(), FALSE, uri, lname );
2551  if ( !contentHnd->endElement(uri,lname,name()) ) {
2552  d->error = contentHnd->errorString();
2553  return FALSE;
2554  }
2555  }
2556  else {
2557  if ( !contentHnd->endElement("","",name()) ) {
2558  d->error = contentHnd->errorString();
2559  return FALSE;
2560  }
2561  }
2562  }
2563  // namespace support?
2564  if ( d->useNamespaces ) {
2565  QStringList prefixesBefore, prefixesAfter;
2566  if ( contentHnd ) {
2567  prefixesBefore = d->namespaceSupport.prefixes();
2568  }
2570  // call the handler for prefix mapping
2571  if ( contentHnd ) {
2572  prefixesAfter = d->namespaceSupport.prefixes();
2573  for ( QStringList::Iterator it = prefixesBefore.begin(); it != prefixesBefore.end(); ++it ) {
2574  if ( prefixesAfter.contains(*it) == 0 ) {
2575  if ( !contentHnd->endPrefixMapping( *it ) ) {
2576  d->error = contentHnd->errorString();
2577  return FALSE;
2578  }
2579  }
2580  }
2581  }
2582  }
2583  return TRUE;
2584 }
QValueStack< QString > tags
Definition: qxml.h:295
Iterator end()
Definition: qvaluelist.h:363
void processName(const QString &, bool, QString &, QString &) const
Definition: qxml.cpp:421
const bool FALSE
Definition: qglobal.h:370
#define XMLERR_TAGMISMATCH
Definition: qxml.cpp:48
QString & name()
Definition: qxml.h:592
QXmlContentHandler * contentHnd
Definition: qxml.h:269
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
A list of strings.
Definition: qstringlist.h:51
QStringList prefixes() const
Definition: qxml.cpp:453
QXmlNamespaceSupport namespaceSupport
Definition: qxml.cpp:1675
uint contains(const T &x) const
Definition: qvaluelist.h:392
virtual bool endPrefixMapping(const QString &prefix)=0
Iterator begin()
Definition: qvaluelist.h:361
virtual QString errorString()=0
const bool TRUE
Definition: qglobal.h:371
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)=0
bool QXmlSimpleReader::parseEntityDecl ( )
private

Parse a EntityDecl [70].

Precondition: the beginning '<!E' is already read and the head stand on the 'N' of '<!ENTITY'

Definition at line 4908 of file qxml.cpp.

4909 {
4910  const signed char Init = 0;
4911  const signed char Ent = 1; // parse "ENTITY"
4912  const signed char Ws1 = 2; // white space read
4913  const signed char Name = 3; // parse name
4914  const signed char Ws2 = 4; // white space read
4915  const signed char EValue = 5; // parse entity value
4916  const signed char ExtID = 6; // parse ExternalID
4917  const signed char Ws3 = 7; // white space read
4918  const signed char Ndata = 8; // parse "NDATA"
4919  const signed char Ws4 = 9; // white space read
4920  const signed char NNam = 10; // parse name
4921  const signed char PEDec = 11; // parse PEDecl
4922  const signed char Ws6 = 12; // white space read
4923  const signed char PENam = 13; // parse name
4924  const signed char Ws7 = 14; // white space read
4925  const signed char PEVal = 15; // parse entity value
4926  const signed char PEEID = 16; // parse ExternalID
4927  const signed char WsE = 17; // white space read
4928  const signed char EDDone = 19; // done, but also report an external, unparsed entity decl
4929  const signed char Done = 18;
4930 
4931  const signed char InpWs = 0; // white space
4932  const signed char InpPer = 1; // %
4933  const signed char InpQuot = 2; // " or '
4934  const signed char InpGt = 3; // >
4935  const signed char InpN = 4; // N
4936  const signed char InpUnknown = 5;
4937 
4938  // use some kind of state machine for parsing
4939  static signed char table[18][6] = {
4940  /* InpWs InpPer InpQuot InpGt InpN InpUnknown */
4941  { -1, -1, -1, -1, Ent, -1 }, // Init
4942  { Ws1, -1, -1, -1, -1, -1 }, // Ent
4943  { -1, PEDec, -1, -1, Name, Name }, // Ws1
4944  { Ws2, -1, -1, -1, -1, -1 }, // Name
4945  { -1, -1, EValue, -1, -1, ExtID }, // Ws2
4946  { WsE, -1, -1, Done, -1, -1 }, // EValue
4947  { Ws3, -1, -1, EDDone,-1, -1 }, // ExtID
4948  { -1, -1, -1, EDDone,Ndata, -1 }, // Ws3
4949  { Ws4, -1, -1, -1, -1, -1 }, // Ndata
4950  { -1, -1, -1, -1, NNam, NNam }, // Ws4
4951  { WsE, -1, -1, Done, -1, -1 }, // NNam
4952  { Ws6, -1, -1, -1, -1, -1 }, // PEDec
4953  { -1, -1, -1, -1, PENam, PENam }, // Ws6
4954  { Ws7, -1, -1, -1, -1, -1 }, // PENam
4955  { -1, -1, PEVal, -1, -1, PEEID }, // Ws7
4956  { WsE, -1, -1, Done, -1, -1 }, // PEVal
4957  { WsE, -1, -1, Done, -1, -1 }, // PEEID
4958  { -1, -1, -1, Done, -1, -1 } // WsE
4959  };
4960  signed char state = Init;
4961  signed char input;
4962  bool parseOk = TRUE;
4963 
4964  while ( TRUE ) {
4965 
4966  // get input
4967  if ( atEnd() ) {
4969  goto parseError;
4970  }
4971  if ( is_S(c) ) {
4972  input = InpWs;
4973  } else if ( c == '%' ) {
4974  input = InpPer;
4975  } else if ( c == '"' || c == '\'' ) {
4976  input = InpQuot;
4977  } else if ( c == '>' ) {
4978  input = InpGt;
4979  } else if ( c == 'N' ) {
4980  input = InpN;
4981  } else {
4982  input = InpUnknown;
4983  }
4984 
4985  // set state according to input
4986  state = table[state][input];
4987 
4988  // do some actions according to state
4989  switch ( state ) {
4990  case Ent:
4991  parseOk = parseString( "NTITY" );
4992  break;
4993  case Ws1:
4994  eat_ws();
4995  break;
4996  case Name:
4997  parseOk = parseName();
4998  break;
4999  case Ws2:
5000  eat_ws();
5001  break;
5002  case EValue:
5003  parseOk = parseEntityValue();
5004  break;
5005  case ExtID:
5006  parseOk = parseExternalID();
5007  break;
5008  case Ws3:
5009  eat_ws();
5010  break;
5011  case Ndata:
5012  parseOk = parseString( "NDATA" );
5013  break;
5014  case Ws4:
5015  eat_ws();
5016  break;
5017  case NNam:
5018  parseOk = parseName( TRUE );
5019  break;
5020  case PEDec:
5021  next();
5022  break;
5023  case Ws6:
5024  eat_ws();
5025  break;
5026  case PENam:
5027  parseOk = parseName();
5028  break;
5029  case Ws7:
5030  eat_ws();
5031  break;
5032  case PEVal:
5033  parseOk = parseEntityValue();
5034  break;
5035  case PEEID:
5036  parseOk = parseExternalID();
5037  break;
5038  case WsE:
5039  eat_ws();
5040  break;
5041  case EDDone:
5042  next();
5043  break;
5044  case Done:
5045  next();
5046  break;
5047  }
5048  // no input is read after this
5049  switch ( state ) {
5050  case Ent:
5051  if ( !parseOk ) {
5053  goto parseError;
5054  }
5055  break;
5056  case Name:
5057  if ( !parseOk ) {
5059  goto parseError;
5060  }
5061  break;
5062  case EValue:
5063  if ( !parseOk ) {
5065  goto parseError;
5066  }
5067  if ( !entityExist( name() ) ) {
5068  d->entities.insert( name(), string() );
5069  if ( declHnd ) {
5070  if ( !declHnd->internalEntityDecl( name(), string() ) ) {
5071  d->error = declHnd->errorString();
5072  goto parseError;
5073  }
5074  }
5075  }
5076  break;
5077  case ExtID:
5078  if ( !parseOk ) {
5080  goto parseError;
5081  }
5082  break;
5083  case Ndata:
5084  if ( !parseOk ) {
5086  goto parseError;
5087  }
5088  break;
5089  case NNam:
5090  if ( !parseOk ) {
5092  goto parseError;
5093  }
5094  if ( !entityExist( name() ) ) {
5096  if ( dtdHnd ) {
5097  if ( !dtdHnd->unparsedEntityDecl( name(), d->publicId, d->systemId, ref() ) ) {
5098  d->error = declHnd->errorString();
5099  goto parseError;
5100  }
5101  }
5102  }
5103  break;
5104  case PENam:
5105  if ( !parseOk ) {
5107  goto parseError;
5108  }
5109  break;
5110  case PEVal:
5111  if ( !parseOk ) {
5113  goto parseError;
5114  }
5115  if ( !entityExist( name() ) ) {
5116  d->parameterEntities.insert( name(), string() );
5117  if ( declHnd ) {
5118  if ( !declHnd->internalEntityDecl( QString("%")+name(), string() ) ) {
5119  d->error = declHnd->errorString();
5120  goto parseError;
5121  }
5122  }
5123  }
5124  break;
5125  case PEEID:
5126  if ( !parseOk ) {
5128  goto parseError;
5129  }
5130  if ( !entityExist( name() ) ) {
5132  if ( declHnd ) {
5133  if ( !declHnd->externalEntityDecl( QString("%")+name(), d->publicId, d->systemId ) ) {
5134  d->error = declHnd->errorString();
5135  goto parseError;
5136  }
5137  }
5138  }
5139  break;
5140  case EDDone:
5141  if ( !entityExist( name() ) ) {
5143  if ( declHnd ) {
5144  if ( !declHnd->externalEntityDecl( name(), d->publicId, d->systemId ) ) {
5145  d->error = declHnd->errorString();
5146  goto parseError;
5147  }
5148  }
5149  }
5150  return TRUE;
5151  case Done:
5152  return TRUE;
5153  case -1:
5154  // Error
5156  goto parseError;
5157  }
5158 
5159  }
5160 
5161  return TRUE;
5162 
5163 parseError:
5164  reportParseError();
5165  return FALSE;
5166 }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
QMap< QString, QString > entities
Definition: qxml.cpp:1650
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
bool parseExternalID(bool allowPublicID=FALSE)
Definition: qxml.cpp:3443
const bool FALSE
Definition: qglobal.h:370
ChannelGroupService::Name Name
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QString & name()
Definition: qxml.h:592
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
QXmlDeclHandler * declHnd
Definition: qxml.h:274
void eat_ws()
Definition: qxml.h:578
#define XMLERR_ERRORPARSINGEXTERNALID
Definition: qxml.cpp:73
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:51
virtual bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString &notationName)=0
static int input(void)
Definition: code.cpp:15695
Iterator insert(const Key &key, const T &value)
Definition: qmap.h:545
void next()
Definition: qxml.h:555
QMap< QString, ExternParameterEntity > externParameterEntities
Definition: qxml.cpp:1647
#define XMLERR_ERRORPARSINGNAME
Definition: qxml.cpp:56
bool entityExist(const QString &) const
Definition: qxml.cpp:6045
void Init(void)
Definition: gXSecComp.cxx:138
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
QMap< QString, QString > parameterEntities
Definition: qxml.cpp:1648
QString & ref()
Definition: qxml.h:598
void reportParseError()
Definition: qxml.cpp:6055
QXmlDTDHandler * dtdHnd
Definition: qxml.h:271
#define XMLERR_ERRORPARSINGENTITYVALUE
Definition: qxml.cpp:75
bool parseEntityValue()
Definition: qxml.cpp:5171
bool parseString(const QString &s)
Definition: qxml.cpp:5964
static const Null null
Definition: qstring.h:376
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
virtual QString errorString()=0
virtual bool internalEntityDecl(const QString &name, const QString &value)=0
QMap< QString, ExternEntity > externEntities
Definition: qxml.cpp:1649
const bool TRUE
Definition: qglobal.h:371
virtual bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId)=0
bool QXmlSimpleReader::parseEntityValue ( )
private

Parse a EntityValue [9]

Definition at line 5171 of file qxml.cpp.

5172 {
5173  bool tmp;
5174 
5175  const signed char Init = 0;
5176  const signed char Dq = 1; // EntityValue is double quoted
5177  const signed char DqC = 2; // signed character
5178  const signed char DqPER = 3; // PERefence
5179  const signed char DqRef = 4; // Reference
5180  const signed char Sq = 5; // EntityValue is double quoted
5181  const signed char SqC = 6; // signed character
5182  const signed char SqPER = 7; // PERefence
5183  const signed char SqRef = 8; // Reference
5184  const signed char Done = 9;
5185 
5186  const signed char InpDq = 0; // "
5187  const signed char InpSq = 1; // '
5188  const signed char InpAmp = 2; // &
5189  const signed char InpPer = 3; // %
5190  const signed char InpUnknown = 4;
5191 
5192  // use some kind of state machine for parsing
5193  static signed char table[9][5] = {
5194  /* InpDq InpSq InpAmp InpPer InpUnknown */
5195  { Dq, Sq, -1, -1, -1 }, // Init
5196  { Done, DqC, DqRef, DqPER, DqC }, // Dq
5197  { Done, DqC, DqRef, DqPER, DqC }, // DqC
5198  { Done, DqC, DqRef, DqPER, DqC }, // DqPER
5199  { Done, DqC, DqRef, DqPER, DqC }, // DqRef
5200  { SqC, Done, SqRef, SqPER, SqC }, // Sq
5201  { SqC, Done, SqRef, SqPER, SqC }, // SqC
5202  { SqC, Done, SqRef, SqPER, SqC }, // SqPER
5203  { SqC, Done, SqRef, SqPER, SqC } // SqRef
5204  };
5205  signed char state = Init;
5206  signed char input;
5207  bool parseOk = TRUE;
5208 
5209  while ( TRUE ) {
5210 
5211  // get input
5212  if ( atEnd() ) {
5214  goto parseError;
5215  }
5216  if ( c == '"' ) {
5217  input = InpDq;
5218  } else if ( c == '\'' ) {
5219  input = InpSq;
5220  } else if ( c == '&' ) {
5221  input = InpAmp;
5222  } else if ( c == '%' ) {
5223  input = InpPer;
5224  } else {
5225  input = InpUnknown;
5226  }
5227 
5228  // set state according to input
5229  state = table[state][input];
5230 
5231  // do some actions according to state
5232  switch ( state ) {
5233  case Dq:
5234  case Sq:
5235  stringClear();
5236  next();
5237  break;
5238  case DqC:
5239  case SqC:
5240  stringAddC();
5241  next();
5242  break;
5243  case DqPER:
5244  case SqPER:
5245  parseOk = parsePEReference( InEntityValue );
5246  break;
5247  case DqRef:
5248  case SqRef:
5249  parseOk = parseReference( tmp, InEntityValue );
5250  break;
5251  case Done:
5252  next();
5253  break;
5254  }
5255  // no input is read after this
5256  switch ( state ) {
5257  case DqPER:
5258  case SqPER:
5259  if ( !parseOk ) {
5261  goto parseError;
5262  }
5263  break;
5264  case DqRef:
5265  case SqRef:
5266  if ( !parseOk ) {
5268  goto parseError;
5269  }
5270  break;
5271  case Done:
5272  return TRUE;
5273  case -1:
5274  // Error
5276  goto parseError;
5277  }
5278 
5279  }
5280 
5281  return TRUE;
5282 
5283 parseError:
5284  reportParseError();
5285  return FALSE;
5286 }
bool parseReference(bool &charDataRead, EntityRecognitionContext context)
Definition: qxml.cpp:5658
#define XMLERR_ERRORPARSINGDOCTYPE
Definition: qxml.cpp:78
const bool FALSE
Definition: qglobal.h:370
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
void stringClear()
Definition: qxml.h:605
bool parsePEReference(EntityRecognitionContext context)
Definition: qxml.cpp:3776
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:51
#define XMLERR_ERRORPARSINGREFERENCE
Definition: qxml.cpp:65
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
string tmp
Definition: languages.py:63
void Init(void)
Definition: gXSecComp.cxx:138
void stringAddC()
Definition: qxml.h:612
void reportParseError()
Definition: qxml.cpp:6055
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseExternalID ( bool  allowPublicID = FALSE)
private

Parse a ExternalID [75].

If allowPublicID is TRUE parse ExternalID [75] or PublicID [83].

Definition at line 3443 of file qxml.cpp.

3444 {
3445  // some init-stuff
3448 
3449  const signed char Init = 0;
3450  const signed char Sys = 1; // parse 'SYSTEM'
3451  const signed char SysWS = 2; // parse the whitespace after 'SYSTEM'
3452  const signed char SysSQ = 3; // parse SystemLiteral with '
3453  const signed char SysSQ2 = 4; // parse SystemLiteral with '
3454  const signed char SysDQ = 5; // parse SystemLiteral with "
3455  const signed char SysDQ2 = 6; // parse SystemLiteral with "
3456  const signed char Pub = 7; // parse 'PUBLIC'
3457  const signed char PubWS = 8; // parse the whitespace after 'PUBLIC'
3458  const signed char PubSQ = 9; // parse PubidLiteral with '
3459  const signed char PubSQ2 = 10; // parse PubidLiteral with '
3460  const signed char PubDQ = 11; // parse PubidLiteral with "
3461  const signed char PubDQ2 = 12; // parse PubidLiteral with "
3462  const signed char PubE = 13; // finished parsing the PubidLiteral
3463  const signed char PubWS2 = 14; // parse the whitespace after the PubidLiteral
3464  const signed char PDone = 15; // done if allowPublicID is TRUE
3465  const signed char Done = 16;
3466 
3467  const signed char InpSQ = 0; // '
3468  const signed char InpDQ = 1; // "
3469  const signed char InpS = 2; // S
3470  const signed char InpP = 3; // P
3471  const signed char InpWs = 4; // white space
3472  const signed char InpUnknown = 5;
3473 
3474  // use some kind of state machine for parsing
3475  static signed char table[15][6] = {
3476  /* InpSQ InpDQ InpS InpP InpWs InpUnknown */
3477  { -1, -1, Sys, Pub, -1, -1 }, // Init
3478  { -1, -1, -1, -1, SysWS, -1 }, // Sys
3479  { SysSQ, SysDQ, -1, -1, -1, -1 }, // SysWS
3480  { Done, SysSQ2, SysSQ2, SysSQ2, SysSQ2, SysSQ2 }, // SysSQ
3481  { Done, SysSQ2, SysSQ2, SysSQ2, SysSQ2, SysSQ2 }, // SysSQ2
3482  { SysDQ2, Done, SysDQ2, SysDQ2, SysDQ2, SysDQ2 }, // SysDQ
3483  { SysDQ2, Done, SysDQ2, SysDQ2, SysDQ2, SysDQ2 }, // SysDQ2
3484  { -1, -1, -1, -1, PubWS, -1 }, // Pub
3485  { PubSQ, PubDQ, -1, -1, -1, -1 }, // PubWS
3486  { PubE, -1, PubSQ2, PubSQ2, PubSQ2, PubSQ2 }, // PubSQ
3487  { PubE, -1, PubSQ2, PubSQ2, PubSQ2, PubSQ2 }, // PubSQ2
3488  { -1, PubE, PubDQ2, PubDQ2, PubDQ2, PubDQ2 }, // PubDQ
3489  { -1, PubE, PubDQ2, PubDQ2, PubDQ2, PubDQ2 }, // PubDQ2
3490  { PDone, PDone, PDone, PDone, PubWS2, PDone }, // PubE
3491  { SysSQ, SysDQ, PDone, PDone, PDone, PDone } // PubWS2
3492  };
3493  signed char state = Init;
3494  signed char input;
3495  bool parseOk = TRUE;
3496 
3497  while ( TRUE ) {
3498 
3499  // get input
3500  if ( atEnd() ) {
3502  goto parseError;
3503  }
3504  if ( is_S(c) ) {
3505  input = InpWs;
3506  } else if ( c == '\'' ) {
3507  input = InpSQ;
3508  } else if ( c == '"' ) {
3509  input = InpDQ;
3510  } else if ( c == 'S' ) {
3511  input = InpS;
3512  } else if ( c == 'P' ) {
3513  input = InpP;
3514  } else {
3515  input = InpUnknown;
3516  }
3517 
3518  // set state according to input
3519  state = table[state][input];
3520 
3521  // do some actions according to state
3522  switch ( state ) {
3523  case Sys:
3524  parseOk = parseString( "SYSTEM" );
3525  break;
3526  case SysWS:
3527  eat_ws();
3528  break;
3529  case SysSQ:
3530  case SysDQ:
3531  stringClear();
3532  next();
3533  break;
3534  case SysSQ2:
3535  case SysDQ2:
3536  stringAddC();
3537  next();
3538  break;
3539  case Pub:
3540  parseOk = parseString( "PUBLIC" );
3541  break;
3542  case PubWS:
3543  eat_ws();
3544  break;
3545  case PubSQ:
3546  case PubDQ:
3547  stringClear();
3548  next();
3549  break;
3550  case PubSQ2:
3551  case PubDQ2:
3552  stringAddC();
3553  next();
3554  break;
3555  case PubE:
3556  next();
3557  break;
3558  case PubWS2:
3559  d->publicId = string();
3560  eat_ws();
3561  break;
3562  case Done:
3563  d->systemId = string();
3564  next();
3565  break;
3566  }
3567  // no input is read after this
3568  switch ( state ) {
3569  case Sys:
3570  if( !parseOk ) {
3572  goto parseError;
3573  }
3574  break;
3575  case Pub:
3576  if( !parseOk ) {
3578  goto parseError;
3579  }
3580  break;
3581  case PDone:
3582  if ( allowPublicID ) {
3583  d->publicId = string();
3584  return TRUE;
3585  } else {
3587  goto parseError;
3588  }
3589  break;
3590  case Done:
3591  return TRUE;
3592  case -1:
3593  // Error
3595  goto parseError;
3596  }
3597 
3598  }
3599 
3600  return TRUE;
3601 
3602 parseError:
3603  reportParseError();
3604  return FALSE;
3605 }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
const bool FALSE
Definition: qglobal.h:370
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
void eat_ws()
Definition: qxml.h:578
void stringClear()
Definition: qxml.h:605
QString & string()
Definition: qxml.h:586
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
void Init(void)
Definition: gXSecComp.cxx:138
void stringAddC()
Definition: qxml.h:612
void reportParseError()
Definition: qxml.cpp:6055
bool parseString(const QString &s)
Definition: qxml.cpp:5964
static const Null null
Definition: qstring.h:376
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseMarkupdecl ( )
private

Parse a markupdecl [29].

Definition at line 3610 of file qxml.cpp.

3611 {
3612  const signed char Init = 0;
3613  const signed char Lt = 1; // < was read
3614  const signed char Em = 2; // ! was read
3615  const signed char CE = 3; // E was read
3616  const signed char Qm = 4; // ? was read
3617  const signed char Dash = 5; // - was read
3618  const signed char CA = 6; // A was read
3619  const signed char CEL = 7; // EL was read
3620  const signed char CEN = 8; // EN was read
3621  const signed char CN = 9; // N was read
3622  const signed char Done = 10;
3623 
3624  const signed char InpLt = 0; // <
3625  const signed char InpQm = 1; // ?
3626  const signed char InpEm = 2; // !
3627  const signed char InpDash = 3; // -
3628  const signed char InpA = 4; // A
3629  const signed char InpE = 5; // E
3630  const signed char InpL = 6; // L
3631  const signed char InpN = 7; // N
3632  const signed char InpUnknown = 8;
3633 
3634  // use some kind of state machine for parsing
3635  static signed char table[4][9] = {
3636  /* InpLt InpQm InpEm InpDash InpA InpE InpL InpN InpUnknown */
3637  { Lt, -1, -1, -1, -1, -1, -1, -1, -1 }, // Init
3638  { -1, Qm, Em, -1, -1, -1, -1, -1, -1 }, // Lt
3639  { -1, -1, -1, Dash, CA, CE, -1, CN, -1 }, // Em
3640  { -1, -1, -1, -1, -1, -1, CEL, CEN, -1 } // CE
3641  };
3642  signed char state = Init;
3643  signed char input;
3644  bool parseOk = TRUE;
3645 
3646  while ( TRUE ) {
3647 
3648  // get input
3649  if ( atEnd() ) {
3651  goto parseError;
3652  }
3653  if ( c == '<' ) {
3654  input = InpLt;
3655  } else if ( c == '?' ) {
3656  input = InpQm;
3657  } else if ( c == '!' ) {
3658  input = InpEm;
3659  } else if ( c == '-' ) {
3660  input = InpDash;
3661  } else if ( c == 'A' ) {
3662  input = InpA;
3663  } else if ( c == 'E' ) {
3664  input = InpE;
3665  } else if ( c == 'L' ) {
3666  input = InpL;
3667  } else if ( c == 'N' ) {
3668  input = InpN;
3669  } else {
3670  input = InpUnknown;
3671  }
3672 
3673  // set state according to input
3674  state = table[state][input];
3675 
3676  // do some actions according to state
3677  switch ( state ) {
3678  case Lt:
3679  next();
3680  break;
3681  case Em:
3682  next();
3683  break;
3684  case CE:
3685  next();
3686  break;
3687  case Qm:
3688  parseOk = parsePI();
3689  break;
3690  case Dash:
3691  parseOk = parseComment();
3692  break;
3693  case CA:
3694  parseOk = parseAttlistDecl();
3695  break;
3696  case CEL:
3697  parseOk = parseElementDecl();
3698  break;
3699  case CEN:
3700  parseOk = parseEntityDecl();
3701  break;
3702  case CN:
3703  parseOk = parseNotationDecl();
3704  break;
3705  }
3706  // no input is read after this
3707  switch ( state ) {
3708  case Qm:
3709  if ( !parseOk ) {
3711  goto parseError;
3712  }
3713  if ( contentHnd ) {
3714  if ( !contentHnd->processingInstruction(name(),string()) ) {
3715  d->error = contentHnd->errorString();
3716  goto parseError;
3717  }
3718  }
3719  return TRUE;
3720  case Dash:
3721  if ( !parseOk ) {
3723  goto parseError;
3724  }
3725  if ( lexicalHnd ) {
3726  if ( !lexicalHnd->comment( string() ) ) {
3727  d->error = lexicalHnd->errorString();
3728  goto parseError;
3729  }
3730  }
3731  return TRUE;
3732  case CA:
3733  if ( !parseOk ) {
3735  goto parseError;
3736  }
3737  return TRUE;
3738  case CEL:
3739  if ( !parseOk ) {
3741  goto parseError;
3742  }
3743  return TRUE;
3744  case CEN:
3745  if ( !parseOk ) {
3747  goto parseError;
3748  }
3749  return TRUE;
3750  case CN:
3751  if ( !parseOk ) {
3753  goto parseError;
3754  }
3755  return TRUE;
3756  case Done:
3757  return TRUE;
3758  case -1:
3759  // Error
3761  goto parseError;
3762  }
3763 
3764  }
3765 
3766  return TRUE;
3767 
3768 parseError:
3769  reportParseError();
3770  return FALSE;
3771 }
QXmlLexicalHandler * lexicalHnd
Definition: qxml.h:273
#define XMLERR_ERRORPARSINGENTITYDECL
Definition: qxml.cpp:71
#define XMLERR_ERRORPARSINGNOTATIONDECL
Definition: qxml.cpp:72
const bool FALSE
Definition: qglobal.h:370
bool parseNotationDecl()
Definition: qxml.cpp:4661
QString & name()
Definition: qxml.h:592
QXmlContentHandler * contentHnd
Definition: qxml.h:269
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
bool parseEntityDecl()
Definition: qxml.cpp:4908
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:51
bool parseElementDecl()
Definition: qxml.cpp:4438
#define XMLERR_ERRORPARSINGCOMMENT
Definition: qxml.cpp:74
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
virtual bool comment(const QString &ch)=0
virtual bool processingInstruction(const QString &target, const QString &data)=0
#define XMLERR_ERRORPARSINGATTLISTDECL
Definition: qxml.cpp:67
bool parseComment()
Definition: qxml.cpp:5297
void Init(void)
Definition: gXSecComp.cxx:138
void reportParseError()
Definition: qxml.cpp:6055
bool parseAttlistDecl()
Definition: qxml.cpp:3880
virtual QString errorString()=0
virtual QString errorString()=0
#define XMLERR_ERRORPARSINGELEMENTDECL
Definition: qxml.cpp:70
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
#define XMLERR_ERRORPARSINGPI
Definition: qxml.cpp:66
bool parsePI(bool xmldecl=FALSE)
Definition: qxml.cpp:3042
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseMisc ( )
private

Parse Misc [27].

Definition at line 2922 of file qxml.cpp.

2923 {
2924  const signed char Init = 0;
2925  const signed char Lt = 1; // '<' was read
2926  const signed char Comment = 2; // read comment
2927  const signed char eatWS = 3; // eat whitespaces
2928  const signed char PI = 4; // read PI
2929  const signed char Comment2 = 5; // read comment
2930 
2931  const signed char InpWs = 0; // S
2932  const signed char InpLt = 1; // <
2933  const signed char InpQm = 2; // ?
2934  const signed char InpEm = 3; // !
2935  const signed char InpUnknown = 4;
2936 
2937  // use some kind of state machine for parsing
2938  static signed char table[3][5] = {
2939  /* InpWs InpLt InpQm InpEm InpUnknown */
2940  { eatWS, Lt, -1, -1, -1 }, // Init
2941  { -1, -1, PI, Comment, -1 }, // Lt
2942  { -1, -1, -1, -1, Comment2 } // Comment
2943  };
2944  signed char state = Init;
2945  signed char input;
2946  bool parseOk = TRUE;
2947 
2948  while ( TRUE ) {
2949 
2950  // get input
2951  if ( atEnd() ) {
2953  goto parseError;
2954  }
2955  if ( is_S(c) ) {
2956  input = InpWs;
2957  } else if ( c == '<' ) {
2958  input = InpLt;
2959  } else if ( c == '?' ) {
2960  input = InpQm;
2961  } else if ( c == '!' ) {
2962  input = InpEm;
2963  } else {
2964  input = InpUnknown;
2965  }
2966 
2967  // set state according to input
2968  state = table[state][input];
2969 
2970  // do some actions according to state
2971  switch ( state ) {
2972  case eatWS:
2973  eat_ws();
2974  break;
2975  case Lt:
2976  next();
2977  break;
2978  case PI:
2979  parseOk = parsePI();
2980  break;
2981  case Comment:
2982  next();
2983  break;
2984  case Comment2:
2985  parseOk = parseComment();
2986  break;
2987  }
2988  // no input is read after this
2989  switch ( state ) {
2990  case eatWS:
2991  return TRUE;
2992  case PI:
2993  if ( !parseOk ) {
2995  goto parseError;
2996  }
2997  if ( contentHnd ) {
2998  if ( !contentHnd->processingInstruction(name(),string()) ) {
2999  d->error = contentHnd->errorString();
3000  goto parseError;
3001  }
3002  }
3003  return TRUE;
3004  case Comment2:
3005  if ( !parseOk ) {
3007  goto parseError;
3008  }
3009  if ( lexicalHnd ) {
3010  if ( !lexicalHnd->comment( string() ) ) {
3011  d->error = lexicalHnd->errorString();
3012  goto parseError;
3013  }
3014  }
3015  return TRUE;
3016  case -1:
3017  // Error
3019  goto parseError;
3020  }
3021 
3022  }
3023 
3024  return TRUE;
3025 
3026 parseError:
3027  reportParseError();
3028  return FALSE;
3029 }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
QXmlLexicalHandler * lexicalHnd
Definition: qxml.h:273
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
const bool FALSE
Definition: qglobal.h:370
QString & name()
Definition: qxml.h:592
QXmlContentHandler * contentHnd
Definition: qxml.h:269
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
constexpr double PI
void eat_ws()
Definition: qxml.h:578
#define XMLERR_ERRORPARSINGCOMMENT
Definition: qxml.cpp:74
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
virtual bool comment(const QString &ch)=0
virtual bool processingInstruction(const QString &target, const QString &data)=0
bool parseComment()
Definition: qxml.cpp:5297
void Init(void)
Definition: gXSecComp.cxx:138
void reportParseError()
Definition: qxml.cpp:6055
#define Comment
virtual QString errorString()=0
virtual QString errorString()=0
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
#define XMLERR_ERRORPARSINGPI
Definition: qxml.cpp:66
bool parsePI(bool xmldecl=FALSE)
Definition: qxml.cpp:3042
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseName ( bool  useRef = FALSE)
private

Parse a Name [5] and store the name in name or ref (if useRef is TRUE).

Definition at line 5498 of file qxml.cpp.

5499 {
5500  const signed char Init = 0;
5501  const signed char Name1 = 1; // parse first signed character of the name
5502  const signed char Name = 2; // parse name
5503  const signed char Done = 3;
5504 
5505  const signed char InpNameBe = 0; // name beginning signed characters
5506  const signed char InpNameCh = 1; // NameChar without InpNameBe
5507  const signed char InpUnknown = 2;
5508 
5509  // use some kind of state machine for parsing
5510  static signed char table[3][3] = {
5511  /* InpNameBe InpNameCh InpUnknown */
5512  { Name1, -1, -1 }, // Init
5513  { Name, Name, Done }, // Name1
5514  { Name, Name, Done } // Name
5515  };
5516  signed char state = Init;
5517  signed char input;
5518 
5519  while ( TRUE ) {
5520 
5521  // get input
5522  if ( atEnd() ) {
5524  goto parseError;
5525  }
5526  if ( is_NameBeginning(c) ) {
5527  input = InpNameBe;
5528  } else if ( is_NameChar(c) ) {
5529  input = InpNameCh;
5530  } else {
5531  input = InpUnknown;
5532  }
5533 
5534  // set state according to input
5535  state = table[state][input];
5536 
5537  // do some actions according to state
5538  switch ( state ) {
5539  case Name1:
5540  if ( useRef ) {
5541  refClear();
5542  refAddC();
5543  } else {
5544  nameClear();
5545  nameAddC();
5546  }
5547  next();
5548  break;
5549  case Name:
5550  if ( useRef ) {
5551  refAddC();
5552  } else {
5553  nameAddC();
5554  }
5555  next();
5556  break;
5557  }
5558  // no input is read after this
5559  switch ( state ) {
5560  case Done:
5561  return TRUE;
5562  case -1:
5563  // Error
5565  goto parseError;
5566  }
5567 
5568  }
5569 
5570  return TRUE;
5571 
5572 parseError:
5573  reportParseError();
5574  return FALSE;
5575 }
void nameClear()
Definition: qxml.h:607
const bool FALSE
Definition: qglobal.h:370
ChannelGroupService::Name Name
void nameAddC()
Definition: qxml.h:620
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
void refAddC()
Definition: qxml.h:628
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:51
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
void Init(void)
Definition: gXSecComp.cxx:138
void reportParseError()
Definition: qxml.cpp:6055
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
virtual bool is_NameChar(const QChar &)
Definition: qxml.h:548
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
void refClear()
Definition: qxml.h:609
virtual bool is_NameBeginning(const QChar &)
Definition: qxml.h:536
bool QXmlSimpleReader::parseNmtoken ( )
private

Parse a Nmtoken [7] and store the name in name.

Definition at line 5580 of file qxml.cpp.

5581 {
5582  const signed char Init = 0;
5583  const signed char NameF = 1;
5584  const signed char Name = 2;
5585  const signed char Done = 3;
5586 
5587  const signed char InpNameCh = 0; // NameChar without InpNameBe
5588  const signed char InpUnknown = 1;
5589 
5590  // use some kind of state machine for parsing
5591  static signed char table[3][2] = {
5592  /* InpNameCh InpUnknown */
5593  { NameF, -1 }, // Init
5594  { Name, Done }, // NameF
5595  { Name, Done } // Name
5596  };
5597  signed char state = Init;
5598  signed char input;
5599 
5600  while ( TRUE ) {
5601 
5602  // get input
5603  if ( atEnd() ) {
5605  goto parseError;
5606  }
5607  if ( is_NameChar(c) ) {
5608  input = InpNameCh;
5609  } else {
5610  input = InpUnknown;
5611  }
5612 
5613  // set state according to input
5614  state = table[state][input];
5615 
5616  // do some actions according to state
5617  switch ( state ) {
5618  case NameF:
5619  nameClear();
5620  nameAddC();
5621  next();
5622  break;
5623  case Name:
5624  nameAddC();
5625  next();
5626  break;
5627  }
5628  // no input is read after this
5629  switch ( state ) {
5630  case Done:
5631  return TRUE;
5632  case -1:
5633  // Error
5635  goto parseError;
5636  }
5637 
5638  }
5639 
5640  return TRUE;
5641 
5642 parseError:
5643  reportParseError();
5644  return FALSE;
5645 }
void nameClear()
Definition: qxml.h:607
const bool FALSE
Definition: qglobal.h:370
ChannelGroupService::Name Name
void nameAddC()
Definition: qxml.h:620
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:51
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
void Init(void)
Definition: gXSecComp.cxx:138
void reportParseError()
Definition: qxml.cpp:6055
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
virtual bool is_NameChar(const QChar &)
Definition: qxml.h:548
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseNotationDecl ( )
private

Parse a NotationDecl [82].

Precondition: the beginning '<!' is already read and the head stands on the 'N' of '<!NOTATION'

Definition at line 4661 of file qxml.cpp.

4662 {
4663  const signed char Init = 0;
4664  const signed char Not = 1; // read NOTATION
4665  const signed char Ws1 = 2; // eat whitespaces
4666  const signed char Nam = 3; // read Name
4667  const signed char Ws2 = 4; // eat whitespaces
4668  const signed char ExtID = 5; // parse ExternalID
4669  const signed char Ws3 = 6; // eat whitespaces
4670  const signed char Done = 7;
4671 
4672  const signed char InpWs = 0;
4673  const signed char InpGt = 1; // >
4674  const signed char InpN = 2; // N
4675  const signed char InpUnknown = 3;
4676 
4677  // use some kind of state machine for parsing
4678  static signed char table[7][4] = {
4679  /* InpWs InpGt InpN InpUnknown */
4680  { -1, -1, Not, -1 }, // Init
4681  { Ws1, -1, -1, -1 }, // Not
4682  { -1, -1, Nam, Nam }, // Ws1
4683  { Ws2, Done, -1, -1 }, // Nam
4684  { -1, Done, ExtID, ExtID }, // Ws2
4685  { Ws3, Done, -1, -1 }, // ExtID
4686  { -1, Done, -1, -1 } // Ws3
4687  };
4688  signed char state = Init;
4689  signed char input;
4690  bool parseOk = TRUE;
4691 
4692  while ( TRUE ) {
4693 
4694  // get input
4695  if ( atEnd() ) {
4697  goto parseError;
4698  }
4699  if ( is_S(c) ) {
4700  input = InpWs;
4701  } else if ( c == '>' ) {
4702  input = InpGt;
4703  } else if ( c == 'N' ) {
4704  input = InpN;
4705  } else {
4706  input = InpUnknown;
4707  }
4708 
4709  // set state according to input
4710  state = table[state][input];
4711 
4712  // do some actions according to state
4713  switch ( state ) {
4714  case Not:
4715  parseOk = parseString( "NOTATION" );
4716  break;
4717  case Ws1:
4718  eat_ws();
4719  break;
4720  case Nam:
4721  parseOk = parseName();
4722  break;
4723  case Ws2:
4724  eat_ws();
4725  break;
4726  case ExtID:
4727  parseOk = parseExternalID( TRUE );
4728  break;
4729  case Ws3:
4730  eat_ws();
4731  break;
4732  case Done:
4733  next();
4734  break;
4735  }
4736  // no input is read after this
4737  switch ( state ) {
4738  case Not:
4739  if ( !parseOk ) {
4741  goto parseError;
4742  }
4743  break;
4744  case Nam:
4745  if ( !parseOk ) {
4747  goto parseError;
4748  }
4749  break;
4750  case ExtID:
4751  if ( !parseOk ) {
4753  goto parseError;
4754  }
4755  // call the handler
4756  if ( dtdHnd ) {
4757  if ( !dtdHnd->notationDecl( name(), d->publicId, d->systemId ) ) {
4758  d->error = dtdHnd->errorString();
4759  goto parseError;
4760  }
4761  }
4762  break;
4763  case Done:
4764  return TRUE;
4765  case -1:
4766  // Error
4768  goto parseError;
4769  }
4770 
4771  }
4772 
4773  return TRUE;
4774 
4775 parseError:
4776  reportParseError();
4777  return FALSE;
4778 }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
virtual QString errorString()=0
bool parseExternalID(bool allowPublicID=FALSE)
Definition: qxml.cpp:3443
const bool FALSE
Definition: qglobal.h:370
QString & name()
Definition: qxml.h:592
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
void eat_ws()
Definition: qxml.h:578
#define XMLERR_ERRORPARSINGEXTERNALID
Definition: qxml.cpp:73
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
#define XMLERR_ERRORPARSINGNAME
Definition: qxml.cpp:56
virtual bool notationDecl(const QString &name, const QString &publicId, const QString &systemId)=0
void Init(void)
Definition: gXSecComp.cxx:138
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
void reportParseError()
Definition: qxml.cpp:6055
QXmlDTDHandler * dtdHnd
Definition: qxml.h:271
bool parseString(const QString &s)
Definition: qxml.cpp:5964
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parsePEReference ( EntityRecognitionContext  context)
private

Parse a PEReference [69]

Definition at line 3776 of file qxml.cpp.

3777 {
3778  const signed char Init = 0;
3779  const signed char Next = 1;
3780  const signed char Name = 2;
3781  const signed char Done = 3;
3782 
3783  const signed char InpSemi = 0; // ;
3784  const signed char InpPer = 1; // %
3785  const signed char InpUnknown = 2;
3786 
3787  // use some kind of state machine for parsing
3788  static signed char table[3][3] = {
3789  /* InpSemi InpPer InpUnknown */
3790  { -1, Next, -1 }, // Init
3791  { -1, -1, Name }, // Next
3792  { Done, -1, -1 } // Name
3793  };
3794  signed char state = Init;
3795  signed char input;
3796  bool parseOk = TRUE;
3797 
3798  while ( TRUE ) {
3799 
3800  // get input
3801  if ( atEnd() ) {
3803  goto parseError;
3804  }
3805  if ( c == ';' ) {
3806  input = InpSemi;
3807  } else if ( c == '%' ) {
3808  input = InpPer;
3809  } else {
3810  input = InpUnknown;
3811  }
3812 
3813  // set state according to input
3814  state = table[state][input];
3815 
3816  // do some actions according to state
3817  switch ( state ) {
3818  case Next:
3819  next();
3820  break;
3821  case Name:
3822  parseOk = parseName( TRUE );
3823  break;
3824  case Done:
3825  next();
3826  break;
3827  }
3828  // no input is read after this
3829  switch ( state ) {
3830  case Name:
3831  if ( !parseOk ) {
3833  goto parseError;
3834  }
3835  if ( d->parameterEntities.find( ref() ) == d->parameterEntities.end() ) {
3836  // ### skip it???
3837  if ( contentHnd ) {
3838  if ( !contentHnd->skippedEntity( QString("%") + ref() ) ) {
3839  d->error = contentHnd->errorString();
3840  goto parseError;
3841  }
3842  }
3843  } else {
3844  if ( context == InEntityValue ) {
3845  // Included in literal
3847  .data().replace( QRegExp("\""), "&quot;" ).replace( QRegExp("'"), "&apos;" )
3848  + xmlRef;
3849  } else if ( context == InDTD ) {
3850  // Included as PE
3851  xmlRef = QString(" ") +
3852  d->parameterEntities.find( ref() ).data() +
3853  QString(" ") + xmlRef;
3854  }
3855  }
3856  break;
3857  case Done:
3858  return TRUE;
3859  case -1:
3860  // Error
3862  goto parseError;
3863  }
3864 
3865  }
3866 
3867  return TRUE;
3868 
3869 parseError:
3870  reportParseError();
3871  return FALSE;
3872 }
virtual bool skippedEntity(const QString &name)=0
The QRegExp class provides pattern matching using regular expressions or wildcards.
Definition: qregexp.h:46
Iterator end()
Definition: qmap.h:523
const bool FALSE
Definition: qglobal.h:370
ChannelGroupService::Name Name
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QXmlContentHandler * contentHnd
Definition: qxml.h:269
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
T & data()
Definition: qmap.h:115
#define XMLERR_LETTEREXPECTED
Definition: qxml.cpp:51
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
QString xmlRef
Definition: qxml.h:293
#define XMLERR_ERRORPARSINGNAME
Definition: qxml.cpp:56
Iterator find(const Key &k)
Definition: qmap.h:527
void Init(void)
Definition: gXSecComp.cxx:138
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
QMap< QString, QString > parameterEntities
Definition: qxml.cpp:1648
QString & ref()
Definition: qxml.h:598
void reportParseError()
Definition: qxml.cpp:6055
virtual QString errorString()=0
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parsePI ( bool  xmldecl = FALSE)
private

Parse a processing instruction [16].

If xmldec is TRUE, it tries to parse a PI or a XML declaration [23].

Precondition: the beginning '<' of the PI is already read and the head stand on the '?' of '<?'.

If this funktion was successful, the head-position is on the first character after the PI.

Definition at line 3042 of file qxml.cpp.

3043 {
3044  const signed char Init = 0;
3045  const signed char QmI = 1; // ? was read
3046  const signed char Name = 2; // read Name
3047  const signed char XMLDecl = 3; // read XMLDecl
3048  const signed char Ws1 = 4; // eat ws after "xml" of XMLDecl
3049  const signed char PI = 5; // read PI
3050  const signed char Ws2 = 6; // eat ws after Name of PI
3051  const signed char Version = 7; // read versionInfo
3052  const signed char Ws3 = 8; // eat ws after versionInfo
3053  const signed char EorSD = 9; // read EDecl or SDDecl
3054  const signed char Ws4 = 10; // eat ws after EDecl or SDDecl
3055  const signed char SD = 11; // read SDDecl
3056  const signed char Ws5 = 12; // eat ws after SDDecl
3057  const signed char ADone = 13; // almost done
3058  const signed char Char = 14; // Char was read
3059  const signed char Qm = 15; // Qm was read
3060  const signed char Done = 16; // finished reading content
3061 
3062  const signed char InpWs = 0; // whitespace
3063  const signed char InpNameBe = 1; // is_nameBeginning()
3064  const signed char InpGt = 2; // >
3065  const signed char InpQm = 3; // ?
3066  const signed char InpUnknown = 4;
3067 
3068  // use some kind of state machine for parsing
3069  static signed char table[16][5] = {
3070  /* InpWs, InpNameBe InpGt InpQm InpUnknown */
3071  { -1, -1, -1, QmI, -1 }, // Init
3072  { -1, Name, -1, -1, -1 }, // QmI
3073  { -1, -1, -1, -1, -1 }, // Name (this state is left not through input)
3074  { Ws1, -1, -1, -1, -1 }, // XMLDecl
3075  { -1, Version, -1, -1, -1 }, // Ws1
3076  { Ws2, -1, -1, Qm, -1 }, // PI
3077  { Char, Char, Char, Qm, Char }, // Ws2
3078  { Ws3, -1, -1, ADone, -1 }, // Version
3079  { -1, EorSD, -1, ADone, -1 }, // Ws3
3080  { Ws4, -1, -1, ADone, -1 }, // EorSD
3081  { -1, SD, -1, ADone, -1 }, // Ws4
3082  { Ws5, -1, -1, ADone, -1 }, // SD
3083  { -1, -1, -1, ADone, -1 }, // Ws5
3084  { -1, -1, Done, -1, -1 }, // ADone
3085  { Char, Char, Char, Qm, Char }, // Char
3086  { Char, Char, Done, Qm, Char }, // Qm
3087  };
3088  signed char state = Init;
3089  signed char input;
3090  bool parseOk = TRUE;
3091 
3092  while ( TRUE ) {
3093 
3094  // get input
3095  if ( atEnd() ) {
3097  goto parseError;
3098  }
3099  if ( is_S(c) ) {
3100  input = InpWs;
3101  } else if ( is_NameBeginning(c) ) {
3102  input = InpNameBe;
3103  } else if ( c == '>' ) {
3104  input = InpGt;
3105  } else if ( c == '?' ) {
3106  input = InpQm;
3107  } else {
3108  input = InpUnknown;
3109  }
3110 
3111  // set state according to input
3112  state = table[state][input];
3113 
3114  // do some actions according to state
3115  switch ( state ) {
3116  case QmI:
3117  next();
3118  break;
3119  case Name:
3120  parseOk = parseName();
3121  break;
3122  case Ws1:
3123  case Ws2:
3124  case Ws3:
3125  case Ws4:
3126  case Ws5:
3127  eat_ws();
3128  break;
3129  case Version:
3130  parseOk = parseAttribute();
3131  break;
3132  case EorSD:
3133  parseOk = parseAttribute();
3134  break;
3135  case SD:
3136  // get the SDDecl (syntax like an attribute)
3138  // already parsed the standalone declaration
3140  goto parseError;
3141  }
3142  parseOk = parseAttribute();
3143  break;
3144  case ADone:
3145  next();
3146  break;
3147  case Char:
3148  stringAddC();
3149  next();
3150  break;
3151  case Qm:
3152  // skip the '?'
3153  next();
3154  break;
3155  case Done:
3156  next();
3157  break;
3158  }
3159  // no input is read after this
3160  switch ( state ) {
3161  case Name:
3162  if ( !parseOk ) {
3164  goto parseError;
3165  }
3166  // test what name was read and determine the next state
3167  // (not very beautiful, I admit)
3168  if ( name().lower() == "xml" ) {
3169  if ( xmldecl && name()=="xml" ) {
3170  state = XMLDecl;
3171  } else {
3173  goto parseError;
3174  }
3175  } else {
3176  state = PI;
3177  stringClear();
3178  }
3179  break;
3180  case Version:
3181  // get version (syntax like an attribute)
3182  if ( !parseOk ) {
3184  goto parseError;
3185  }
3186  if ( name() != "version" ) {
3188  goto parseError;
3189  }
3190  d->xmlVersion = string();
3191  break;
3192  case EorSD:
3193  // get the EDecl or SDDecl (syntax like an attribute)
3194  if ( !parseOk ) {
3196  goto parseError;
3197  }
3198  if ( name() == "standalone" ) {
3199  if ( string()=="yes" ) {
3201  } else if ( string()=="no" ) {
3203  } else {
3205  goto parseError;
3206  }
3207  } else if ( name() == "encoding" ) {
3208  d->encoding = string();
3209  } else {
3211  goto parseError;
3212  }
3213  break;
3214  case SD:
3215  if ( !parseOk ) {
3217  goto parseError;
3218  }
3219  if ( name() != "standalone" ) {
3221  goto parseError;
3222  }
3223  if ( string()=="yes" ) {
3225  } else if ( string()=="no" ) {
3227  } else {
3229  goto parseError;
3230  }
3231  break;
3232  case Qm:
3233  // test if the skipping was legal
3234  if ( c != '>' ) {
3235  stringAddC( '?' );
3236  }
3237  break;
3238  case Done:
3239  return TRUE;
3240  case -1:
3241  // Error
3243  goto parseError;
3244  }
3245 
3246  }
3247 
3248  return TRUE;
3249 
3250 parseError:
3251  reportParseError();
3252  return FALSE;
3253 }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
const bool FALSE
Definition: qglobal.h:370
ChannelGroupService::Name Name
#define XMLERR_VERSIONEXPECTED
Definition: qxml.cpp:80
bool parseAttribute()
Definition: qxml.cpp:5402
QString & name()
Definition: qxml.h:592
#define XMLERR_SDDECLEXPECTED
Definition: qxml.cpp:82
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
constexpr double PI
void eat_ws()
Definition: qxml.h:578
void stringClear()
Definition: qxml.h:605
QString & string()
Definition: qxml.h:586
static int input(void)
Definition: code.cpp:15695
Standalone standalone
Definition: qxml.cpp:1658
void next()
Definition: qxml.h:555
#define XMLERR_INVALIDNAMEFORPI
Definition: qxml.cpp:79
#define XMLERR_ERRORPARSINGNAME
Definition: qxml.cpp:56
void Init(void)
Definition: gXSecComp.cxx:138
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
void stringAddC()
Definition: qxml.h:612
void reportParseError()
Definition: qxml.cpp:6055
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
#define XMLERR_WRONGVALUEFORSDECL
Definition: qxml.cpp:83
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
virtual bool is_NameBeginning(const QChar &)
Definition: qxml.h:536
#define XMLERR_EDECLORSDDECLEXPECTED
Definition: qxml.cpp:81
bool QXmlSimpleReader::parseProlog ( )
private

Parses the prolog [22].

Definition at line 2131 of file qxml.cpp.

2132 {
2133  bool xmldecl_possible = TRUE;
2134  bool doctype_read = FALSE;
2135 
2136  const signed char Init = 0;
2137  const signed char EatWS = 1; // eat white spaces
2138  const signed char Lt = 2; // '<' read
2139  const signed char Em = 3; // '!' read
2140  const signed char DocType = 4; // read doctype
2141  const signed char Comment = 5; // read comment
2142  const signed char PI = 6; // read PI
2143  const signed char Done = 7;
2144 
2145  const signed char InpWs = 0;
2146  const signed char InpLt = 1; // <
2147  const signed char InpQm = 2; // ?
2148  const signed char InpEm = 3; // !
2149  const signed char InpD = 4; // D
2150  const signed char InpDash = 5; // -
2151  const signed char InpUnknown = 6;
2152 
2153  // use some kind of state machine for parsing
2154  static signed char table[7][7] = {
2155  /* InpWs InpLt InpQm InpEm InpD InpDash InpUnknown */
2156  { EatWS, Lt, -1, -1, -1, -1, -1 }, // Init
2157  { -1, Lt, -1, -1, -1, -1, -1 }, // EatWS
2158  { -1, -1, PI, Em, Done, -1, Done }, // Lt
2159  { -1, -1, -1, -1, DocType, Comment, -1 }, // Em
2160  { EatWS, Lt, -1, -1, -1, -1, -1 }, // DocType
2161  { EatWS, Lt, -1, -1, -1, -1, -1 }, // Comment
2162  { EatWS, Lt, -1, -1, -1, -1, -1 } // PI
2163  };
2164  signed char state = Init;
2165  signed char input;
2166  bool parseOk = TRUE;
2167 
2168  while ( TRUE ) {
2169 
2170  // read input
2171  if ( atEnd() ) {
2173  goto parseError;
2174  }
2175  if ( is_S(c) ) {
2176  input = InpWs;
2177  } else if ( c == '<' ) {
2178  input = InpLt;
2179  } else if ( c == '?' ) {
2180  input = InpQm;
2181  } else if ( c == '!' ) {
2182  input = InpEm;
2183  } else if ( c == 'D' ) {
2184  input = InpD;
2185  } else if ( c == '-' ) {
2186  input = InpDash;
2187  } else {
2188  input = InpUnknown;
2189  }
2190  // get new state
2191  state = table[state][input];
2192 
2193  // in some cases do special actions depending on state
2194  switch ( state ) {
2195  case EatWS:
2196  // XML declaration only on first position possible
2197  xmldecl_possible = FALSE;
2198  // eat white spaces
2199  eat_ws();
2200  break;
2201  case Lt:
2202  // next character
2203  next();
2204  break;
2205  case Em:
2206  // XML declaration only on first position possible
2207  xmldecl_possible = FALSE;
2208  // next character
2209  next();
2210  break;
2211  case DocType:
2212  parseOk = parseDoctype();
2213  break;
2214  case Comment:
2215  parseOk = parseComment();
2216  break;
2217  case PI:
2218  parseOk = parsePI( xmldecl_possible );
2219  break;
2220  }
2221  // no input is read after this
2222  switch ( state ) {
2223  case DocType:
2224  if ( !parseOk ) {
2226  goto parseError;
2227  }
2228  if ( doctype_read ) {
2230  goto parseError;
2231  } else {
2232  doctype_read = FALSE;
2233  }
2234  break;
2235  case Comment:
2236  if ( !parseOk ) {
2238  goto parseError;
2239  }
2240  if ( lexicalHnd ) {
2241  if ( !lexicalHnd->comment( string() ) ) {
2242  d->error = lexicalHnd->errorString();
2243  goto parseError;
2244  }
2245  }
2246  break;
2247  case PI:
2248  if ( !parseOk ) {
2250  goto parseError;
2251  }
2252  // call the handler
2253  if ( contentHnd ) {
2254  if ( xmldecl_possible && !d->xmlVersion.isEmpty() ) {
2255  QString value( "version = '" );
2256  value += d->xmlVersion;
2257  value += "'";
2258  if ( !d->encoding.isEmpty() ) {
2259  value += " encoding = '";
2260  value += d->encoding;
2261  value += "'";
2262  }
2264  value += " standalone = 'yes'";
2265  } else if ( d->standalone == QXmlSimpleReaderPrivate::No ) {
2266  value += " standalone = 'no'";
2267  }
2268  if ( !contentHnd->processingInstruction( "xml", value ) ) {
2269  d->error = contentHnd->errorString();
2270  goto parseError;
2271  }
2272  } else {
2273  if ( !contentHnd->processingInstruction( name(), string() ) ) {
2274  d->error = contentHnd->errorString();
2275  goto parseError;
2276  }
2277  }
2278  }
2279  // XML declaration only on first position possible
2280  xmldecl_possible = FALSE;
2281  break;
2282  case Done:
2283  return TRUE;
2284  case -1:
2286  goto parseError;
2287  }
2288 
2289  }
2290 
2291  return TRUE;
2292 
2293 parseError:
2294  reportParseError();
2295  return FALSE;
2296 }
virtual bool is_S(const QChar &)
Definition: qxml.h:530
QXmlLexicalHandler * lexicalHnd
Definition: qxml.h:273
bool isEmpty() const
Definition: qstring.h:682
const bool FALSE
Definition: qglobal.h:370
#define XMLERR_ERRORPARSINGELEMENT
Definition: qxml.cpp:52
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
#define XMLERR_ERRORPARSINGPROLOG
Definition: qxml.cpp:53
QString & name()
Definition: qxml.h:592
#define XMLERR_MORETHANONEDOCTYPE
Definition: qxml.cpp:77
QXmlContentHandler * contentHnd
Definition: qxml.h:269
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
constexpr double PI
void eat_ws()
Definition: qxml.h:578
static int input(void)
Definition: code.cpp:15695
Standalone standalone
Definition: qxml.cpp:1658
void next()
Definition: qxml.h:555
virtual bool comment(const QString &ch)=0
virtual bool processingInstruction(const QString &target, const QString &data)=0
bool parseComment()
Definition: qxml.cpp:5297
void Init(void)
Definition: gXSecComp.cxx:138
void reportParseError()
Definition: qxml.cpp:6055
#define Comment
virtual QString errorString()=0
bool parseDoctype()
Definition: qxml.cpp:3264
virtual QString errorString()=0
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
bool parsePI(bool xmldecl=FALSE)
Definition: qxml.cpp:3042
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::parseReference ( bool charDataRead,
EntityRecognitionContext  context 
)
private

Parse a Reference [67].

charDataRead is set to TRUE if the reference must not be parsed. The character(s) which the reference mapped to are appended to string. The head stands on the first character after the reference.

charDataRead is set to FALSE if the reference must be parsed. The charachter(s) which the reference mapped to are inserted at the reference position. The head stands on the first character of the replacement).

Definition at line 5658 of file qxml.cpp.

5659 {
5660  // temporary variables
5661  uint tmp;
5662  bool ok;
5663 
5664  const signed char Init = 0;
5665  const signed char SRef = 1; // start of a reference
5666  const signed char ChRef = 2; // parse CharRef
5667  const signed char ChDec = 3; // parse CharRef decimal
5668  const signed char ChHexS = 4; // start CharRef hexadecimal
5669  const signed char ChHex = 5; // parse CharRef hexadecimal
5670  const signed char Name = 6; // parse name
5671  const signed char DoneD = 7; // done CharRef decimal
5672  const signed char DoneH = 8; // done CharRef hexadecimal
5673  const signed char DoneN = 9; // done EntityRef
5674 
5675  const signed char InpAmp = 0; // &
5676  const signed char InpSemi = 1; // ;
5677  const signed char InpHash = 2; // #
5678  const signed char InpX = 3; // x
5679  const signed char InpNum = 4; // 0-9
5680  const signed char InpHex = 5; // a-f A-F
5681  const signed char InpUnknown = 6;
5682 
5683  // use some kind of state machine for parsing
5684  static signed char table[8][7] = {
5685  /* InpAmp InpSemi InpHash InpX InpNum InpHex InpUnknown */
5686  { SRef, -1, -1, -1, -1, -1, -1 }, // Init
5687  { -1, -1, ChRef, Name, Name, Name, Name }, // SRef
5688  { -1, -1, -1, ChHexS, ChDec, -1, -1 }, // ChRef
5689  { -1, DoneD, -1, -1, ChDec, -1, -1 }, // ChDec
5690  { -1, -1, -1, -1, ChHex, ChHex, -1 }, // ChHexS
5691  { -1, DoneH, -1, -1, ChHex, ChHex, -1 }, // ChHex
5692  { -1, DoneN, -1, -1, -1, -1, -1 } // Name
5693  };
5694  signed char state = Init;
5695  signed char input;
5696 
5697  while ( TRUE ) {
5698 
5699  // get input
5700  if ( atEnd() ) {
5702  goto parseError;
5703  }
5704  if ( c.row() ) {
5705  input = InpUnknown;
5706  } else if ( c.cell() == '&' ) {
5707  input = InpAmp;
5708  } else if ( c.cell() == ';' ) {
5709  input = InpSemi;
5710  } else if ( c.cell() == '#' ) {
5711  input = InpHash;
5712  } else if ( c.cell() == 'x' ) {
5713  input = InpX;
5714  } else if ( '0' <= c.cell() && c.cell() <= '9' ) {
5715  input = InpNum;
5716  } else if ( 'a' <= c.cell() && c.cell() <= 'f' ) {
5717  input = InpHex;
5718  } else if ( 'A' <= c.cell() && c.cell() <= 'F' ) {
5719  input = InpHex;
5720  } else {
5721  input = InpUnknown;
5722  }
5723 
5724  // set state according to input
5725  state = table[state][input];
5726 
5727  // do some actions according to state
5728  switch ( state ) {
5729  case SRef:
5730  refClear();
5731  next();
5732  break;
5733  case ChRef:
5734  next();
5735  break;
5736  case ChDec:
5737  refAddC();
5738  next();
5739  break;
5740  case ChHexS:
5741  next();
5742  break;
5743  case ChHex:
5744  refAddC();
5745  next();
5746  break;
5747  case Name:
5748  // read the name into the ref
5749  parseName( TRUE );
5750  break;
5751  case DoneD:
5752  tmp = ref().toUInt( &ok, 10 );
5753  if ( ok ) {
5754  stringAddC( QChar(tmp) );
5755  } else {
5757  goto parseError;
5758  }
5759  charDataRead = TRUE;
5760  next();
5761  break;
5762  case DoneH:
5763  tmp = ref().toUInt( &ok, 16 );
5764  if ( ok ) {
5765  stringAddC( QChar(tmp) );
5766  } else {
5768  goto parseError;
5769  }
5770  charDataRead = TRUE;
5771  next();
5772  break;
5773  case DoneN:
5774  if ( !processReference( charDataRead, context ) )
5775  goto parseError;
5776  next();
5777  break;
5778  }
5779  // no input is read after this
5780  switch ( state ) {
5781  case DoneD:
5782  return TRUE;
5783  case DoneH:
5784  return TRUE;
5785  case DoneN:
5786  return TRUE;
5787  case -1:
5788  // Error
5790  goto parseError;
5791  }
5792 
5793  }
5794 
5795  return TRUE;
5796 
5797 parseError:
5798  reportParseError();
5799  return FALSE;
5800 }
uint toUInt(bool *ok=0, int base=10) const
Definition: qstring.cpp:14058
const bool FALSE
Definition: qglobal.h:370
ChannelGroupService::Name Name
The QChar class provides a light-weight Unicode character.
Definition: qstring.h:56
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
void refAddC()
Definition: qxml.h:628
uchar & cell()
Definition: qstring.h:167
#define XMLERR_ERRORPARSINGREFERENCE
Definition: qxml.cpp:65
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
bool processReference(bool &charDataRead, EntityRecognitionContext context)
Definition: qxml.cpp:5805
string tmp
Definition: languages.py:63
void Init(void)
Definition: gXSecComp.cxx:138
bool parseName(bool useRef=FALSE)
Definition: qxml.cpp:5498
void stringAddC()
Definition: qxml.h:612
QString & ref()
Definition: qxml.h:598
void reportParseError()
Definition: qxml.cpp:6055
uchar & row()
Definition: qstring.h:168
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
unsigned uint
Definition: qglobal.h:351
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
void refClear()
Definition: qxml.h:609
bool QXmlSimpleReader::parseString ( const QString s)
private

Parse over a simple string.

After the string was successfully parsed, the head is on the first character after the string.

Definition at line 5964 of file qxml.cpp.

5965 {
5966  signed char Done = s.length();
5967 
5968  const signed char InpCharExpected = 0; // the character that was expected
5969  const signed char InpUnknown = 1;
5970 
5971  signed char state = 0; // state in this function is the position in the string s
5972  signed char input;
5973 
5974  while ( TRUE ) {
5975 
5976  // get input
5977  if ( atEnd() ) {
5979  goto parseError;
5980  }
5981  if ( c == s[(int)state] ) {
5982  input = InpCharExpected;
5983  } else {
5984  input = InpUnknown;
5985  }
5986 
5987  // set state according to input
5988  if ( input == InpCharExpected ) {
5989  state++;
5990  } else {
5991  // Error
5993  goto parseError;
5994  }
5995 
5996  // do some actions according to state
5997  next();
5998  // no input is read after this
5999  if ( state == Done ) {
6000  return TRUE;
6001  }
6002 
6003  }
6004 
6005  return TRUE;
6006 
6007 parseError:
6008  reportParseError();
6009  return FALSE;
6010 }
#define XMLERR_UNEXPECTEDCHARACTER
Definition: qxml.cpp:62
const bool FALSE
Definition: qglobal.h:370
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
static int input(void)
Definition: code.cpp:15695
void next()
Definition: qxml.h:555
uint length() const
Definition: qstring.h:679
void reportParseError()
Definition: qxml.cpp:6055
#define XMLERR_UNEXPECTEDEOF
Definition: qxml.cpp:49
bool atEnd()
Definition: qxml.h:575
const bool TRUE
Definition: qglobal.h:371
bool QXmlSimpleReader::processReference ( bool charDataRead,
EntityRecognitionContext  context 
)
private

Helper function for parseReference()

Definition at line 5805 of file qxml.cpp.

5806 {
5807  QString reference = ref();
5808  if ( reference == "amp" ) {
5809  if ( context == InEntityValue ) {
5810  // Bypassed
5811  stringAddC( '&' ); stringAddC( 'a' ); stringAddC( 'm' ); stringAddC( 'p' ); stringAddC( ';' );
5812  } else {
5813  // Included or Included in literal
5814  stringAddC( '&' );
5815  }
5816  charDataRead = TRUE;
5817  } else if ( reference == "lt" ) {
5818  if ( context == InEntityValue ) {
5819  // Bypassed
5820  stringAddC( '&' ); stringAddC( 'l' ); stringAddC( 't' ); stringAddC( ';' );
5821  } else {
5822  // Included or Included in literal
5823  stringAddC( '<' );
5824  }
5825  charDataRead = TRUE;
5826  } else if ( reference == "gt" ) {
5827  if ( context == InEntityValue ) {
5828  // Bypassed
5829  stringAddC( '&' ); stringAddC( 'g' ); stringAddC( 't' ); stringAddC( ';' );
5830  } else {
5831  // Included or Included in literal
5832  stringAddC( '>' );
5833  }
5834  charDataRead = TRUE;
5835  } else if ( reference == "apos" ) {
5836  if ( context == InEntityValue ) {
5837  // Bypassed
5838  stringAddC( '&' ); stringAddC( 'a' ); stringAddC( 'p' ); stringAddC( 'o' ); stringAddC( 's' ); stringAddC( ';' );
5839  } else {
5840  // Included or Included in literal
5841  stringAddC( '\'' );
5842  }
5843  charDataRead = TRUE;
5844  } else if ( reference == "quot" ) {
5845  if ( context == InEntityValue ) {
5846  // Bypassed
5847  stringAddC( '&' ); stringAddC( 'q' ); stringAddC( 'u' ); stringAddC( 'o' ); stringAddC( 't' ); stringAddC( ';' );
5848  } else {
5849  // Included or Included in literal
5850  stringAddC( '"' );
5851  }
5852  charDataRead = TRUE;
5853  } else {
5855  it = d->entities.find( reference );
5856  if ( it != d->entities.end() ) {
5857  // "Internal General"
5858  switch ( context ) {
5859  case InContent:
5860  // Included
5861  xmlRef = it.data() + xmlRef;
5862  charDataRead = FALSE;
5863  break;
5864  case InAttributeValue:
5865  // Included in literal
5866  xmlRef = it.data().replace( QRegExp("\""), "&quot;" ).replace( QRegExp("'"), "&apos;" )
5867  + xmlRef;
5868  charDataRead = FALSE;
5869  break;
5870  case InEntityValue:
5871  {
5872  // Bypassed
5873  stringAddC( '&' );
5874  for ( int i=0; i<(int)reference.length(); i++ ) {
5875  stringAddC( reference[i] );
5876  }
5877  stringAddC( ';');
5878  charDataRead = TRUE;
5879  }
5880  break;
5881  case InDTD:
5882  // Forbidden
5884  charDataRead = FALSE;
5885  break;
5886  }
5887  } else {
5889  itExtern = d->externEntities.find( reference );
5890  if ( itExtern == d->externEntities.end() ) {
5891  // entity not declared
5892  // ### check this case for conformance
5893  if ( context == InEntityValue ) {
5894  // Bypassed
5895  stringAddC( '&' );
5896  for ( int i=0; i<(int)reference.length(); i++ ) {
5897  stringAddC( reference[i] );
5898  }
5899  stringAddC( ';');
5900  charDataRead = TRUE;
5901  } else {
5902  if ( contentHnd ) {
5903  if ( !contentHnd->skippedEntity( reference ) ) {
5904  d->error = contentHnd->errorString();
5905  return FALSE; // error
5906  }
5907  }
5908  }
5909  } else if ( (*itExtern).notation.isNull() ) {
5910  // "External Parsed General"
5911  switch ( context ) {
5912  case InContent:
5913  // Included if validating
5914  if ( contentHnd ) {
5915  if ( !contentHnd->skippedEntity( reference ) ) {
5916  d->error = contentHnd->errorString();
5917  return FALSE; // error
5918  }
5919  }
5920  charDataRead = FALSE;
5921  break;
5922  case InAttributeValue:
5923  // Forbidden
5925  charDataRead = FALSE;
5926  break;
5927  case InEntityValue:
5928  {
5929  // Bypassed
5930  stringAddC( '&' );
5931  for ( int i=0; i<(int)reference.length(); i++ ) {
5932  stringAddC( reference[i] );
5933  }
5934  stringAddC( ';');
5935  charDataRead = TRUE;
5936  }
5937  break;
5938  case InDTD:
5939  // Forbidden
5941  charDataRead = FALSE;
5942  break;
5943  }
5944  } else {
5945  // "Unparsed"
5946  // ### notify for "Occurs as Attribute Value" missing (but this is no refence, anyway)
5947  // Forbidden
5949  charDataRead = FALSE;
5950  return FALSE; // error
5951  }
5952  }
5953  }
5954  return TRUE; // no error
5955 }
QMap< QString, QString > entities
Definition: qxml.cpp:1650
virtual bool skippedEntity(const QString &name)=0
The QRegExp class provides pattern matching using regular expressions or wildcards.
Definition: qregexp.h:46
Iterator end()
Definition: qmap.h:523
Iterator replace(const Key &k, const T &v)
Definition: qmap.h:560
const bool FALSE
Definition: qglobal.h:370
#define XMLERR_INTERNALGENERALENTITYINDTD
Definition: qxml.cpp:85
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
#define XMLERR_UNPARSEDENTITYREFERENCE
Definition: qxml.cpp:84
QXmlContentHandler * contentHnd
Definition: qxml.h:269
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
uint length() const
Definition: qstring.h:679
#define XMLERR_EXTERNALGENERALENTITYINDTD
Definition: qxml.cpp:86
QString xmlRef
Definition: qxml.h:293
Iterator find(const Key &k)
Definition: qmap.h:527
void stringAddC()
Definition: qxml.h:612
#define XMLERR_EXTERNALGENERALENTITYINAV
Definition: qxml.cpp:87
QString & ref()
Definition: qxml.h:598
virtual QString errorString()=0
QMap< QString, ExternEntity > externEntities
Definition: qxml.cpp:1649
const bool TRUE
Definition: qglobal.h:371
Definition: qmap.h:501
void * QXmlSimpleReader::property ( const QString name,
bool ok = 0 
) const
virtual

Returns 0 since this class does not support any properties.

Implements QXmlReader.

Definition at line 2004 of file qxml.cpp.

2005 {
2006  if ( ok != 0 )
2007  *ok = FALSE;
2008  return 0;
2009 }
const bool FALSE
Definition: qglobal.h:370
QString & QXmlSimpleReader::ref ( )
inlineprivate

Definition at line 598 of file qxml.h.

599 {
601  refPos = 0;
602  return refValue;
603 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QChar refArray[256]
Definition: qxml.h:285
QString refValue
Definition: qxml.h:286
void QXmlSimpleReader::refAddC ( )
inlineprivate

Definition at line 628 of file qxml.h.

629 {
630  if ( refPos >= 256 ) {
632  refPos = 0;
633  }
634  refArray[refPos++] = c;
635 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QChar refArray[256]
Definition: qxml.h:285
QString refValue
Definition: qxml.h:286
void QXmlSimpleReader::refAddC ( const QChar ch)
inlineprivate

Definition at line 653 of file qxml.h.

654 {
655  if ( refPos >= 256 ) {
657  refPos = 0;
658  }
659  refArray[refPos++] = ch;
660 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QChar refArray[256]
Definition: qxml.h:285
QString refValue
Definition: qxml.h:286
void QXmlSimpleReader::refClear ( )
inlineprivate

Definition at line 609 of file qxml.h.

610 { refValue = ""; refPos = 0; }
QString refValue
Definition: qxml.h:286
void QXmlSimpleReader::reportParseError ( )
private

Definition at line 6055 of file qxml.cpp.

6056 {
6057  if ( errorHnd )
6059 }
int columnNr
Definition: qxml.h:278
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
The QXmlParseException class is used to report errors with the QXmlErrorHandler interface.
Definition: qxml.h:185
QXmlErrorHandler * errorHnd
Definition: qxml.h:270
virtual bool fatalError(const QXmlParseException &exception)=0
void QXmlSimpleReader::setContentHandler ( QXmlContentHandler handler)
virtual

Implements QXmlReader.

Definition at line 2043 of file qxml.cpp.

2044 { contentHnd = handler; }
QXmlContentHandler * contentHnd
Definition: qxml.h:269
static msg_handler handler
Definition: qglobal.cpp:234
void QXmlSimpleReader::setDeclHandler ( QXmlDeclHandler handler)
virtual

Implements QXmlReader.

Definition at line 2067 of file qxml.cpp.

2068 { declHnd = handler; }
QXmlDeclHandler * declHnd
Definition: qxml.h:274
static msg_handler handler
Definition: qglobal.cpp:234
void QXmlSimpleReader::setDTDHandler ( QXmlDTDHandler handler)
virtual

Implements QXmlReader.

Definition at line 2035 of file qxml.cpp.

2036 { dtdHnd = handler; }
QXmlDTDHandler * dtdHnd
Definition: qxml.h:271
static msg_handler handler
Definition: qglobal.cpp:234
void QXmlSimpleReader::setEntityResolver ( QXmlEntityResolver handler)
virtual

Implements QXmlReader.

Definition at line 2027 of file qxml.cpp.

2028 { entityRes = handler; }
QXmlEntityResolver * entityRes
Definition: qxml.h:272
static msg_handler handler
Definition: qglobal.cpp:234
void QXmlSimpleReader::setErrorHandler ( QXmlErrorHandler handler)
virtual

Implements QXmlReader.

Definition at line 2051 of file qxml.cpp.

2052 { errorHnd = handler; }
static msg_handler handler
Definition: qglobal.cpp:234
QXmlErrorHandler * errorHnd
Definition: qxml.h:270
void QXmlSimpleReader::setFeature ( const QString name,
bool  value 
)
virtual

Sets the state of a feature.

Supported features are:

See also
feature() hasFeature()

Implements QXmlReader.

Definition at line 1972 of file qxml.cpp.

1973 {
1974  if ( name == "http://xml.org/sax/features/namespaces" ) {
1975  d->useNamespaces = value;
1976  } else if ( name == "http://xml.org/sax/features/namespace-prefixes" ) {
1978  } else if ( name == "http://trolltech.com/xml/features/report-whitespace-only-CharData" ) {
1980  } else {
1981  qWarning( "Unknown feature %s", name.ascii() );
1982  }
1983 }
void qWarning(const char *msg,...)
Definition: qglobal.cpp:409
QXmlSimpleReaderPrivate * d
Definition: qxml.h:297
const char * ascii() const
Definition: qstring.cpp:14494
void QXmlSimpleReader::setLexicalHandler ( QXmlLexicalHandler handler)
virtual

Implements QXmlReader.

Definition at line 2059 of file qxml.cpp.

2060 { lexicalHnd = handler; }
QXmlLexicalHandler * lexicalHnd
Definition: qxml.h:273
static msg_handler handler
Definition: qglobal.cpp:234
void QXmlSimpleReader::setProperty ( const QString name,
void *  value 
)
virtual

Does nothing since this class does not support any properties.

Implements QXmlReader.

Definition at line 2014 of file qxml.cpp.

2015 {
2016 }
QString & QXmlSimpleReader::string ( )
inlineprivate

Definition at line 586 of file qxml.h.

587 {
589  stringPos = 0;
590  return stringValue;
591 }
QChar stringArray[256]
Definition: qxml.h:288
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
int stringPos
Definition: qxml.h:287
QString stringValue
Definition: qxml.h:289
void QXmlSimpleReader::stringAddC ( )
inlineprivate

Definition at line 612 of file qxml.h.

613 {
614  if ( stringPos >= 256 ) {
616  stringPos = 0;
617  }
618  stringArray[stringPos++] = c;
619 }
QChar stringArray[256]
Definition: qxml.h:288
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
int stringPos
Definition: qxml.h:287
QString stringValue
Definition: qxml.h:289
void QXmlSimpleReader::stringAddC ( const QChar ch)
inlineprivate

Definition at line 637 of file qxml.h.

638 {
639  if ( stringPos >= 256 ) {
641  stringPos = 0;
642  }
643  stringArray[stringPos++] = ch;
644 }
QChar stringArray[256]
Definition: qxml.h:288
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
int stringPos
Definition: qxml.h:287
QString stringValue
Definition: qxml.h:289
void QXmlSimpleReader::stringClear ( )
inlineprivate

Definition at line 605 of file qxml.h.

606 { stringValue = ""; stringPos = 0; }
int stringPos
Definition: qxml.h:287
QString stringValue
Definition: qxml.h:289

Friends And Related Function Documentation

friend class QXmlLocator
friend

Definition at line 372 of file qxml.h.

friend class QXmlSimpleReaderPrivate
friend

Definition at line 371 of file qxml.h.

Member Data Documentation

QChar QXmlSimpleReader::c
private

Definition at line 276 of file qxml.h.

int QXmlSimpleReader::columnNr
private

Definition at line 278 of file qxml.h.

QXmlContentHandler* QXmlSimpleReader::contentHnd
private

Definition at line 269 of file qxml.h.

QXmlSimpleReaderPrivate* QXmlSimpleReader::d
private

Definition at line 297 of file qxml.h.

QXmlDeclHandler* QXmlSimpleReader::declHnd
private

Definition at line 274 of file qxml.h.

QXmlDTDHandler* QXmlSimpleReader::dtdHnd
private

Definition at line 271 of file qxml.h.

QXmlEntityResolver* QXmlSimpleReader::entityRes
private

Definition at line 272 of file qxml.h.

QXmlErrorHandler* QXmlSimpleReader::errorHnd
private

Definition at line 270 of file qxml.h.

QXmlLexicalHandler* QXmlSimpleReader::lexicalHnd
private

Definition at line 273 of file qxml.h.

int QXmlSimpleReader::lineNr
private

Definition at line 277 of file qxml.h.

QChar QXmlSimpleReader::nameArray[256]
private

Definition at line 282 of file qxml.h.

int QXmlSimpleReader::namePos
private

Definition at line 281 of file qxml.h.

QString QXmlSimpleReader::nameValue
private

Definition at line 283 of file qxml.h.

int QXmlSimpleReader::pos
private

Definition at line 279 of file qxml.h.

const QChar QXmlSimpleReader::QEOF = QChar((ushort)0xffff)
staticprivate

Definition at line 299 of file qxml.h.

QChar QXmlSimpleReader::refArray[256]
private

Definition at line 285 of file qxml.h.

int QXmlSimpleReader::refPos
private

Definition at line 284 of file qxml.h.

QString QXmlSimpleReader::refValue
private

Definition at line 286 of file qxml.h.

QChar QXmlSimpleReader::stringArray[256]
private

Definition at line 288 of file qxml.h.

int QXmlSimpleReader::stringPos
private

Definition at line 287 of file qxml.h.

QString QXmlSimpleReader::stringValue
private

Definition at line 289 of file qxml.h.

QValueStack<QString> QXmlSimpleReader::tags
private

Definition at line 295 of file qxml.h.

QString QXmlSimpleReader::xml
private

Definition at line 291 of file qxml.h.

int QXmlSimpleReader::xmlLength
private

Definition at line 292 of file qxml.h.

QString QXmlSimpleReader::xmlRef
private

Definition at line 293 of file qxml.h.


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