2003-01-02 20:35:31 +01:00
|
|
|
/* Portable <regex.h>.
|
2017-01-01 07:50:51 +01:00
|
|
|
Copyright (C) 2000-2017 Free Software Foundation, Inc.
|
2000-04-04 04:08:52 +02:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 20:08:50 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2000-04-04 04:08:52 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2000-04-04 04:08:52 +02:00
|
|
|
|
2015-07-15 20:27:32 +02:00
|
|
|
#ifndef GDB_REGEX_H
|
|
|
|
#define GDB_REGEX_H 1
|
2001-09-01 23:38:05 +02:00
|
|
|
|
2000-04-04 04:08:52 +02:00
|
|
|
#ifdef USE_INCLUDED_REGEX
|
2003-01-02 20:35:31 +01:00
|
|
|
# include "xregex.h"
|
2000-04-04 04:08:52 +02:00
|
|
|
#else
|
2003-01-02 20:35:31 +01:00
|
|
|
/* Request 4.2 BSD regex functions. */
|
|
|
|
# define _REGEX_RE_COMP
|
|
|
|
# include <regex.h>
|
2000-04-04 04:08:52 +02:00
|
|
|
#endif
|
2001-09-01 23:38:05 +02:00
|
|
|
|
2017-06-07 15:21:40 +02:00
|
|
|
/* A compiled regex. This is mainly a wrapper around regex_t. The
|
|
|
|
the constructor throws on regcomp error and the destructor is
|
|
|
|
responsible for calling regfree. The former means that it's not
|
|
|
|
possible to create an instance of compiled_regex that isn't
|
|
|
|
compiled, hence the name. */
|
|
|
|
class compiled_regex
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/* Compile a regexp and throw an exception on error, including
|
|
|
|
MESSAGE. REGEX and MESSAGE must not be NULL. */
|
|
|
|
compiled_regex (const char *regex, int cflags,
|
|
|
|
const char *message)
|
|
|
|
ATTRIBUTE_NONNULL (2) ATTRIBUTE_NONNULL (4);
|
|
|
|
|
|
|
|
~compiled_regex ();
|
|
|
|
|
2017-09-19 11:10:03 +02:00
|
|
|
DISABLE_COPY_AND_ASSIGN (compiled_regex);
|
2017-06-07 15:21:40 +02:00
|
|
|
|
|
|
|
/* Wrapper around ::regexec. */
|
|
|
|
int exec (const char *string,
|
|
|
|
size_t nmatch, regmatch_t pmatch[],
|
|
|
|
int eflags) const;
|
|
|
|
|
|
|
|
/* Wrapper around ::re_search. (Not const because re_search's
|
|
|
|
regex_t parameter isn't either.) */
|
|
|
|
int search (const char *string, int size, int startpos,
|
|
|
|
int range, struct re_registers *regs);
|
|
|
|
|
|
|
|
private:
|
|
|
|
/* The compiled pattern. */
|
|
|
|
regex_t m_pattern;
|
|
|
|
};
|
2011-01-17 17:50:42 +01:00
|
|
|
|
2015-07-15 20:27:32 +02:00
|
|
|
#endif /* not GDB_REGEX_H */
|