21 static const char* conditionValues[] =
23 "deliver",
"expire-at",
"match-resource"
26 static const char* actionValues[] =
28 "alert",
"error",
"drop",
"notify"
31 static const char* deliverValues[] =
33 "direct",
"forward",
"gateway",
"none",
"stored"
36 static const char* matchResourceValues[] =
38 "any",
"exact",
"other"
41 static const char* statusValues[] =
48 : m_condition( ConditionDeliver ), m_deliver( deliver ), m_action( action )
63 const std::string& value )
65 m_condition = (
ConditionType)util::lookup( condition, conditionValues );
66 m_action = (
ActionType)util::lookup( action, actionValues );
70 m_deliver = (
DeliverType)util::lookup( value, deliverValues );
73 m_expireat =
new std::string( value );
98 Tag* rule =
new Tag(
"rule" );
99 rule->
addAttribute(
"condition", util::lookup( m_condition, conditionValues ) );
100 rule->
addAttribute(
"action", util::lookup( m_action, actionValues ) );
102 switch( m_condition )
105 rule->
addAttribute(
"value", util::lookup( m_deliver, deliverValues ) );
111 rule->
addAttribute(
"value", util::lookup( m_matchresource, matchResourceValues ) );
134 ConstTagList::const_iterator it = rules.begin();
135 for( ; it != rules.end(); ++it )
137 m_rules.push_back(
new Rule( (*it)->findAttribute(
"condition" ),
138 (*it)->findAttribute(
"action" ),
139 (*it)->findAttribute(
"value" ) ) );
158 m_rules.push_back( rule );
163 static const std::string filter =
"/message/amp[@xmlns='" +
XMLNS_AMP +
"']";
169 if( !m_valid || !m_rules.size() )
172 Tag* amp =
new Tag(
"amp" );
179 amp->
addAttribute(
"status", util::lookup( m_status, statusValues ) );
182 RuleList::const_iterator it = m_rules.begin();
183 for( ; it != m_rules.end(); ++it )
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
virtual Tag * tag() const
void clearList(std::list< T * > &L)
std::list< const Tag * > ConstTagList
const RuleList & rules() const
virtual const std::string & filterString() const
const std::string XMLNS_AMP
void addChild(Tag *child)
void addRule(const Rule *rule)
The namespace for the gloox library.
This class abstracts a stanza extension, which is usually an element in a specific namespace...
const std::string & xmlns() const
const std::string & findAttribute(const std::string &name) const
bool hasAttribute(const std::string &name, const std::string &value=EmptyString) const
Rule(DeliverType deliver, ActionType action)
bool addAttribute(Attribute *attr)
const std::string & name() const
const std::string & full() const
virtual ~AMP()
Virtual Destructor.
ConstTagList findTagList(const std::string &expression) const
This is an abstraction of an XML element.