self_msgproto 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +19 -0
- data/ext/self_msgproto/acl.cpp +108 -0
- data/ext/self_msgproto/auth.cpp +107 -0
- data/ext/self_msgproto/extconf.rb +11 -0
- data/ext/self_msgproto/header.cpp +53 -0
- data/ext/self_msgproto/message.cpp +131 -0
- data/ext/self_msgproto/msgproto/acl_generated.h +137 -0
- data/ext/self_msgproto/msgproto/auth_generated.h +151 -0
- data/ext/self_msgproto/msgproto/header_generated.h +111 -0
- data/ext/self_msgproto/msgproto/message_generated.h +234 -0
- data/ext/self_msgproto/msgproto/notification_generated.h +137 -0
- data/ext/self_msgproto/msgproto/types_generated.h +208 -0
- data/ext/self_msgproto/notification.cpp +57 -0
- data/ext/self_msgproto/self_msgproto.cpp +21 -0
- data/lib/self_msgproto.rb +12 -0
- data/lib/self_msgproto/acl.rb +9 -0
- data/lib/self_msgproto/auth.rb +9 -0
- data/lib/self_msgproto/header.rb +9 -0
- data/lib/self_msgproto/message.rb +10 -0
- data/lib/self_msgproto/notification.rb +9 -0
- data/lib/self_msgproto/version.rb +7 -0
- data/test/spec/test_message.rb +20 -0
- data/test/unit/test_header.rb +16 -0
- data/test/unit/test_message.rb +24 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 942aa1cdb3405dedc5c909d8a1e78e748e0b0720f7e18ee312ac21ed599bf069
|
4
|
+
data.tar.gz: 6fb51a8cb6df6d3cb4533c249f3cdc6d09085780048b7982c18e5ed218d37a65
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4293de44b79d15028271c37adc119f13babc823826dede717c89563508b03396fa5ed2a348c47e66f8862d21968d080aaa40884a47bd200ea05dc85a1a941e9a
|
7
|
+
data.tar.gz: 66cbf37d983e27eb422bd9ccfc3f35c141e1035ebc6f9e66967af8c8e369473223ecdba409e94e2c324970977a9b1fab55de4f580449c1fc88c8da51cba0fa7d
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
require 'rake/extensiontask'
|
3
|
+
|
4
|
+
Rake::ExtensionTask.new do |ext|
|
5
|
+
ext.name = "self_msgproto"
|
6
|
+
ext.ext_dir = "ext/self_msgproto"
|
7
|
+
ext.lib_dir = "lib/self_msgproto"
|
8
|
+
end
|
9
|
+
|
10
|
+
task :test => :compile
|
11
|
+
|
12
|
+
Rake::TestTask.new do |t|
|
13
|
+
t.name = :test
|
14
|
+
t.libs << "lib"
|
15
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
16
|
+
t.verbose = true
|
17
|
+
end
|
18
|
+
|
19
|
+
task :default => :test
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
#include "rice/rice.hpp"
|
3
|
+
#include "flatbuffers/flatbuffers.h"
|
4
|
+
#include "msgproto/acl_generated.h"
|
5
|
+
|
6
|
+
using namespace SelfMessaging;
|
7
|
+
|
8
|
+
VALUE acl_initialize(int argc, VALUE *argv, VALUE self)
|
9
|
+
{
|
10
|
+
VALUE opts;
|
11
|
+
|
12
|
+
(void)rb_scan_args(argc, argv, "0:", &opts);
|
13
|
+
|
14
|
+
opts = (opts == Qnil) ? rb_hash_new(): opts;
|
15
|
+
|
16
|
+
VALUE data = rb_hash_aref(opts, ID2SYM(rb_intern("data")));
|
17
|
+
|
18
|
+
if (data != Qnil) {
|
19
|
+
if(rb_obj_is_kind_of(data, rb_cString) != Qtrue){
|
20
|
+
rb_raise(rb_eTypeError, "acl data must be kind of String");
|
21
|
+
}
|
22
|
+
|
23
|
+
const uint8_t *data_ptr = (uint8_t *)RSTRING_PTR(data);
|
24
|
+
long data_len = RSTRING_LEN(data);
|
25
|
+
|
26
|
+
auto acl = GetACL(data_ptr);
|
27
|
+
|
28
|
+
flatbuffers::Verifier verifier(data_ptr, data_len);
|
29
|
+
|
30
|
+
if (!VerifyACLBuffer(verifier)) {
|
31
|
+
rb_raise(rb_eStandardError, "acl buffer is invalid");
|
32
|
+
}
|
33
|
+
|
34
|
+
auto id = acl->id()->c_str();
|
35
|
+
auto mtype = acl->msgtype();
|
36
|
+
auto command = acl->command();
|
37
|
+
auto payload = acl->payload();
|
38
|
+
|
39
|
+
VALUE idstr = rb_str_new(id, std::strlen(id));
|
40
|
+
rb_ivar_set(self, rb_intern("@id"), idstr);
|
41
|
+
|
42
|
+
VALUE mtypeint = rb_int2inum(mtype);
|
43
|
+
rb_ivar_set(self, rb_intern("@type"), mtypeint);
|
44
|
+
|
45
|
+
VALUE commandint = rb_int2inum(command);
|
46
|
+
rb_ivar_set(self, rb_intern("@command"), commandint);
|
47
|
+
|
48
|
+
const u_char *payloaddata = payload->data();
|
49
|
+
long payloadsize = payload->size();
|
50
|
+
|
51
|
+
VALUE payloadstr = rb_str_new((const char *)payloaddata, payloadsize);
|
52
|
+
rb_ivar_set(self, rb_intern("@payload"), payloadstr);
|
53
|
+
}
|
54
|
+
|
55
|
+
return self;
|
56
|
+
}
|
57
|
+
|
58
|
+
VALUE acl_to_fb(VALUE self)
|
59
|
+
{
|
60
|
+
VALUE idv = rb_ivar_get(self, rb_intern("@id"));
|
61
|
+
char *idstr = RSTRING_PTR(idv);
|
62
|
+
|
63
|
+
VALUE commandv = rb_ivar_get(self, rb_intern("@command"));
|
64
|
+
uint8_t commandint = NUM2INT(commandv);
|
65
|
+
|
66
|
+
ACLCommand command;
|
67
|
+
|
68
|
+
if (commandint < ACLCommand_MIN || commandint > ACLCommand_MAX) {
|
69
|
+
rb_raise(rb_eStandardError, "acl command is invalid");
|
70
|
+
}
|
71
|
+
|
72
|
+
VALUE payloadv = rb_ivar_get(self, rb_intern("@payload"));
|
73
|
+
u_char *payloadstr = (u_char *)RSTRING_PTR(payloadv);
|
74
|
+
long payloadlen = RSTRING_LEN(payloadv);
|
75
|
+
|
76
|
+
flatbuffers::FlatBufferBuilder builder(1024);
|
77
|
+
|
78
|
+
auto id = builder.CreateString(idstr);
|
79
|
+
auto payload = builder.CreateVector(payloadstr, payloadlen);
|
80
|
+
|
81
|
+
ACLBuilder acl_builder(builder);
|
82
|
+
|
83
|
+
acl_builder.add_id(id);
|
84
|
+
acl_builder.add_msgtype(MsgType_ACL);
|
85
|
+
acl_builder.add_command(command);
|
86
|
+
acl_builder.add_payload(payload);
|
87
|
+
|
88
|
+
auto acl = acl_builder.Finish();
|
89
|
+
builder.Finish(acl);
|
90
|
+
|
91
|
+
uint8_t *buf = builder.GetBufferPointer();
|
92
|
+
int size = builder.GetSize();
|
93
|
+
|
94
|
+
VALUE data = rb_str_new((char *)buf, size);
|
95
|
+
|
96
|
+
builder.Release();
|
97
|
+
|
98
|
+
return data;
|
99
|
+
}
|
100
|
+
|
101
|
+
void acl_init() {
|
102
|
+
VALUE cRubySelfMsg = rb_define_module("SelfMsg");
|
103
|
+
VALUE cAcl = rb_define_class_under(cRubySelfMsg, "Acl", rb_cObject);
|
104
|
+
|
105
|
+
rb_define_method(cAcl, "initialize", acl_initialize, -1);
|
106
|
+
rb_define_method(cAcl, "to_fb", acl_to_fb, 0);
|
107
|
+
}
|
108
|
+
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
#include "rice/rice.hpp"
|
3
|
+
#include "flatbuffers/flatbuffers.h"
|
4
|
+
#include "msgproto/auth_generated.h"
|
5
|
+
|
6
|
+
using namespace SelfMessaging;
|
7
|
+
|
8
|
+
VALUE auth_initialize(int argc, VALUE *argv, VALUE self)
|
9
|
+
{
|
10
|
+
VALUE opts;
|
11
|
+
|
12
|
+
(void)rb_scan_args(argc, argv, "0:", &opts);
|
13
|
+
|
14
|
+
opts = (opts == Qnil) ? rb_hash_new(): opts;
|
15
|
+
|
16
|
+
VALUE data = rb_hash_aref(opts, ID2SYM(rb_intern("data")));
|
17
|
+
|
18
|
+
if (data != Qnil) {
|
19
|
+
if(rb_obj_is_kind_of(data, rb_cString) != Qtrue){
|
20
|
+
rb_raise(rb_eTypeError, "auth data must be kind of String");
|
21
|
+
}
|
22
|
+
|
23
|
+
const uint8_t *data_ptr = (uint8_t *)RSTRING_PTR(data);
|
24
|
+
long data_len = RSTRING_LEN(data);
|
25
|
+
|
26
|
+
auto auth = GetAuth(data_ptr);
|
27
|
+
|
28
|
+
flatbuffers::Verifier verifier(data_ptr, data_len);
|
29
|
+
|
30
|
+
if (!VerifyAuthBuffer(verifier)) {
|
31
|
+
rb_raise(rb_eStandardError, "auth buffer is invalid");
|
32
|
+
}
|
33
|
+
|
34
|
+
auto id = auth->id()->c_str();
|
35
|
+
auto mtype = auth->msgtype();
|
36
|
+
auto token = auth->token()->c_str();
|
37
|
+
auto device = auth->device()->c_str();
|
38
|
+
auto offset = auth->offset();
|
39
|
+
|
40
|
+
VALUE idstr = rb_str_new(id, std::strlen(id));
|
41
|
+
rb_ivar_set(self, rb_intern("@id"), idstr);
|
42
|
+
|
43
|
+
VALUE mtypeint = rb_int2inum(mtype);
|
44
|
+
rb_ivar_set(self, rb_intern("@type"), mtypeint);
|
45
|
+
|
46
|
+
VALUE offsetint = rb_int2inum(offset);
|
47
|
+
rb_ivar_set(self, rb_intern("@offset"), offsetint);
|
48
|
+
|
49
|
+
VALUE tokenstr = rb_str_new(token, std::strlen(token));
|
50
|
+
rb_ivar_set(self, rb_intern("@token"), tokenstr);
|
51
|
+
|
52
|
+
VALUE devicestr = rb_str_new(device, std::strlen(device));
|
53
|
+
rb_ivar_set(self, rb_intern("@device"), devicestr);
|
54
|
+
}
|
55
|
+
|
56
|
+
return self;
|
57
|
+
}
|
58
|
+
|
59
|
+
VALUE auth_to_fb(VALUE self)
|
60
|
+
{
|
61
|
+
VALUE idv = rb_ivar_get(self, rb_intern("@id"));
|
62
|
+
char *idstr = RSTRING_PTR(idv);
|
63
|
+
|
64
|
+
VALUE tokenv = rb_ivar_get(self, rb_intern("@token"));
|
65
|
+
char *tokenstr = RSTRING_PTR(tokenv);
|
66
|
+
|
67
|
+
VALUE devicev = rb_ivar_get(self, rb_intern("@device"));
|
68
|
+
char *devicestr = RSTRING_PTR(devicev);
|
69
|
+
|
70
|
+
VALUE offsetv = rb_ivar_get(self, rb_intern("@offset"));
|
71
|
+
int64_t offset = NUM2INT(offsetv);
|
72
|
+
|
73
|
+
flatbuffers::FlatBufferBuilder builder(1024);
|
74
|
+
|
75
|
+
auto id = builder.CreateString(idstr);
|
76
|
+
auto token = builder.CreateString(tokenstr);
|
77
|
+
auto device = builder.CreateString(devicestr);
|
78
|
+
|
79
|
+
AuthBuilder auth_builder(builder);
|
80
|
+
|
81
|
+
auth_builder.add_id(id);
|
82
|
+
auth_builder.add_msgtype(MsgType_AUTH);
|
83
|
+
auth_builder.add_token(token);
|
84
|
+
auth_builder.add_device(device);
|
85
|
+
auth_builder.add_offset(offset);
|
86
|
+
|
87
|
+
auto auth = auth_builder.Finish();
|
88
|
+
builder.Finish(auth);
|
89
|
+
|
90
|
+
uint8_t *buf = builder.GetBufferPointer();
|
91
|
+
int size = builder.GetSize();
|
92
|
+
|
93
|
+
VALUE data = rb_str_new((char *)buf, size);
|
94
|
+
|
95
|
+
builder.Release();
|
96
|
+
|
97
|
+
return data;
|
98
|
+
}
|
99
|
+
|
100
|
+
void auth_init() {
|
101
|
+
VALUE cRubySelfMsg = rb_define_module("SelfMsg");
|
102
|
+
VALUE cAuth = rb_define_class_under(cRubySelfMsg, "Auth", rb_cObject);
|
103
|
+
|
104
|
+
rb_define_method(cAuth, "initialize", auth_initialize, -1);
|
105
|
+
rb_define_method(cAuth, "to_fb", auth_to_fb, 0);
|
106
|
+
}
|
107
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
#include "rice/rice.hpp"
|
3
|
+
#include "flatbuffers/flatbuffers.h"
|
4
|
+
#include "msgproto/header_generated.h"
|
5
|
+
|
6
|
+
using namespace SelfMessaging;
|
7
|
+
|
8
|
+
VALUE header_initialize(int argc, VALUE *argv, VALUE self)
|
9
|
+
{
|
10
|
+
VALUE opts;
|
11
|
+
|
12
|
+
(void)rb_scan_args(argc, argv, "0:", &opts);
|
13
|
+
|
14
|
+
opts = (opts == Qnil) ? rb_hash_new(): opts;
|
15
|
+
|
16
|
+
VALUE data = rb_hash_aref(opts, ID2SYM(rb_intern("data")));
|
17
|
+
|
18
|
+
if (data != Qnil) {
|
19
|
+
if(rb_obj_is_kind_of(data, rb_cString) != Qtrue){
|
20
|
+
rb_raise(rb_eTypeError, "header data must be kind of String");
|
21
|
+
}
|
22
|
+
|
23
|
+
const uint8_t *data_ptr = (uint8_t *)RSTRING_PTR(data);
|
24
|
+
long data_len = RSTRING_LEN(data);
|
25
|
+
|
26
|
+
auto hdr = GetHeader(data_ptr);
|
27
|
+
|
28
|
+
flatbuffers::Verifier verifier(data_ptr, data_len);
|
29
|
+
|
30
|
+
if (!VerifyHeaderBuffer(verifier)) {
|
31
|
+
rb_raise(rb_eStandardError, "header buffer is invalid");
|
32
|
+
}
|
33
|
+
|
34
|
+
auto id = hdr->id()->c_str();
|
35
|
+
auto mtype = hdr->msgtype();
|
36
|
+
|
37
|
+
VALUE idstr = rb_str_new(id, std::strlen(id));
|
38
|
+
rb_ivar_set(self, rb_intern("@id"), idstr);
|
39
|
+
|
40
|
+
VALUE mtypeint = rb_int2inum(mtype);
|
41
|
+
rb_ivar_set(self, rb_intern("@type"), mtypeint);
|
42
|
+
}
|
43
|
+
|
44
|
+
return self;
|
45
|
+
}
|
46
|
+
|
47
|
+
void header_init() {
|
48
|
+
VALUE cRubySelfMsg = rb_define_module("SelfMsg");
|
49
|
+
VALUE cHeader = rb_define_class_under(cRubySelfMsg, "Header", rb_cObject);
|
50
|
+
|
51
|
+
rb_define_method(cHeader, "initialize", header_initialize, -1);
|
52
|
+
}
|
53
|
+
|
@@ -0,0 +1,131 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
#include "rice/rice.hpp"
|
3
|
+
#include "flatbuffers/flatbuffers.h"
|
4
|
+
#include "msgproto/message_generated.h"
|
5
|
+
|
6
|
+
using namespace SelfMessaging;
|
7
|
+
|
8
|
+
VALUE message_initialize(int argc, VALUE *argv, VALUE self)
|
9
|
+
{
|
10
|
+
VALUE opts;
|
11
|
+
|
12
|
+
(void)rb_scan_args(argc, argv, "0:", &opts);
|
13
|
+
|
14
|
+
opts = (opts == Qnil) ? rb_hash_new(): opts;
|
15
|
+
|
16
|
+
VALUE data = rb_hash_aref(opts, ID2SYM(rb_intern("data")));
|
17
|
+
|
18
|
+
if (data != Qnil) {
|
19
|
+
if(rb_obj_is_kind_of(data, rb_cString) != Qtrue){
|
20
|
+
rb_raise(rb_eTypeError, "message data must be kind of String");
|
21
|
+
}
|
22
|
+
|
23
|
+
const uint8_t *data_ptr = (uint8_t *)RSTRING_PTR(data);
|
24
|
+
long data_len = RSTRING_LEN(data);
|
25
|
+
|
26
|
+
auto msg = GetMessage(data_ptr);
|
27
|
+
|
28
|
+
flatbuffers::Verifier verifier(data_ptr, data_len);
|
29
|
+
|
30
|
+
if (!VerifyMessageBuffer(verifier)) {
|
31
|
+
rb_raise(rb_eStandardError, "message buffer is invalid");
|
32
|
+
}
|
33
|
+
|
34
|
+
// std::cout << std::strlen(msg->id()->c_str()) << std::endl;
|
35
|
+
|
36
|
+
auto id = msg->id()->c_str();
|
37
|
+
auto mtype = msg->msgtype();
|
38
|
+
auto stype = msg->subtype();
|
39
|
+
auto sender = msg->sender()->c_str();
|
40
|
+
auto recipient = msg->recipient()->c_str();
|
41
|
+
auto ciphertext = msg->ciphertext();
|
42
|
+
auto metadata = msg->metadata();
|
43
|
+
|
44
|
+
auto offset = metadata->offset();
|
45
|
+
auto timestamp = metadata->timestamp();
|
46
|
+
|
47
|
+
VALUE idstr = rb_str_new(id, std::strlen(id));
|
48
|
+
rb_ivar_set(self, rb_intern("@id"), idstr);
|
49
|
+
|
50
|
+
VALUE mtypeint = rb_int2inum(mtype);
|
51
|
+
rb_ivar_set(self, rb_intern("@type"), mtypeint);
|
52
|
+
|
53
|
+
VALUE stypeint = rb_int2inum(stype);
|
54
|
+
rb_ivar_set(self, rb_intern("@subtype"), stypeint);
|
55
|
+
|
56
|
+
VALUE offsetint = rb_int2inum(offset);
|
57
|
+
rb_ivar_set(self, rb_intern("@offset"), offsetint);
|
58
|
+
|
59
|
+
VALUE timestampint = rb_int2inum(timestamp);
|
60
|
+
rb_ivar_set(self, rb_intern("@timestamp"), timestampint);
|
61
|
+
|
62
|
+
VALUE senderstr = rb_str_new(sender, std::strlen(sender));
|
63
|
+
rb_ivar_set(self, rb_intern("@sender"), senderstr);
|
64
|
+
|
65
|
+
VALUE recipientstr = rb_str_new(recipient, std::strlen(recipient));
|
66
|
+
rb_ivar_set(self, rb_intern("@recipient"), recipientstr);
|
67
|
+
|
68
|
+
const u_char *ciphertextdata = ciphertext->data();
|
69
|
+
long ciphertextsize = ciphertext->size();
|
70
|
+
|
71
|
+
VALUE ciphertextstr = rb_str_new((const char *)ciphertextdata, ciphertextsize);
|
72
|
+
rb_ivar_set(self, rb_intern("@ciphertext"), ciphertextstr);
|
73
|
+
}
|
74
|
+
|
75
|
+
return self;
|
76
|
+
}
|
77
|
+
|
78
|
+
VALUE message_to_fb(VALUE self)
|
79
|
+
{
|
80
|
+
VALUE idv = rb_ivar_get(self, rb_intern("@id"));
|
81
|
+
char *idstr = RSTRING_PTR(idv);
|
82
|
+
|
83
|
+
VALUE senderv = rb_ivar_get(self, rb_intern("@sender"));
|
84
|
+
char *senderstr = RSTRING_PTR(senderv);
|
85
|
+
|
86
|
+
VALUE recipientv = rb_ivar_get(self, rb_intern("@recipient"));
|
87
|
+
char *recipientstr = RSTRING_PTR(recipientv);
|
88
|
+
|
89
|
+
VALUE ciphertextv = rb_ivar_get(self, rb_intern("@ciphertext"));
|
90
|
+
u_char *ciphertextstr = (u_char *)RSTRING_PTR(ciphertextv);
|
91
|
+
long ciphertextlen = RSTRING_LEN(ciphertextv);
|
92
|
+
|
93
|
+
flatbuffers::FlatBufferBuilder builder(1024);
|
94
|
+
|
95
|
+
auto id = builder.CreateString(idstr);
|
96
|
+
auto sender = builder.CreateString(senderstr);
|
97
|
+
auto recipient = builder.CreateString(recipientstr);
|
98
|
+
auto ciphertext = builder.CreateVector(ciphertextstr, ciphertextlen);
|
99
|
+
|
100
|
+
SelfMessaging::Metadata metadata(0, 0);
|
101
|
+
|
102
|
+
MessageBuilder msg_builder(builder);
|
103
|
+
|
104
|
+
msg_builder.add_id(id);
|
105
|
+
msg_builder.add_msgtype(MsgType_MSG);
|
106
|
+
msg_builder.add_sender(sender);
|
107
|
+
msg_builder.add_recipient(recipient);
|
108
|
+
msg_builder.add_ciphertext(ciphertext);
|
109
|
+
msg_builder.add_metadata(&metadata);
|
110
|
+
|
111
|
+
auto msg = msg_builder.Finish();
|
112
|
+
builder.Finish(msg);
|
113
|
+
|
114
|
+
uint8_t *buf = builder.GetBufferPointer();
|
115
|
+
int size = builder.GetSize();
|
116
|
+
|
117
|
+
VALUE data = rb_str_new((char *)buf, size);
|
118
|
+
|
119
|
+
builder.Release();
|
120
|
+
|
121
|
+
return data;
|
122
|
+
}
|
123
|
+
|
124
|
+
void message_init() {
|
125
|
+
VALUE cRubySelfMsg = rb_define_module("SelfMsg");
|
126
|
+
VALUE cMessage = rb_define_class_under(cRubySelfMsg, "Message", rb_cObject);
|
127
|
+
|
128
|
+
rb_define_method(cMessage, "initialize", message_initialize, -1);
|
129
|
+
rb_define_method(cMessage, "to_fb", message_to_fb, 0);
|
130
|
+
}
|
131
|
+
|
@@ -0,0 +1,137 @@
|
|
1
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
2
|
+
|
3
|
+
|
4
|
+
#ifndef FLATBUFFERS_GENERATED_ACL_SELFMESSAGING_H_
|
5
|
+
#define FLATBUFFERS_GENERATED_ACL_SELFMESSAGING_H_
|
6
|
+
|
7
|
+
#include "flatbuffers/flatbuffers.h"
|
8
|
+
|
9
|
+
#include "types_generated.h"
|
10
|
+
|
11
|
+
namespace SelfMessaging {
|
12
|
+
|
13
|
+
struct ACL;
|
14
|
+
struct ACLBuilder;
|
15
|
+
|
16
|
+
struct ACL FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
17
|
+
typedef ACLBuilder Builder;
|
18
|
+
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
19
|
+
VT_ID = 4,
|
20
|
+
VT_MSGTYPE = 6,
|
21
|
+
VT_COMMAND = 8,
|
22
|
+
VT_PAYLOAD = 10
|
23
|
+
};
|
24
|
+
const flatbuffers::String *id() const {
|
25
|
+
return GetPointer<const flatbuffers::String *>(VT_ID);
|
26
|
+
}
|
27
|
+
SelfMessaging::MsgType msgtype() const {
|
28
|
+
return static_cast<SelfMessaging::MsgType>(GetField<int8_t>(VT_MSGTYPE, 0));
|
29
|
+
}
|
30
|
+
SelfMessaging::ACLCommand command() const {
|
31
|
+
return static_cast<SelfMessaging::ACLCommand>(GetField<int8_t>(VT_COMMAND, 0));
|
32
|
+
}
|
33
|
+
const flatbuffers::Vector<uint8_t> *payload() const {
|
34
|
+
return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_PAYLOAD);
|
35
|
+
}
|
36
|
+
bool Verify(flatbuffers::Verifier &verifier) const {
|
37
|
+
return VerifyTableStart(verifier) &&
|
38
|
+
VerifyOffset(verifier, VT_ID) &&
|
39
|
+
verifier.VerifyString(id()) &&
|
40
|
+
VerifyField<int8_t>(verifier, VT_MSGTYPE) &&
|
41
|
+
VerifyField<int8_t>(verifier, VT_COMMAND) &&
|
42
|
+
VerifyOffset(verifier, VT_PAYLOAD) &&
|
43
|
+
verifier.VerifyVector(payload()) &&
|
44
|
+
verifier.EndTable();
|
45
|
+
}
|
46
|
+
};
|
47
|
+
|
48
|
+
struct ACLBuilder {
|
49
|
+
typedef ACL Table;
|
50
|
+
flatbuffers::FlatBufferBuilder &fbb_;
|
51
|
+
flatbuffers::uoffset_t start_;
|
52
|
+
void add_id(flatbuffers::Offset<flatbuffers::String> id) {
|
53
|
+
fbb_.AddOffset(ACL::VT_ID, id);
|
54
|
+
}
|
55
|
+
void add_msgtype(SelfMessaging::MsgType msgtype) {
|
56
|
+
fbb_.AddElement<int8_t>(ACL::VT_MSGTYPE, static_cast<int8_t>(msgtype), 0);
|
57
|
+
}
|
58
|
+
void add_command(SelfMessaging::ACLCommand command) {
|
59
|
+
fbb_.AddElement<int8_t>(ACL::VT_COMMAND, static_cast<int8_t>(command), 0);
|
60
|
+
}
|
61
|
+
void add_payload(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> payload) {
|
62
|
+
fbb_.AddOffset(ACL::VT_PAYLOAD, payload);
|
63
|
+
}
|
64
|
+
explicit ACLBuilder(flatbuffers::FlatBufferBuilder &_fbb)
|
65
|
+
: fbb_(_fbb) {
|
66
|
+
start_ = fbb_.StartTable();
|
67
|
+
}
|
68
|
+
flatbuffers::Offset<ACL> Finish() {
|
69
|
+
const auto end = fbb_.EndTable(start_);
|
70
|
+
auto o = flatbuffers::Offset<ACL>(end);
|
71
|
+
return o;
|
72
|
+
}
|
73
|
+
};
|
74
|
+
|
75
|
+
inline flatbuffers::Offset<ACL> CreateACL(
|
76
|
+
flatbuffers::FlatBufferBuilder &_fbb,
|
77
|
+
flatbuffers::Offset<flatbuffers::String> id = 0,
|
78
|
+
SelfMessaging::MsgType msgtype = SelfMessaging::MsgType_MSG,
|
79
|
+
SelfMessaging::ACLCommand command = SelfMessaging::ACLCommand_LIST,
|
80
|
+
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> payload = 0) {
|
81
|
+
ACLBuilder builder_(_fbb);
|
82
|
+
builder_.add_payload(payload);
|
83
|
+
builder_.add_id(id);
|
84
|
+
builder_.add_command(command);
|
85
|
+
builder_.add_msgtype(msgtype);
|
86
|
+
return builder_.Finish();
|
87
|
+
}
|
88
|
+
|
89
|
+
inline flatbuffers::Offset<ACL> CreateACLDirect(
|
90
|
+
flatbuffers::FlatBufferBuilder &_fbb,
|
91
|
+
const char *id = nullptr,
|
92
|
+
SelfMessaging::MsgType msgtype = SelfMessaging::MsgType_MSG,
|
93
|
+
SelfMessaging::ACLCommand command = SelfMessaging::ACLCommand_LIST,
|
94
|
+
const std::vector<uint8_t> *payload = nullptr) {
|
95
|
+
auto id__ = id ? _fbb.CreateString(id) : 0;
|
96
|
+
auto payload__ = payload ? _fbb.CreateVector<uint8_t>(*payload) : 0;
|
97
|
+
return SelfMessaging::CreateACL(
|
98
|
+
_fbb,
|
99
|
+
id__,
|
100
|
+
msgtype,
|
101
|
+
command,
|
102
|
+
payload__);
|
103
|
+
}
|
104
|
+
|
105
|
+
inline const SelfMessaging::ACL *GetACL(const void *buf) {
|
106
|
+
return flatbuffers::GetRoot<SelfMessaging::ACL>(buf);
|
107
|
+
}
|
108
|
+
|
109
|
+
inline const SelfMessaging::ACL *GetSizePrefixedACL(const void *buf) {
|
110
|
+
return flatbuffers::GetSizePrefixedRoot<SelfMessaging::ACL>(buf);
|
111
|
+
}
|
112
|
+
|
113
|
+
inline bool VerifyACLBuffer(
|
114
|
+
flatbuffers::Verifier &verifier) {
|
115
|
+
return verifier.VerifyBuffer<SelfMessaging::ACL>(nullptr);
|
116
|
+
}
|
117
|
+
|
118
|
+
inline bool VerifySizePrefixedACLBuffer(
|
119
|
+
flatbuffers::Verifier &verifier) {
|
120
|
+
return verifier.VerifySizePrefixedBuffer<SelfMessaging::ACL>(nullptr);
|
121
|
+
}
|
122
|
+
|
123
|
+
inline void FinishACLBuffer(
|
124
|
+
flatbuffers::FlatBufferBuilder &fbb,
|
125
|
+
flatbuffers::Offset<SelfMessaging::ACL> root) {
|
126
|
+
fbb.Finish(root);
|
127
|
+
}
|
128
|
+
|
129
|
+
inline void FinishSizePrefixedACLBuffer(
|
130
|
+
flatbuffers::FlatBufferBuilder &fbb,
|
131
|
+
flatbuffers::Offset<SelfMessaging::ACL> root) {
|
132
|
+
fbb.FinishSizePrefixed(root);
|
133
|
+
}
|
134
|
+
|
135
|
+
} // namespace SelfMessaging
|
136
|
+
|
137
|
+
#endif // FLATBUFFERS_GENERATED_ACL_SELFMESSAGING_H_
|