forked from PolusAI/filepattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvectorpattern.hpp
More file actions
48 lines (40 loc) · 1.85 KB
/
Copy pathvectorpattern.hpp
File metadata and controls
48 lines (40 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include "internal_pattern.hpp"
#include "../pattern.hpp"
#include "../util/vector_parser.hpp"
#include "../util/util.hpp"
class VectorPattern: public InternalPattern {
private:
std::string path_; // path to stitching vector
std::ifstream infile_; // stream to read in stitching vector
public:
const static std::regex STITCH_REGEX_; // regex to match stitching vector line
const static std::vector<std::regex> STITCH_REGEX_VECTOR_;
const static std::vector<std::string> STITCH_VARIABLES_; // variable names for stitching vector
/**
* @brief Constructor of VectorPattern.
*
* @param path Path to stitching vector
* @param pattern Pattern to match filename to
*/
VectorPattern(const std::string& path, const std::string& pattern, bool suppress_warnings = false, bool sorted=true);
/**
* @brief Match filenames to the pattern.
*
* Compares the filename from each line of the stitching vector to the provided pattern.
* Each variable from the line of the stitching vector is extracted and added to the variable value
* map. Each variable from the named groups in the pattern are also added to the mapping. The matching
* files are stored in memory in the validFiles vector.
*/
void matchFiles();
/**
* @brief Makes a guess of the pattern given a stitching vector.
*
* Reads in the filenames from the stitching vector and makes a guess of the pattern.
*
* @param path Path to the stitching vector.
* @param variables Name of variables. Optional
* @return std::string Guess of the pattern
*/
std::string inferPattern(const std::string& path, std::string& variables, const std::string& block_size);
};