2017-03-05 02:05:02 -08:00
|
|
|
#include "common_protocol.h"
|
|
|
|
|
|
|
|
flatbuffers::Offset<flatbuffers::String> to_flatbuf(
|
|
|
|
flatbuffers::FlatBufferBuilder &fbb,
|
|
|
|
ObjectID object_id) {
|
|
|
|
return fbb.CreateString((char *) &object_id.id[0], sizeof(object_id.id));
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjectID from_flatbuf(const flatbuffers::String *string) {
|
|
|
|
ObjectID object_id;
|
|
|
|
CHECK(string->size() == sizeof(object_id.id));
|
|
|
|
memcpy(&object_id.id[0], string->data(), sizeof(object_id.id));
|
|
|
|
return object_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
flatbuffers::Offset<
|
|
|
|
flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>>
|
|
|
|
to_flatbuf(flatbuffers::FlatBufferBuilder &fbb,
|
|
|
|
ObjectID object_ids[],
|
|
|
|
int64_t num_objects) {
|
|
|
|
std::vector<flatbuffers::Offset<flatbuffers::String>> results;
|
2017-10-12 21:00:23 -07:00
|
|
|
for (int64_t i = 0; i < num_objects; i++) {
|
2017-03-05 02:05:02 -08:00
|
|
|
results.push_back(to_flatbuf(fbb, object_ids[i]));
|
|
|
|
}
|
|
|
|
return fbb.CreateVector(results);
|
|
|
|
}
|