Diffusion C API  5.9.24
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
utils.h File Reference

Miscellaneous utility functions that don't fit anywhere else. More...

Functions

char * uint32_to_str (uint32_t val)
 Safely convert an unsigned integer to a NULL-terminated string. More...
 
char * int_to_str (int val)
 Safely convert a signed integer to a NULL-terminated string. More...
 
char * double_to_str (double val)
 Safely convert a signed double to a NULL-terminated string. More...
 
uint32_t float_to_uint32 (float f)
 Encode an ieee754 float as a uint32_t (4 bytes). More...
 
float uint32_to_float (uint32_t i)
 Decocde an ieee754 float from a 4-byte unsigned int. More...
 
char * selector_get_prefix (const char *selector)
 Returns the largest non-regexp part of a topic selector. More...
 

Detailed Description

Miscellaneous utility functions that don't fit anywhere else.

Copyright © 2014, 2015 Push Technology Ltd., All Rights Reserved.

Use is subject to license terms.

NOTICE: All information contained herein is, and remains the property of Push Technology. The intellectual and technical concepts contained herein are proprietary to Push Technology and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law.

Function Documentation

char* double_to_str ( double  val)

Safely convert a signed double to a NULL-terminated string.

The "float" format specifier is used. The caller should free the return value after use.

Parameters
valThe signed double to convert.
Returns
A NULL-terminated string or NULL if the conversion failed.
uint32_t float_to_uint32 ( float  f)

Encode an ieee754 float as a uint32_t (4 bytes).

Parameters
fFloat to encode
Returns
A uint32_t
char* int_to_str ( int  val)

Safely convert a signed integer to a NULL-terminated string.

The caller should free the return value after use.

Parameters
valThe signed integer to convert.
Returns
A NULL-terminated string or NULL if the conversion failed.
char* selector_get_prefix ( const char *  selector)

Returns the largest non-regexp part of a topic selector.

Parameters
selectorThe topic selector to analyse.
Returns
A pointer to a char array, which should be freed by the caller.
float uint32_to_float ( uint32_t  i)

Decocde an ieee754 float from a 4-byte unsigned int.

Parameters
iuint32_t containing IEEE754-encoded data.
Returns
A float
char* uint32_to_str ( uint32_t  val)

Safely convert an unsigned integer to a NULL-terminated string.

The caller should free the return value after use.

Parameters
valThe unsigned integer to convert.
Return values
ANULL-terminated string or NULL if the conversion failed.