node-addon-layer
C API For writing Node modules
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions
String methods

Functions

shim_val_tshim_string_new (shim_ctx_t *ctx)
 
shim_val_tshim_string_new_copy (shim_ctx_t *ctx, const char *data)
 
shim_val_tshim_string_new_copyn (shim_ctx_t *ctx, const char *data, size_t len)
 
size_t shim_string_length (shim_val_t *val)
 
size_t shim_string_length_utf8 (shim_val_t *val)
 
const char * shim_string_value (shim_val_t *val)
 
size_t shim_string_write_ascii (shim_val_t *val, char *buff, size_t start, size_t len, int32_t options)
 

Detailed Description

Methods for strings

Function Documentation

size_t shim_string_length ( shim_val_t val)

Get the length of the string

Parameters
valThe given string
Returns
The length of the string
size_t shim_string_length_utf8 ( shim_val_t val)

Get the UTF-8 encoded length of the string

Parameters
valThe given string
Returns
The length of the UTF-8 encoded string
shim_val_t* shim_string_new ( shim_ctx_t ctx)

Create a new empty string

Parameters
ctxCurrent executing context
Returns
Wrapped empty string
shim_val_t* shim_string_new_copy ( shim_ctx_t ctx,
const char *  data 
)

Create a new string and from the null terminated C string

Parameters
ctxCurrent executing context
dataSource null terminated string
Returns
The wrapped string
shim_val_t* shim_string_new_copyn ( shim_ctx_t ctx,
const char *  data,
size_t  len 
)

Create a new string of the given length from the existing buffer

Parameters
ctxCurrent executing context
dataSource string
lenLength of created string
Returns
The wrapped string
const char* shim_string_value ( shim_val_t val)

Get the value of the string

Parameters
valThe given string
Returns
The C string value of the string

The caller is responsible for free'ing this memory

size_t shim_string_write_ascii ( shim_val_t val,
char *  buff,
size_t  start,
size_t  len,
int32_t  options 
)

Write the value of the string to a buffer

Parameters
valThe given string
buffThe destination buffer
startThe starting position to encode
lenThe length of the string to create
optionsThe options for how to encode the string