15 namespace internal_use_do_not_use {
76 constexpr explicit name( std::string_view str )
79 if( str.size() > 13 ) {
80 eosio::check(
false,
"string is too long to be a valid name" );
87 for(
decltype(n) i = 0; i < n; ++i ) {
91 value <<= ( 4 + 5*(12 - n) );
92 if( str.size() == 13 ) {
95 eosio::check(
false,
"thirteenth character in name cannot be a letter that comes after j");
110 else if( c >=
'1' && c <=
'5' )
111 return (c -
'1') + 1;
112 else if( c >=
'a' && c <=
'z' )
113 return (c -
'a') + 6;
115 eosio::check(
false,
"character is not in allowed character set for names" );
124 constexpr uint64_t mask = 0xF800000000000000ull;
131 for(
auto v =
value; i < 13; ++i, v <<= 5 ) {
132 if( (v & mask) > 0 ) {
144 uint32_t remaining_bits_after_last_actual_dot = 0;
146 for( int32_t remaining_bits = 59; remaining_bits >= 4; remaining_bits -= 5 ) {
148 auto c = (
value >> remaining_bits) & 0x1Full;
150 tmp =
static_cast<uint32_t>(remaining_bits);
152 remaining_bits_after_last_actual_dot = tmp;
157 if( thirteenth_character ) {
158 remaining_bits_after_last_actual_dot = tmp;
161 if( remaining_bits_after_last_actual_dot == 0 )
167 uint64_t mask = (1ull << remaining_bits_after_last_actual_dot) - 16;
168 uint32_t shift = 64 - remaining_bits_after_last_actual_dot;
170 return name{ ((
value & mask) << shift) + (thirteenth_character << (shift-1)) };
178 bool not_dot_character_seen =
false;
182 for( int32_t offset = 0; offset <= 59; ) {
183 auto c = (
value >> offset) & mask;
186 if(not_dot_character_seen) {
191 not_dot_character_seen =
true;
217 constexpr explicit operator bool()
const {
return value != 0; }
230 static const char* charmap =
".12345abcdefghijklmnopqrstuvwxyz";
231 constexpr uint64_t mask = 0xF800000000000000ull;
233 if( dry_run || (begin + 13 < begin) || (begin + 13 > end) ) {
234 char* actual_end = begin +
length();
235 if( dry_run || (actual_end < begin) || (actual_end > end) )
return actual_end;
239 for(
auto i = 0; i < 13; ++i, v <<= 5 ) {
240 if( v == 0 )
return begin;
242 auto indx = (v & mask) >> (i == 12 ? 60 : 59);
243 *begin = charmap[indx];
258 return {buffer, end};
266 internal_use_do_not_use::printn(
value);
286 return a.value != b.value;
295 return a.value < b.value;
307 template <
char... Str>
309 static constexpr const char value[] = {Str...};
318#pragma clang diagnostic push
319#pragma clang diagnostic ignored "-Wgnu-string-literal-operator-template"
320template <
typename T, T... Str>
325#pragma clang diagnostic pop