Thanks.This is a good idea.
I have another problem.How to equal two message's object instance?
I find one way:
--------------------------------------------------------------------------
Path path;
Element* e1 = path.add_element();
Element* e2 = path.add_element();
string s1,s2;
e1.SerializeToString(&s1);
e2.SerializeToString(&s2);
if( s1 == s2 ){
//do something
}
--------------------------------------------------------------------------
But i think it does not have good performance.
On 8月7日, 上午2时01分, Kenton Varda <[email protected]> wrote:
> You have to make a copy instead, e.g.:
> path.add_element()->CopyFrom(ele);
> delete ele;
>
> On Thu, Aug 6, 2009 at 3:21 AM, 李海波 <[email protected]> wrote:
> > Path path;
> > Element* ele = new Element();
> > if( condition ){
> > delete ele;
> > }else{
> > //add ele to path,how can I do?
> > }
>
> If your code really looks like this, you should probably change it to:
>
> Path path;
> Element* ele = path.add_element();
> if (condition) {
> path.mutable_element()->RemoveLast();
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---