High Performance OPC UA Server SDK  1.1.0.158
ua_bytestring Struct Reference

This Built-in DataType defines a value that is a sequence of Byte values. More...

#include <bytestring.h>

Public Member Functions

void ua_bytestring_init (struct ua_bytestring *bs)
 Initialize an ua_bytestring as empty bytestring.
 
void ua_bytestring_clear (struct ua_bytestring *bs)
 Clear an ua_bytestring and set to empty bytestring.
 
size_t ua_bytestring_length (const struct ua_bytestring *bs)
 Returns the length of the bytestring in bytes. More...
 
char * ua_bytestring_data (struct ua_bytestring *bs)
 Returns the raw data of bs. More...
 
const char * ua_bytestring_const_data (const struct ua_bytestring *bs)
 Returns the raw string data of bs. More...
 
bool ua_bytestring_is_null (const struct ua_bytestring *bs)
 Returns true if the given bytestring is a NULL bytestring. More...
 
int ua_bytestring_compare (const struct ua_bytestring *a, const struct ua_bytestring *b)
 Compare to ua_bytestrings. More...
 
int ua_bytestring_copy (struct ua_bytestring *dst, const struct ua_bytestring *src)
 Copy ua_bytestring src to dst. More...
 
int ua_bytestring_set (struct ua_bytestring *bs, const char *src, int32_t len)
 Initializes the bytestring bs with the given data. More...
 
void ua_bytestring_attach (struct ua_bytestring *bs, char *src, int32_t len)
 Initializes the bytestring bs with the given data. More...
 
int ua_bytestring_to_string (const struct ua_bytestring *bs, struct ua_string *dst)
 Creates a ua_string dst with base64 encoded content from a ua_bytestring bs. More...
 
int ua_bytestring_snprintf (char *dst, size_t size, const struct ua_bytestring *bs)
 Converts the given bytestring into a base64 string. More...
 
int ua_bytestring_from_string (struct ua_bytestring *bs, const struct ua_string *src)
 Creates a ua_bytestring bs from a given base46 string src. More...
 

Data Fields

int32_t len
 Number of bytes, or -1 for a ‘null’ bytestring. More...
 
char * data
 Pointer to actual array with bytes.
 

Related Functions

#define UA_BYTESTRING_INITIALIZER   { 0, NULL }
 Initializer for empty ua_bytestrings.
 

Detailed Description

This Built-in DataType defines a value that is a sequence of Byte values.

Member Function Documentation

void ua_bytestring_attach ( struct ua_bytestring bs,
char *  src,
int32_t  len 
)

Initializes the bytestring bs with the given data.

This function takes ownership of src and will free it when calling ua_bytestring_clear().

int ua_bytestring_compare ( const struct ua_bytestring a,
const struct ua_bytestring b 
)

Compare to ua_bytestrings.

Returns
Zero if both are the same.
const char * ua_bytestring_const_data ( const struct ua_bytestring bs)

Returns the raw string data of bs.

This version of the function returns a const pointer.

int ua_bytestring_copy ( struct ua_bytestring dst,
const struct ua_bytestring src 
)

Copy ua_bytestring src to dst.

Returns
Zero on success or errorcode on failure.
char * ua_bytestring_data ( struct ua_bytestring bs)

Returns the raw data of bs.

This pointer can be used to access and modify the data that compose the bytestring.

int ua_bytestring_from_string ( struct ua_bytestring bs,
const struct ua_string src 
)

Creates a ua_bytestring bs from a given base46 string src.

Parameters
bsDestination for the base64 decoded bytestring. It is save to pass an uninitialized ua_bytestring.
srcua_string with base64 encoded content to be decoded.
Returns
Returns 0 on success.
bool ua_bytestring_is_null ( const struct ua_bytestring bs)

Returns true if the given bytestring is a NULL bytestring.

In OPC UA len is set to -1 for NULL bytestrings, however we only check the data pointer. If data is NULL the bytestring is a NULL bytestring and len is ignored.

size_t ua_bytestring_length ( const struct ua_bytestring bs)

Returns the length of the bytestring in bytes.

A value of 0 indicates null bytestring, or an invalid argument.

int ua_bytestring_set ( struct ua_bytestring bs,
const char *  src,
int32_t  len 
)

Initializes the bytestring bs with the given data.

This function creates a copy of src.

int ua_bytestring_snprintf ( char *  dst,
size_t  size,
const struct ua_bytestring bs 
)

Converts the given bytestring into a base64 string.

Parameters
dstDestination string where the base64 string will be written to.
sizeSize in bytes of dst.
bsThe bytestring to be converted.
Returns
Upon successful return, these functions return the number of characters printed (excluding the null byte used to end output to strings). This function does not write more than size bytes (including the terminating null byte). If the output was truncated due to this limit then the return value is the number of characters (excluding the terminating null byte) which would have been written to the final string if enough space had been available. Thus, a return value of size or more means that the output was truncated.
int ua_bytestring_to_string ( const struct ua_bytestring bs,
struct ua_string dst 
)

Creates a ua_string dst with base64 encoded content from a ua_bytestring bs.

Parameters
bsua_bytestring to be converted to a base64 ua_string.
dstua_string to write the encoded data to. It is save to pass an uninitialized ua_string.
Returns
Returns 0 on success

Field Documentation

int32_t len

Number of bytes, or -1 for a ‘null’ bytestring.


The documentation for this struct was generated from the following files: