Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXDictionaryOf.h
1 /********************************************************************************
2 * *
3 * D i c t i o n a r y O f P o i n t e r s T o T y p e *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXDICTIONARYOF_H
22 #define FXDICTIONARYOF_H
23 
24 namespace FX {
25 
26 
30 template<typename TYPE>
31 class FXDictionaryOf : public FXDictionary {
32 public:
33 
36 
39 
42 
45 
47  TYPE*& at(const FXchar* ky){ return reinterpret_cast<TYPE*&>(FXDictionary::at(ky)); }
48 
50  TYPE *const& at(const FXchar* ky) const { return reinterpret_cast<TYPE *const&>(FXDictionary::at(ky)); }
51 
53  TYPE*& at(const FXString& ky){ return reinterpret_cast<TYPE*&>(FXDictionary::at(ky.text())); }
54 
56  TYPE *const& at(const FXString& ky) const { return reinterpret_cast<TYPE *const&>(FXDictionary::at(ky.text())); }
57 
59  TYPE*& operator[](const FXchar* ky){ return reinterpret_cast<TYPE*&>(FXDictionary::at(ky)); }
60 
62  TYPE *const& operator[](const FXchar* ky) const { return reinterpret_cast<TYPE *const&>(FXDictionary::at(ky)); }
63 
65  TYPE*& operator[](const FXString& ky){ return reinterpret_cast<TYPE*&>(FXDictionary::at(ky.text())); }
66 
68  TYPE *const& operator[](const FXString& ky) const { return reinterpret_cast<TYPE *const&>(FXDictionary::at(ky.text())); }
69 
71  TYPE* insert(const FXchar* ky,TYPE* ptr=nullptr){ return reinterpret_cast<TYPE*>(FXDictionary::insert(ky,ptr)); }
72 
74  TYPE* insert(const FXString& ky,TYPE* ptr=nullptr){ return insert(ky.text(),ptr); }
75 
77  TYPE* remove(const FXchar* ky){ return reinterpret_cast<TYPE*>(FXDictionary::remove(ky)); }
78 
80  TYPE* remove(const FXString& ky){ return reinterpret_cast<TYPE*>(FXDictionary::remove(ky.text())); }
81 
83  TYPE* erase(FXival pos){ return reinterpret_cast<TYPE*>(FXDictionary::erase(pos)); }
84 
86  TYPE*& data(FXival pos){ return reinterpret_cast<TYPE*&>(FXDictionary::data(pos)); }
87 
89  TYPE *const& data(FXival pos) const { return reinterpret_cast<TYPE *const&>(FXDictionary::data(pos)); }
90  };
91 
92 }
93 
94 #endif
void *& at(const FXchar *ky)
Return reference to slot assocated with given key.
Dictionary of pointers to TYPE.
Definition: FXDictionaryOf.h:31
FXDictionaryOf()
Default constructor.
Definition: FXDictionaryOf.h:35
FXDictionary & operator=(const FXDictionary &other)
Assignment operator.
void * erase(FXival pos)
Erase data at pos in the table; return old value, if any.
TYPE * insert(const FXString &ky, TYPE *ptr=nullptr)
Insert association with given key; return old value, if any.
Definition: FXDictionaryOf.h:74
TYPE *& operator[](const FXString &ky)
Return reference to slot assocated with given key.
Definition: FXDictionaryOf.h:65
The dictionary class is a fast-access hash table, mapping strings to void-pointers.
Definition: FXDictionary.h:36
TYPE *& data(FXival pos)
Return reference to slot at position pos.
Definition: FXDictionaryOf.h:86
TYPE *const & operator[](const FXString &ky) const
Return constant reference to slot assocated with given key.
Definition: FXDictionaryOf.h:68
FXDictionaryOf< TYPE > & operator=(const FXDictionaryOf< TYPE > &other)
Assignment operator.
Definition: FXDictionaryOf.h:41
FXDictionary & adopt(FXDictionary &other)
Adopt dictionary from another.
TYPE *& operator[](const FXchar *ky)
Return reference to slot assocated with given key.
Definition: FXDictionaryOf.h:59
void *& data(FXival pos)
Return reference to slot at position pos.
Definition: FXDictionary.h:142
FXchar * text()
Get text contents as pointer.
Definition: FXString.h:119
FXDictionaryOf(const FXDictionaryOf< TYPE > &other)
Copy constructor.
Definition: FXDictionaryOf.h:38
TYPE *& at(const FXchar *ky)
Return reference to slot assocated with given key.
Definition: FXDictionaryOf.h:47
Definition: FX4Splitter.h:28
TYPE *const & data(FXival pos) const
Return constant reference to slot at position pos.
Definition: FXDictionaryOf.h:89
TYPE *& at(const FXString &ky)
Return reference to slot assocated with given key.
Definition: FXDictionaryOf.h:53
void * insert(const FXchar *ky, void *ptr=nullptr)
Insert association with given key; return old value, if any.
Definition: FXDictionary.h:121
FXDictionaryOf< TYPE > & adopt(FXDictionaryOf< TYPE > &other)
Adopt dictionary from another.
Definition: FXDictionaryOf.h:44
TYPE *const & operator[](const FXchar *ky) const
Return constant reference to slot assocated with given key.
Definition: FXDictionaryOf.h:62
TYPE * insert(const FXchar *ky, TYPE *ptr=nullptr)
Insert association with given key; return old value, if any.
Definition: FXDictionaryOf.h:71
TYPE *const & at(const FXString &ky) const
Return constant reference to slot assocated with given key.
Definition: FXDictionaryOf.h:56
void * remove(const FXchar *ky)
Remove association with given key; return old value, if any.
TYPE * erase(FXival pos)
Erase data at pos in the table; return old value, if any.
Definition: FXDictionaryOf.h:83
TYPE *const & at(const FXchar *ky) const
Return constant reference to slot assocated with given key.
Definition: FXDictionaryOf.h:50
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp