0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-06 05:48:54 +01:00
construct/include/ircd/util/blackwhite.h

56 lines
1.2 KiB
C
Raw Normal View History

2023-02-28 08:58:08 +01:00
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2023 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#pragma once
#define HAVE_IRCD_UTIL_BLACKWHITE_H
namespace ircd { inline namespace util
{
namespace blackwhite
{
struct list;
}
}}
class ircd::util::blackwhite::list
{
string_view black;
string_view white;
char delim;
bool match(const string_view &) const;
public:
bool operator()(const string_view &) const;
list(const char delim = ' ',
const string_view &black = {},
const string_view &white = {});
};
inline
ircd::util::blackwhite::list::list(const char delim,
const string_view &black,
const string_view &white)
:black{black}
,white{white}
,delim{delim}
{}
inline bool
ircd::util::blackwhite::list::operator()(const string_view &s)
const
{
if(!this->black && !this->white)
return true;
return match(s);
}