mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
added concept for iterators, reworked interface
This commit is contained in:
@@ -36,10 +36,11 @@ namespace omath
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static std::optional<std::span<std::byte>::const_iterator> scan_for_pattern(const std::span<std::byte>& range,
|
static std::span<std::byte>::const_iterator scan_for_pattern(const std::span<std::byte>& range,
|
||||||
const std::string_view& pattern);
|
const std::string_view& pattern);
|
||||||
|
|
||||||
template<class IteratorType>
|
template<class IteratorType>
|
||||||
|
requires std::input_or_output_iterator<std::remove_cvref_t<IteratorType>>
|
||||||
static IteratorType scan_for_pattern(const IteratorType& begin, const IteratorType& end,
|
static IteratorType scan_for_pattern(const IteratorType& begin, const IteratorType& end,
|
||||||
const std::string_view& pattern)
|
const std::string_view& pattern)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,15 +7,10 @@
|
|||||||
namespace omath
|
namespace omath
|
||||||
{
|
{
|
||||||
|
|
||||||
std::optional<std::span<std::byte>::const_iterator>
|
std::span<std::byte>::const_iterator
|
||||||
PatternScanner::scan_for_pattern(const std::span<std::byte>& range, const std::string_view& pattern)
|
PatternScanner::scan_for_pattern(const std::span<std::byte>& range, const std::string_view& pattern)
|
||||||
{
|
{
|
||||||
auto result = scan_for_pattern(range.begin(), range.end(), pattern);
|
return scan_for_pattern(range.begin(), range.end(), pattern);
|
||||||
|
|
||||||
if (result == range.end())
|
|
||||||
return std::nullopt;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
std::expected<std::vector<std::optional<std::byte>>, PatternScanError>
|
std::expected<std::vector<std::optional<std::byte>>, PatternScanError>
|
||||||
PatternScanner::parse_pattern(const std::string_view& pattern_string)
|
PatternScanner::parse_pattern(const std::string_view& pattern_string)
|
||||||
|
|||||||
Reference in New Issue
Block a user