Extract shared basic_name<Traits> template from sysio::name#64
Open
heifner wants to merge 2 commits into
Open
Conversation
sysio::name packs a short string into a uint64_t. To share that scheme with sysio::slug_name, factor the encoding and value semantics into a generic sysio::basic_name<Traits>: a Traits type supplies the alphabet, max length, and sysio::check messages; the template derives the symbol width and MSB-first bit layout. name becomes a thin derived type holding only the contract-side surface: raw, char_to_value, length, prefix()/suffix(), operator raw, write_as_string, and print. Encoding is byte-identical. basic_name compares via a defaulted operator<=> / operator== (C++20).
Mirrors the wire-sysio review changes onto the contract-side basic_name so it is ready to back a slug-style identifier: - Add a basic_name_traits concept and constrain basic_name<Traits> with it, replacing the prose list of trait requirements. - to_string() honours a Traits::zero_terminates flag: true ends the string at the first symbol-0 slot (slug-style), false keeps symbol 0 as an ordinary interior character (name's '.'). sysio_name_traits sets it false, so name decoding is byte-identical. Add tests/unit/basic_name_tests.cpp: native unit tests covering basic_name through a slug-style Traits policy — the concept, encoding round-trips, the zero-terminated to_string (incl. an interior-zero value), defaulted comparisons, and constructor validation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Description
sysio::namepacks a short string into auint64_t. It andslug_nameare near-duplicate packed-identifier types, so this extracts the encoding and value semantics into a reusablesysio::basic_name<Traits>that either can build on.Traitstype supplies the alphabet, max length, andsysio::checkmessages; the template derives the symbol width and MSB-first bit layout.namebecomes a thin derived type that keeps only the contract-side surface —raw,char_to_value,length,prefix()/suffix(),operator raw,write_as_string,print. Encoding is byte-identical.basic_namecompares via a defaultedoperator<=>/operator==(C++20).The host side is a parallel change in wire-sysio (
fc::basic_name); the two are meant to be merged together.