mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::rfc1459: Add util to build string of characters by attribute.
This commit is contained in:
parent
9e027b2212
commit
f446081021
2 changed files with 26 additions and 0 deletions
|
@ -65,11 +65,16 @@ namespace character
|
|||
// Transforms
|
||||
const uint8_t &tolower(const uint8_t &c);
|
||||
const uint8_t &toupper(const uint8_t &c);
|
||||
|
||||
// Get all characters for an attribute mask
|
||||
size_t gather(const attr &attr, uint8_t *const &buf, const size_t &max);
|
||||
std::string gather(const attr &attr);
|
||||
}
|
||||
|
||||
using character::is;
|
||||
using character::toupper;
|
||||
using character::tolower;
|
||||
using character::gather;
|
||||
|
||||
struct less
|
||||
{
|
||||
|
|
|
@ -23,6 +23,27 @@
|
|||
|
||||
using namespace ircd;
|
||||
|
||||
std::string
|
||||
rfc1459::character::gather(const attr &attr)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
const size_t len(gather(attr, buf, sizeof(buf)));
|
||||
return { reinterpret_cast<const char *>(buf), len };
|
||||
}
|
||||
|
||||
size_t
|
||||
rfc1459::character::gather(const attr &attr,
|
||||
uint8_t *const &buf,
|
||||
const size_t &max)
|
||||
{
|
||||
size_t ret(0);
|
||||
for(ssize_t i(attrs.size() - 1); i >= 0 && ret < max; --i)
|
||||
if(is(i, attr))
|
||||
buf[ret++] = i;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
decltype(rfc1459::character::tolower_tab)
|
||||
rfc1459::character::tolower_tab
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue