Discussion:
[capnproto] initialise nested lists
'Frank' via Cap'n Proto
2018-02-20 23:04:57 UTC
Permalink
Hi,


I use Capnproto to serialise data. What is the best way to fill
nestedList and list from std::vector<std::vector<bool>> resp.
std::vector<bool>? For list I used initList() and the set() method in a
loop but I am not sure how to proceed with nestedList. Do I have to
create kj::Arrays for the nested lists?

--
struct Name {
nestedList @0 :List(List(Bool));
list @1 :List(Bool);
}
--


Best,

Frank
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
'Kenton Varda' via Cap'n Proto
2018-02-21 00:58:53 UTC
Permalink
Hi Frank,

I think you want something like:

auto outer = name.initNestedList(vec.size());
for (uint i = 0; i < vec.size(); i++) {
auto inner = outer.init(i, vec[i].size());
for (uint j = 0; j < vec[i].size(); j++) {
inner.set(j, vec[i][j]);
}
}

-Kenton

On Tue, Feb 20, 2018 at 3:04 PM, 'Frank' via Cap'n Proto <
Post by 'Frank' via Cap'n Proto
Hi,
I use Capnproto to serialise data. What is the best way to fill
nestedList and list from std::vector<std::vector<bool>> resp.
std::vector<bool>? For list I used initList() and the set() method in a
loop but I am not sure how to proceed with nestedList. Do I have to
create kj::Arrays for the nested lists?
--
struct Name {
}
--
Best,
Frank
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/capnproto.
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
'Fritz Lehmann' via Cap'n Proto
2018-03-03 01:08:05 UTC
Permalink
Hi Kenton,
Post by 'Kenton Varda' via Cap'n Proto
auto outer = name.initNestedList(vec.size());
for (uint i = 0; i < vec.size(); i++) {
auto inner = outer.init(i, vec[i].size());
for (uint j = 0; j < vec[i].size(); j++) {
inner.set(j, vec[i][j]);
}
}
works like a charm. Thank you very much!


Frank
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
Loading...