2014-10-03 16:47:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "types.hh"
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <regex.h>
|
|
|
|
|
2014-11-25 10:47:06 +00:00
|
|
|
#include <map>
|
|
|
|
|
2014-10-03 16:47:16 +00:00
|
|
|
namespace nix {
|
|
|
|
|
2014-11-25 10:47:06 +00:00
|
|
|
MakeError(RegexError, Error)
|
|
|
|
|
2014-10-03 16:47:16 +00:00
|
|
|
class Regex
|
|
|
|
{
|
|
|
|
public:
|
2014-11-25 10:47:06 +00:00
|
|
|
Regex(const string & pattern, bool subs = false);
|
2014-10-03 16:47:16 +00:00
|
|
|
~Regex();
|
|
|
|
bool matches(const string & s);
|
2014-11-25 10:47:06 +00:00
|
|
|
typedef std::map<unsigned int, string> Subs;
|
|
|
|
bool matches(const string & s, Subs & subs);
|
2014-10-03 16:47:16 +00:00
|
|
|
|
|
|
|
private:
|
2014-11-25 10:47:06 +00:00
|
|
|
unsigned nrParens;
|
2014-10-03 16:47:16 +00:00
|
|
|
regex_t preg;
|
|
|
|
string showError(int err);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|