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 )
53 : m_condition(
ConditionExpireAt ), m_expireat( new std::string( date ) ), m_action( action )
63 const std::string& value )
65 m_condition =
static_cast<ConditionType>( util::lookup( condition, conditionValues ) );
66 m_action =
static_cast<ActionType>( util::lookup( action, actionValues ) );
70 m_deliver =
static_cast<DeliverType>( util::lookup( value, deliverValues ) );
73 m_expireat =
new std::string( value );
76 m_matchresource =
static_cast<MatchResourceType>( util::lookup( value, matchResourceValues ) );
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 )
Rule(DeliverType deliver, ActionType action)
const RuleList & rules() const
void addRule(const Rule *rule)
virtual const std::string & filterString() const
virtual ~AMP()
Virtual Destructor.
virtual Tag * tag() const
const std::string & full() const
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
This is an abstraction of an XML element.
const std::string xmlns() const
bool addAttribute(Attribute *attr)
ConstTagList findTagList(const std::string &expression) const
void addChild(Tag *child)
bool hasAttribute(const std::string &name, const std::string &value=EmptyString) const
const std::string & findAttribute(const std::string &name) const
const std::string & name() const
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
void clearList(std::list< T * > &L)
The namespace for the gloox library.
std::list< const Tag * > ConstTagList
const std::string XMLNS_AMP