diff options
author | Aaron Seigo <aseigo@kde.org> | 2014-12-16 12:05:54 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2014-12-16 12:05:54 +0100 |
commit | 5fbb9c7a5e927ad7cd3f3f14593104855499101a (patch) | |
tree | 3428609ae7960ea80af2b999a28330016059ad67 /common/commands.cpp | |
parent | f41f2ee922d1a653fbe64913dcc209a23758774e (diff) | |
download | sink-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.cpp | 18 |
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 | |||
28 | namespace Commands | 28 | namespace Commands |
29 | { | 29 | { |
30 | 30 | ||
31 | void write(QIODevice *device, int commandId) | ||
32 | { | ||
33 | write(device, commandId, 0, 0); | ||
34 | } | ||
35 | |||
36 | void 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 | |||
31 | void write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb) | 49 | void write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb) |
32 | { | 50 | { |
33 | const int dataSize = fbb.GetSize(); | 51 | const int dataSize = fbb.GetSize(); |