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