1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/regex/v4/cregex.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,301 @@
1.4 +/*
1.5 + *
1.6 + * Copyright (c) 1998-2002
1.7 + * John Maddock
1.8 + *
1.9 + * Use, modification and distribution are subject to the
1.10 + * Boost Software License, Version 1.0. (See accompanying file
1.11 + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
1.12 + *
1.13 + */
1.14 +
1.15 + /*
1.16 + * LOCATION: see http://www.boost.org for most recent version.
1.17 + * FILE cregex.cpp
1.18 + * VERSION see <boost/version.hpp>
1.19 + * DESCRIPTION: Declares POSIX API functions
1.20 + * + boost::RegEx high level wrapper.
1.21 + */
1.22 +
1.23 +#ifndef BOOST_RE_CREGEX_HPP_INCLUDED
1.24 +#define BOOST_RE_CREGEX_HPP_INCLUDED
1.25 +
1.26 +#ifndef BOOST_REGEX_CONFIG_HPP
1.27 +#include <boost/regex/config.hpp>
1.28 +#endif
1.29 +#include <boost/regex/v4/match_flags.hpp>
1.30 +#include <boost/regex/v4/error_type.hpp>
1.31 +
1.32 +#ifdef __cplusplus
1.33 +#include <cstddef>
1.34 +#else
1.35 +#include <stddef.h>
1.36 +#endif
1.37 +
1.38 +#ifdef BOOST_HAS_ABI_HEADERS
1.39 +# include BOOST_ABI_PREFIX
1.40 +#endif
1.41 +
1.42 +/* include these defs only for POSIX compatablity */
1.43 +#ifdef __cplusplus
1.44 +namespace boost{
1.45 +extern "C" {
1.46 +#endif
1.47 +
1.48 +#if defined(__cplusplus) && !defined(BOOST_NO_STDC_NAMESPACE)
1.49 +typedef std::ptrdiff_t regoff_t;
1.50 +typedef std::size_t regsize_t;
1.51 +#else
1.52 +typedef ptrdiff_t regoff_t;
1.53 +typedef size_t regsize_t;
1.54 +#endif
1.55 +
1.56 +typedef struct
1.57 +{
1.58 + unsigned int re_magic;
1.59 +#ifdef __cplusplus
1.60 + std::size_t re_nsub; /* number of parenthesized subexpressions */
1.61 +#else
1.62 + size_t re_nsub;
1.63 +#endif
1.64 + const char* re_endp; /* end pointer for REG_PEND */
1.65 + void* guts; /* none of your business :-) */
1.66 + match_flag_type eflags; /* none of your business :-) */
1.67 +} regex_tA;
1.68 +
1.69 +#ifndef BOOST_NO_WREGEX
1.70 +typedef struct
1.71 +{
1.72 + unsigned int re_magic;
1.73 +#ifdef __cplusplus
1.74 + std::size_t re_nsub; /* number of parenthesized subexpressions */
1.75 +#else
1.76 + size_t re_nsub;
1.77 +#endif
1.78 + const wchar_t* re_endp; /* end pointer for REG_PEND */
1.79 + void* guts; /* none of your business :-) */
1.80 + match_flag_type eflags; /* none of your business :-) */
1.81 +} regex_tW;
1.82 +#endif
1.83 +
1.84 +typedef struct
1.85 +{
1.86 + regoff_t rm_so; /* start of match */
1.87 + regoff_t rm_eo; /* end of match */
1.88 +} regmatch_t;
1.89 +
1.90 +/* regcomp() flags */
1.91 +typedef enum{
1.92 + REG_BASIC = 0000,
1.93 + REG_EXTENDED = 0001,
1.94 + REG_ICASE = 0002,
1.95 + REG_NOSUB = 0004,
1.96 + REG_NEWLINE = 0010,
1.97 + REG_NOSPEC = 0020,
1.98 + REG_PEND = 0040,
1.99 + REG_DUMP = 0200,
1.100 + REG_NOCOLLATE = 0400,
1.101 + REG_ESCAPE_IN_LISTS = 01000,
1.102 + REG_NEWLINE_ALT = 02000,
1.103 + REG_PERLEX = 04000,
1.104 +
1.105 + REG_PERL = REG_EXTENDED | REG_NOCOLLATE | REG_ESCAPE_IN_LISTS | REG_PERLEX,
1.106 + REG_AWK = REG_EXTENDED | REG_ESCAPE_IN_LISTS,
1.107 + REG_GREP = REG_BASIC | REG_NEWLINE_ALT,
1.108 + REG_EGREP = REG_EXTENDED | REG_NEWLINE_ALT,
1.109 +
1.110 + REG_ASSERT = 15,
1.111 + REG_INVARG = 16,
1.112 + REG_ATOI = 255, /* convert name to number (!) */
1.113 + REG_ITOA = 0400 /* convert number to name (!) */
1.114 +} reg_comp_flags;
1.115 +
1.116 +/* regexec() flags */
1.117 +typedef enum{
1.118 + REG_NOTBOL = 00001,
1.119 + REG_NOTEOL = 00002,
1.120 + REG_STARTEND = 00004
1.121 +} reg_exec_flags;
1.122 +
1.123 +//
1.124 +// POSIX error codes:
1.125 +//
1.126 +typedef unsigned reg_error_t;
1.127 +typedef reg_error_t reg_errcode_t; // backwards compatibility
1.128 +
1.129 +static const reg_error_t REG_NOERROR = 0; /* Success. */
1.130 +static const reg_error_t REG_NOMATCH = 1; /* Didn't find a match (for regexec). */
1.131 +
1.132 + /* POSIX regcomp return error codes. (In the order listed in the
1.133 + standard.) */
1.134 +static const reg_error_t REG_BADPAT = 2; /* Invalid pattern. */
1.135 +static const reg_error_t REG_ECOLLATE = 3; /* Undefined collating element. */
1.136 +static const reg_error_t REG_ECTYPE = 4; /* Invalid character class name. */
1.137 +static const reg_error_t REG_EESCAPE = 5; /* Trailing backslash. */
1.138 +static const reg_error_t REG_ESUBREG = 6; /* Invalid back reference. */
1.139 +static const reg_error_t REG_EBRACK = 7; /* Unmatched left bracket. */
1.140 +static const reg_error_t REG_EPAREN = 8; /* Parenthesis imbalance. */
1.141 +static const reg_error_t REG_EBRACE = 9; /* Unmatched \{. */
1.142 +static const reg_error_t REG_BADBR = 10; /* Invalid contents of \{\}. */
1.143 +static const reg_error_t REG_ERANGE = 11; /* Invalid range end. */
1.144 +static const reg_error_t REG_ESPACE = 12; /* Ran out of memory. */
1.145 +static const reg_error_t REG_BADRPT = 13; /* No preceding re for repetition op. */
1.146 +static const reg_error_t REG_EEND = 14; /* unexpected end of expression */
1.147 +static const reg_error_t REG_ESIZE = 15; /* expression too big */
1.148 +static const reg_error_t REG_ERPAREN = 8; /* = REG_EPAREN : unmatched right parenthesis */
1.149 +static const reg_error_t REG_EMPTY = 17; /* empty expression */
1.150 +static const reg_error_t REG_E_MEMORY = 15; /* = REG_ESIZE : out of memory */
1.151 +static const reg_error_t REG_ECOMPLEXITY = 18; /* complexity too high */
1.152 +static const reg_error_t REG_ESTACK = 19; /* out of stack space */
1.153 +static const reg_error_t REG_E_UNKNOWN = 20; /* unknown error */
1.154 +static const reg_error_t REG_ENOSYS = 20; /* = REG_E_UNKNOWN : Reserved. */
1.155 +
1.156 +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA*, const char*, int);
1.157 +BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int, const regex_tA*, char*, regsize_t);
1.158 +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA*, const char*, regsize_t, regmatch_t*, int);
1.159 +BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA*);
1.160 +
1.161 +#ifndef BOOST_NO_WREGEX
1.162 +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW*, const wchar_t*, int);
1.163 +BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int, const regex_tW*, wchar_t*, regsize_t);
1.164 +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW*, const wchar_t*, regsize_t, regmatch_t*, int);
1.165 +BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW*);
1.166 +#endif
1.167 +
1.168 +#ifdef UNICODE
1.169 +#define regcomp regcompW
1.170 +#define regerror regerrorW
1.171 +#define regexec regexecW
1.172 +#define regfree regfreeW
1.173 +#define regex_t regex_tW
1.174 +#else
1.175 +#define regcomp regcompA
1.176 +#define regerror regerrorA
1.177 +#define regexec regexecA
1.178 +#define regfree regfreeA
1.179 +#define regex_t regex_tA
1.180 +#endif
1.181 +
1.182 +#ifdef BOOST_HAS_ABI_HEADERS
1.183 +# include BOOST_ABI_SUFFIX
1.184 +#endif
1.185 +
1.186 +#ifdef __cplusplus
1.187 +} // extern "C"
1.188 +} // namespace
1.189 +#endif
1.190 +
1.191 +//
1.192 +// C++ high level wrapper goes here:
1.193 +//
1.194 +#if defined(__cplusplus)
1.195 +#include <string>
1.196 +#include <vector>
1.197 +namespace boost{
1.198 +
1.199 +#ifdef BOOST_HAS_ABI_HEADERS
1.200 +# include BOOST_ABI_PREFIX
1.201 +#endif
1.202 +
1.203 +class RegEx;
1.204 +
1.205 +namespace re_detail{
1.206 +
1.207 +class RegExData;
1.208 +struct pred1;
1.209 +struct pred2;
1.210 +struct pred3;
1.211 +struct pred4;
1.212 +
1.213 +} // namespace re_detail
1.214 +
1.215 +#if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_DISABLE_WIN32)
1.216 +typedef bool (__cdecl *GrepCallback)(const RegEx& expression);
1.217 +typedef bool (__cdecl *GrepFileCallback)(const char* file, const RegEx& expression);
1.218 +typedef bool (__cdecl *FindFilesCallback)(const char* file);
1.219 +#else
1.220 +typedef bool (*GrepCallback)(const RegEx& expression);
1.221 +typedef bool (*GrepFileCallback)(const char* file, const RegEx& expression);
1.222 +typedef bool (*FindFilesCallback)(const char* file);
1.223 +#endif
1.224 +
1.225 +class BOOST_REGEX_DECL RegEx
1.226 +{
1.227 +private:
1.228 + re_detail::RegExData* pdata;
1.229 +public:
1.230 + RegEx();
1.231 + RegEx(const RegEx& o);
1.232 + ~RegEx();
1.233 + explicit RegEx(const char* c, bool icase = false);
1.234 + explicit RegEx(const std::string& s, bool icase = false);
1.235 + RegEx& operator=(const RegEx& o);
1.236 + RegEx& operator=(const char* p);
1.237 + RegEx& operator=(const std::string& s){ return this->operator=(s.c_str()); }
1.238 + unsigned int SetExpression(const char* p, bool icase = false);
1.239 + unsigned int SetExpression(const std::string& s, bool icase = false){ return SetExpression(s.c_str(), icase); }
1.240 + std::string Expression()const;
1.241 + unsigned int error_code()const;
1.242 + //
1.243 + // now matching operators:
1.244 + //
1.245 + bool Match(const char* p, match_flag_type flags = match_default);
1.246 + bool Match(const std::string& s, match_flag_type flags = match_default) { return Match(s.c_str(), flags); }
1.247 + bool Search(const char* p, match_flag_type flags = match_default);
1.248 + bool Search(const std::string& s, match_flag_type flags = match_default) { return Search(s.c_str(), flags); }
1.249 + unsigned int Grep(GrepCallback cb, const char* p, match_flag_type flags = match_default);
1.250 + unsigned int Grep(GrepCallback cb, const std::string& s, match_flag_type flags = match_default) { return Grep(cb, s.c_str(), flags); }
1.251 + unsigned int Grep(std::vector<std::string>& v, const char* p, match_flag_type flags = match_default);
1.252 + 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); }
1.253 + unsigned int Grep(std::vector<std::size_t>& v, const char* p, match_flag_type flags = match_default);
1.254 + 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); }
1.255 +#ifndef BOOST_REGEX_NO_FILEITER
1.256 + unsigned int GrepFiles(GrepFileCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default);
1.257 + 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); }
1.258 + unsigned int FindFiles(FindFilesCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default);
1.259 + 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); }
1.260 +#endif
1.261 +
1.262 + std::string Merge(const std::string& in, const std::string& fmt,
1.263 + bool copy = true, match_flag_type flags = match_default);
1.264 + std::string Merge(const char* in, const char* fmt,
1.265 + bool copy = true, match_flag_type flags = match_default);
1.266 +
1.267 + std::size_t Split(std::vector<std::string>& v, std::string& s, match_flag_type flags = match_default, unsigned max_count = ~0);
1.268 + //
1.269 + // now operators for returning what matched in more detail:
1.270 + //
1.271 + std::size_t Position(int i = 0)const;
1.272 + std::size_t Length(int i = 0)const;
1.273 + bool Matched(int i = 0)const;
1.274 + std::size_t Marks()const;
1.275 + std::string What(int i = 0)const;
1.276 + std::string operator[](int i)const { return What(i); }
1.277 +
1.278 + static const std::size_t npos;
1.279 +
1.280 + friend struct re_detail::pred1;
1.281 + friend struct re_detail::pred2;
1.282 + friend struct re_detail::pred3;
1.283 + friend struct re_detail::pred4;
1.284 +};
1.285 +
1.286 +#ifdef BOOST_HAS_ABI_HEADERS
1.287 +# include BOOST_ABI_SUFFIX
1.288 +#endif
1.289 +
1.290 +} // namespace boost
1.291 +
1.292 +#endif
1.293 +
1.294 +#endif // include guard
1.295 +
1.296 +
1.297 +
1.298 +
1.299 +
1.300 +
1.301 +
1.302 +
1.303 +
1.304 +