C and C++ Binaries

cs_string64.h

Defines a set of utility operations on string types cs_const_string64, cs_const_string64_pin_t, cs_const_string.



Links


Defines

#define CS_STRING64_H
#define CS_CONST_STRING64_NULL (cs_const_string64_get_null()) The null cs_const_string64.

Functions

cs_result cs_const_string64_value ( cs_const_string64 s, cs_string out_string, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Retrieve characters from a cs_const_string64.
cs_const_string cs_const_string64_pin ( cs_const_string64 s, cs_size_t * capacity_bytes, cs_const_string64_pin_t * pin_ptr )
'Pin' a cs_const_string64 - that is, specify that the tool should not free it until it is subsequently 'unpinned' with cs_const_string64_unpin().
void cs_const_string64_unpin ( cs_const_string64_pin_t * pin_ptr )
'Unpin' a previously-pinned cs_const_string64 - that is, specify that you no longer require it and the tool is free to delete it.
cs_result cs_const_string64_create ( cs_const_string s, cs_const_string64 * out_string )
Create and return a cs_const_string64.
cs_boolean cs_string_equal ( cs_const_string str1, cs_const_string str2 )
Check: are two cs_string objects (case-sensitively) equal?
cs_hash_t cs_string_hash ( cs_const_string str )
Hash function for cs_string.
cs_hash_t cs_string_hash_seed ( cs_const_string str, cs_hash_t hseed )
Seeded hash function for cs_const_string.
csuint64 cs_string_hash64 ( cs_const_string str )
Hash function for cs_const_string.

Function Descriptions

Function cs_const_string64_value
cs_result cs_const_string64_value (
Retrieve characters from a cs_const_string64.
Parameters
s [in] A cs_const_string64 to extract into out_string.
out_string [out] A user-allocated cs_string to be populated with the cs_string representation of s.
capacity_bytes [in] The capacity of out_string, in bytes.
bytes_needed [out] The number of bytes required to store the entire cs_string representation of s.
Returns A cs_result:
  • CS_SUCCESS if out_string represents the entire contents of s.
  • CS_TRUNCATED if out_string could not accommodate all of s.
Notes Call this function with out_string NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire representation.
Function cs_const_string64_pin
cs_const_string cs_const_string64_pin (
'Pin' a cs_const_string64 - that is, specify that the tool should not free it until it is subsequently 'unpinned' with cs_const_string64_unpin().
Parameters
s [in] The cs_const_string64 to pin.
capacity_bytes [out] The capacity of s, in bytes.
pin_ptr [out] The 'pin' (cs_const_string64_pin_t) associated with the string.
Returns A cs_const_string with the same contents as s. This value is safe for use until the pin is released.
Notes Call cs_const_string64_unpin(pin_ptr) when you have finished using the returned cs_const_string64.

The following example code extracts and uses the 'name' field of a cs_ast.

cs_ast myast;
cs_ast_field field;
cs_size_t bytes;
cs_const_string64_pin_t mypin;
cs_const_string name;
   // [... omitted: set myast to the AST of interest]
CSRC(cs_ast_get_field(myast, csao_nc_name, &field));
if (field.type != csft_const_str64) {return 0;}
name = cs_const_string64_pin(field._.const_str64, &bytes, &mypin );
   // [... omitted: use name]
cs_const_string64_unpin(&mypin);

Function cs_const_string64_unpin
void cs_const_string64_unpin (
'Unpin' a previously-pinned cs_const_string64 - that is, specify that you no longer require it and the tool is free to delete it.
Parameters
pin_ptr [in] The pin to release.
Returns void
Notes See the cs_const_string64_pin() documentation for a code example.
Function cs_const_string64_create
cs_result cs_const_string64_create (
Create and return a cs_const_string64.
Parameters
s [in] A cs_const_string for which a 64-bit version is required.
out_string [out] A pointer to a new, cs_const_string64 version of s.
Returns CS_SUCCESS on success
Function cs_string_equal
cs_boolean cs_string_equal (
Check: are two cs_string objects (case-sensitively) equal?
Parameters
str1 [in] First argument to equality check.
str2 [in] Second argument to equality check.
Returns A cs_boolean:
  • cs_true if str1 is case sensitively equivalent to str2;
  • cs_false otherwise.
Function cs_string_hash
cs_hash_t cs_string_hash (
Hash function for cs_string.
Parameters
str [in] The cs_string to hash.
Returns A case sensitive hash of str.
Function cs_string_hash_seed
cs_hash_t cs_string_hash_seed (
Seeded hash function for cs_const_string.
Parameters
str [in] The string to hash.
hseed [in] The hash seed.
Returns A hash of str using seed hseed.
Function cs_string_hash64
csuint64 cs_string_hash64 (
Hash function for cs_const_string.
Parameters
str [in] The string to hash.
Returns A hash of str.