mirror of
https://github.com/matrix-construct/construct
synced 2024-11-04 04:48:53 +01:00
ea4d74967b
ircd:Ⓜ️:dbs: Fix typos.
69 lines
2.8 KiB
C++
69 lines
2.8 KiB
C++
// Matrix Construct
|
|
//
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
// Copyright (C) 2016-2018 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_M_EVENTS_H
|
|
|
|
namespace ircd::m::events
|
|
{
|
|
struct range;
|
|
using closure_bool = std::function<bool (const event::idx &, const event &)>;
|
|
using closure_type_bool = std::function<bool (const string_view &, const event::idx &)>;
|
|
using closure_sender_bool = std::function<bool (const id::user &, const event::idx &)>;
|
|
using closure_type_name_bool = std::function<bool (const string_view &)>;
|
|
using closure_sender_name_bool = std::function<bool (const id::user &)>;
|
|
using closure_origin_name_bool = std::function<bool (const string_view &)>;
|
|
|
|
// Iterate types starting with some prefix, or all types.
|
|
bool for_each_type(const closure_type_name_bool &);
|
|
bool for_each_type(const string_view &prefix, const closure_type_name_bool &);
|
|
|
|
// Iterate servers starting at the hostname equal to or greater than provided
|
|
bool for_each_origin(const closure_origin_name_bool &);
|
|
bool for_each_origin(const string_view &hostlb, const closure_origin_name_bool &);
|
|
|
|
// Iterate senders of events (users).
|
|
bool for_each_sender(const closure_sender_name_bool &);
|
|
bool for_each_sender(const string_view &key, const closure_sender_name_bool &);
|
|
|
|
// Iterate event indexes matching the argument
|
|
bool for_each_in_type(const string_view &, const closure_type_bool &);
|
|
bool for_each_in_sender(const id::user &, const closure_sender_bool &);
|
|
bool for_each_in_origin(const string_view &, const closure_sender_bool &);
|
|
|
|
// Iterate viable event indexes in a range
|
|
bool for_each(const range &, const event::closure_idx_bool &);
|
|
bool for_each(const range &, const event_filter &, const event::closure_idx_bool &);
|
|
|
|
// Iterate events in an index range
|
|
bool for_each(const range &, const closure_bool &);
|
|
bool for_each(const range &, const event_filter &, const closure_bool &);
|
|
|
|
// util
|
|
void dump__file(const string_view &filename);
|
|
}
|
|
|
|
/// Range to start (inclusive) and stop (exclusive). If start is greater than
|
|
/// stop a reverse iteration will occur. -1 (or unsigned max value) can be used
|
|
/// to start or stop at the end. 0 can be used to start or stop at the beginning.
|
|
/// (event::idx of 0 is a sentinel)
|
|
///
|
|
struct ircd::m::events::range
|
|
:event::idx_range
|
|
{
|
|
const event::fetch::opts *fopts {nullptr};
|
|
|
|
range(const event::idx &start,
|
|
const event::idx &stop = -1,
|
|
const event::fetch::opts *const &fopts = nullptr)
|
|
:event::idx_range{start, stop}
|
|
,fopts{fopts}
|
|
{}
|
|
};
|