KVIrc  4.9.2
DeveloperAPIs
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 {
35 public:
38 
39 protected:
42 
43 public:
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  {
69  KviKvsVariant * t;
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
This class defines a new data type which contains variant data.
Definition: KviKvsVariant.h:351
#define KVIRC_API
Definition: kvi_settings.h:128
char s char s char s s s s s char char c s *s c s s s d c s *s d c d d d d c
Definition: KviIrcNumericCodes.h:391
btnDict clear()
Definition: KviKvsSwitchList.h:33
Pointer Hash Table.
KviPointerHashTable< QString, KviKvsVariant > * m_pLongSwitchDict
Definition: KviKvsSwitchList.h:41
KviKvsVariant * find(const QString &szLongKey)
Definition: KviKvsSwitchList.h:60
bool isEmpty()
Definition: KviKvsSwitchList.h:48
KviKvsVariant * find(unsigned short uShortKey)
Definition: KviKvsSwitchList.h:55
KviKvsVariant * find(const QChar &c)
Definition: KviKvsSwitchList.h:50
QHashIterator< int, QFile * > t(getDict)
KviPointerHashTable< unsigned short, KviKvsVariant > * m_pShortSwitchDict
Definition: KviKvsSwitchList.h:40
void asString(QString &szBuffer) const
Evaluates anything to a string.
Definition: KviKvsVariant.cpp:846
bool getAsStringIfExisting(unsigned short uShortKey, const QString &szLongKey, QString &szBuffer)
Definition: KviKvsSwitchList.h:77
Handling of variant data type in KVS.
char szBuffer[4096]
Definition: winamp.cpp:77
KviKvsVariant * find(unsigned short uShortKey, const QString &szLongKey)
Definition: KviKvsSwitchList.h:65
This file contains compile time settings.
#define v
Definition: detector.cpp:86
Helper functions for the QString class.