2019-07-11 22:46:32 +02:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2019 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_GLOBULAR_H
|
|
|
|
|
|
|
|
namespace ircd
|
|
|
|
{
|
|
|
|
// Globular ('*' and '?') expression utils.
|
2020-03-19 19:29:11 +01:00
|
|
|
struct globular_imatch;
|
|
|
|
struct globular_iequals;
|
2019-07-11 22:46:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Globular equals. This allows either side of the comparison to include '*'
|
|
|
|
/// and '?' characters and equality of the string expressions will be
|
2020-03-19 19:29:11 +01:00
|
|
|
/// determined. Case insensitive.
|
|
|
|
struct ircd::globular_iequals
|
2020-03-19 19:25:58 +01:00
|
|
|
:boolean
|
2019-07-11 22:46:32 +02:00
|
|
|
{
|
|
|
|
using is_transparent = std::true_type;
|
|
|
|
|
2020-03-19 19:25:58 +01:00
|
|
|
bool operator()(const string_view &a, const string_view &b) const noexcept;
|
2019-07-11 22:46:32 +02:00
|
|
|
|
|
|
|
template<class A,
|
|
|
|
class B>
|
2020-03-19 19:29:11 +01:00
|
|
|
globular_iequals(A&& a, B&& b)
|
2020-03-19 19:25:58 +01:00
|
|
|
:boolean{operator()(std::forward<A>(a), std::forward<B>(b))}
|
2019-07-11 22:46:32 +02:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Globular match. Similar to globular_equals but only one side of the
|
|
|
|
/// comparison is considered to be the expression with '*' and '?' characters.
|
|
|
|
/// The expression string is passed at construction. The comparison inputs are
|
|
|
|
/// treated as non-expression strings. This allows for greater optimization
|
2020-03-19 19:29:11 +01:00
|
|
|
/// than globular_equals. Case insensitive.
|
|
|
|
struct ircd::globular_imatch
|
2019-07-11 22:46:32 +02:00
|
|
|
{
|
2020-04-27 01:38:01 +02:00
|
|
|
string_view a;
|
2019-07-11 22:46:32 +02:00
|
|
|
|
2020-04-27 01:38:01 +02:00
|
|
|
bool operator()(const string_view &b) const noexcept;
|
2019-07-11 22:46:32 +02:00
|
|
|
|
2020-04-27 01:38:01 +02:00
|
|
|
globular_imatch(const string_view &expr)
|
|
|
|
:a{expr}
|
2019-07-11 22:46:32 +02:00
|
|
|
{}
|
|
|
|
};
|