Loading...
Searching...
No Matches
Data Structures | Functions
as_string.h File Reference
#include <aerospike/as_std.h>
#include <aerospike/as_util.h>
#include <aerospike/as_val.h>
+ Include dependency graph for as_string.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  as_string
 

Functions

AS_EXTERN const char * as_basename (as_string *filename, const char *path)
 
static void as_string_destroy (as_string *string)
 
static as_stringas_string_fromval (const as_val *v)
 
static char * as_string_get (const as_string *string)
 
static char * as_string_getorelse (const as_string *string, char *fallback)
 
AS_EXTERN as_stringas_string_init (as_string *string, char *value, bool free)
 
AS_EXTERN as_stringas_string_init_wlen (as_string *string, char *value, size_t len, bool free)
 
AS_EXTERN size_t as_string_len (as_string *string)
 
AS_EXTERN as_stringas_string_new (char *value, bool free)
 
AS_EXTERN as_stringas_string_new_strdup (const char *value)
 
AS_EXTERN as_stringas_string_new_wlen (char *value, size_t len, bool free)
 
static char * as_string_tostring (const as_string *string)
 
static as_valas_string_toval (const as_string *s)
 
AS_EXTERN void as_string_val_destroy (as_val *v)
 
AS_EXTERN uint32_t as_string_val_hashcode (const as_val *v)
 
AS_EXTERN char * as_string_val_tostring (const as_val *v)
 
AS_EXTERN bool as_strncpy (char *trg, const char *src, int size)
 

Function Documentation

◆ as_basename()

AS_EXTERN const char * as_basename ( as_string * filename,
const char * path )

Return filename component of full path.

If path is empty, the current directory is returned. If path contains trailing directory slashes, create new string to hold filename without slashes. The input path is guaranteed not to be modified. as_string_destroy() must be called when finished with filename.

◆ as_string_destroy()

static void as_string_destroy ( as_string * string)
inlinestatic

Destroy the as_string and associated resources.

Definition at line 209 of file as_string.h.

◆ as_string_fromval()

static as_string * as_string_fromval ( const as_val * v)
inlinestatic

Convert from an as_val.

Definition at line 291 of file as_string.h.

◆ as_string_get()

static char * as_string_get ( const as_string * string)
inlinestatic

Get the string value.

Definition at line 244 of file as_string.h.

◆ as_string_getorelse()

static char * as_string_getorelse ( const as_string * string,
char * fallback )
inlinestatic

Get the string value. If string is NULL, then return the fallback value.

Definition at line 234 of file as_string.h.

◆ as_string_init()

AS_EXTERN as_string * as_string_init ( as_string * string,
char * value,
bool free )

Initialize a stack allocated as_string.

If free is true, then the string value will be freed when the as_string is destroyed.

Parameters
stringThe stack allocated as_string to initialize
valueThe NULL terminated string of character.
freeIf true, then the value will be freed when as_string is destroyed.
Returns
On success, the initialized string. Otherwise NULL.

◆ as_string_init_wlen()

AS_EXTERN as_string * as_string_init_wlen ( as_string * string,
char * value,
size_t len,
bool free )

Initialize a stack allocated as_string and its length.

If free is true, then the string value will be freed when the as_string is destroyed.

Parameters
stringThe stack allocated as_string to initialize
valueThe NULL terminated string of character.
lenThe length of the string.
freeIf true, then the value will be freed when as_string is destroyed.
Returns
On success, the initialized string. Otherwise NULL.

◆ as_string_len()

AS_EXTERN size_t as_string_len ( as_string * string)

The length of the string

Parameters
stringThe string to get the length of.
Returns
the length of the string in bytes.

◆ as_string_new()

AS_EXTERN as_string * as_string_new ( char * value,
bool free )

Create and initialize a new heap allocated as_string.

If free is true, then the string value will be freed when the as_string is destroyed.

Parameters
valueThe NULL terminated string of character.
freeIf true, then the value will be freed when as_string is destroyed.
Returns
On success, the new string. Otherwise NULL.

◆ as_string_new_strdup()

AS_EXTERN as_string * as_string_new_strdup ( const char * value)

Create and initialize a new heap allocated as_string.

Value is cf_strdup()'d and will be freed when the as_string is destroyed.

Parameters
valueThe NULL terminated string of character.
Returns
On success, the new string. Otherwise NULL.

◆ as_string_new_wlen()

AS_EXTERN as_string * as_string_new_wlen ( char * value,
size_t len,
bool free )

Create and initialize a new heap allocated as_string and its length.

If free is true, then the string value will be freed when the as_string is destroyed.

Parameters
valueThe NULL terminated string of character.
lenThe length of the string.
freeIf true, then the value will be freed when as_string is destroyed.
Returns
On success, the new string. Otherwise NULL.

◆ as_string_tostring()

static char * as_string_tostring ( const as_string * string)
inlinestatic

Get the string value.

Deprecated
Use as_string_get() instead

Definition at line 255 of file as_string.h.

◆ as_string_toval()

static as_val * as_string_toval ( const as_string * s)
inlinestatic

Convert to an as_val.

Definition at line 281 of file as_string.h.

◆ as_string_val_destroy()

AS_EXTERN void as_string_val_destroy ( as_val * v)
private

Internal helper function for destroying an as_val.

◆ as_string_val_hashcode()

AS_EXTERN uint32_t as_string_val_hashcode ( const as_val * v)
private

Internal helper function for getting the hashcode of an as_val.

◆ as_string_val_tostring()

AS_EXTERN char * as_string_val_tostring ( const as_val * v)
private

Internal helper function for getting the string representation of an as_val.

◆ as_strncpy()

AS_EXTERN bool as_strncpy ( char * trg,
const char * src,
int size )
private

Copy null terminated src to trg up to a maximum size. If maximum size reached, null terminate last character and and return true that truncation occurred.

as_strncpy does not pad unused bytes with zeroes like the standard strncpy.

char target[64];
as_strncpy(target, "source string", sizeof(target));
AS_EXTERN bool as_strncpy(char *trg, const char *src, int size)