|
rapidyaml
0.12.1
parse and emit YAML, and do it fast
|
To serialize user scalar types, implement the appropriate function to_chars (see also to_chars: generalized chars to value): More...
Functions | |
| template<class T > | |
| size_t | to_chars (ryml::substr buf, vec2< T > v) |
| template<class T > | |
| size_t | to_chars (ryml::substr buf, vec3< T > v) |
| template<class T > | |
| size_t | to_chars (ryml::substr buf, vec4< T > v) |
| template<class T > | |
| size_t | to_chars (ryml::substr buf, emit_only_vec2< T > v) |
| template<class T > | |
| size_t | to_chars (ryml::substr buf, emit_only_vec3< T > v) |
| template<class T > | |
| size_t | to_chars (ryml::substr buf, emit_only_vec4< T > v) |
To serialize user scalar types, implement the appropriate function to_chars (see also to_chars: generalized chars to value):
See the sample sample_user_scalar_types() for an example usage.
Your implementation of to_chars must format v to the given string view + return the number of characters written into it. The view size (buf.len) must be strictly respected. Return the number of characters that need to be written for the value to be completely serialized in the string. So if the return value is larger than buf.len, ryml will know that the buffer resize the buffer and call this again with a larger buffer of the correct size.
In your implementation, you may be interested in using the formatting facilities in Format utilities and Charconv utilities; refer to their documentation for further details. But this is not mandatory, and anything can be used, provided that the implemented to_chars() fulfills its contract, described above.
to_chars() implementation before any other headers that use functions from it. See the include order at the top of this source file. This constraint also applies to the conversion functions for your types; just like with the STL's headers, they should be included prior to ryml's headers. Lately, some effort was directed to provide forward declarations to alleviate this problem, but it may still occur.| size_t to_chars | ( | ryml::substr | buf, |
| vec2< T > | v | ||
| ) |
Definition at line 3514 of file quickstart.cpp.
References c4::format(), vec2< T >::x, and vec2< T >::y.
| size_t to_chars | ( | ryml::substr | buf, |
| vec3< T > | v | ||
| ) |
Definition at line 3515 of file quickstart.cpp.
References c4::format(), vec3< T >::x, vec3< T >::y, and vec3< T >::z.
| size_t to_chars | ( | ryml::substr | buf, |
| vec4< T > | v | ||
| ) |
Definition at line 3516 of file quickstart.cpp.
References c4::format(), vec4< T >::w, vec4< T >::x, vec4< T >::y, and vec4< T >::z.
| size_t to_chars | ( | ryml::substr | buf, |
| emit_only_vec2< T > | v | ||
| ) |
Definition at line 3518 of file quickstart.cpp.
References c4::format(), emit_only_vec2< T >::x, and emit_only_vec2< T >::y.
| size_t to_chars | ( | ryml::substr | buf, |
| emit_only_vec3< T > | v | ||
| ) |
Definition at line 3519 of file quickstart.cpp.
References c4::format(), emit_only_vec3< T >::x, emit_only_vec3< T >::y, and emit_only_vec3< T >::z.
| size_t to_chars | ( | ryml::substr | buf, |
| emit_only_vec4< T > | v | ||
| ) |
Definition at line 3520 of file quickstart.cpp.
References c4::format(), emit_only_vec4< T >::w, emit_only_vec4< T >::x, emit_only_vec4< T >::y, and emit_only_vec4< T >::z.