summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-09-23 19:12:44 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-09-23 19:12:44 (GMT)
commitde660b763459cdd707876ec244b6866abca07fa2 (patch)
treecc9e34f17a18dc152b8a90a0c7cf0076c46a297e /Swiften/Parser/Tree
parentde50064af14eb31f027ea7fa59501c9b3754eafd (diff)
downloadswift-contrib-de660b763459cdd707876ec244b6866abca07fa2.zip
swift-contrib-de660b763459cdd707876ec244b6866abca07fa2.tar.bz2
Whitespace tweaks.
Diffstat (limited to 'Swiften/Parser/Tree')
-rw-r--r--Swiften/Parser/Tree/NullParserElement.cpp13
-rw-r--r--Swiften/Parser/Tree/NullParserElement.h6
-rw-r--r--Swiften/Parser/Tree/ParserElement.cpp8
-rw-r--r--Swiften/Parser/Tree/ParserElement.h50
4 files changed, 46 insertions, 31 deletions
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_;
+ };
}