diff options
Diffstat (limited to 'src/regengine.h')
-rw-r--r-- | src/regengine.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/regengine.h b/src/regengine.h index bac3661..0b7b4a5 100644 --- a/src/regengine.h +++ b/src/regengine.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2017 by Hans-Peter Deifel * + * Copyright (C) 2015-2018 by Hans-Peter Deifel * * hpd@hpdeifel.de * * * * This program is free software; you can redistribute it and/or modify * @@ -31,6 +31,7 @@ #endif #include <vector> #include <string> +#include <memory> struct match; @@ -43,6 +44,22 @@ public: virtual ~Regengine() {} }; +// This matches the union of a set of patterns +// +// It just tries all patterns in turn. This could be more efficient by using +// some engine-specific way of combining patterns, e.g with "|" in the posix +// case. +class PatternList : public Regengine +{ +public: + PatternList() {} + ~PatternList() {} + bool exec(const std::string &str, size_t offset, struct match &m) const override; + void add_pattern(std::unique_ptr<Regengine> pattern); +private: + std::vector<std::unique_ptr<Regengine>> patterns; +}; + class PosixRegex : public Regengine { public: @@ -76,3 +93,7 @@ private: }; #endif /* REGENGINE_H */ + +/* Local Variables: */ +/* mode: c++ */ +/* End: */ |