ZFFramework
Loading...
Searching...
No Matches
zfvalueSwitch.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_zfvalueSwitch_h_
7#define _ZFI_zfvalueSwitch_h_
8
9#include "ZFCoreMap.h"
10
12
14template<typename T_Key, typename T_Hash = ZFCoreMapKeyHash<T_Key>, typename T_Equal = ZFCoreMapKeyEqual<T_Key> >
16public:
18 zfvalueSwitchData &v(ZF_IN T_Key const &v) {
19 m.set(v, m.count());
20 return *this;
21 }
22private:
24 template<typename T_KeyV, typename T_Key_, typename T_Hash_, typename T_Equal_>
26public:
28 zfvalueSwitchData(void) : m() {}
30 zfvalueSwitchData &operator = (ZF_IN const zfvalueSwitchData<T_Key, T_Hash, T_Equal> &ref) {m = ref.m; return *this;}
32};
33
68template<typename T_KeyV, typename T_Key, typename T_Hash, typename T_Equal>
70 const zfindex *t = data.m.get(v);
71 return t ? *t : zfindexMax();
72}
73
75
76#endif // #ifndef _ZFI_zfvalueSwitch_h_
77
core map type for private use only
#define zfclassLikePOD
shows the class is not a POD type, but you may use it like a POD except memset it to 0
Definition ZFCoreTypeDef_ClassType.h:41
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:196
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
#define zfindexMax()
(zfindex)-1, indicate a max index value, see zfindex
Definition ZFCoreTypeDef_CoreType.h:159
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
core map type for private use only
Definition ZFCoreMap.h:102
see zfvalueSwitch
Definition zfvalueSwitch.h:15
zfvalueSwitchData & v(T_Key const &v)
see zfvalueSwitch
Definition zfvalueSwitch.h:18
zfindex zfvalueSwitch(T_KeyV const &v, zfvalueSwitchData< T_Key, T_Hash, T_Equal > const &data)
util to switch-case on any value type
Definition zfvalueSwitch.h:69