Function rcutils_time_point_value_as_nanoseconds_string

Function Documentation

rcutils_ret_t rcutils_time_point_value_as_nanoseconds_string(const rcutils_time_point_value_t *time_point, char *str, size_t str_size)

Return a time point as nanoseconds in a string.

The number is always fixed width, with left padding zeros up to the maximum number of digits the time point can represent. Right now that is 19 digits (so 19 characters) for a signed 64-bit integer. Negative values will have a leading -, so they will be one character longer than the positive values.

The recommended minimum size of the input string is 32 characters, but 21 ( or - for sign, 19 digits, null terminator) should be sufficiently large for both positive and negative values. If the given string is not large enough, the result will be truncated. If you need a string with variable width, using snprintf() directly is recommended.

Attribute

Adherence

Allocates Memory

No [1]

Thread-Safe

Yes

Uses Atomics

No

Lock-Free

Yes

[1] if does not allocate additional memory internally

Parameters:
  • time_point[in] the time to be made into a string

  • str[out] the output string in which it is stored

  • str_size[in] the size of the output string

Returns:

RCUTILS_RET_OK if successful (even if truncated), or

Returns:

RCUTILS_RET_INVALID_ARGUMENT if any arguments are invalid, or

Returns:

RCUTILS_RET_ERROR if an unspecified error occur.