Add skeleton for search::search().
- Type for matches - Type for options.
This commit is contained in:
parent
78230b26e6
commit
1f82d9927a
33
src/search.cpp
Normal file
33
src/search.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* This file is part of epubgrep.
|
||||
* Copyright © 2021 tastytea <tastytea@tastytea.de>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "search.hpp"
|
||||
|
||||
#include "fs-compat.hpp"
|
||||
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace epubgrep::search
|
||||
{
|
||||
|
||||
std::vector<match> search(const fs::path &filepath, std::string_view regex,
|
||||
const options &opts)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace epubgrep::search
|
55
src/search.hpp
Normal file
55
src/search.hpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* This file is part of epubgrep.
|
||||
* Copyright © 2021 tastytea <tastytea@tastytea.de>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EPUBGREP_SEARCH_HPP
|
||||
#define EPUBGREP_SEARCH_HPP
|
||||
|
||||
#include "fs-compat.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace epubgrep::search
|
||||
{
|
||||
|
||||
using match_context = std::pair<std::string, std::string>;
|
||||
|
||||
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<match> search(const fs::path &filepath, std::string_view regex,
|
||||
const options &opts);
|
||||
|
||||
} // namespace epubgrep::search
|
||||
|
||||
#endif // EPUBGREP_SEARCH_HPP
|
Loading…
Reference in New Issue
Block a user