1 /*-----------------------------------------------------------------------------
 2 Name:      XmlQoSBase.cpp
 3 Project:   xmlBlaster.org
 4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
 5 Comment:   Handling one QoS (quality of service), knows how to parse it 
 6            with the implemented xml parser.
 7 -----------------------------------------------------------------------------*/
 8 
 9 #include <util/xmlBlasterDef.h>
10 #include <util/XmlQoSBase.h>
11 #include <string>
12 #include <util/Global.h>
13 #include <util/StringTrim.h>
14 
15 using namespace std;
16 
17 namespace org { namespace xmlBlaster { namespace util {
18 
19 XmlQoSBase::XmlQoSBase(Global& global) : XmlHandlerBase(global), ReferenceCounterBase()
20 {
21    inQos_ = false;
22    if (log_.call()) log_.trace(me(), "Creating new XmlQoSBase");
23 }
24 
25 bool XmlQoSBase::isEmpty(const string &qos) 
26 {
27    if (qos.empty()) return true;
28    string trimHelper  = StringTrim::trim(qos);
29    if (trimHelper.size() < 11) return true;
30    
31    string middle;
32    middle.assign(qos, 5, qos.length()-6); // or minus 11 ???
33    if (middle.size() < 1) return true;
34    return false;
35 }
36 
37 bool XmlQoSBase::startElementBase(const string &name, const parser::AttributeMap& /*attrs*/) 
38 {
39    if (name.compare("qos") == 0) {
40       inQos_ = true;
41       return true;
42    }
43    return false;
44 }
45 
46 void XmlQoSBase::startElement(const string &name, const parser::AttributeMap &attrs) 
47 {
48    startElementBase(name, attrs);
49 }
50 
51 bool XmlQoSBase::endElementBase(const string &name) 
52 {
53    if (name.compare("qos") == 0) {
54       inQos_     = false;
55       character_ = "";
56       return true;
57    }
58    return false;
59 }
60 
61 void XmlQoSBase::endElement(const string &name) 
62 {
63    endElementBase(name);
64 }
65 
66 }}} // namespace


syntax highlighted by Code2HTML, v. 0.9.1