diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-02 13:52:04 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-02 13:52:04 +0100 |
commit | 2e98a7f6eb11a071a8ac232bcbb37abea85f6f06 (patch) | |
tree | 30031cbca265656373c3ec24a39000451585102c | |
parent | 7654452afc4fa81fe4fbb26347b58c6ba202dcc9 (diff) | |
download | sink-2e98a7f6eb11a071a8ac232bcbb37abea85f6f06.tar.gz sink-2e98a7f6eb11a071a8ac232bcbb37abea85f6f06.zip |
Cleaner EntityBuffer constructor
-rw-r--r-- | common/entitybuffer.cpp | 6 | ||||
-rw-r--r-- | common/entitybuffer.h | 2 | ||||
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 4 |
3 files changed, 10 insertions, 2 deletions
diff --git a/common/entitybuffer.cpp b/common/entitybuffer.cpp index 344bccc..b4a5cb2 100644 --- a/common/entitybuffer.cpp +++ b/common/entitybuffer.cpp | |||
@@ -18,6 +18,12 @@ EntityBuffer::EntityBuffer(const void *dataValue, int dataSize) | |||
18 | } | 18 | } |
19 | } | 19 | } |
20 | 20 | ||
21 | EntityBuffer::EntityBuffer(const QByteArray &data) | ||
22 | : EntityBuffer(data.constData(), data.size()) | ||
23 | { | ||
24 | |||
25 | } | ||
26 | |||
21 | bool EntityBuffer::isValid() const | 27 | bool EntityBuffer::isValid() const |
22 | { | 28 | { |
23 | return mEntity; | 29 | return mEntity; |
diff --git a/common/entitybuffer.h b/common/entitybuffer.h index 0c0162d..495e94e 100644 --- a/common/entitybuffer.h +++ b/common/entitybuffer.h | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sinkcommon_export.h" | 3 | #include "sinkcommon_export.h" |
4 | #include <functional> | 4 | #include <functional> |
5 | #include <flatbuffers/flatbuffers.h> | 5 | #include <flatbuffers/flatbuffers.h> |
6 | #include <QByteArray> | ||
6 | 7 | ||
7 | namespace Sink { | 8 | namespace Sink { |
8 | struct Entity; | 9 | struct Entity; |
@@ -10,6 +11,7 @@ struct Entity; | |||
10 | class SINKCOMMON_EXPORT EntityBuffer { | 11 | class SINKCOMMON_EXPORT EntityBuffer { |
11 | public: | 12 | public: |
12 | EntityBuffer(const void *dataValue, int size); | 13 | EntityBuffer(const void *dataValue, int size); |
14 | EntityBuffer(const QByteArray &data); | ||
13 | const uint8_t *resourceBuffer(); | 15 | const uint8_t *resourceBuffer(); |
14 | const uint8_t *metadataBuffer(); | 16 | const uint8_t *metadataBuffer(); |
15 | const uint8_t *localBuffer(); | 17 | const uint8_t *localBuffer(); |
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 6d1ec02..3b263a7 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -216,7 +216,7 @@ KAsync::Job<void> MaildirResource::replay(Sink::Storage &synchronizationStore, c | |||
216 | 216 | ||
217 | Trace() << "Replaying " << key << type; | 217 | Trace() << "Replaying " << key << type; |
218 | if (type == ENTITY_TYPE_FOLDER) { | 218 | if (type == ENTITY_TYPE_FOLDER) { |
219 | Sink::EntityBuffer buffer(value.data(), value.size()); | 219 | Sink::EntityBuffer buffer(value); |
220 | const Sink::Entity &entity = buffer.entity(); | 220 | const Sink::Entity &entity = buffer.entity(); |
221 | const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); | 221 | const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); |
222 | if (metadataBuffer && !metadataBuffer->replayToSource()) { | 222 | if (metadataBuffer && !metadataBuffer->replayToSource()) { |
@@ -248,7 +248,7 @@ KAsync::Job<void> MaildirResource::replay(Sink::Storage &synchronizationStore, c | |||
248 | Warning() << "Unkown operation" << operation; | 248 | Warning() << "Unkown operation" << operation; |
249 | } | 249 | } |
250 | } else if (type == ENTITY_TYPE_MAIL) { | 250 | } else if (type == ENTITY_TYPE_MAIL) { |
251 | Sink::EntityBuffer buffer(value.data(), value.size()); | 251 | Sink::EntityBuffer buffer(value); |
252 | const Sink::Entity &entity = buffer.entity(); | 252 | const Sink::Entity &entity = buffer.entity(); |
253 | const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); | 253 | const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); |
254 | if (metadataBuffer && !metadataBuffer->replayToSource()) { | 254 | if (metadataBuffer && !metadataBuffer->replayToSource()) { |