|
rapidyaml
0.7.0
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 | sample::to_chars (ryml::substr buf, vec2< T > v) |
| template<class T > | |
| size_t | sample::to_chars (ryml::substr buf, vec3< T > v) |
| template<class T > | |
| size_t | sample::to_chars (ryml::substr buf, vec4< T > v) |
| template<class T > | |
| size_t | sample::to_chars (ryml::substr buf, emit_only_vec2< T > v) |
| template<class T > | |
| size_t | sample::to_chars (ryml::substr buf, emit_only_vec3< T > v) |
| template<class T > | |
| size_t | sample::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 sample::to_chars | ( | ryml::substr | buf, |
| vec2< T > | v | ||
| ) |
Definition at line 3415 of file quickstart.cpp.
References c4::format(), sample::vec2< T >::x, and sample::vec2< T >::y.
Referenced by c4::yml::Tree::to_arena(), and c4::yml::to_chars_float().
| size_t sample::to_chars | ( | ryml::substr | buf, |
| vec3< T > | v | ||
| ) |
Definition at line 3416 of file quickstart.cpp.
References c4::format(), sample::vec3< T >::x, sample::vec3< T >::y, and sample::vec3< T >::z.
| size_t sample::to_chars | ( | ryml::substr | buf, |
| vec4< T > | v | ||
| ) |
Definition at line 3417 of file quickstart.cpp.
References c4::format(), sample::vec4< T >::w, sample::vec4< T >::x, sample::vec4< T >::y, and sample::vec4< T >::z.
| size_t sample::to_chars | ( | ryml::substr | buf, |
| emit_only_vec2< T > | v | ||
| ) |
Definition at line 3419 of file quickstart.cpp.
References c4::format(), sample::emit_only_vec2< T >::x, and sample::emit_only_vec2< T >::y.
| size_t sample::to_chars | ( | ryml::substr | buf, |
| emit_only_vec3< T > | v | ||
| ) |
Definition at line 3420 of file quickstart.cpp.
References c4::format(), sample::emit_only_vec3< T >::x, sample::emit_only_vec3< T >::y, and sample::emit_only_vec3< T >::z.
| size_t sample::to_chars | ( | ryml::substr | buf, |
| emit_only_vec4< T > | v | ||
| ) |
Definition at line 3421 of file quickstart.cpp.
References c4::format(), sample::emit_only_vec4< T >::w, sample::emit_only_vec4< T >::x, sample::emit_only_vec4< T >::y, and sample::emit_only_vec4< T >::z.