You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
147 lines
3.6 KiB
147 lines
3.6 KiB
15 years ago
|
/*
|
||
|
This file is part of the KDE libraries
|
||
|
Copyright (c) 1999-2000 Preston Brown <pbrown@kde.org>
|
||
|
Copyright (C) 1996-2000 Matthias Kalle Dalheimer <kalle@kde.org>
|
||
|
|
||
|
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; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#ifndef _KCONFIGDATA_H
|
||
|
#define _KCONFIGDATA_H
|
||
|
|
||
15 years ago
|
#include <tqmap.h> // generic red-black tree class
|
||
13 years ago
|
#include "tdelibs_export.h"
|
||
15 years ago
|
|
||
|
/**
|
||
|
* map/dict/list config node entry.
|
||
|
* @internal
|
||
|
*/
|
||
13 years ago
|
struct TDECORE_EXPORT KEntry
|
||
15 years ago
|
{
|
||
|
KEntry()
|
||
|
: mValue(0), bDirty(false), bNLS(false),
|
||
|
bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false) {}
|
||
15 years ago
|
TQCString mValue;
|
||
15 years ago
|
/**
|
||
|
* Must the entry be written back to disk?
|
||
|
*/
|
||
|
bool bDirty :1;
|
||
|
/**
|
||
|
* Entry should be written with locale tag
|
||
|
*/
|
||
|
bool bNLS :1;
|
||
|
/**
|
||
|
* Entry should be written to the global config file
|
||
|
*/
|
||
|
bool bGlobal:1;
|
||
|
/**
|
||
|
* Entry can not be modified.
|
||
|
*/
|
||
|
bool bImmutable:1;
|
||
|
/**
|
||
|
* Entry has been deleted.
|
||
|
*/
|
||
|
bool bDeleted:1;
|
||
|
/**
|
||
|
* Whether to apply dollar expansion or not.
|
||
|
*/
|
||
|
bool bExpand:1;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* key structure holding both the actual key and the the group
|
||
|
* to which it belongs.
|
||
|
* @internal
|
||
|
*/
|
||
13 years ago
|
struct TDECORE_EXPORT KEntryKey
|
||
15 years ago
|
{
|
||
15 years ago
|
KEntryKey(const TQCString& _group = 0,
|
||
|
const TQCString& _key = 0)
|
||
15 years ago
|
: mGroup(_group), mKey(_key), bLocal(false), bDefault(false),
|
||
|
c_key(_key.data()) {}
|
||
|
/**
|
||
|
* The "group" to which this EntryKey belongs
|
||
|
*/
|
||
15 years ago
|
TQCString mGroup;
|
||
15 years ago
|
/**
|
||
|
* The _actual_ key of the entry in question
|
||
|
*/
|
||
15 years ago
|
TQCString mKey;
|
||
15 years ago
|
/**
|
||
|
* Entry is localised or not
|
||
|
*/
|
||
|
bool bLocal :1;
|
||
|
/**
|
||
|
* Entry indicates if this is a default value.
|
||
|
*/
|
||
|
bool bDefault:1;
|
||
|
|
||
|
const char *c_key;
|
||
|
};
|
||
|
|
||
|
/**
|
||
15 years ago
|
* compares two KEntryKeys (needed for TQMap).
|
||
15 years ago
|
* @internal
|
||
|
*/
|
||
|
inline bool operator <(const KEntryKey &k1, const KEntryKey &k2)
|
||
|
{
|
||
|
//saves one strcmp on each call
|
||
|
int result=qstrcmp(k1.mGroup.data(),k2.mGroup.data());
|
||
|
if (result!=0)
|
||
|
return (result<0);
|
||
|
|
||
|
if (!k1.c_key && k2.c_key)
|
||
|
return true;
|
||
|
|
||
|
result = 0;
|
||
|
if (k1.c_key && k2.c_key)
|
||
|
result = strcmp(k1.c_key, k2.c_key);
|
||
|
if (result != 0)
|
||
|
return result < 0;
|
||
|
if (!k1.bLocal && k2.bLocal)
|
||
|
return true;
|
||
|
if (k1.bLocal && !k2.bLocal)
|
||
|
return false;
|
||
|
return (!k1.bDefault && k2.bDefault);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* \relates KEntry
|
||
|
* type specifying a map of entries (key,value pairs).
|
||
|
* The keys are actually a key in a particular config file group together
|
||
|
* with the group name.
|
||
|
* @internal
|
||
|
*/
|
||
15 years ago
|
typedef TQMap<KEntryKey, KEntry> KEntryMap;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* \relates KEntry
|
||
|
* type for iterating over keys in a KEntryMap in sorted order.
|
||
|
* @internal
|
||
|
*/
|
||
15 years ago
|
typedef TQMap<KEntryKey, KEntry>::Iterator KEntryMapIterator;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* \relates KEntry
|
||
|
* type for iterating over keys in a KEntryMap in sorted order.
|
||
|
* It is const, thus you cannot change the entries in the iterator,
|
||
|
* only examine them.
|
||
|
* @internal
|
||
|
*/
|
||
15 years ago
|
typedef TQMap<KEntryKey, KEntry>::ConstIterator KEntryMapConstIterator;
|
||
15 years ago
|
|
||
|
#endif
|