// -*- Mode: C++; c-basic-offset: 4 -*- /* $Id: changeset.ccg,v 1.2 2002/12/10 23:12:11 murrayc Exp $ */ /* changeset.ccg * * Copyright (C) 2002 GConfmm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include namespace Gnome { namespace Conf { ChangeSet::ChangeSet() : gobject_ (gconf_change_set_new()) {} ChangeSet::ChangeSet(const ChangeSet& src) : gobject_ ((src.gobject_) ? do_ref(src.gobject_) : 0) {} ChangeSet::ChangeSet(GConfChangeSet* castitem, bool make_a_copy /* = false */) { if(!make_a_copy) { gobject_ = castitem; } else { if(castitem) gobject_ = do_ref(castitem); else gobject_ = 0; } } ChangeSet& ChangeSet::operator=(const ChangeSet& src) { GConfChangeSet *const new_gobject = (src.gobject_) ? do_ref(src.gobject_) : 0; if(gobject_) gconf_change_set_unref(gobject_); gobject_ = new_gobject; return *this; } ChangeSet::~ChangeSet() { if(gobject_) gconf_change_set_unref(gobject_); } GConfChangeSet* ChangeSet::gobj_copy() const { return do_ref(gobject_); } Value* ChangeSet::exists(const Glib::ustring& key) const { GConfValue* gcv = 0; bool retval = (bool)gconf_change_set_check_value(const_cast(gobj()),key.c_str(),&gcv); if(retval) return new Value(gcv,true); else return 0; } GConfChangeSet* ChangeSet::do_ref(GConfChangeSet* cs) { gconf_change_set_ref(cs); return cs; } static void for_each_helper(GConfChangeSet *cs, const gchar *key, GConfValue *value, gpointer user_data) { ChangeSet::ForeachSlot *s = reinterpret_cast(user_data); (*s)(key, Value(value, true)); } void ChangeSet::for_each(const ForeachSlot& s) { gconf_change_set_foreach(gobj(),for_each_helper, (gpointer)(&(s))); } } /* namespace Conf */ } /* namespace Gnome */