38 typedef std::pair<std::string, std::string>
Attribute;
54 GLOOX_DEPRECATED_CTOR
Tag();
63 explicit Tag(
const std::string& name,
const std::string& cdata =
"",
bool incoming =
false );
74 explicit Tag(
Tag *parent,
const std::string& name,
const std::string& cdata =
"",
75 bool incoming =
false );
86 explicit Tag(
const std::string& name,
const std::string& attrib,
const std::string& value,
87 bool incoming =
false );
100 explicit Tag(
Tag *parent,
const std::string& name,
const std::string& attrib,
const std::string& value,
101 bool incoming =
false );
113 virtual const std::string xml()
const;
120 virtual void addAttribute(
const std::string& name,
const std::string& value );
128 virtual void addAttribute(
const std::string& name,
int value );
136 virtual void addAttribute(
const std::string& name,
long value );
149 virtual void addChild(
Tag *child );
156 virtual void addChildCopy(
const Tag *child );
162 virtual void setCData(
const std::string& cdata )
163 { m_cdata = m_incoming ? relax( cdata ) : cdata; }
169 virtual void addCData(
const std::string& cdata )
170 { m_cdata += m_incoming ? relax( cdata ) : cdata; }
176 virtual const std::string&
name()
const {
return m_name; }
182 virtual const std::string&
cdata()
const {
return m_cdata; }
213 virtual const std::string findAttribute(
const std::string& name )
const;
221 virtual bool hasAttribute(
const std::string& name,
const std::string& value =
"" )
const;
229 virtual Tag* findChild(
const std::string& name )
const;
239 virtual Tag* findChild(
const std::string& name,
const std::string& attr,
240 const std::string& value =
"" )
const;
250 virtual inline bool hasChild(
const std::string& name,
const std::string& attr =
"",
251 const std::string& value =
"" )
const
252 {
return findChild( name, attr, value ) ?
true :
false; }
261 virtual Tag* findChildWithAttrib(
const std::string& attr,
const std::string& value =
"" )
const;
270 virtual inline bool hasChildWithAttrib(
const std::string& attr,
271 const std::string& value =
"" )
const
272 {
return findChildWithAttrib( attr, value ) ?
true :
false; }
281 TagList findChildren(
const std::string& name )
const;
295 virtual GLOOX_DEPRECATED
bool empty()
const {
return m_name.empty(); }
304 bool hasChildWithCData(
const std::string& name,
const std::string& cdata )
const;
323 virtual Tag* clone()
const;
335 Tag* findTag(
const std::string& expression );
346 Tag::TagList findTagList(
const std::string& expression );
353 bool operator==(
const Tag &right )
const;
365 operator bool()
const {
return m_valid; }
372 static const std::string escape( std::string what );
379 static const std::string relax( std::string what );
392 AttributeList m_attribs;
437 Tag* parse(
const std::string& expression,
unsigned& len, TokenType border = XTNone );
439 void closePreviousToken( Tag**, Tag**, TokenType&, std::string& );
440 void addToken( Tag **root, Tag **current, TokenType type,
const std::string& token );
441 void addOperator( Tag **root, Tag **current, Tag *arg, TokenType type,
442 const std::string& token );
443 bool addPredicate( Tag **root, Tag **current, Tag *token );
445 TagList findChildren(
const TagList& list,
const std::string& name )
const;
450 static TokenType getType(
const std::string& c );
452 static bool isWhitespace(
const char c );
455 bool evaluateBoolean( Tag *token );
456 bool evaluatePredicate( Tag *token ) {
return evaluateBoolean( token ); }
457 bool evaluateEquals( Tag *token );