![]() |
qtty-cpp
Header-only C++ wrapper for qtty
|
JSON serialization helpers for qtty quantities. More...
#include <stdexcept>#include <string>#include <string_view>#include <type_traits>#include "qtty_ffi.h"#include "ffi_core.hpp"
Go to the source code of this file.
Namespaces | |
| namespace | qtty |
| namespace | qtty::serialization |
Functions | |
| int32_t | qtty_quantity_to_json_value (qtty_quantity_t src, char **out_json) |
| int32_t | qtty_quantity_from_json_value (UnitId unit, const char *json, qtty_quantity_t *out) |
| int32_t | qtty_quantity_to_json (qtty_quantity_t src, char **out_json) |
| int32_t | qtty_quantity_from_json (const char *json, qtty_quantity_t *out) |
| void | qtty_string_free (char *s) |
| std::string | qtty::serialization::from_owned_c (char *ptr) |
| Convert an owned C string from FFI into std::string and free it. | |
| template<typename UnitTag > | |
| std::string | qtty::serialization::to_json_value (const Quantity< UnitTag > &q) |
| Serialize only the numeric value as JSON for a typed quantity. | |
| template<typename T > | |
| Quantity< typename ExtractTag< T >::type > | qtty::serialization::from_json_value (std::string_view json) |
| Deserialize a JSON numeric value into a typed quantity. | |
| template<typename UnitTag > | |
| std::string | qtty::serialization::to_json (const Quantity< UnitTag > &q) |
| Serialize a typed quantity as JSON object with value and unit id. | |
| UnitId | qtty::serialization::unit_id_from_u32 (uint32_t raw) |
| template<typename T > | |
| Quantity< typename ExtractTag< T >::type > | qtty::serialization::from_json (std::string_view json) |
| Deserialize a JSON quantity object into a requested target type. | |
JSON serialization helpers for qtty quantities.
Definition in file serialization.hpp.
| int32_t qtty_quantity_from_json | ( | const char * | json, |
| qtty_quantity_t * | out | ||
| ) |
Referenced by qtty::serialization::from_json().
| int32_t qtty_quantity_from_json_value | ( | UnitId | unit, |
| const char * | json, | ||
| qtty_quantity_t * | out | ||
| ) |
Referenced by qtty::serialization::from_json_value().
| int32_t qtty_quantity_to_json | ( | qtty_quantity_t | src, |
| char ** | out_json | ||
| ) |
Referenced by qtty::serialization::to_json().
| int32_t qtty_quantity_to_json_value | ( | qtty_quantity_t | src, |
| char ** | out_json | ||
| ) |
Referenced by qtty::serialization::to_json_value().
| void qtty_string_free | ( | char * | s | ) |
Referenced by qtty::serialization::from_owned_c().