Ipelib
|
#include <ipexml.h>
Inherited by ipe::ImlParser.
Public Member Functions | |
XmlParser (DataSource &source) | |
virtual | ~XmlParser () |
int | parsePosition () const |
String | parseToTag () |
bool | parseAttributes (XmlAttributes &attr, bool qm=false) |
bool | parsePCDATA (String tag, String &pcdata) |
bool | isTagChar (int ch) |
void | getChar () |
bool | eos () |
void | skipWhitespace () |
Protected Member Functions | |
String | parseToTagX () |
Protected Attributes | |
DataSource & | iSource |
String | iTopElement |
int | iCh |
int | iPos |
Base class for XML stream parsing.
This is the base class for Ipe's XML parser. It only provides some utility functions for parsing tags and PCDATA. Derived classes implement the actual parsing using recursive descent parsers—after experimenting with various schemes for XML parsing, this seems to work best for Ipe.
Tag names and attribute names must consist of ASCII letters only. Only entities for '&', '<', and '>' are recognized.
XmlParser::XmlParser | ( | DataSource & | source | ) |
|
virtual |
Virtual destructor, so one can destroy through pointer.
|
inline |
References iPos.
String XmlParser::parseToTag | ( | ) |
Parse whitespace and the name of a tag.
Like ParseToTagX, but silently skips over all tags whose name starts with "x-"
References parseAttributes(), parseToTagX(), and ipe::String::size().
Referenced by ipe::ImlParser::parseDocument(), ipe::ImlParser::parseObject(), ipe::ImlParser::parsePage(), ipe::ImlParser::parsePageSelection(), ipe::ImlParser::parseStyle(), ipe::ImlParser::parseStyleSheet(), and ipe::ImlParser::parseView().
bool XmlParser::parseAttributes | ( | XmlAttributes & | attr, |
bool | qm = false |
||
) |
Parse XML attributes.
Returns with stream just after >. Caller can check whether the tag ended with a / by checking attr.slash().
Set qm to true to allow a question mark just before the >.
References ipe::XmlAttributes::add(), ipe::XmlAttributes::clear(), ipe::String::empty(), eos(), getChar(), iCh, isTagChar(), ipe::XmlAttributes::setSlash(), and skipWhitespace().
Referenced by ipe::ImlParser::parseBitmap(), ipe::ImlParser::parseDocument(), ipe::ImlParser::parseObject(), ipe::ImlParser::parsePage(), ipe::ImlParser::parsePageSelection(), ipe::ImlParser::parseStyle(), ipe::ImlParser::parseStyleSheet(), parseToTag(), and ipe::ImlParser::parseView().
Parse PCDATA.
Checks whether the data is terminated by </tag>
, and returns with stream past the >.
References eos(), getChar(), iCh, ipe::String::size(), and skipWhitespace().
Referenced by ipe::ImlParser::parseBitmap(), ipe::ImlParser::parseDocument(), ipe::ImlParser::parseObject(), ipe::ImlParser::parsePage(), and ipe::ImlParser::parseStyle().
|
inline |
Referenced by parseAttributes(), and parseToTagX().
|
inline |
References ipe::DataSource::getChar(), iCh, iPos, and iSource.
Referenced by parseAttributes(), parsePCDATA(), parseToTagX(), skipWhitespace(), and XmlParser().
|
inline |
References iCh.
Referenced by parseAttributes(), parsePCDATA(), parseToTagX(), and skipWhitespace().
void XmlParser::skipWhitespace | ( | ) |
References eos(), getChar(), and iCh.
Referenced by parseAttributes(), parsePCDATA(), and parseToTagX().
|
protected |
Parse whitespace and the name of a tag.
If the tag is a closing tag, skips > and returns with stream after that. Otherwise, returns with stream just after the tag name.
Comments and <!TAG .. > are skipped silently.
References eos(), getChar(), iCh, isTagChar(), and skipWhitespace().
Referenced by parseToTag().
|
protected |
Referenced by getChar().
|
protected |
|
protected |
Referenced by eos(), getChar(), parseAttributes(), parsePCDATA(), parseToTagX(), and skipWhitespace().
|
protected |
Referenced by getChar(), parsePosition(), and XmlParser().