Generic Values

A generic interface for reading and writing binary values.

EXESS_ALIGN

Attribute to align a buffer for any supported value.

EXESS_MAX_FIXED_SIZE

12U

The maximum size of a supported fixed-size value in bytes.

ExessOrder exess_compare_value(ExessDatatype lhs_datatype, size_t lhs_size, const void *lhs_value, ExessDatatype rhs_datatype, size_t rhs_size, const void *rhs_value)

Compare two values.

Returns:

Less than, equal to, or greater than zero if the left-hand value is less than, equal to, or greater than the right-hand value, respectively. Comparable and incomparable cases may also be distinguished, see ExessOrder for details.

ExessVariableResult exess_read_value(ExessDatatype datatype, const char *str, size_t out_size, void *out)

Read any supported datatype from a string.

Note that out must be suitably aligned for the datatype being read, it will be dereferenced directly as a pointer to the value type. A 64-bit aligned buffer will be suitably aligned for any datatype.

Parameters:
  • str – String to read.

  • datatype – Datatype to read the string as.

  • out_size – Size of out in bytes.

  • out – Parsed value on success.

Returns:

The read_count from str, write_count to out (both in bytes), and a status.

ExessResult exess_write_value(ExessDatatype datatype, size_t value_size, const void *value, size_t buf_size, char *buf)

Write any supported datatype to a canonical string.

Note that value must be suitably aligned for the datatype being written, it will be dereferenced directly as a pointer to the value type. A 64-bit aligned buffer will be suitably aligned for any datatype.

Parameters:
  • datatype – Datatype of value.

  • value_size – Size of value in bytes.

  • value – Value to write.

  • buf_size – Size of buf in bytes.

  • buf – Output buffer, or null to only measure.

Returns:

The count of characters in the output, and a status (ExessStatus.EXESS_SUCCESS, or ExessStatus.EXESS_NO_SPACE if the buffer is too small).