diff options
Diffstat (limited to 'src/libutil/regex.hh')
-rw-r--r-- | src/libutil/regex.hh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libutil/regex.hh b/src/libutil/regex.hh new file mode 100644 index 000000000000..53e31f4edc4a --- /dev/null +++ b/src/libutil/regex.hh @@ -0,0 +1,29 @@ +#pragma once + +#include "types.hh" + +#include <sys/types.h> +#include <regex.h> + +#include <map> + +namespace nix { + +MakeError(RegexError, Error) + +class Regex +{ +public: + Regex(const string & pattern, bool subs = false); + ~Regex(); + bool matches(const string & s); + typedef std::map<unsigned int, string> Subs; + bool matches(const string & s, Subs & subs); + +private: + unsigned nrParens; + regex_t preg; + string showError(int err); +}; + +} |