When using arena, I create an proto-object message in arena by CreateMessage<>,but I want to get this object,I didn鈥檛 find the similar to "GetMessage"...
What I to do? @haon4 @acozzette @TeBoring
please,thanks a lot.
google::protobuf::ArenaOptions options;
options.initial_block = reinterpret_cast
options.initial_block_size = sizeof(value_ptr->data_ptr);
_farena.Reset();
_farena.Init(options);
_finfo_msg =
google::protobuf::Arena::CreateMessage
int len = info.items_size();
for (int pos = 0; pos < len; ++pos) {
auto items_ptr = _finfo_msg->mutable_items()->Add();
items_ptr->set_id(info.items(pos).id());
items_ptr->set_fmt(info.items(pos).fmt());
items_ptr->set_vp(info.items(pos).vp());
items_ptr->set_filesize(info.items(pos).filesize());
items_ptr->set_timelength(info.items(pos).timelength());
items_ptr->set_ahead(info.items(pos).ahead());
items_ptr->set_vhead(info.items(pos).vhead());
items_ptr->set_ahead(info.items(pos).ahead());
items_ptr->set_ver(info.items(pos).ver());
I want to get this object from my area,please,How I to do it?
When you call Arena::CreateMessage<T>() it will return a pointer to the message, so you can just access the message through that pointer. I'm not sure what you mean when you say you want to get the object from the arena.
When you call
Arena::CreateMessage<T>()it will return a pointer to the message, so you can just access the message through that pointer. I'm not sure what you mean when you say you want to get the object from the arena.
oh,thankyou,but what I mean that the second,get the object second time.@acozzette
object is "bvc::videoresource::VideoInfos"
this is "area.h"'s comment,because I want to get the objects again.in other functions.
// API to create proto2 message objects on the arena. If the arena passed in
// is NULL, then a heap allocated object is returned. Type T must be a message
// defined in a .proto file with cc_enable_arenas set to true, otherwise a
// compilation error will occur.
You have to hold onto the pointer returned from CreateMessage(). There is no way to query the Arena for objects that it has already allocated.
You have to hold onto the pointer returned from
CreateMessage(). There is no way to query theArenafor objects that it has already allocated.
oh,thank you.I am sad...