diff --git a/src/search.cpp b/src/search.cpp new file mode 100644 index 0000000..a8aa441 --- /dev/null +++ b/src/search.cpp @@ -0,0 +1,33 @@ +/* This file is part of epubgrep. + * Copyright © 2021 tastytea + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "search.hpp" + +#include "fs-compat.hpp" + +#include +#include + +namespace epubgrep::search +{ + +std::vector search(const fs::path &filepath, std::string_view regex, + const options &opts) +{ + return {}; +} + +} // namespace epubgrep::search diff --git a/src/search.hpp b/src/search.hpp new file mode 100644 index 0000000..981771a --- /dev/null +++ b/src/search.hpp @@ -0,0 +1,55 @@ +/* This file is part of epubgrep. + * Copyright © 2021 tastytea + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef EPUBGREP_SEARCH_HPP +#define EPUBGREP_SEARCH_HPP + +#include "fs-compat.hpp" + +#include +#include +#include +#include +#include + +namespace epubgrep::search +{ + +using match_context = std::pair; + +struct match +{ + std::string text; //!< Matched string. + match_context context; //!< The context around the match. + std::string filepath; //!< The file path of the matched line. + std::string headline; //!< The last headline, if available. + std::string page; //!< The page number, if available. +}; + +struct options +{ + // TODO: regex type + bool ignore_case{false}; + bool nostrip{false}; + std::uint64_t context{0}; +}; + +std::vector search(const fs::path &filepath, std::string_view regex, + const options &opts); + +} // namespace epubgrep::search + +#endif // EPUBGREP_SEARCH_HPP