annotate DEPENDENCIES/generic/include/boost/regex/v4/cregex.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*
Chris@16 2 *
Chris@16 3 * Copyright (c) 1998-2002
Chris@16 4 * John Maddock
Chris@16 5 *
Chris@16 6 * Use, modification and distribution are subject to the
Chris@16 7 * Boost Software License, Version 1.0. (See accompanying file
Chris@16 8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 *
Chris@16 10 */
Chris@16 11
Chris@16 12 /*
Chris@16 13 * LOCATION: see http://www.boost.org for most recent version.
Chris@16 14 * FILE cregex.cpp
Chris@16 15 * VERSION see <boost/version.hpp>
Chris@16 16 * DESCRIPTION: Declares POSIX API functions
Chris@16 17 * + boost::RegEx high level wrapper.
Chris@16 18 */
Chris@16 19
Chris@16 20 #ifndef BOOST_RE_CREGEX_HPP_INCLUDED
Chris@16 21 #define BOOST_RE_CREGEX_HPP_INCLUDED
Chris@16 22
Chris@16 23 #ifndef BOOST_REGEX_CONFIG_HPP
Chris@16 24 #include <boost/regex/config.hpp>
Chris@16 25 #endif
Chris@16 26 #include <boost/regex/v4/match_flags.hpp>
Chris@16 27 #include <boost/regex/v4/error_type.hpp>
Chris@16 28
Chris@16 29 #ifdef __cplusplus
Chris@16 30 #include <cstddef>
Chris@16 31 #else
Chris@16 32 #include <stddef.h>
Chris@16 33 #endif
Chris@16 34
Chris@16 35 #ifdef BOOST_MSVC
Chris@16 36 #pragma warning(push)
Chris@16 37 #pragma warning(disable: 4103)
Chris@16 38 #endif
Chris@16 39 #ifdef BOOST_HAS_ABI_HEADERS
Chris@16 40 # include BOOST_ABI_PREFIX
Chris@16 41 #endif
Chris@16 42 #ifdef BOOST_MSVC
Chris@16 43 #pragma warning(pop)
Chris@16 44 #endif
Chris@16 45
Chris@16 46 /* include these defs only for POSIX compatablity */
Chris@16 47 #ifdef __cplusplus
Chris@16 48 namespace boost{
Chris@16 49 extern "C" {
Chris@16 50 #endif
Chris@16 51
Chris@16 52 #if defined(__cplusplus) && !defined(BOOST_NO_STDC_NAMESPACE)
Chris@16 53 typedef std::ptrdiff_t regoff_t;
Chris@16 54 typedef std::size_t regsize_t;
Chris@16 55 #else
Chris@16 56 typedef ptrdiff_t regoff_t;
Chris@16 57 typedef size_t regsize_t;
Chris@16 58 #endif
Chris@16 59
Chris@16 60 typedef struct
Chris@16 61 {
Chris@16 62 unsigned int re_magic;
Chris@16 63 #ifdef __cplusplus
Chris@16 64 std::size_t re_nsub; /* number of parenthesized subexpressions */
Chris@16 65 #else
Chris@16 66 size_t re_nsub;
Chris@16 67 #endif
Chris@16 68 const char* re_endp; /* end pointer for REG_PEND */
Chris@16 69 void* guts; /* none of your business :-) */
Chris@16 70 match_flag_type eflags; /* none of your business :-) */
Chris@16 71 } regex_tA;
Chris@16 72
Chris@16 73 #ifndef BOOST_NO_WREGEX
Chris@16 74 typedef struct
Chris@16 75 {
Chris@16 76 unsigned int re_magic;
Chris@16 77 #ifdef __cplusplus
Chris@16 78 std::size_t re_nsub; /* number of parenthesized subexpressions */
Chris@16 79 #else
Chris@16 80 size_t re_nsub;
Chris@16 81 #endif
Chris@16 82 const wchar_t* re_endp; /* end pointer for REG_PEND */
Chris@16 83 void* guts; /* none of your business :-) */
Chris@16 84 match_flag_type eflags; /* none of your business :-) */
Chris@16 85 } regex_tW;
Chris@16 86 #endif
Chris@16 87
Chris@16 88 typedef struct
Chris@16 89 {
Chris@16 90 regoff_t rm_so; /* start of match */
Chris@16 91 regoff_t rm_eo; /* end of match */
Chris@16 92 } regmatch_t;
Chris@16 93
Chris@16 94 /* regcomp() flags */
Chris@16 95 typedef enum{
Chris@16 96 REG_BASIC = 0000,
Chris@16 97 REG_EXTENDED = 0001,
Chris@16 98 REG_ICASE = 0002,
Chris@16 99 REG_NOSUB = 0004,
Chris@16 100 REG_NEWLINE = 0010,
Chris@16 101 REG_NOSPEC = 0020,
Chris@16 102 REG_PEND = 0040,
Chris@16 103 REG_DUMP = 0200,
Chris@16 104 REG_NOCOLLATE = 0400,
Chris@16 105 REG_ESCAPE_IN_LISTS = 01000,
Chris@16 106 REG_NEWLINE_ALT = 02000,
Chris@16 107 REG_PERLEX = 04000,
Chris@16 108
Chris@16 109 REG_PERL = REG_EXTENDED | REG_NOCOLLATE | REG_ESCAPE_IN_LISTS | REG_PERLEX,
Chris@16 110 REG_AWK = REG_EXTENDED | REG_ESCAPE_IN_LISTS,
Chris@16 111 REG_GREP = REG_BASIC | REG_NEWLINE_ALT,
Chris@16 112 REG_EGREP = REG_EXTENDED | REG_NEWLINE_ALT,
Chris@16 113
Chris@16 114 REG_ASSERT = 15,
Chris@16 115 REG_INVARG = 16,
Chris@16 116 REG_ATOI = 255, /* convert name to number (!) */
Chris@16 117 REG_ITOA = 0400 /* convert number to name (!) */
Chris@16 118 } reg_comp_flags;
Chris@16 119
Chris@16 120 /* regexec() flags */
Chris@16 121 typedef enum{
Chris@16 122 REG_NOTBOL = 00001,
Chris@16 123 REG_NOTEOL = 00002,
Chris@16 124 REG_STARTEND = 00004
Chris@16 125 } reg_exec_flags;
Chris@16 126
Chris@16 127 /*
Chris@16 128 * POSIX error codes:
Chris@16 129 */
Chris@16 130 typedef unsigned reg_error_t;
Chris@16 131 typedef reg_error_t reg_errcode_t; /* backwards compatibility */
Chris@16 132
Chris@16 133 static const reg_error_t REG_NOERROR = 0; /* Success. */
Chris@16 134 static const reg_error_t REG_NOMATCH = 1; /* Didn't find a match (for regexec). */
Chris@16 135
Chris@16 136 /* POSIX regcomp return error codes. (In the order listed in the
Chris@16 137 standard.) */
Chris@16 138 static const reg_error_t REG_BADPAT = 2; /* Invalid pattern. */
Chris@16 139 static const reg_error_t REG_ECOLLATE = 3; /* Undefined collating element. */
Chris@16 140 static const reg_error_t REG_ECTYPE = 4; /* Invalid character class name. */
Chris@16 141 static const reg_error_t REG_EESCAPE = 5; /* Trailing backslash. */
Chris@16 142 static const reg_error_t REG_ESUBREG = 6; /* Invalid back reference. */
Chris@16 143 static const reg_error_t REG_EBRACK = 7; /* Unmatched left bracket. */
Chris@16 144 static const reg_error_t REG_EPAREN = 8; /* Parenthesis imbalance. */
Chris@16 145 static const reg_error_t REG_EBRACE = 9; /* Unmatched \{. */
Chris@16 146 static const reg_error_t REG_BADBR = 10; /* Invalid contents of \{\}. */
Chris@16 147 static const reg_error_t REG_ERANGE = 11; /* Invalid range end. */
Chris@16 148 static const reg_error_t REG_ESPACE = 12; /* Ran out of memory. */
Chris@16 149 static const reg_error_t REG_BADRPT = 13; /* No preceding re for repetition op. */
Chris@16 150 static const reg_error_t REG_EEND = 14; /* unexpected end of expression */
Chris@16 151 static const reg_error_t REG_ESIZE = 15; /* expression too big */
Chris@16 152 static const reg_error_t REG_ERPAREN = 8; /* = REG_EPAREN : unmatched right parenthesis */
Chris@16 153 static const reg_error_t REG_EMPTY = 17; /* empty expression */
Chris@16 154 static const reg_error_t REG_E_MEMORY = 15; /* = REG_ESIZE : out of memory */
Chris@16 155 static const reg_error_t REG_ECOMPLEXITY = 18; /* complexity too high */
Chris@16 156 static const reg_error_t REG_ESTACK = 19; /* out of stack space */
Chris@16 157 static const reg_error_t REG_E_PERL = 20; /* Perl (?...) error */
Chris@16 158 static const reg_error_t REG_E_UNKNOWN = 21; /* unknown error */
Chris@16 159 static const reg_error_t REG_ENOSYS = 21; /* = REG_E_UNKNOWN : Reserved. */
Chris@16 160
Chris@16 161 BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA*, const char*, int);
Chris@16 162 BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int, const regex_tA*, char*, regsize_t);
Chris@16 163 BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA*, const char*, regsize_t, regmatch_t*, int);
Chris@16 164 BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA*);
Chris@16 165
Chris@16 166 #ifndef BOOST_NO_WREGEX
Chris@16 167 BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW*, const wchar_t*, int);
Chris@16 168 BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int, const regex_tW*, wchar_t*, regsize_t);
Chris@16 169 BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW*, const wchar_t*, regsize_t, regmatch_t*, int);
Chris@16 170 BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW*);
Chris@16 171 #endif
Chris@16 172
Chris@16 173 #ifdef UNICODE
Chris@16 174 #define regcomp regcompW
Chris@16 175 #define regerror regerrorW
Chris@16 176 #define regexec regexecW
Chris@16 177 #define regfree regfreeW
Chris@16 178 #define regex_t regex_tW
Chris@16 179 #else
Chris@16 180 #define regcomp regcompA
Chris@16 181 #define regerror regerrorA
Chris@16 182 #define regexec regexecA
Chris@16 183 #define regfree regfreeA
Chris@16 184 #define regex_t regex_tA
Chris@16 185 #endif
Chris@16 186
Chris@16 187 #ifdef BOOST_MSVC
Chris@16 188 #pragma warning(push)
Chris@16 189 #pragma warning(disable: 4103)
Chris@16 190 #endif
Chris@16 191 #ifdef BOOST_HAS_ABI_HEADERS
Chris@16 192 # include BOOST_ABI_SUFFIX
Chris@16 193 #endif
Chris@16 194 #ifdef BOOST_MSVC
Chris@16 195 #pragma warning(pop)
Chris@16 196 #endif
Chris@16 197
Chris@16 198 #ifdef __cplusplus
Chris@16 199 } /* extern "C" */
Chris@16 200 } /* namespace */
Chris@16 201 #endif
Chris@16 202
Chris@16 203 #if defined(__cplusplus)
Chris@16 204 /*
Chris@16 205 * C++ high level wrapper goes here:
Chris@16 206 */
Chris@16 207 #include <string>
Chris@16 208 #include <vector>
Chris@16 209 namespace boost{
Chris@16 210
Chris@16 211 #ifdef BOOST_MSVC
Chris@16 212 #pragma warning(push)
Chris@16 213 #pragma warning(disable: 4103)
Chris@16 214 #endif
Chris@16 215 #ifdef BOOST_HAS_ABI_HEADERS
Chris@16 216 # include BOOST_ABI_PREFIX
Chris@16 217 #endif
Chris@16 218 #ifdef BOOST_MSVC
Chris@16 219 #pragma warning(pop)
Chris@16 220 #endif
Chris@16 221
Chris@16 222 class RegEx;
Chris@16 223
Chris@16 224 namespace re_detail{
Chris@16 225
Chris@16 226 class RegExData;
Chris@16 227 struct pred1;
Chris@16 228 struct pred2;
Chris@16 229 struct pred3;
Chris@16 230 struct pred4;
Chris@16 231
Chris@16 232 } /* namespace re_detail */
Chris@16 233
Chris@16 234 #if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_DISABLE_WIN32)
Chris@16 235 typedef bool (__cdecl *GrepCallback)(const RegEx& expression);
Chris@16 236 typedef bool (__cdecl *GrepFileCallback)(const char* file, const RegEx& expression);
Chris@16 237 typedef bool (__cdecl *FindFilesCallback)(const char* file);
Chris@16 238 #else
Chris@16 239 typedef bool (*GrepCallback)(const RegEx& expression);
Chris@16 240 typedef bool (*GrepFileCallback)(const char* file, const RegEx& expression);
Chris@16 241 typedef bool (*FindFilesCallback)(const char* file);
Chris@16 242 #endif
Chris@16 243
Chris@16 244 class BOOST_REGEX_DECL RegEx
Chris@16 245 {
Chris@16 246 private:
Chris@16 247 re_detail::RegExData* pdata;
Chris@16 248 public:
Chris@16 249 RegEx();
Chris@16 250 RegEx(const RegEx& o);
Chris@16 251 ~RegEx();
Chris@16 252 explicit RegEx(const char* c, bool icase = false);
Chris@16 253 explicit RegEx(const std::string& s, bool icase = false);
Chris@16 254 RegEx& operator=(const RegEx& o);
Chris@16 255 RegEx& operator=(const char* p);
Chris@16 256 RegEx& operator=(const std::string& s){ return this->operator=(s.c_str()); }
Chris@16 257 unsigned int SetExpression(const char* p, bool icase = false);
Chris@16 258 unsigned int SetExpression(const std::string& s, bool icase = false){ return SetExpression(s.c_str(), icase); }
Chris@16 259 std::string Expression()const;
Chris@16 260 unsigned int error_code()const;
Chris@16 261 /*
Chris@16 262 * now matching operators:
Chris@16 263 */
Chris@16 264 bool Match(const char* p, match_flag_type flags = match_default);
Chris@16 265 bool Match(const std::string& s, match_flag_type flags = match_default) { return Match(s.c_str(), flags); }
Chris@16 266 bool Search(const char* p, match_flag_type flags = match_default);
Chris@16 267 bool Search(const std::string& s, match_flag_type flags = match_default) { return Search(s.c_str(), flags); }
Chris@16 268 unsigned int Grep(GrepCallback cb, const char* p, match_flag_type flags = match_default);
Chris@16 269 unsigned int Grep(GrepCallback cb, const std::string& s, match_flag_type flags = match_default) { return Grep(cb, s.c_str(), flags); }
Chris@16 270 unsigned int Grep(std::vector<std::string>& v, const char* p, match_flag_type flags = match_default);
Chris@16 271 unsigned int Grep(std::vector<std::string>& v, const std::string& s, match_flag_type flags = match_default) { return Grep(v, s.c_str(), flags); }
Chris@16 272 unsigned int Grep(std::vector<std::size_t>& v, const char* p, match_flag_type flags = match_default);
Chris@16 273 unsigned int Grep(std::vector<std::size_t>& v, const std::string& s, match_flag_type flags = match_default) { return Grep(v, s.c_str(), flags); }
Chris@16 274 #ifndef BOOST_REGEX_NO_FILEITER
Chris@16 275 unsigned int GrepFiles(GrepFileCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default);
Chris@16 276 unsigned int GrepFiles(GrepFileCallback cb, const std::string& files, bool recurse = false, match_flag_type flags = match_default) { return GrepFiles(cb, files.c_str(), recurse, flags); }
Chris@16 277 unsigned int FindFiles(FindFilesCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default);
Chris@16 278 unsigned int FindFiles(FindFilesCallback cb, const std::string& files, bool recurse = false, match_flag_type flags = match_default) { return FindFiles(cb, files.c_str(), recurse, flags); }
Chris@16 279 #endif
Chris@16 280
Chris@16 281 std::string Merge(const std::string& in, const std::string& fmt,
Chris@16 282 bool copy = true, match_flag_type flags = match_default);
Chris@16 283 std::string Merge(const char* in, const char* fmt,
Chris@16 284 bool copy = true, match_flag_type flags = match_default);
Chris@16 285
Chris@16 286 std::size_t Split(std::vector<std::string>& v, std::string& s, match_flag_type flags = match_default, unsigned max_count = ~0);
Chris@16 287 /*
Chris@16 288 * now operators for returning what matched in more detail:
Chris@16 289 */
Chris@16 290 std::size_t Position(int i = 0)const;
Chris@16 291 std::size_t Length(int i = 0)const;
Chris@16 292 bool Matched(int i = 0)const;
Chris@16 293 std::size_t Marks()const;
Chris@16 294 std::string What(int i = 0)const;
Chris@16 295 std::string operator[](int i)const { return What(i); }
Chris@16 296
Chris@16 297 static const std::size_t npos;
Chris@16 298
Chris@16 299 friend struct re_detail::pred1;
Chris@16 300 friend struct re_detail::pred2;
Chris@16 301 friend struct re_detail::pred3;
Chris@16 302 friend struct re_detail::pred4;
Chris@16 303 };
Chris@16 304
Chris@16 305 #ifdef BOOST_MSVC
Chris@16 306 #pragma warning(push)
Chris@16 307 #pragma warning(disable: 4103)
Chris@16 308 #endif
Chris@16 309 #ifdef BOOST_HAS_ABI_HEADERS
Chris@16 310 # include BOOST_ABI_SUFFIX
Chris@16 311 #endif
Chris@16 312 #ifdef BOOST_MSVC
Chris@16 313 #pragma warning(pop)
Chris@16 314 #endif
Chris@16 315
Chris@16 316 } /* namespace boost */
Chris@16 317
Chris@16 318 #endif /* __cplusplus */
Chris@16 319
Chris@16 320 #endif /* include guard */
Chris@16 321
Chris@16 322
Chris@16 323
Chris@16 324
Chris@16 325
Chris@16 326
Chris@16 327
Chris@16 328
Chris@16 329
Chris@16 330