felixguendling / cista

Cista is a simple, high-performance, zero-copy C++ serialization & reflection library.
https://cista.rocks
MIT License
1.74k stars 110 forks source link

RFC: Add cista::*::cstring type #202

Closed khng300 closed 8 months ago

khng300 commented 9 months ago

This new type is able to store a trailing \0 character, without compromising one byte for storage when the string is a small-string.

Storage of NUL character within data is also supported.

This is inspired by https://github.com/felixguendling/cista/issues/187#issuecomment-1603128882.

See https://github.com/felixguendling/cista/issues/187.

felixguendling commented 9 months ago

Thank you for your PR! I think some tests would be useful, formatting should be fixed (using clang-format), and maybe a bit of description in the code how it works could help me to understand what's going on (just the tricky spots where the magic happens).

felixguendling commented 8 months ago

Still in draft mode. Something missing?

khng300 commented 8 months ago

I was considering if it is still worth keeping cstring_view in such case. If not, the corner case of checking null can be omitted.

khng300 commented 8 months ago

Still in draft mode. Something missing?

The latest commit pulled out the null-pointer checks for set_owning related calls().

khng300 commented 8 months ago
felixguendling commented 8 months ago

Thank you!