ZFFramework
Loading...
Searching...
No Matches
zfvalueSwitch.h File Reference

utilities for ZFFramework More...

#include "ZFCoreMap.h"

Go to the source code of this file.

Classes

class  zfvalueSwitchData< T_Key, T_Hash, T_Equal >
 see zfvalueSwitch More...

Functions

template<typename T_KeyV, typename T_Key, typename T_Hash, typename T_Equal>
zfindex zfvalueSwitch (T_KeyV const &v, zfvalueSwitchData< T_Key, T_Hash, T_Equal > const &data)
 util to switch-case on any value type

Detailed Description

utilities for ZFFramework

Function Documentation

◆ zfvalueSwitch()

template<typename T_KeyV, typename T_Key, typename T_Hash, typename T_Equal>
zfindex zfvalueSwitch ( T_KeyV const & v,
zfvalueSwitchData< T_Key, T_Hash, T_Equal > const & data )

util to switch-case on any value type

.v("111")
.v("222")
)) {
case 0:
ZFLog("case 111");
break;
case 1:
ZFLog("case 222");
break;
default:
ZFLog("default");
break;
}
#define ZFLog(...)
thread-safe log utility
Definition ZFLog.h:76
see zfvalueSwitch
Definition zfvalueSwitch.h:15
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

or, store pre initialized switch data for better performance:

// the data can be stored for reuse
.v("111")
.v("222")
;
switch(zfvalueSwitch(v, m)) {
case 0:
...
}
zfvalueSwitchData & v(T_Key const &v)
see zfvalueSwitch
Definition zfvalueSwitch.h:18