1999-11-09 22:20:24 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
|
|
|
|
/* C++ wrapper around the POSIX regex functions:
|
|
|
|
regcomp, regexec, regerror, regfree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LREGEX_H
|
|
|
|
#define LREGEX_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
1999-12-13 07:33:00 +00:00
|
|
|
#include "LString.h"
|
|
|
|
|
1999-11-09 22:20:24 +00:00
|
|
|
#include <vector>
|
2000-03-28 02:18:55 +00:00
|
|
|
|
1999-11-09 22:20:24 +00:00
|
|
|
///
|
|
|
|
class LRegex {
|
|
|
|
public:
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
explicit
|
1999-11-09 22:20:24 +00:00
|
|
|
LRegex(string const & regex);
|
|
|
|
|
|
|
|
///
|
|
|
|
~LRegex();
|
|
|
|
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
typedef std::pair<string::size_type, string::size_type> MatchPair;
|
1999-11-09 22:20:24 +00:00
|
|
|
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
typedef std::vector<MatchPair> SubMatches;
|
1999-11-09 22:20:24 +00:00
|
|
|
|
|
|
|
/// Returns all the matches in a vector
|
|
|
|
SubMatches const & exec(string const & str) const;
|
|
|
|
|
|
|
|
/// The whole of str matches regex.
|
|
|
|
bool exact_match(string const & str) const;
|
|
|
|
|
|
|
|
///
|
2000-08-01 17:33:32 +00:00
|
|
|
MatchPair const first_match(string const & str) const;
|
1999-11-09 22:20:24 +00:00
|
|
|
|
|
|
|
///
|
2000-08-01 17:33:32 +00:00
|
|
|
string const getError() const;
|
1999-11-09 22:20:24 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
int getErrorCode() const;
|
|
|
|
|
|
|
|
/// Will the next operation fail of not.
|
|
|
|
bool ok() const;
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
struct Impl;
|
|
|
|
|
|
|
|
///
|
|
|
|
Impl * impl;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|