summaryrefslogtreecommitdiffstats
path: root/common/commands.cpp
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2014-12-16 12:05:54 +0100
committerAaron Seigo <aseigo@kde.org>2014-12-16 12:05:54 +0100
commit5fbb9c7a5e927ad7cd3f3f14593104855499101a (patch)
tree3428609ae7960ea80af2b999a28330016059ad67 /common/commands.cpp
parentf41f2ee922d1a653fbe64913dcc209a23758774e (diff)
downloadsink-5fbb9c7a5e927ad7cd3f3f14593104855499101a.tar.gz
sink-5fbb9c7a5e927ad7cd3f3f14593104855499101a.zip
support writing commands without buffers and with pre-allocated buffers
Diffstat (limited to 'common/commands.cpp')
-rw-r--r--common/commands.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/common/commands.cpp b/common/commands.cpp
index abed8b9..ecbbfdb 100644
--- a/common/commands.cpp
+++ b/common/commands.cpp
@@ -28,6 +28,24 @@ namespace Akonadi2
28namespace Commands 28namespace Commands
29{ 29{
30 30
31void write(QIODevice *device, int commandId)
32{
33 write(device, commandId, 0, 0);
34}
35
36void write(QIODevice *device, int commandId, const char *buffer, uint size)
37{
38 if (size > 0 && !buffer) {
39 size = 0;
40 }
41
42 device->write((const char*)&commandId, sizeof(int));
43 device->write((const char*)&size, sizeof(uint));
44 if (buffer) {
45 device->write(buffer, size);
46 }
47}
48
31void write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb) 49void write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb)
32{ 50{
33 const int dataSize = fbb.GetSize(); 51 const int dataSize = fbb.GetSize();