1 1.1 christos /* Portable <regex.h>. 2 1.1.1.2 christos Copyright (C) 2000-2024 Free Software Foundation, Inc. 3 1.1 christos 4 1.1 christos This file is part of GDB. 5 1.1 christos 6 1.1 christos This program is free software; you can redistribute it and/or modify 7 1.1 christos it under the terms of the GNU General Public License as published by 8 1.1 christos the Free Software Foundation; either version 3 of the License, or 9 1.1 christos (at your option) any later version. 10 1.1 christos 11 1.1 christos This program is distributed in the hope that it will be useful, 12 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 13 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 1.1 christos GNU General Public License for more details. 15 1.1 christos 16 1.1 christos You should have received a copy of the GNU General Public License 17 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 18 1.1 christos 19 1.1.1.3 christos #ifndef GDBSUPPORT_GDB_REGEX_H 20 1.1.1.3 christos #define GDBSUPPORT_GDB_REGEX_H 21 1.1 christos 22 1.1 christos # include "xregex.h" 23 1.1 christos 24 1.1 christos /* A compiled regex. This is mainly a wrapper around regex_t. The 25 1.1 christos the constructor throws on regcomp error and the destructor is 26 1.1 christos responsible for calling regfree. The former means that it's not 27 1.1 christos possible to create an instance of compiled_regex that isn't 28 1.1 christos compiled, hence the name. */ 29 1.1 christos class compiled_regex 30 1.1 christos { 31 1.1 christos public: 32 1.1 christos /* Compile a regexp and throw an exception on error, including 33 1.1 christos MESSAGE. REGEX and MESSAGE must not be NULL. */ 34 1.1 christos compiled_regex (const char *regex, int cflags, 35 1.1 christos const char *message) 36 1.1 christos ATTRIBUTE_NONNULL (2) ATTRIBUTE_NONNULL (4); 37 1.1 christos 38 1.1 christos ~compiled_regex (); 39 1.1 christos 40 1.1 christos DISABLE_COPY_AND_ASSIGN (compiled_regex); 41 1.1 christos 42 1.1 christos /* Wrapper around ::regexec. */ 43 1.1 christos int exec (const char *string, 44 1.1 christos size_t nmatch, regmatch_t pmatch[], 45 1.1 christos int eflags) const; 46 1.1 christos 47 1.1 christos /* Wrapper around ::re_search. (Not const because re_search's 48 1.1 christos regex_t parameter isn't either.) */ 49 1.1 christos int search (const char *string, int size, int startpos, 50 1.1 christos int range, struct re_registers *regs); 51 1.1 christos 52 1.1 christos private: 53 1.1 christos /* The compiled pattern. */ 54 1.1 christos regex_t m_pattern; 55 1.1 christos }; 56 1.1 christos 57 1.1.1.3 christos #endif /* GDBSUPPORT_GDB_REGEX_H */ 58