26 #error C++ is required
29 #include <yateclass.h>
117 inline unsigned int row()
const
139 bool parse(
const char* data);
162 bool setError(Error error,
XmlChild* child = 0);
169 inline const char*
getError(
const char* defVal =
"Xml error")
170 {
return getError(m_error,defVal); }
176 {
return m_unparsed; }
188 virtual void reset();
202 static inline const char*
getError(
int code,
const char* defVal =
"Xml error")
203 {
return lookup(code,s_errorString,defVal); }
211 {
return (c == 0x20) || (c == 0x09) || (c == 0x0d) || (c == 0x0a); }
219 static bool checkFirstNameCharacter(
unsigned char ch);
226 static bool checkDataChar(
unsigned char c);
233 static bool checkNameCharacter(
unsigned char ch);
240 static bool validTag(
const String& buf);
271 bool parseInstruction();
299 bool parseDeclaration();
336 void unEscape(
String& text);
349 {
return c ==
'<' || c ==
'>'; }
355 { m_error = NoError; }
361 { m_parsed.clear(); m_parsed.clearParams(); }
367 String* extractName(
bool& empty);
454 bool processElement(
NamedList& list,
bool empty);
461 bool processText(
String& text);
548 virtual XmlSaxParser::Error addChild(
XmlChild* child) = 0;
556 XmlSaxParser::Error err = addChild(child);
557 if (err != XmlSaxParser::NoError)
597 {
return getChildren().skipNull() != 0; }
613 XmlDomParser(
const char* name =
"XmlDomParser",
bool fragment =
false);
644 virtual void reset();
652 {
return el == m_current; }
660 virtual void gotComment(
const String& text);
666 virtual void gotProcessing(
const NamedString& instr);
672 virtual void gotDeclaration(
const NamedList& decl);
678 virtual void gotText(
const String& text);
684 virtual void gotCdata(
const String& data);
691 virtual void gotElement(
const NamedList& element,
bool empty);
697 virtual void endElement(
const String& name);
703 virtual void gotDoctype(
const String& doc);
710 {
return m_current == 0; }
796 XmlDeclaration(
const char* version =
"1.0",
const char* enc =
"utf-8");
820 {
return m_declaration; }
835 void toString(
String& dump,
bool escape =
true)
const;
884 virtual XmlSaxParser::Error addChild(
XmlChild* child);
889 virtual void reset();
896 {
return static_cast<XmlChild*
>(m_list.remove(
false)); }
945 bool noPrefix =
true);
985 virtual XmlSaxParser::Error addChild(
XmlChild* child);
998 XmlElement* root(
bool completed =
false)
const;
1016 virtual void reset();
1025 {
return m_beforeRoot.removeChild(child,delObj); }
1033 virtual XmlSaxParser::Error read(
Stream& in,
int* error = 0);
1047 virtual int write(
Stream& out,
bool escape =
true,
1049 bool completeOnly =
true)
const;
1058 XmlSaxParser::Error loadFile(
const char* file,
int* error = 0);
1069 int saveFile(
const char* file = 0,
bool escape =
true,
1112 XmlElement(
const char* name,
bool complete =
true);
1120 XmlElement(
const char* name,
const char* value,
bool complete =
true);
1137 inline const char*
tag()
const
1138 {
return m_element; }
1145 {
return m_prefixed == 0; }
1152 {
return m_prefixed ? m_prefixed->name() :
static_cast<const String&
>(m_element); }
1158 void setUnprefixedTag(
const String& s);
1165 {
return m_prefixed ? m_prefixed->name() :
static_cast<const String&
>(m_element); }
1173 bool getTag(
const String*& tag,
const String*& ns)
const;
1193 virtual XmlSaxParser::Error addChild(
XmlChild* child);
1207 { m_complete =
true; }
1213 {
return m_complete; }
1226 {
return m_parent ? m_parent->
element() : 0; }
1232 {
return m_parent; }
1238 virtual void setParent(
XmlParent* parent);
1244 {
return m_element; }
1250 {
return m_element; }
1257 {
return m_children.getChildren(); }
1263 {
return m_children.clearChildren(); }
1270 {
return m_inheritedNs; }
1277 void setInheritedNs(
const XmlElement* xml = 0,
bool inherit =
true);
1283 void addInheritedNs(
const NamedList& list);
1293 m_children.removeChild(x,
false);
1302 {
return m_element; }
1317 const String* auth = 0)
const;
1329 bool noPrefix =
true)
const
1342 bool noPrefix =
true)
const
1356 const String* ns = 0,
bool noPrefix =
true)
const {
1358 return findFirstChild(name,ns,noPrefix);
1374 const String* ns = 0,
bool noPrefix =
true)
const
1375 {
return findNextChild(prev,&name,ns,noPrefix); }
1387 bool noPrefix =
true)
const {
1388 XmlElement* c = findFirstChild(&name,ns,noPrefix);
1389 return c ? &(c->
getText()) : 0;
1401 const String& getText()
const;
1410 XmlText* setText(
const char* text);
1416 void addText(
const char* text);
1423 {
return m_element; }
1431 unsigned int copyAttributes(
NamedList& list,
const String& prefix)
const;
1440 void setAttributes(
NamedList& list,
const String& prefix,
bool skipPrefix =
true);
1448 { m_element.setParam(name,value); }
1457 m_element.setParam(name,value);
1459 removeAttribute(name);
1468 {
return m_element.getValue(name); }
1476 {
return m_element.getParam(name); }
1485 String* a = getAttribute(name);
1486 return a && *a == value;
1494 { m_element.clearParam(name); }
1502 return xmlnsAttribute(s_ns);
1503 return xmlnsAttribute(s_nsPrefix + *m_prefixed);
1518 const String* x = xmlns();
1519 return x && *x == ns;
1540 {
return str == s_ns || str.
startsWith(s_nsPrefix); }
1559 bool copyXml =
false);
1571 bool copyXml =
false);
1584 bool copyXml =
false);
1598 inline void setPrefixed() {
1600 int pos = m_element.find(
":");
1602 m_prefixed =
new NamedString(m_element.substr(pos + 1),m_element.substr(0,pos));
1644 {
return m_comment; }
1808 {
return m_doctype; }
const char * getError(const char *defVal="Xml error")
Definition: yatexml.h:169
const String * childText(const String &name, const String *ns=0, bool noPrefix=true) const
Definition: yatexml.h:1386
virtual XmlText * xmlText()
Definition: yatexml.h:1770
Xml Declaration.
Definition: yatexml.h:787
virtual ~XmlParent()
Definition: yatexml.h:516
bool startsWith(const char *what, bool wordBreak=false, bool caseInsensitive=false) const
void clearChildren()
Definition: yatexml.h:1262
const char * tag() const
Definition: yatexml.h:1137
Document Object Model XML Parser.
Definition: yatexml.h:604
const String & getDoctype() const
Definition: yatexml.h:1807
virtual XmlCData * xmlCData()
Definition: yatexml.h:757
String m_buf
Definition: yatexml.h:486
Xml Document.
Definition: yatexml.h:955
virtual const ObjList & getChildren() const
Definition: yatexml.h:876
const ObjList & getChildren() const
Definition: yatexml.h:1256
XmlChild * pop()
Definition: yatexml.h:895
Xml Declaration.
Definition: yatexml.h:1719
virtual void gotText(const String &text)
Definition: yatexml.h:404
virtual void gotElement(const NamedList &element, bool empty)
Definition: yatexml.h:421
XmlDocument * document()
Definition: yatexml.h:631
XmlParent()
Definition: yatexml.h:510
char replace
Definition: yatexml.h:59
virtual bool completed()
Definition: yatexml.h:709
NamedList m_parsed
Definition: yatexml.h:492
Xml Fragment.
Definition: yatexml.h:845
Serial Access XML Parser.
Definition: yatexml.h:66
unsigned int column() const
Definition: yatexml.h:124
Xml Child.
Definition: yatexml.h:722
virtual XmlChild * removeChild(XmlChild *child, bool delObj=true)
Definition: yatexml.h:1024
virtual XmlDoctype * xmlDoctype()
Definition: yatexml.h:778
virtual const ObjList & getChildren() const
Definition: yatexml.h:582
Xml Element.
Definition: yatexml.h:1095
void setAttribute(const String &name, const char *value)
Definition: yatexml.h:1447
void resetError()
Definition: yatexml.h:354
const String & getText() const
unsigned int m_column
Definition: yatexml.h:476
virtual XmlCData * xmlCData()
Definition: yatexml.h:1708
const String & getCData() const
Definition: yatexml.h:1694
ObjList * find(const GenObject *obj) const
int lookup(const char *str, const TokenDict *tokens, int defvalue=0, int base=0)
bool isCurrent(const XmlElement *el) const
Definition: yatexml.h:651
void destruct(GenObject *obj)
Definition: yateclass.h:933
virtual XmlFragment * fragment()
Definition: yatexml.h:532
virtual void gotProcessing(const NamedString &instr)
Definition: yatexml.h:388
virtual void gotDeclaration(const NamedList &decl)
Definition: yatexml.h:396
bool hasAttribute(const String &name, const String &value) const
Definition: yatexml.h:1484
virtual XmlDoctype * xmlDoctype()
Definition: yatexml.h:1814
const String & getTag() const
Definition: yatexml.h:1164
const char * attribute(const String &name) const
Definition: yatexml.h:1467
bool hasChildren() const
Definition: yatexml.h:596
static const char * getError(int code, const char *defVal="Xml error")
Definition: yatexml.h:202
A holder for a debug level.
Definition: yateclass.h:309
XmlElement * parent() const
Definition: yatexml.h:1225
virtual void setCompleted()
Definition: yatexml.h:1206
virtual bool completed()
Definition: yatexml.h:445
virtual const String & getName() const
Definition: yatexml.h:1243
virtual const NamedList & getElement() const
Definition: yatexml.h:1249
bool hasXmlns(const String &ns) const
Definition: yatexml.h:1517
static const ObjList & empty()
virtual void clearChildren()
Definition: yatexml.h:589
virtual void endElement(const String &name)
Definition: yatexml.h:429
A named string class.
Definition: yateclass.h:3111
virtual void gotCdata(const String &data)
Definition: yatexml.h:412
virtual XmlFragment * fragment()
Definition: yatexml.h:869
const NamedList & attributes() const
Definition: yatexml.h:1422
virtual void gotComment(const String &text)
Definition: yatexml.h:380
const String & getText() const
Definition: yatexml.h:1743
bool null(const char *str)
Definition: yateclass.h:2829
virtual XmlText * xmlText()
Definition: yatexml.h:764
virtual void reset()
Definition: yatexml.h:574
A named string container class.
Definition: yateclass.h:4553
const NamedList * inheritedNs() const
Definition: yatexml.h:1269
virtual XmlElement * xmlElement()
Definition: yatexml.h:1179
void setText(const char *text)
Definition: yatexml.h:1750
bool completed() const
Definition: yatexml.h:1212
Type m_unparsed
Definition: yatexml.h:497
const NamedList & getDec() const
Definition: yatexml.h:819
An abstract stream class capable of reading and writing.
Definition: yateclass.h:6322
virtual const String & toString() const
Definition: yatexml.h:1301
void setUnparsed(Type id)
Definition: yatexml.h:182
unsigned int m_offset
Definition: yatexml.h:466
Definition: yatexml.h:1782
void setAttributeValid(const String &name, const char *value)
Definition: yatexml.h:1455
virtual XmlDeclaration * xmlDeclaration()
Definition: yatexml.h:827
const String & buffer() const
Definition: yatexml.h:131
XmlElement * findFirstChild(const String &name, const String *ns=0, bool noPrefix=true) const
Definition: yatexml.h:1341
ObjList * skipNext() const
const char * value
Definition: yatexml.h:54
virtual XmlElement * element()
Definition: yatexml.h:1186
const String & unprefixedTag() const
Definition: yatexml.h:1151
virtual void setParent(XmlParent *parent)
Definition: yatexml.h:736
Definition: yateclass.h:217
XmlElement * pop()
Definition: yatexml.h:1289
virtual XmlParent * getParent()
Definition: yatexml.h:1231
unsigned int offset() const
Definition: yatexml.h:110
XmlElement * findNextChild(const XmlElement *prev=0, const String *name=0, const String *ns=0, bool noPrefix=true) const
Definition: yatexml.h:1355
void removeAttribute(const String &name)
Definition: yatexml.h:1493
static bool blank(char c)
Definition: yatexml.h:210
A C-style string handling class.
Definition: yateclass.h:1832
Error error()
Definition: yatexml.h:153
Error m_error
Definition: yatexml.h:481
Definition: yateclass.h:683
static const String s_nsPrefix
Definition: yatexml.h:1594
virtual XmlDocument * document()
Definition: yatexml.h:973
Type unparsed()
Definition: yatexml.h:175
An object list class.
Definition: yateclass.h:1229
XmlChild * addChildSafe(XmlChild *child)
Definition: yatexml.h:555
String * getAttribute(const String &name) const
Definition: yatexml.h:1475
XmlFragment * fragment()
Definition: yatexml.h:638
static bool isXmlns(const String &str)
Definition: yatexml.h:1539
XmlElement * findFirstChild(const String *name=0, const String *ns=0, bool noPrefix=true) const
Definition: yatexml.h:1328
void resetParsed()
Definition: yatexml.h:360
void YCLASS(class type, class base)
virtual XmlElement * element()
Definition: yatexml.h:540
bool isDefaultNs() const
Definition: yatexml.h:1144
XmlElement * takeRoot(bool completed=false)
Definition: yatexml.h:1005
Xml Declaration.
Definition: yatexml.h:1668
bool badCharacter(char c)
Definition: yatexml.h:348
static const String & empty()
bool empty() const
Definition: yatexml.h:1218
XmlElement * findNextChild(const String &name, const XmlElement *prev=0, const String *ns=0, bool noPrefix=true) const
Definition: yatexml.h:1373
virtual void gotDoctype(const String &doc)
Definition: yatexml.h:437
virtual XmlComment * xmlComment()
Definition: yatexml.h:750
unsigned int row() const
Definition: yatexml.h:117
virtual XmlDocument * document()
Definition: yatexml.h:524
virtual XmlElement * xmlElement()
Definition: yatexml.h:743
Xml Parent.
Definition: yatexml.h:504
String * xmlns() const
Definition: yatexml.h:1500
const String & getBuffer() const
Definition: yatexml.h:193
static const String s_ns
Definition: yatexml.h:1589
virtual XmlDeclaration * xmlDeclaration()
Definition: yatexml.h:771
static XmlElement * findElement(ObjList *list, const String *name, const String *ns, bool noPrefix=true)
Definition: yateclass.h:830
virtual void clearChildren()
Definition: yatexml.h:915
unsigned int m_row
Definition: yatexml.h:471