Main Page   Class Hierarchy   Compound List   File List   Compound Members  

kconfigdata.h

00001 // vi:ts=4:shiftwidth=4:expandtab
00002 /*
00003    This file is part of the KDE libraries
00004    Copyright (c) 1999-2000 Preston Brown <pbrown@kde.org>
00005    Copyright (C) 1996-2000 Matthias Kalle Dalheimer <kalle@kde.org>
00006    Copyright (C) 2002 Zhang Le <ejoy@users.sourceforge.net>
00007    Last Change:20-Jul-2002.
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 License
00020    along with this library; see the file COPYING.LIB.  If not, write to
00021    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022    Boston, MA 02111-1307, USA.
00023 */
00024 
00025 #ifndef _KCONFIGDATA_H
00026 #define _KCONFIGDATA_H
00027 
00028 #include <map> 
00029 #include <string>
00030 using std::map; 
00031 using std::string; 
00032 //using namespace std;
00033 namespace config {
00034 
00039 struct KEntry
00040 {
00041   KEntry()
00042     : bDirty(false), bNLS(false), 
00043       bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false) {}
00044   string mValue;
00045   bool    bDirty :1;  // must the entry be written back to disk?
00046   bool    bNLS   :1;  // entry should be written with locale tag
00047   bool    bGlobal:1;  // entry should be written to the global config file
00048   bool    bImmutable:1; // Entry can not be modified
00049   bool    bDeleted:1; // Entry has been deleted
00050   bool    bExpand:1;  // Whether to apply dollar expansion
00051 };
00052 
00058 struct KEntryKey
00059 {
00060   KEntryKey(const string& _group = "",
00061             const string& _key = "")
00062       : mGroup(_group), mKey(_key), bLocal(false), bDefault(false),
00063         c_key(_key.c_str()) {}
00064   string mGroup; // the "group" to which this EntryKey belongs
00065   string mKey;   // the _actual_ key of the entry in question
00066   bool    bLocal  :1; // Entry is localised
00067   bool    bDefault:1; // Entry indicates default value
00068   const char *c_key;
00069 };
00070 
00075 inline bool operator <(const KEntryKey &k1, const KEntryKey &k2)
00076 {
00077    //saves one strcmp on each call
00078    int result=strcmp(k1.mGroup.c_str(),k2.mGroup.c_str());
00079    if (result!=0)
00080       return (result<0);     
00081 
00082   if (!k1.c_key && k2.c_key)
00083     return true;
00084 
00085   result = 0;
00086   if (k1.c_key && k2.c_key)
00087      result = strcmp(k1.c_key, k2.c_key);
00088   if (result != 0)
00089      return result < 0;
00090   if (!k1.bLocal && k2.bLocal)
00091     return true;
00092   if (k1.bLocal && !k2.bLocal)
00093     return false;
00094   return (!k1.bDefault && k2.bDefault);
00095 }
00096 
00103 typedef map<KEntryKey, KEntry> KEntryMap;
00104 
00109 //MSVC++ 6 need std:: before map to work
00110 typedef std::map<KEntryKey, KEntry>::iterator KEntryMapIterator;
00111 
00118 //MSVC++ 6 need std:: before map to work
00119 typedef std::map<KEntryKey, KEntry>::const_iterator KEntryMapConstIterator;
00120 
00121  }; //namespace config
00122 #endif

Generated on Sat Dec 14 20:05:52 2002 for libconfig by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002