summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Entity')
-rw-r--r--Swiften/Entity/Entity.cpp20
-rw-r--r--Swiften/Entity/Entity.h58
-rw-r--r--Swiften/Entity/GenericPayloadPersister.h38
-rw-r--r--Swiften/Entity/PayloadPersister.cpp50
-rw-r--r--Swiften/Entity/PayloadPersister.h26
5 files changed, 96 insertions, 96 deletions
diff --git a/Swiften/Entity/Entity.cpp b/Swiften/Entity/Entity.cpp
index af6f636..0875fb1 100644
--- a/Swiften/Entity/Entity.cpp
+++ b/Swiften/Entity/Entity.cpp
@@ -12,38 +12,38 @@
namespace Swift {
Entity::Entity() {
- payloadParserFactories = new FullPayloadParserFactoryCollection();
- payloadSerializers = new FullPayloadSerializerCollection();
+ payloadParserFactories = new FullPayloadParserFactoryCollection();
+ payloadSerializers = new FullPayloadSerializerCollection();
}
Entity::~Entity() {
- delete payloadSerializers;
- delete payloadParserFactories;
+ delete payloadSerializers;
+ delete payloadParserFactories;
}
void Entity::addPayloadParserFactory(PayloadParserFactory* payloadParserFactory) {
- payloadParserFactories->addFactory(payloadParserFactory);
+ payloadParserFactories->addFactory(payloadParserFactory);
}
void Entity::removePayloadParserFactory(PayloadParserFactory* payloadParserFactory) {
- payloadParserFactories->removeFactory(payloadParserFactory);
+ payloadParserFactories->removeFactory(payloadParserFactory);
}
void Entity::addPayloadSerializer(PayloadSerializer* payloadSerializer) {
- payloadSerializers->addSerializer(payloadSerializer);
+ payloadSerializers->addSerializer(payloadSerializer);
}
void Entity::removePayloadSerializer(PayloadSerializer* payloadSerializer) {
- payloadSerializers->removeSerializer(payloadSerializer);
+ payloadSerializers->removeSerializer(payloadSerializer);
}
PayloadParserFactoryCollection* Entity::getPayloadParserFactories() {
- return payloadParserFactories;
+ return payloadParserFactories;
}
PayloadSerializerCollection* Entity::getPayloadSerializers() {
- return payloadSerializers;
+ return payloadSerializers;
}
}
diff --git a/Swiften/Entity/Entity.h b/Swiften/Entity/Entity.h
index d563c5e..a44c145 100644
--- a/Swiften/Entity/Entity.h
+++ b/Swiften/Entity/Entity.h
@@ -9,33 +9,33 @@
#include <Swiften/Base/API.h>
namespace Swift {
- class PayloadParserFactory;
- class PayloadSerializer;
- class FullPayloadParserFactoryCollection;
- class FullPayloadSerializerCollection;
- class PayloadParserFactoryCollection;
- class PayloadSerializerCollection;
-
- /**
- * The base class for XMPP entities (Clients, Components).
- */
- class SWIFTEN_API Entity {
- public:
- Entity();
- virtual ~Entity();
-
- void addPayloadParserFactory(PayloadParserFactory* payloadParserFactory);
- void removePayloadParserFactory(PayloadParserFactory* payloadParserFactory);
-
- void addPayloadSerializer(PayloadSerializer* payloadSerializer);
- void removePayloadSerializer(PayloadSerializer* payloadSerializer);
-
- protected:
- PayloadParserFactoryCollection* getPayloadParserFactories();
- PayloadSerializerCollection* getPayloadSerializers();
-
- private:
- FullPayloadParserFactoryCollection* payloadParserFactories;
- FullPayloadSerializerCollection* payloadSerializers;
- };
+ class PayloadParserFactory;
+ class PayloadSerializer;
+ class FullPayloadParserFactoryCollection;
+ class FullPayloadSerializerCollection;
+ class PayloadParserFactoryCollection;
+ class PayloadSerializerCollection;
+
+ /**
+ * The base class for XMPP entities (Clients, Components).
+ */
+ class SWIFTEN_API Entity {
+ public:
+ Entity();
+ virtual ~Entity();
+
+ void addPayloadParserFactory(PayloadParserFactory* payloadParserFactory);
+ void removePayloadParserFactory(PayloadParserFactory* payloadParserFactory);
+
+ void addPayloadSerializer(PayloadSerializer* payloadSerializer);
+ void removePayloadSerializer(PayloadSerializer* payloadSerializer);
+
+ protected:
+ PayloadParserFactoryCollection* getPayloadParserFactories();
+ PayloadSerializerCollection* getPayloadSerializers();
+
+ private:
+ FullPayloadParserFactoryCollection* payloadParserFactories;
+ FullPayloadSerializerCollection* payloadSerializers;
+ };
}
diff --git a/Swiften/Entity/GenericPayloadPersister.h b/Swiften/Entity/GenericPayloadPersister.h
index 6f07c3b..19afc61 100644
--- a/Swiften/Entity/GenericPayloadPersister.h
+++ b/Swiften/Entity/GenericPayloadPersister.h
@@ -11,27 +11,27 @@
#include <Swiften/Parser/GenericPayloadParserFactory.h>
namespace Swift {
- template<typename PAYLOAD, typename PARSER, typename SERIALIZER>
- class SWIFTEN_API GenericPayloadPersister : public PayloadPersister {
- public:
- GenericPayloadPersister() {
- }
+ template<typename PAYLOAD, typename PARSER, typename SERIALIZER>
+ class SWIFTEN_API GenericPayloadPersister : public PayloadPersister {
+ public:
+ GenericPayloadPersister() {
+ }
- public:
- boost::shared_ptr<PAYLOAD> loadPayloadGeneric(const boost::filesystem::path& path) {
- return boost::dynamic_pointer_cast<PAYLOAD>(loadPayload(path));
- }
+ public:
+ boost::shared_ptr<PAYLOAD> loadPayloadGeneric(const boost::filesystem::path& path) {
+ return boost::dynamic_pointer_cast<PAYLOAD>(loadPayload(path));
+ }
- protected:
- virtual const PayloadSerializer* getSerializer() const {
- return &serializer;
- }
+ protected:
+ virtual const PayloadSerializer* getSerializer() const {
+ return &serializer;
+ }
- virtual PayloadParser* createParser() const {
- return new PARSER();
- }
+ virtual PayloadParser* createParser() const {
+ return new PARSER();
+ }
- private:
- SERIALIZER serializer;
- };
+ private:
+ SERIALIZER serializer;
+ };
}
diff --git a/Swiften/Entity/PayloadPersister.cpp b/Swiften/Entity/PayloadPersister.cpp
index 2ad8e09..7147615 100644
--- a/Swiften/Entity/PayloadPersister.cpp
+++ b/Swiften/Entity/PayloadPersister.cpp
@@ -26,32 +26,32 @@ PayloadPersister::~PayloadPersister() {
}
void PayloadPersister::savePayload(boost::shared_ptr<Payload> payload, const boost::filesystem::path& path) {
- try {
- if (!boost::filesystem::exists(path.parent_path())) {
- boost::filesystem::create_directories(path.parent_path());
- }
- boost::filesystem::ofstream file(path);
- file << getSerializer()->serialize(payload);
- file.close();
- }
- catch (const boost::filesystem::filesystem_error& e) {
- std::cerr << "ERROR: " << e.what() << std::endl;
- }
+ try {
+ if (!boost::filesystem::exists(path.parent_path())) {
+ boost::filesystem::create_directories(path.parent_path());
+ }
+ boost::filesystem::ofstream file(path);
+ file << getSerializer()->serialize(payload);
+ file.close();
+ }
+ catch (const boost::filesystem::filesystem_error& e) {
+ std::cerr << "ERROR: " << e.what() << std::endl;
+ }
}
boost::shared_ptr<Payload> PayloadPersister::loadPayload(const boost::filesystem::path& path) {
- try {
- if (boost::filesystem::exists(path)) {
- ByteArray data;
- readByteArrayFromFile(data, path);
- boost::shared_ptr<PayloadParser> parser(createParser());
- PayloadParserTester tester(parser.get());
- tester.parse(byteArrayToString(data));
- return parser->getPayload();
- }
- }
- catch (const boost::filesystem::filesystem_error& e) {
- std::cerr << "ERROR: " << e.what() << std::endl;
- }
- return boost::shared_ptr<Payload>();
+ try {
+ if (boost::filesystem::exists(path)) {
+ ByteArray data;
+ readByteArrayFromFile(data, path);
+ boost::shared_ptr<PayloadParser> parser(createParser());
+ PayloadParserTester tester(parser.get());
+ tester.parse(byteArrayToString(data));
+ return parser->getPayload();
+ }
+ }
+ catch (const boost::filesystem::filesystem_error& e) {
+ std::cerr << "ERROR: " << e.what() << std::endl;
+ }
+ return boost::shared_ptr<Payload>();
}
diff --git a/Swiften/Entity/PayloadPersister.h b/Swiften/Entity/PayloadPersister.h
index 44f400f..9102f4b 100644
--- a/Swiften/Entity/PayloadPersister.h
+++ b/Swiften/Entity/PayloadPersister.h
@@ -12,21 +12,21 @@
#include <Swiften/Base/API.h>
namespace Swift {
- class Payload;
- class PayloadSerializer;
- class PayloadParser;
+ class Payload;
+ class PayloadSerializer;
+ class PayloadParser;
- class SWIFTEN_API PayloadPersister {
- public:
- PayloadPersister();
- virtual ~PayloadPersister();
+ class SWIFTEN_API PayloadPersister {
+ public:
+ PayloadPersister();
+ virtual ~PayloadPersister();
- void savePayload(boost::shared_ptr<Payload>, const boost::filesystem::path&);
- boost::shared_ptr<Payload> loadPayload(const boost::filesystem::path&);
+ void savePayload(boost::shared_ptr<Payload>, const boost::filesystem::path&);
+ boost::shared_ptr<Payload> loadPayload(const boost::filesystem::path&);
- protected:
+ protected:
- virtual const PayloadSerializer* getSerializer() const = 0;
- virtual PayloadParser* createParser() const = 0;
- };
+ virtual const PayloadSerializer* getSerializer() const = 0;
+ virtual PayloadParser* createParser() const = 0;
+ };
}