- get_hv
-
Returns the HV of the specified Perl hash. If create is set and the Perl
variable does not exist then it will be created. If create is not set and the
variable does not exist then NULL is returned.
NOTE: the perl_ form of this function is deprecated.
HV* get_hv(const char* name, I32 create)
|
|
- HeHASH
-
Returns the computed hash stored in the hash entry.
- HeKEY
-
Returns the actual pointer stored in the key slot of the hash entry. The pointer may be
either char* or SV*, depending on the value of HeKLEN().
Can be assigned to. The HePV() or HeSVKEY() macros are usually
preferable for finding the value of a key.
- HeKLEN
-
If this is negative, and amounts to HEf_SVKEY, it indicates the entry
holds an SV* key. Otherwise, holds the actual length of the key. Can be
assigned to. The HePV() macro is usually preferable for finding key lengths.
- HePV
-
Returns the key slot of the hash entry as a char* value, doing any
necessary dereferencing of possibly SV* keys. The length of the string is
placed in len (this is a macro, so do not use &len).
If you do not care about what the length of the key is, you may use the global variable PL_na,
though this is rather less efficient than using a local variable. Remember though, that
hash keys in perl are free to contain embedded nulls, so using strlen() or
similar is not a good way to find the length of hash keys. This is very similar to the SvPV()
macro described elsewhere in this document.
char* HePV(HE* he, STRLEN len)
|
|
- HeSVKEY
-
Returns the key as an SV*, or Nullsv if the hash entry does
not contain an SV* key.
- HeSVKEY_force
-
Returns the key as an SV*. Will create and return a temporary mortal SV*
if the hash entry contains only a char* key.
SV* HeSVKEY_force(HE* he)
|
|
- HeSVKEY_set
-
Sets the key to a given SV*, taking care to set the appropriate flags to
indicate the presence of an SV* key, and returns the same SV*.
SV* HeSVKEY_set(HE* he, SV* sv)
|
|
- HeVAL
-
Returns the value slot (type SV*) stored in the hash entry.
- HvNAME
-
Returns the package name of a stash. See SvSTASH, CvSTASH.
- hv_clear
-
Clears a hash, making it empty.
- hv_delete
-
Deletes a key/value pair in the hash. The value SV is removed from the hash and
returned to the caller. The klen is the length of the key. The flags
value will normally be zero; if set to G_DISCARD then NULL will be returned.
SV* hv_delete(HV* tb, const char* key, I32 klen, I32 flags)
|
|
- hv_delete_ent
-
Deletes a key/value pair in the hash. The value SV is removed from the hash and
returned to the caller. The flags value will normally be zero; if set to
G_DISCARD then NULL will be returned. hash can be a valid precomputed hash
value, or 0 to ask for it to be computed.
SV* hv_delete_ent(HV* tb, SV* key, I32 flags, U32 hash)
|
|
- hv_exists
-
Returns a boolean indicating whether the specified hash key exists. The klen
is the length of the key.
bool hv_exists(HV* tb, const char* key, I32 klen)
|
|
- hv_exists_ent
-
Returns a boolean indicating whether the specified hash key exists. hash
can be a valid precomputed hash value, or 0 to ask for it to be computed.
bool hv_exists_ent(HV* tb, SV* key, U32 hash)
|
|
- hv_fetch
-
Returns the SV which corresponds to the specified key in the hash. The klen
is the length of the key. If lval is set then the fetch will be part of a
store. Check that the return value is non-null before dereferencing it to an SV*.
See perlguts/"Understanding
the Magic of Tied Hashes and Arrays" for more information on how to use this
function on tied hashes.
SV** hv_fetch(HV* tb, const char* key, I32 klen, I32 lval)
|
|
- hv_fetch_ent
-
Returns the hash entry which corresponds to the specified key in the hash. hash
must be a valid precomputed hash number for the given key, or 0 if you want
the function to compute it. IF lval is set then the fetch will be part of a
store. Make sure the return value is non-null before accessing it. The return value when tb
is a tied hash is a pointer to a static location, so be sure to make a copy of the
structure if you need to store it somewhere.
See perlguts/"Understanding
the Magic of Tied Hashes and Arrays" for more information on how to use this
function on tied hashes.
HE* hv_fetch_ent(HV* tb, SV* key, I32 lval, U32 hash)
|
|
- hv_iterinit
-
Prepares a starting point to traverse a hash table. Returns the number of keys in the
hash (i.e. the same as HvKEYS(tb)). The return value is currently only
meaningful for hashes without tie magic.
NOTE: Before version 5.004_65, hv_iterinit used to return the number of
hash buckets that happen to be in use. If you still need that esoteric value, you can get
it through the macro HvFILL(tb).
- hv_iterkey
-
Returns the key from the current position of the hash iterator. See hv_iterinit.
char* hv_iterkey(HE* entry, I32* retlen)
|
|
- hv_iterkeysv
-
Returns the key as an SV* from the current position of the hash iterator.
The return value will always be a mortal copy of the key. Also see hv_iterinit.
SV* hv_iterkeysv(HE* entry)
|
|
- hv_iternext
-
Returns entries from a hash iterator. See hv_iterinit.
You may call hv_delete or hv_delete_ent on the hash entry
that the iterator currently points to, without losing your place or invalidating your
iterator. Note that in this case the current entry is deleted from the hash with your
iterator holding the last reference to it. Your iterator is flagged to free the entry on
the next call to hv_iternext, so you must not discard your iterator
immediately else the entry will leak - call hv_iternext to trigger the
resource deallocation.
- hv_iternextsv
-
Performs an hv_iternext, hv_iterkey, and hv_iterval
in one operation.
SV* hv_iternextsv(HV* hv, char** key, I32* retlen)
|
|
- hv_iternext_flags
-
Returns entries from a hash iterator. See hv_iterinit and hv_iternext.
The flags value will normally be zero; if HV_ITERNEXT_WANTPLACEHOLDERS is set
the placeholders keys (for restricted hashes) will be returned in addition to normal keys.
By default placeholders are automatically skipped over. Currently a placeholder is
implemented with a value that is literally <&Perl_sv_undef> (a regular undef
value is a normal read-write SV for which !SvOK is false). Note that the
implementation of placeholders and restricted hashes may change, and the implementation
currently is insufficiently abstracted for any change to be tidy.
NOTE: this function is experimental and may change or be removed without notice.
HE* hv_iternext_flags(HV* tb, I32 flags)
|
|
- hv_iterval
-
Returns the value from the current position of the hash iterator. See hv_iterkey.
SV* hv_iterval(HV* tb, HE* entry)
|
|
- hv_magic
-
Adds magic to a hash. See sv_magic.
void hv_magic(HV* hv, GV* gv, int how)
|
|
- hv_store
-
Stores an SV in a hash. The hash key is specified as key and klen
is the length of the key. The hash parameter is the precomputed hash value;
if it is zero then Perl will compute it. The return value will be NULL if the operation
failed or if the value did not need to be actually stored within the hash (as in the case
of tied hashes). Otherwise it can be dereferenced to get the original SV*.
Note that the caller is responsible for suitably incrementing the reference count of val
before the call, and decrementing it if the function returned NULL.
See perlguts/"Understanding
the Magic of Tied Hashes and Arrays" for more information on how to use this
function on tied hashes.
SV** hv_store(HV* tb, const char* key, I32 klen, SV* val, U32 hash)
|
|
- hv_store_ent
-
Stores val in a hash. The hash key is specified as key. The hash
parameter is the precomputed hash value; if it is zero then Perl will compute it. The
return value is the new hash entry so created. It will be NULL if the operation failed or
if the value did not need to be actually stored within the hash (as in the case of tied
hashes). Otherwise the contents of the return value can be accessed using the He?
macros described here. Note that the caller is responsible for suitably incrementing the
reference count of val before the call, and decrementing it if the function
returned NULL.
See perlguts/"Understanding
the Magic of Tied Hashes and Arrays" for more information on how to use this
function on tied hashes.
HE* hv_store_ent(HV* tb, SV* key, SV* val, U32 hash)
|
|
- hv_undef
-
Undefines the hash.
- newHV
-
Creates a new HV. The reference count is set to 1.
- Nullhv
-
Null HV pointer.