0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-20 17:01:55 +01:00

ircd:Ⓜ️ Add random alpha-based ID generator.

This commit is contained in:
Jason Volk 2018-02-15 13:00:23 -08:00
parent 7b0c53501a
commit 08335c3883

View file

@ -292,6 +292,7 @@ catch(const qi::expectation_failure<const char *> &e)
struct ircd::m::id::printer
:output<const char *>
{
static string_view random_alpha(const id::sigil &, const mutable_buffer &buf, const size_t &len);
static string_view random_timebased(const id::sigil &, const mutable_buffer &);
static string_view random_prefixed(const id::sigil &, const string_view &prefix, const mutable_buffer &);
@ -378,6 +379,22 @@ ircd::m::id::printer::random_timebased(const id::sigil &sigil,
return { data(buf), size_t(len) };
}
ircd::string_view
ircd::m::id::printer::random_alpha(const id::sigil &sigil,
const mutable_buffer &buf,
const size_t &len)
{
using buffer::data;
using buffer::size;
const mutable_buffer out
{
data(buf), std::min(size(buf), len)
};
return rand::string(rand::dict::alpha, out);
}
//
// id
//