Regex.h
/*
* $Id: Regex.h 2839 2009-09-28 11:36:20Z karijes $
*
* Regex class
* Copyright (c) 2007-2009 edelib authors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EDELIB_REGEX_H__
#define __EDELIB_REGEX_H__
#include "List.h"
#include "String.h"
EDELIB_NS_BEGIN
enum RegexMode {
RX_EXTENDED = (1 << 1),
RX_CASELESS = (1 << 2),
RX_DOLLAR_ENDONLY = (1 << 3),
RX_DOTALL = (1 << 4),
RX_MULTILINE = (1 << 5),
RX_UNGREEDY = (1 << 6)
};
enum RegexMatchMode {
RX_MATCH_ANCHORED = (1 << 1),
RX_MATCH_NOTBOL = (1 << 2),
RX_MATCH_NOTEOL = (1 << 3),
RX_MATCH_NOTEMPTY = (1 << 4)
};
#ifndef SKIP_DOCS
struct RegexData;
#endif
struct RegexMatch {
int offset;
int length;
};
class EDELIB_API Regex {
private:
RegexData* data;
void clear(void);
E_DISABLE_CLASS_COPY(Regex)
public:
typedef list<RegexMatch> MatchVec;
Regex();
~Regex();
bool compile(const char* pattern, int m = 0);
operator bool(void) const;
int match(const char* str, int match_mode, int start, int len, MatchVec* matches);
int match(const char* str, int match_mode = 0, MatchVec* matches = 0)
{ return match(str, match_mode, 0, -1, matches); }
int split(const char* str, list<String>& ls, int match_mode = 0);
const char* strerror(void) const;
};
EDELIB_NS_END
#endif
edelib::Regex::match
int match(const char *str, int match_mode=0, MatchVec *matches=0)
Definition: Regex.h:156
edelib::RX_MATCH_ANCHORED
Match only at the first position.
Definition: Regex.h:49
edelib::Regex::MatchVec
list< RegexMatch > MatchVec
Definition: Regex.h:106
edelib::RX_MULTILINE
^ and $ match newlines within data
Definition: Regex.h:39
edelib::RX_DOLLAR_ENDONLY
$ not to match newline at end
Definition: Regex.h:37
edelib::list
Linked list class.
Definition: List.h:160
edelib::RegexMode
RegexMode
Flags used for compile()
Definition: Regex.h:34
edelib::RegexMatchMode
RegexMatchMode
Flags used for match()
Definition: Regex.h:48
edelib::RegexMatch
RegexMatch class.
Definition: Regex.h:65
edelib::RX_MATCH_NOTEOL
Subject is not the end of a line.
Definition: Regex.h:51
edelib::RX_EXTENDED
extended features
Definition: Regex.h:35
edelib::RegexMatch::offset
int offset
Definition: Regex.h:67
edelib::RegexMatch::length
int length
Definition: Regex.h:69
E_DISABLE_CLASS_COPY
#define E_DISABLE_CLASS_COPY(klass)
Definition: edelib-global.h:161
edelib::Regex
Regex class.
Definition: Regex.h:98