summaryrefslogtreecommitdiffstats
path: root/common/entitybuffer.h
blob: bd9360d638798df004442de5b26a468c43bbcd38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once

#include <functional>
#include <flatbuffers/flatbuffers.h>

namespace Akonadi2 {
class Entity;

class EntityBuffer {
public:
    EntityBuffer(void *dataValue, int size);
    const flatbuffers::Vector<uint8_t> *resourceBuffer();
    const flatbuffers::Vector<uint8_t> *metadataBuffer();
    const flatbuffers::Vector<uint8_t> *localBuffer();
    const Entity &entity();

    static void extractResourceBuffer(void *dataValue, int dataSize, const std::function<void(const flatbuffers::Vector<uint8_t> *)> &handler);
    static void assembleEntityBuffer(flatbuffers::FlatBufferBuilder &fbb, void *metadataData, size_t metadataSize, void *resourceData, size_t resourceSize, void *localData, size_t localSize);

private:
    const Entity *mEntity;
};

}