31 typedef std::list<Tag*>
TagList;
77 Attribute(
Tag* parent,
const std::string& name,
const std::string& value,
86 Attribute(
const std::string& name,
const std::string& value,
104 const std::string&
name()
const {
return m_name; }
110 const std::string&
value()
const {
return m_value; }
118 bool setValue(
const std::string& value );
124 const std::string& xmlns()
const;
132 bool setXmlns(
const std::string& xmlns );
140 bool setPrefix(
const std::string& prefix );
146 const std::string& prefix()
const;
152 const std::string xml()
const;
159 {
return m_name == right.m_name && m_value == right.m_value && m_xmlns == right.m_xmlns; }
166 {
return !( *
this == right ); }
171 operator bool()
const {
return !m_name.empty(); }
174 void init(
const std::string& name,
const std::string& value,
175 const std::string& xmlns );
180 std::string m_prefix;
194 Tag(
const std::string& name,
const std::string& cdata =
EmptyString );
203 Tag(
Tag* parent,
const std::string& name,
const std::string& cdata =
EmptyString );
211 Tag(
const std::string& name,
const std::string& attrib,
const std::string& value );
221 Tag(
Tag* parent,
const std::string& name,
const std::string& attrib,
const std::string& value );
233 const std::string xml()
const;
242 bool setPrefix(
const std::string& prefix );
249 const std::string&
prefix()
const {
return m_prefix; }
256 const std::string& prefix(
const std::string& xmlns )
const;
278 bool setXmlns(
const std::string& xmlns,
const std::string& prefix =
EmptyString );
286 const std::string& xmlns()
const;
305 const std::string& xmlns(
const std::string& prefix )
const;
317 bool addAttribute( Attribute* attr );
327 bool addAttribute(
const std::string& name,
const std::string& value );
338 bool addAttribute(
const std::string& name,
int value );
349 bool addAttribute(
const std::string& name,
long value );
359 void setAttributes(
const AttributeList& attributes );
365 void addChild(
Tag* child );
372 void addChildCopy(
const Tag* child );
380 bool setCData(
const std::string& cdata );
388 bool addCData(
const std::string& cdata );
394 const std::string&
name()
const {
return m_name; }
400 const std::string cdata()
const;
406 const AttributeList& attributes()
const;
412 const TagList& children()
const;
419 const std::string& findAttribute(
const std::string& name )
const;
427 bool hasAttribute(
const std::string& name,
const std::string& value =
EmptyString )
const;
435 Tag* findChild(
const std::string& name )
const;
445 Tag* findChild(
const std::string& name,
const std::string& attr,
456 bool hasChild(
const std::string& name,
const std::string& attr =
EmptyString,
466 Tag* findChildWithAttrib(
const std::string& attr,
const std::string& value =
EmptyString )
const;
477 {
return findChildWithAttrib( attr, value ) ?
true :
false; }
487 TagList findChildren(
const std::string& name,
const std::string& xmlns =
EmptyString )
const;
495 void removeChild(
const std::string& name,
const std::string& xmlns =
EmptyString );
502 void removeChild(
Tag* tag );
510 void removeAttribute(
const std::string& attr,
const std::string& value =
EmptyString,
520 bool hasChildWithCData(
const std::string& name,
const std::string& cdata )
const;
545 const std::string findCData(
const std::string& expression )
const;
557 const Tag* findTag(
const std::string& expression )
const;
568 ConstTagList findTagList(
const std::string& expression )
const;
575 bool operator==(
const Tag &right )
const;
587 operator bool()
const {
return !m_name.empty(); }
603 XPExpectedLeftOperand,
615 Node( NodeType _type, Tag* _tag ) : type( _type ), tag( _tag ) {}
616 Node( NodeType _type, std::string* _str ) : type( _type ), str( _str ) {}
627 typedef std::list<Node*> NodeList;
632 AttributeList* m_attribs;
637 std::string m_prefix;
680 {
delete m_xmlnss; m_xmlnss = xmlns; }
682 Tag* parse(
const std::string& expression,
unsigned& len, TokenType border = XTNone )
const;
684 void closePreviousToken( Tag**, Tag**, TokenType&, std::string& )
const;
685 void addToken( Tag **root, Tag **current, TokenType type,
const std::string& token )
const;
686 void addOperator( Tag **root, Tag **current, Tag* arg, TokenType type,
687 const std::string& token )
const;
688 bool addPredicate( Tag **root, Tag **current, Tag* token )
const;
690 TagList findChildren(
const TagList& list,
const std::string& name,
692 ConstTagList evaluateTagList( Tag* token )
const;
693 ConstTagList evaluateUnion( Tag* token )
const;
694 ConstTagList allDescendants()
const;
696 static TokenType getType(
const std::string& c );
698 static bool isWhitespace(
const char c );
699 bool isNumber()
const;
701 bool evaluateBoolean( Tag* token )
const;
702 bool evaluatePredicate( Tag* token )
const {
return evaluateBoolean( token ); }
703 bool evaluateEquals( Tag* token )
const;
705 static void add( ConstTagList& one,
const ConstTagList& two );
This class implements an XML parser.
std::list< Attribute * > AttributeList
bool hasChildWithAttrib(const std::string &attr, const std::string &value=EmptyString) const
std::list< Tag * > TagList
std::list< const Tag * > ConstTagList
bool operator!=(const Tag &right) const
bool operator==(const Attribute &right) const
bool operator!=(const Attribute &right) const
const std::string & name() const
The namespace for the gloox library.
std::map< std::string, std::string > StringMap
const std::string & prefix() const
std::list< std::string * > StringPList
const std::string & name() const
const std::string & value() const
const std::string EmptyString
This is an abstraction of an XML element.