value_listhelpers.h

Go to the documentation of this file.
00001 #ifndef GCONFMM_VALUE_LISTHELPERS_H
00002 #define GCONFMM_VALUE_LISTHELPERS_H
00003 // -*- Mode: C++; c-basic-offset: 4  -*-
00004 
00005 /* value_listhelpers.ccg
00006  * 
00007  * Copyright (C) 2000-2002 GConfmm Development Team
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Library General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Library General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Library General Public
00020  * License along with this library; if not, write to the Free
00021  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00022  */
00023 
00024 extern "C" {
00025     typedef struct _GConfValue GConfValue;
00026 }
00027 
00028 namespace Gnome
00029 {
00030 namespace Conf
00031 {
00032 
00033 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00034 
00035 class Schema;
00036 class Value;
00037 
00038 struct ValueTraits 
00039 {
00040     typedef GConfValue*      CType;
00041     typedef GConfValue*      CTypeNonConst;
00042 
00043     static CType   to_c_type      (CType          ptr) { return ptr; }
00044     static void    release_c_type (CType          ptr);    
00045 };
00046 
00047 struct ValueSchemaTraits : public ValueTraits
00048 {
00049     typedef Schema           CppType;
00050     
00051     static CType   to_c_type      (const CppType& ptr);
00052     static CppType to_cpp_type    (CType          ptr);
00053 };
00054 typedef Glib::SListHandle< Schema, ValueSchemaTraits > SListHandle_ValueSchema;
00055 
00056 struct ValueStringTraits : public ValueTraits
00057 {
00058     typedef Glib::ustring CppType;
00059     
00060     static CType   to_c_type      (const CppType& ptr);
00061     static CppType to_cpp_type    (CType          ptr);
00062 };
00063 typedef Glib::SListHandle< Glib::ustring, ValueStringTraits > SListHandle_ValueString;
00064 
00065 struct ValueIntTraits : public ValueTraits
00066 {
00067     typedef int           CppType;
00068     
00069     static CType   to_c_type      (const CppType& ptr);
00070     static CppType to_cpp_type    (CType          ptr);
00071 };
00072 typedef Glib::SListHandle< int, ValueIntTraits > SListHandle_ValueInt;
00073 
00074 struct ValueBoolTraits : public ValueTraits
00075 {
00076     typedef bool          CppType;
00077     
00078     static CType   to_c_type      (const CppType& ptr);
00079     static CppType to_cpp_type    (CType          ptr);
00080 };
00081 typedef Glib::SListHandle< bool, ValueBoolTraits > SListHandle_ValueBool;
00082 
00083 struct ValueFloatTraits : public ValueTraits
00084 {
00085     typedef double        CppType;
00086     
00087     static CType   to_c_type      (const CppType& ptr);
00088     static CppType to_cpp_type    (CType          ptr);
00089 };
00090 typedef Glib::SListHandle< double, ValueFloatTraits > SListHandle_ValueFloat;
00091 
00092 
00093 } /* namespace Conf */
00094 } /* namespace Gnome */
00095 
00096 namespace Glib
00097 {
00098 namespace Container_Helpers
00099 {
00100 template<class Tr,class Cont>
00101 struct ValueSourceTraits {
00102     static GSList* get_data(const Cont& cont) {
00103         return Glib::Container_Helpers::create_slist(cont.begin(), cont.end(), Tr());
00104     }
00105 };
00106 
00107 //partial template specializations:
00108 template<class Cont>
00109 struct SListSourceTraits<Gnome::Conf::ValueIntTraits,Cont> : ValueSourceTraits<Gnome::Conf::ValueIntTraits,Cont>{
00110     static const Glib::OwnershipType initial_ownership = Glib::OWNERSHIP_NONE;
00111 };
00112 template<class Cont>
00113 struct SListSourceTraits<Gnome::Conf::ValueBoolTraits,Cont> : ValueSourceTraits<Gnome::Conf::ValueBoolTraits,Cont>{
00114     static const Glib::OwnershipType initial_ownership = Glib::OWNERSHIP_NONE;
00115 };
00116 template<class Cont>
00117 struct SListSourceTraits<Gnome::Conf::ValueFloatTraits,Cont> : ValueSourceTraits<Gnome::Conf::ValueFloatTraits,Cont>{
00118     static const Glib::OwnershipType initial_ownership = Glib::OWNERSHIP_NONE;
00119 };
00120 template<class Cont>
00121 struct SListSourceTraits<Gnome::Conf::ValueStringTraits,Cont> : ValueSourceTraits<Gnome::Conf::ValueStringTraits,Cont>{
00122     static const Glib::OwnershipType initial_ownership = Glib::OWNERSHIP_NONE;
00123 };
00124 template<class Cont>
00125 struct SListSourceTraits<Gnome::Conf::ValueSchemaTraits,Cont> : ValueSourceTraits<Gnome::Conf::ValueSchemaTraits,Cont>{
00126     static const Glib::OwnershipType initial_ownership = Glib::OWNERSHIP_NONE;
00127 };
00128 
00129 #endif // DOXYGEN_SHOULD_SKIP_THIS
00130 
00131 }
00132 }
00133 
00134 #endif

Generated on Fri Aug 11 09:35:40 2006 for gconfmm by  doxygen 1.4.7