]> git.tdb.fi Git - builder.git/blob - source/lib/pattern.h
5da52eb7d1f3a4786fcd76b5a8b0b47e742e563e
[builder.git] / source / lib / pattern.h
1 #ifndef PATTERN_H_
2 #define PATTERN_H_
3
4 #include <string>
5 #include <vector>
6
7 /**
8 Stores a filename pattern.  A pattern consists of a prefix and a suffix, and
9 can be applied to a body to form a complete filename.  Either or both of the
10 prefix and suffix may be empty.
11 */
12 class Pattern
13 {
14 private:
15         std::string prefix;
16         std::string suffix;
17
18 public:
19         /** Constructs a pattern from a single string.  The string must have exactly
20         one percent sign (%) to separate the prefix and suffix. */
21         Pattern(const std::string &);
22
23         const std::string &get_prefix() const { return prefix; }
24         const std::string &get_suffix() const { return suffix; }
25
26         /** Applies the pattern to a body string. */
27         std::string apply(const std::string &) const;
28
29         /** Applies a list of patterns to the same body. */
30         static std::vector<std::string> apply_list(const std::vector<Pattern> &, const std::string &);
31 };
32
33 #endif