diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-09-23 19:12:44 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-09-23 19:12:44 (GMT) |
commit | de660b763459cdd707876ec244b6866abca07fa2 (patch) | |
tree | cc9e34f17a18dc152b8a90a0c7cf0076c46a297e /Swiften/Parser | |
parent | de50064af14eb31f027ea7fa59501c9b3754eafd (diff) | |
download | swift-de660b763459cdd707876ec244b6866abca07fa2.zip swift-de660b763459cdd707876ec244b6866abca07fa2.tar.bz2 |
Whitespace tweaks.
Diffstat (limited to 'Swiften/Parser')
-rw-r--r-- | Swiften/Parser/GenericPayloadTreeParser.cpp | 8 | ||||
-rw-r--r-- | Swiften/Parser/GenericPayloadTreeParser.h | 8 | ||||
-rw-r--r-- | Swiften/Parser/SConscript | 2 | ||||
-rw-r--r-- | Swiften/Parser/Tree/NullParserElement.cpp | 13 | ||||
-rw-r--r-- | Swiften/Parser/Tree/NullParserElement.h | 6 | ||||
-rw-r--r-- | Swiften/Parser/Tree/ParserElement.cpp | 8 | ||||
-rw-r--r-- | Swiften/Parser/Tree/ParserElement.h | 50 |
7 files changed, 49 insertions, 46 deletions
diff --git a/Swiften/Parser/GenericPayloadTreeParser.cpp b/Swiften/Parser/GenericPayloadTreeParser.cpp deleted file mode 100644 index 0e25cbc..0000000 --- a/Swiften/Parser/GenericPayloadTreeParser.cpp +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2011 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#include <Swiften/Parser/GenericPayloadTreeParser.h> - diff --git a/Swiften/Parser/GenericPayloadTreeParser.h b/Swiften/Parser/GenericPayloadTreeParser.h index a1946ee..df6d022 100644 --- a/Swiften/Parser/GenericPayloadTreeParser.h +++ b/Swiften/Parser/GenericPayloadTreeParser.h @@ -13,13 +13,8 @@ #include <Swiften/Parser/GenericPayloadParser.h> #include <Swiften/Parser/Tree/ParserElement.h> -#include <Swiften/Parser/Tree/NullParserElement.h> - -#include <iostream> namespace Swift { - - /** * Generic parser offering something a bit like a DOM to work with. */ @@ -30,7 +25,8 @@ namespace Swift { if (!root_) { root_ = boost::make_shared<ParserElement>(element, xmlns, attributes); elementStack_.push_back(root_); - } else { + } + else { ParserElement::ref current = *elementStack_.rbegin(); elementStack_.push_back(current->addChild(element, xmlns, attributes)); } diff --git a/Swiften/Parser/SConscript b/Swiften/Parser/SConscript index b9fcebb..e6c16d1 100644 --- a/Swiften/Parser/SConscript +++ b/Swiften/Parser/SConscript @@ -14,7 +14,6 @@ sources = [ "CompressParser.cpp", "ElementParser.cpp", "IQParser.cpp", - "GenericPayloadTreeParser.cpp", "MessageParser.cpp", "PayloadParser.cpp", "StanzaAckParser.cpp", @@ -67,6 +66,7 @@ sources = [ "StreamResumeParser.cpp", "StreamResumedParser.cpp", "Tree/ParserElement.cpp", + "Tree/NullParserElement.cpp", "XMLParser.cpp", "XMLParserClient.cpp", "XMLParserFactory.cpp", diff --git a/Swiften/Parser/Tree/NullParserElement.cpp b/Swiften/Parser/Tree/NullParserElement.cpp new file mode 100644 index 0000000..7dda9c3 --- /dev/null +++ b/Swiften/Parser/Tree/NullParserElement.cpp @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2011 Kevin Smith + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include <Swiften/Parser/Tree/NullParserElement.h> + +namespace Swift { + +boost::shared_ptr<NullParserElement> NullParserElement::element = boost::make_shared<NullParserElement>(); + +} diff --git a/Swiften/Parser/Tree/NullParserElement.h b/Swiften/Parser/Tree/NullParserElement.h index 93c0662..8dd9bc1 100644 --- a/Swiften/Parser/Tree/NullParserElement.h +++ b/Swiften/Parser/Tree/NullParserElement.h @@ -10,10 +10,12 @@ #include <Swiften/Parser/Tree/ParserElement.h> namespace Swift { - class NullParserElement : public ParserElement { public: NullParserElement() : ParserElement("", "", AttributeMap()) {} - virtual operator bool() {return false;}; + + virtual operator bool() { return false; } + + static boost::shared_ptr<NullParserElement> element; }; } diff --git a/Swiften/Parser/Tree/ParserElement.cpp b/Swiften/Parser/Tree/ParserElement.cpp index 0baf709..9d9b9b6 100644 --- a/Swiften/Parser/Tree/ParserElement.cpp +++ b/Swiften/Parser/Tree/ParserElement.cpp @@ -13,15 +13,9 @@ namespace Swift{ ParserElement::ParserElement(const std::string& name, const std::string& xmlns, const AttributeMap& attributes) : name_(name), xmlns_(xmlns), attributes_(attributes) { - } ParserElement::~ParserElement() { - -} - -ParserElement::operator bool() { - return true; } ParserElement::ref ParserElement::addChild(const std::string& name, const std::string& xmlns, const AttributeMap& attributes) { @@ -52,7 +46,7 @@ std::vector<ParserElement::ref> ParserElement::getChildren(const std::string& na ParserElement::ref ParserElement::getChild(const std::string& name, const std::string& xmlns) const { std::vector<ParserElement::ref> results = getChildren(name, xmlns); - ParserElement::ref result = results.empty() ? boost::make_shared<NullParserElement>() : results[0]; + ParserElement::ref result = results.empty() ? NullParserElement::element : results[0]; return result; } diff --git a/Swiften/Parser/Tree/ParserElement.h b/Swiften/Parser/Tree/ParserElement.h index 7229c5b..b3ad785 100644 --- a/Swiften/Parser/Tree/ParserElement.h +++ b/Swiften/Parser/Tree/ParserElement.h @@ -15,27 +15,33 @@ #include <boost/smart_ptr/make_shared.hpp> namespace Swift { -class ParserElement { - public: - typedef boost::shared_ptr<ParserElement> ref; - ParserElement(const std::string& name, const std::string& xmlns, const AttributeMap& attributes); - virtual ~ParserElement(); - virtual operator bool(); - ParserElement::ref addChild(const std::string& name, const std::string& xmlns, const AttributeMap& attributes); - void appendCharacterData(const std::string& data); - const std::string& getText() const {return text_;}; - const std::string& getName() const {return name_;}; - const std::string& getNamespace() const {return xmlns_;}; - std::vector<ParserElement::ref> getChildren(const std::string& name, const std::string& xmlns) const; - ParserElement::ref getChild(const std::string& name, const std::string& xmlns) const; - const AttributeMap& getAttributes() const {return attributes_;} - private: - std::vector<ParserElement::ref> children_; - std::string name_; - std::string xmlns_; - AttributeMap attributes_; - std::string text_; - -}; + class ParserElement { + public: + typedef boost::shared_ptr<ParserElement> ref; + ParserElement(const std::string& name, const std::string& xmlns, const AttributeMap& attributes); + virtual ~ParserElement(); + + const std::string& getText() const { return text_; } + const std::string& getName() const { return name_; } + const std::string& getNamespace() const { return xmlns_; } + const AttributeMap& getAttributes() const { return attributes_; } + + ParserElement::ref addChild(const std::string& name, const std::string& xmlns, const AttributeMap& attributes); + void appendCharacterData(const std::string& data); + + std::vector<ParserElement::ref> getChildren(const std::string& name, const std::string& xmlns) const; + ParserElement::ref getChild(const std::string& name, const std::string& xmlns) const; + + virtual operator bool() { + return true; + } + + private: + std::vector<ParserElement::ref> children_; + std::string name_; + std::string xmlns_; + AttributeMap attributes_; + std::string text_; + }; } |