KVIrc 5.2.0
Developer APIs
KviKvsSwitchList.h
Go to the documentation of this file.
1#ifndef _KVI_KVS_SWITCHLIST_H_
2#define _KVI_KVS_SWITCHLIST_H_
3//=============================================================================
4//
5// File : KviKvsSwitchList.h
6// Creation date : Mon 27 Oct 2003 03:47:48 by Szymon Stefanek
7//
8// This file is part of the KVIrc IRC client distribution
9// Copyright (C) 2003-2010 Szymon Stefanek <pragma at kvirc dot net>
10//
11// This program is FREE software. You can redistribute it and/or
12// modify it under the terms of the GNU General Public License
13// as published by the Free Software Foundation; either version 2
14// of the License, or (at your option) any later version.
15//
16// This program is distributed in the HOPE that it will be USEFUL,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19// See the GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program. If not, write to the Free Software Foundation,
23// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24//
25//=============================================================================
26
27#include "kvi_settings.h"
28#include "KviQString.h"
29#include "KviKvsVariant.h"
30
31#include "KviPointerHashTable.h"
32
34{
35public:
38
39protected:
42
43public:
44 void clear();
45 void addShort(unsigned short uShortKey, KviKvsVariant * pVariant);
46 void addLong(const QString & szLongKey, KviKvsVariant * pVariant);
47
48 bool isEmpty() { return ((m_pShortSwitchDict == 0) && (m_pLongSwitchDict == 0)); };
49
50 KviKvsVariant * find(const QChar & c)
51 {
52 return m_pShortSwitchDict ? m_pShortSwitchDict->find(c.unicode()) : 0;
53 };
54
55 KviKvsVariant * find(unsigned short uShortKey)
56 {
57 return m_pShortSwitchDict ? m_pShortSwitchDict->find((int)uShortKey) : 0;
58 };
59
60 KviKvsVariant * find(const QString & szLongKey)
61 {
62 return m_pLongSwitchDict ? m_pLongSwitchDict->find(szLongKey) : 0;
63 };
64
65 KviKvsVariant * find(unsigned short uShortKey, const QString & szLongKey)
66 {
67 if(m_pLongSwitchDict)
68 {
70 t = m_pLongSwitchDict->find(szLongKey);
71 if(t)
72 return t;
73 }
74 return m_pShortSwitchDict ? m_pShortSwitchDict->find((int)uShortKey) : 0;
75 };
76
77 bool getAsStringIfExisting(unsigned short uShortKey, const QString & szLongKey, QString & szBuffer)
78 {
79 KviKvsVariant * v = find(uShortKey, szLongKey);
80 if(v)
81 {
82 v->asString(szBuffer);
83 return true;
84 }
85 return false;
86 };
87};
88
89#endif
Handling of variant data type in KVS.
Pointer Hash Table.
Helper functions for the QString class.
btnDict clear()
Definition KviKvsSwitchList.h:34
bool isEmpty()
Definition KviKvsSwitchList.h:48
KviKvsVariant * find(const QString &szLongKey)
Definition KviKvsSwitchList.h:60
KviPointerHashTable< QString, KviKvsVariant > * m_pLongSwitchDict
Definition KviKvsSwitchList.h:41
KviPointerHashTable< unsigned short, KviKvsVariant > * m_pShortSwitchDict
Definition KviKvsSwitchList.h:40
KviKvsVariant * find(unsigned short uShortKey, const QString &szLongKey)
Definition KviKvsSwitchList.h:65
KviKvsVariant * find(const QChar &c)
Definition KviKvsSwitchList.h:50
bool getAsStringIfExisting(unsigned short uShortKey, const QString &szLongKey, QString &szBuffer)
Definition KviKvsSwitchList.h:77
KviKvsVariant * find(unsigned short uShortKey)
Definition KviKvsSwitchList.h:55
This class defines a new data type which contains variant data.
Definition KviKvsVariant.h:352
A fast pointer hash table implementation.
Definition KviPointerHashTable.h:450
T * find(const Key &hKey)
Returns the item associated to the key.
Definition KviPointerHashTable.h:471
#define t
Definition detector.cpp:85
#define v
Definition detector.cpp:87
This file contains compile time settings.
#define KVIRC_API
Definition kvi_settings.h:127
char szBuffer[4096]
Definition winamp.cpp:77