about summary refs log blame commit diff
path: root/src/libutil/regex.hh
blob: 53e31f4edc4ab1a3272239e30af25d4cf063f7d7 (plain) (tree)
1
2
3
4
5
6
7
8
9






                      

              

               

                            


           
                                                     

                                   

                                                

        
                      




                              
#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);
};

}