AsmGrader 0.0.0
Loading...
Searching...
No Matches
file_searcher.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4#include <map>
5#include <regex>
6#include <string>
7#include <string_view>
8#include <vector>
9
10namespace asmgrader {
11
13{
14public:
15 static constexpr auto DEFAULT_SEARCH_DEPTH = 10;
16
17 explicit FileSearcher(std::string expr, std::map<std::string, std::string> args = {});
18
20 std::vector<std::filesystem::path> search(const std::filesystem::path& base);
21
22 std::vector<std::filesystem::path> search_recursive(const std::filesystem::path& base,
23 int max_depth = DEFAULT_SEARCH_DEPTH);
24
25protected:
26 std::string set_arg(const std::string& key, std::string_view value);
27
28 std::string get_expr() const;
29
30private:
31 std::string subst_args() const;
32 static bool does_match(const std::regex& expr, std::string_view filename);
33
34 std::string expr_;
35 std::map<std::string, std::string> args_;
36};
37
38} // namespace asmgrader
Definition file_searcher.hpp:13
std::vector< std::filesystem::path > search_recursive(const std::filesystem::path &base, int max_depth=DEFAULT_SEARCH_DEPTH)
Definition file_searcher.cpp:35
std::string set_arg(const std::string &key, std::string_view value)
Definition file_searcher.cpp:22
std::vector< std::filesystem::path > search(const std::filesystem::path &base)
Equivalent to search_recursive(base, 0)
Definition file_searcher.cpp:31
static constexpr auto DEFAULT_SEARCH_DEPTH
Definition file_searcher.hpp:15
FileSearcher(std::string expr, std::map< std::string, std::string > args={})
Definition file_searcher.cpp:18
std::string get_expr() const
Definition file_searcher.cpp:90
Definition asm_buffer.hpp:20