#pragma once #include #include #include #include #include "sedpp/Options.h" namespace sedpp { struct Match { std::vector groups; }; // Small RAII wrapper for POSIX regex_t. POSIX regex reports match offsets // relative to the searched pointer, so search() rebases groups to the original // subject string before returning. class Regex { public: Regex(const std::string &pattern, const Options &options, bool ignoreCase = false, bool multiline = false); Regex(const Regex &) = delete; Regex &operator=(const Regex &) = delete; Regex(Regex &&other) noexcept; Regex &operator=(Regex &&other) noexcept; ~Regex(); [[nodiscard]] std::optional search(const std::string &text, std::size_t start = 0) const; private: regex_t regex_{}; bool compiled_ = false; }; } // namespace sedpp