felixguendling / cista

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

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

Closed khng300 closed 11 months ago

khng300 commented 1 year 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 1 year 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 11 months ago

Still in draft mode. Something missing?

khng300 commented 11 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 11 months ago

Still in draft mode. Something missing?

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

khng300 commented 11 months ago
felixguendling commented 11 months ago

Thank you!