2009-06-14 10:37 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* include/hbextern.ch
  * source/vm/hashfunc.c
    + Added HB_HGETDEF( <hHash>, <xKey>[, <xDefault> ] ) -> <value>
      This function will return <xDefault> when <xKey> isn't 
      found in the hash table. If <xDefault> isn't passed, it 
      will return NIL.
This commit is contained in:
Viktor Szakats
2009-06-14 08:38:37 +00:00
parent a488c63131
commit 8cff1ae469
3 changed files with 30 additions and 0 deletions

View File

@@ -17,6 +17,14 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-06-14 10:37 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* include/hbextern.ch
* source/vm/hashfunc.c
+ Added HB_HGETDEF( <hHash>, <xKey>[, <xDefault> ] ) -> <value>
This function will return <xDefault> when <xKey> isn't
found in the hash table. If <xDefault> isn't passed, it
will return NIL.
2009-06-14 00:02 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
+ harbour/contrib/hbxbp/gra.ch
* harbour/contrib/hbxbp/Makefile

View File

@@ -1228,6 +1228,7 @@ EXTERNAL HB_HASH
EXTERNAL HB_HHASKEY
EXTERNAL HB_HPOS
EXTERNAL HB_HGET
EXTERNAL HB_HGETDEF
EXTERNAL HB_HSET
EXTERNAL HB_HDEL
EXTERNAL HB_HKEYAT

View File

@@ -126,6 +126,27 @@ HB_FUNC( HB_HGET )
hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( HB_HGETDEF )
{
PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
PHB_ITEM pKey = hb_param( 2, HB_IT_HASHKEY );
if( pHash && pKey )
{
PHB_ITEM pDest = hb_hashGetItemPtr( pHash, pKey, HB_HASH_AUTOADD_ACCESS );
if( pDest )
hb_itemReturn( pDest );
else
{
PHB_ITEM pDefault = hb_param( 3, HB_IT_ANY );
if( pDefault )
hb_itemReturn( pDefault );
}
}
else
hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( HB_HSET )
{
PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );