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
parentde50064af14eb31f027ea7fa59501c9b3754eafd (diff)
downloadswift-contrib-de660b763459cdd707876ec244b6866abca07fa2.zip
swift-contrib-de660b763459cdd707876ec244b6866abca07fa2.tar.bz2
Whitespace tweaks.
-rw-r--r--Swiften/Parser/GenericPayloadTreeParser.cpp8
-rw-r--r--Swiften/Parser/GenericPayloadTreeParser.h8
-rw-r--r--Swiften/Parser/SConscript2
-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
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
@@ -7,36 +7,32 @@
#pragma once
#include <deque>
#include <boost/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#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.
*/
template<typename PAYLOAD_TYPE>
class GenericPayloadTreeParser : public GenericPayloadParser<PAYLOAD_TYPE> {
public:
virtual void handleStartElement(const std::string& element, const std::string& xmlns, const AttributeMap& attributes) {
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));
}
}
virtual void handleEndElement(const std::string& /*element*/, const std::string&) {
elementStack_.pop_back();
if (elementStack_.empty()) {
handleTree(root_);
diff --git a/Swiften/Parser/SConscript b/Swiften/Parser/SConscript
index b9fcebb..e6c16d1 100644
--- a/Swiften/Parser/SConscript
+++ b/Swiften/Parser/SConscript
@@ -8,19 +8,18 @@ myenv.MergeFlags(swiften_env.get("EXPAT_FLAGS", ""))
sources = [
"AttributeMap.cpp",
"AuthRequestParser.cpp",
"AuthChallengeParser.cpp",
"AuthSuccessParser.cpp",
"AuthResponseParser.cpp",
"CompressParser.cpp",
"ElementParser.cpp",
"IQParser.cpp",
- "GenericPayloadTreeParser.cpp",
"MessageParser.cpp",
"PayloadParser.cpp",
"StanzaAckParser.cpp",
"ComponentHandshakeParser.cpp",
"PayloadParserFactory.cpp",
"PayloadParserFactoryCollection.cpp",
"PayloadParsers/BodyParser.cpp",
"PayloadParsers/SubjectParser.cpp",
"PayloadParsers/ChatStateParser.cpp",
@@ -61,18 +60,19 @@ sources = [
"PresenceParser.cpp",
"SerializingParser.cpp",
"StanzaParser.cpp",
"StreamErrorParser.cpp",
"StreamFeaturesParser.cpp",
"StreamManagementEnabledParser.cpp",
"StreamResumeParser.cpp",
"StreamResumedParser.cpp",
"Tree/ParserElement.cpp",
+ "Tree/NullParserElement.cpp",
"XMLParser.cpp",
"XMLParserClient.cpp",
"XMLParserFactory.cpp",
"XMPPParser.cpp",
"XMPPParserClient.cpp",
]
if myenv.get("HAVE_EXPAT", 0) :
myenv.Append(CPPDEFINES = "HAVE_EXPAT")
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
@@ -4,16 +4,18 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <string>
#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
@@ -7,27 +7,21 @@
#include <Swiften/Parser/Tree/ParserElement.h>
#include <Swiften/Parser/Tree/NullParserElement.h>
#include <iostream>
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) {
ParserElement::ref child = boost::make_shared<ParserElement>(name, xmlns, attributes);
children_.push_back(child);
return child;
}
void ParserElement::appendCharacterData(const std::string& data) {
@@ -46,14 +40,14 @@ struct DoesntMatch {
std::vector<ParserElement::ref> ParserElement::getChildren(const std::string& name, const std::string& xmlns) const {
std::vector<ParserElement::ref> result;
std::remove_copy_if(children_.begin(), children_.end(), std::back_inserter(result), DoesntMatch(name, xmlns));
return result;
}
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
@@ -9,33 +9,39 @@
#include <string>
#include <vector>
#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/Parser/AttributeMap.h>
#include <boost/shared_ptr.hpp>
#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_;
+ };
}