#pragma once
#include <cstdint>
#include <string>
#include <string_view>
#include <unordered_map>
#include <utility>
#include <vector>
#include "dynamic_string.hpp"
#include "indexed_multivector.hpp"
#include "matcher/base.hpp"
#include "object_type.hpp"
namespace ddwaf::matcher {
class exact_match : public base_impl<exact_match> {
public:
using data_type = std::vector<std::pair<std::string, uint64_t>>;
static constexpr std::string_view matcher_name = "exact_match";
static constexpr std::string_view negated_matcher_name = "!exact_match";
exact_match() = default;
explicit exact_match(std::vector<std::string> &&data);
explicit exact_match(
const indexed_multivector<std::string, std::pair<std::string, uint64_t>> &data);
explicit exact_match(const data_type &data);
~exact_match() override = default;
exact_match(const exact_match &) = default;
exact_match(exact_match &&) = default;
exact_match &operator=(const exact_match &) = default;
exact_match &operator=(exact_match &&) = default;
protected:
static constexpr std::string_view to_string_impl() { return ""; }
static constexpr bool is_supported_type_impl(object_type type)
{
return (type & object_type::string) != 0;
}
[[nodiscard]] std::pair<bool, dynamic_string> match_impl(std::string_view str) const;
std::vector<std::string> data_;
std::unordered_map<std::string_view, uint64_t> values_;
friend class base_impl<exact_match>;
};
}