Re: copy GVariant



В Вто, 08/02/2011 в 11:18 +0000, Chris Vine пишет:
> On Tue, 08 Feb 2011 06:51:38 +0200
> Povietkin Konstantin <povetkin k gmail com> wrote:
> > В Вто, 08/02/2011 в 02:34 +0000, Chris Vine пишет:
> > > On Mon, 07 Feb 2011 23:07:28 +0200
> > > Povietkin Konstantin <povetkin k gmail com> wrote:
> > > > I asked this question because i needed a c++ class that was using
> > > > GVariant c-object.
> > > > My solution is simple:
> > > > 
> > > >     GVariant * first;
> > > >     GVariant * second;
> > > > 
> > > >     first = g_variant_new_string( "Тестовая строка" );
> > > > 
> > > >     second = g_variant_new_parsed( g_variant_print( first, TRUE )
> > > > );
> > > 
> > > If you are programming in unwrapped glib, the normal thing would be
> > > to copy the pointer and increment the reference count.
> > > 
> > > Chris
> > > 
> > > 
> > 
> > I need an object like Glib::GVariant and possibility to _copy_ data,
> > not only referencing.
> 
> I should use Glib::Variant then, if you don't mind using version 2.27
> of glibmm.  glib-2.28 is due out today so presumably glibmm-2.28 will
> follow shortly thereafter.
> 
> But note that the copy constructor and assignment operator of
> Glib::VariantBase also take a copy of the GVariant object and
> increment the reference count.  GVariant objects are not intended to
> be modified and there are no accessors for them which would permit that
> (I think, I don't mind you showing me to be wrong).  This is reflected
> in Glib::VariantBase which only enables modification by replacing the
> entire underlying GVariant (with the Glib::VariantBase::init()
> function).
> 
> You might also find Glib::VariantBase::get_normal_form() useful if you
> want deep copying or referencing dependent on whether the variant is in
> normal form, which is normally the only justification for carrying out a
> deep copy operation.
> 
> Chris
> 
> 

Thank you a lot for your comment. I will learn documentation better.

-- 
"No Civilization = Freedom"
------------------------------------------------------------------------
Yes, I am a criminal. My crime is that of curiosity.

My crime is that of judging people by what they say and think, not what
they look like.

 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]