forked from boostorg/regex
Compare commits
61 Commits
Author | SHA1 | Date | |
---|---|---|---|
7e23c2b43c | |||
c898c51ea1 | |||
f039773693 | |||
57ca08240e | |||
0cbaa4ef17 | |||
f0afa5d9b8 | |||
9a8d2b13a3 | |||
bd0e76f42f | |||
bb9f2b1984 | |||
49c4e8cb8f | |||
e61e5e111e | |||
ccfc76570f | |||
cff442b3e7 | |||
65726f3d2f | |||
5243906d23 | |||
bd821cdedf | |||
d3697ab023 | |||
dca0bdcd7e | |||
d4e7ac721c | |||
1144c1dad8 | |||
cd92ca1ed0 | |||
e3840cf3a6 | |||
fdacaf7d6d | |||
fa2d2e1008 | |||
e5a7bbd399 | |||
028935b104 | |||
f9c3c8c461 | |||
126875cac9 | |||
e469b8aae5 | |||
801d83fb4f | |||
8e2a51e905 | |||
9ddfbd2923 | |||
456bf7756d | |||
27a5bcb1f4 | |||
3d46d5158b | |||
a12c3c2c14 | |||
d2bfcaf146 | |||
736f0de18d | |||
cc60bce275 | |||
2c0058a902 | |||
72652f7cde | |||
8dc1fd4a3b | |||
e5ac7686cd | |||
fbfdda66fd | |||
b4f600e910 | |||
02f8f3119e | |||
e91fac8614 | |||
6e502179f1 | |||
cf2a60c88b | |||
19931d87bd | |||
7c460d93cf | |||
9e36a0b67e | |||
d347b0d979 | |||
ba61613eff | |||
15acbd5117 | |||
1dcd331879 | |||
cb55913293 | |||
3e32c14965 | |||
571fbaf80d | |||
85580fd1ea | |||
66389f6e21 |
42
.github/workflows/ci.yml
vendored
42
.github/workflows/ci.yml
vendored
@ -9,6 +9,7 @@ on:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
pull_request:
|
||||
release:
|
||||
types: [published, created, edited]
|
||||
@ -134,6 +135,41 @@ jobs:
|
||||
- name: Test
|
||||
run: ../../../b2 toolset=$TOOLSET define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER
|
||||
working-directory: ../boost-root/libs/regex/test
|
||||
ubuntu-jammy-clang-18-modules:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: '0'
|
||||
- uses: mstachniuk/ci-skip@v1
|
||||
with:
|
||||
commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE]'
|
||||
commit-filter-separator: ';'
|
||||
fail-fast: true
|
||||
- name: Grab install script
|
||||
run: wget https://apt.llvm.org/llvm.sh && chmod u+x llvm.sh
|
||||
- name: Install clang 18 packages
|
||||
run: sudo ./llvm.sh 18 && clang++-18 --version
|
||||
- name: Checkout main boost
|
||||
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
|
||||
- name: Update tools/boostdep
|
||||
run: git submodule update --init tools/boostdep
|
||||
working-directory: ../boost-root
|
||||
- name: Copy files
|
||||
run: cp -r $GITHUB_WORKSPACE/* libs/regex
|
||||
working-directory: ../boost-root
|
||||
- name: Install deps
|
||||
run: python tools/boostdep/depinst/depinst.py -I example -g "--jobs 3" regex
|
||||
working-directory: ../boost-root
|
||||
- name: Bootstrap
|
||||
run: ./bootstrap.sh
|
||||
working-directory: ../boost-root
|
||||
- name: Generate headers
|
||||
run: ./b2 headers
|
||||
working-directory: ../boost-root
|
||||
- name: Test
|
||||
run: CXX=clang++-18 LIBRARIES="-licuuc -licudata -licui18n" ./test_clang.sh
|
||||
working-directory: ../boost-root/libs/regex/test/module
|
||||
macos:
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
@ -338,6 +374,9 @@ jobs:
|
||||
commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[apple];[Apple];[APPLE];[linux];[Linux];[LINUX]'
|
||||
commit-filter-separator: ';'
|
||||
fail-fast: true
|
||||
- uses: TheMrMilchmann/setup-msvc-dev@v3
|
||||
with:
|
||||
arch: x64
|
||||
- name: Checkout main boost
|
||||
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
|
||||
- name: Update tools/boostdep
|
||||
@ -364,6 +403,9 @@ jobs:
|
||||
- name: Test
|
||||
run: ..\..\..\b2 --hash %ARGS%
|
||||
working-directory: ../boost-root/libs/regex/test
|
||||
- name: Module Test
|
||||
run: msvc_test.bat
|
||||
working-directory: ../boost-root/libs/regex/test/module
|
||||
ubuntu-cmake-install:
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
|
30
build.jam
Normal file
30
build.jam
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright René Ferdinand Rivera Morell 2023-2024
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/assert//boost_assert
|
||||
/boost/concept_check//boost_concept_check
|
||||
/boost/config//boost_config
|
||||
/boost/predef//boost_predef
|
||||
/boost/static_assert//boost_static_assert
|
||||
/boost/throw_exception//boost_throw_exception
|
||||
/boost/type_traits//boost_type_traits ;
|
||||
|
||||
project /boost/regex
|
||||
: common-requirements
|
||||
<include>include
|
||||
;
|
||||
|
||||
explicit
|
||||
[ alias boost_regex : build//boost_regex ]
|
||||
[ alias all : boost_regex example test ]
|
||||
;
|
||||
|
||||
call-if : boost-library regex
|
||||
: install boost_regex
|
||||
;
|
||||
|
@ -1,15 +1,20 @@
|
||||
# copyright John Maddock 2003
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt.
|
||||
|
||||
import modules ;
|
||||
import testing ;
|
||||
import errors ;
|
||||
|
||||
project : requirements
|
||||
# default to all warnings on:
|
||||
<warnings>all
|
||||
constant boost_dependencies_private :
|
||||
/boost/core//boost_core
|
||||
;
|
||||
|
||||
project
|
||||
: default-build <warnings>all
|
||||
: common-requirements <library>$(boost_dependencies)
|
||||
: requirements <library>$(boost_dependencies_private)
|
||||
;
|
||||
|
||||
local disable-icu = [ MATCH (--disable-icu) : [ modules.peek : ARGV ] ] ;
|
||||
@ -17,13 +22,13 @@ local disable-icu = [ MATCH (--disable-icu) : [ modules.peek : ARGV ] ] ;
|
||||
rule path_options ( properties * )
|
||||
{
|
||||
local result ;
|
||||
if <address-model>64 in $(properties) && <toolset>msvc in $(properties)
|
||||
if <address-model>64 in $(properties) && <toolset>msvc in $(properties)
|
||||
{
|
||||
result = <search>$(ICU_PATH)/bin64 <search>$(ICU_PATH)/lib64 ;
|
||||
result = <search>$(ICU_PATH)/bin64 <search>$(ICU_PATH)/lib64 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = <search>$(ICU_PATH)/bin <search>$(ICU_PATH)/lib ;
|
||||
result = <search>$(ICU_PATH)/bin <search>$(ICU_PATH)/lib ;
|
||||
}
|
||||
return $(result) ;
|
||||
}
|
||||
@ -34,24 +39,24 @@ rule path_options ( properties * )
|
||||
if ! $(disable-icu)
|
||||
{
|
||||
if [ modules.peek : ICU_LINK ]
|
||||
{
|
||||
{
|
||||
errors.user-error : "The ICU_LINK option is no longer supported by the Boost.Regex build - please refer to the documentation for equivalent options" ;
|
||||
}
|
||||
|
||||
if [ modules.peek : ICU_PATH ]
|
||||
{
|
||||
{
|
||||
ICU_PATH = [ modules.peek : ICU_PATH ] ;
|
||||
}
|
||||
if [ modules.peek : ICU_ICUUC_NAME ]
|
||||
{
|
||||
{
|
||||
ICU_ICUUC_NAME = [ modules.peek : ICU_ICUUC_NAME ] ;
|
||||
}
|
||||
if [ modules.peek : ICU_ICUDT_NAME ]
|
||||
{
|
||||
{
|
||||
ICU_ICUDT_NAME = [ modules.peek : ICU_ICUDT_NAME ] ;
|
||||
}
|
||||
if [ modules.peek : ICU_ICUIN_NAME ]
|
||||
{
|
||||
{
|
||||
ICU_ICUIN_NAME = [ modules.peek : ICU_ICUIN_NAME ] ;
|
||||
}
|
||||
|
||||
@ -102,8 +107,8 @@ if ! $(disable-icu)
|
||||
lib icuin : : <name>this_is_an_invalid_library_name ;
|
||||
}
|
||||
|
||||
ICU_OPTS =
|
||||
<include>$(ICU_PATH)/include
|
||||
ICU_OPTS =
|
||||
<include>$(ICU_PATH)/include
|
||||
<runtime-link>shared:<library>icuuc/<link>shared
|
||||
<runtime-link>shared:<library>icudt/<link>shared
|
||||
<runtime-link>shared:<library>icuin/<link>shared
|
||||
@ -111,7 +116,7 @@ if ! $(disable-icu)
|
||||
<runtime-link>static:<library>icudt
|
||||
<runtime-link>static:<library>icuin
|
||||
<target-os>windows,<toolset>clang:<linkflags>"advapi32.lib"
|
||||
<define>BOOST_HAS_ICU=1
|
||||
<define>BOOST_HAS_ICU=1
|
||||
<runtime-link>static:<define>U_STATIC_IMPLEMENTATION=1
|
||||
;
|
||||
|
||||
@ -144,16 +149,15 @@ explicit has_icu ;
|
||||
|
||||
alias icu_options : : : : [ check-target-builds has_icu : $(ICU_OPTS) : ] ;
|
||||
|
||||
SOURCES =
|
||||
SOURCES =
|
||||
posix_api.cpp
|
||||
wide_posix_api.cpp
|
||||
;
|
||||
|
||||
lib boost_regex : ../src/$(SOURCES) icu_options
|
||||
:
|
||||
<link>shared:<define>BOOST_REGEX_DYN_LINK=1
|
||||
<toolset>gcc-cygwin:<link>static
|
||||
:
|
||||
<link>shared:<define>BOOST_REGEX_DYN_LINK=1
|
||||
<toolset>gcc-cygwin:<link>static
|
||||
: :
|
||||
<define>BOOST_REGEX_NO_LIB=1
|
||||
;
|
||||
|
||||
boost-install boost_regex ;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<link rel="home" href="../index.html" title="Boost.Regex 7.0.1">
|
||||
<link rel="up" href="../index.html" title="Boost.Regex 7.0.1">
|
||||
<link rel="prev" href="configuration/tuning.html" title="Algorithm Tuning">
|
||||
<link rel="next" href="intro.html" title="Introduction and Overview">
|
||||
<link rel="next" href="modules.html" title="Module Support (Experimental)">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
@ -21,7 +21,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="configuration/tuning.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="intro.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="configuration/tuning.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="modules.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
@ -109,7 +109,7 @@
|
||||
</div>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="configuration/tuning.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="intro.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="configuration/tuning.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="modules.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Regex 7.0.1">
|
||||
<link rel="up" href="../index.html" title="Boost.Regex 7.0.1">
|
||||
<link rel="prev" href="install.html" title="Building and Installing the Library">
|
||||
<link rel="prev" href="modules.html" title="Module Support (Experimental)">
|
||||
<link rel="next" href="unicode.html" title="Unicode and Boost.Regex">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
@ -21,7 +21,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="install.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unicode.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="modules.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unicode.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
@ -206,7 +206,7 @@
|
||||
</div>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="install.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unicode.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="modules.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unicode.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
108
doc/html/boost_regex/modules.html
Normal file
108
doc/html/boost_regex/modules.html
Normal file
@ -0,0 +1,108 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Module Support (Experimental)</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Regex 7.0.1">
|
||||
<link rel="up" href="../index.html" title="Boost.Regex 7.0.1">
|
||||
<link rel="prev" href="install.html" title="Building and Installing the Library">
|
||||
<link rel="next" href="intro.html" title="Introduction and Overview">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="install.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="intro.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="boost_regex.modules"></a><a class="link" href="modules.html" title="Module Support (Experimental)">Module Support (Experimental)</a>
|
||||
</h2></div></div></div>
|
||||
<p>
|
||||
This library has experimental support for C++ modules (C++20 or later), currently
|
||||
the support is experimental not least because at the time of writing (2025)
|
||||
build tools have yet to catch up with module support.
|
||||
</p>
|
||||
<p>
|
||||
In order to use this library as a module you simply add a:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">import</span> <span class="identifier">boost</span><span class="special">.</span><span class="identifier">regex</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
to your code.
|
||||
</p>
|
||||
<p>
|
||||
Before that you must first build the module, which consists of these steps:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
Depending on your compiler, you may need to build the standard library
|
||||
module, and place the standard module somewhere that your compiler can
|
||||
find it.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Build <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">regex</span><span class="special">/</span><span class="identifier">module</span><span class="special">/</span><span class="identifier">regex</span><span class="special">.</span><span class="identifier">cxx</span></code> into the boost.regex module, and
|
||||
place the module definition file somewhere that your compiler can find
|
||||
it.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Build all the source files in <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">regex</span><span class="special">/</span><span class="identifier">module</span></code>
|
||||
(including regex.cxx) into a library, and place the result somewhere your
|
||||
linker can find it.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
Visual studio users can simplify all of the above into one step, by placing
|
||||
everything in <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">regex</span><span class="special">/</span><span class="identifier">module</span></code>
|
||||
into a static library project, and then adding the <code class="computeroutput"><span class="special">/</span><span class="identifier">interface</span></code> command line option to the regex.cxx
|
||||
source file.
|
||||
</p>
|
||||
<p>
|
||||
Known limitations:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
As of the start of 2025, only very recent versions of clang and msvc are
|
||||
supported. GCC is definitely not supported.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
The regex library must always be consumed via <code class="computeroutput"><span class="identifier">import</span>
|
||||
<span class="identifier">boost</span><span class="special">.</span><span class="identifier">regex</span><span class="special">;</span></code>
|
||||
and you can never mix this with <code class="computeroutput"><span class="preprocessor">#includes</span>
|
||||
<span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">regex</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Ideally the standard library should always be used via <code class="computeroutput"><span class="identifier">import</span>
|
||||
<span class="identifier">std</span></code> and not via #includes: more
|
||||
recent compilers are mostly making this work, but are still very fragile.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
The regex version imported, is always the "standalone" version
|
||||
which includes no other Boost headers.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
Finally... there are some build and test scripts in <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">regex</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">module</span></code>
|
||||
for msvc and clang.
|
||||
</p>
|
||||
</div>
|
||||
<div class="copyright-footer">Copyright © 1998-2013 John Maddock<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="install.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="intro.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -50,6 +50,7 @@
|
||||
<dt><span class="section"><a href="boost_regex/configuration/tuning.html">Algorithm Tuning</a></span></dt>
|
||||
</dl></dd>
|
||||
<dt><span class="section"><a href="boost_regex/install.html">Building and Installing the Library</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_regex/modules.html">Module Support (Experimental)</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_regex/intro.html">Introduction and Overview</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_regex/unicode.html">Unicode and Boost.Regex</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_regex/captures.html">Understanding Marked Sub-Expressions
|
||||
|
40
doc/modules.qbk
Normal file
40
doc/modules.qbk
Normal file
@ -0,0 +1,40 @@
|
||||
[/
|
||||
Copyright 2024 John Maddock.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
]
|
||||
|
||||
[section:modules Module Support (Experimental)]
|
||||
|
||||
This library has experimental support for C++ modules (C++20 or later), currently the support is experimental
|
||||
not least because at the time of writing (2025) build tools have yet to catch up with module support.
|
||||
|
||||
In order to use this library as a module you simply add a:
|
||||
|
||||
```
|
||||
import boost.regex;
|
||||
```
|
||||
|
||||
to your code.
|
||||
|
||||
Before that you must first build the module, which consists of these steps:
|
||||
|
||||
* Depending on your compiler, you may need to build the standard library module, and place the standard module somewhere that your compiler can find it.
|
||||
* Build `libs/regex/module/regex.cxx` into the boost.regex module, and place the module definition file somewhere that your compiler can find it.
|
||||
* Build all the source files in `libs/regex/module` (including regex.cxx) into a library, and place the result somewhere your linker can find it.
|
||||
|
||||
Visual studio users can simplify all of the above into one step, by placing everything in `libs/regex/module` into a static library project, and then adding the `/interface`
|
||||
command line option to the regex.cxx source file.
|
||||
|
||||
Known limitations:
|
||||
|
||||
* As of the start of 2025, only very recent versions of clang and msvc are supported. GCC is definitely not supported.
|
||||
* The regex library must always be consumed via `import boost.regex;` and you can never mix this with `#includes <boost/regex.hpp>`.
|
||||
* Ideally the standard library should always be used via `import std` and not via #includes: more recent compilers are mostly making this work, but are still very fragile.
|
||||
* The regex version imported, is always the "standalone" version which includes no other Boost headers.
|
||||
|
||||
Finally... there are some build and test scripts in `libs/regex/test/module` for msvc and clang.
|
||||
|
||||
[endsect]
|
||||
|
@ -51,6 +51,7 @@ PDF version of this manual is also available].
|
||||
|
||||
[include configuration.qbk]
|
||||
[include install.qbk]
|
||||
[include modules.qbk]
|
||||
[include introduction.qbk]
|
||||
[include unicode.qbk]
|
||||
[include captures.qbk]
|
||||
|
@ -1,32 +1,34 @@
|
||||
# copyright John Maddock 2003
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt.
|
||||
|
||||
project
|
||||
: requirements
|
||||
<threading>multi
|
||||
: requirements
|
||||
<library>/boost/regex//boost_regex
|
||||
<library>/boost/timer//boost_timer
|
||||
<threading>multi
|
||||
<link>shared:<define>BOOST_REGEX_DYN_LINK=1
|
||||
# There are unidentified linker problems on these platforms:
|
||||
<toolset>mipspro-7.4:<link>static
|
||||
<toolset>sun-5.9:<link>static
|
||||
<toolset>msvc:<warnings>all
|
||||
<toolset>gcc:<warnings>all
|
||||
<toolset>gcc:<cxxflags>-Wextra
|
||||
<toolset>gcc:<warnings>extra
|
||||
<define>U_USING_ICU_NAMESPACE=0
|
||||
#<toolset>gcc-mw:<link>static
|
||||
#<toolset>gcc-mingw:<link>static
|
||||
<toolset>gcc-cygwin:<link>static
|
||||
<define>BOOST_TIMER_ENABLE_DEPRECATED
|
||||
;
|
||||
|
||||
rule regex-test-run ( sources + : input * : name * )
|
||||
{
|
||||
return [
|
||||
return [
|
||||
run
|
||||
# sources
|
||||
$(sources)
|
||||
# dependencies
|
||||
../build//boost_regex
|
||||
/boost/regex//boost_regex
|
||||
: # additional args
|
||||
$(input)
|
||||
: # test-files
|
||||
@ -37,32 +39,33 @@ rule regex-test-run ( sources + : input * : name * )
|
||||
] ;
|
||||
}
|
||||
|
||||
path-constant HERE : . ;
|
||||
|
||||
test-suite regex-examples :
|
||||
|
||||
[ regex-test-run timer/regex_timer.cpp : $(BOOST_ROOT)/libs/regex/example/timer/input_script.txt ]
|
||||
[ regex-test-run grep/grep.cpp ../../program_options/build//boost_program_options/<link>static : -n -b $(BOOST_ROOT)/boost/regex.hpp $(BOOST_ROOT)/boost/type_traits.hpp : test_grep ]
|
||||
[ regex-test-run timer/regex_timer.cpp /boost/smart_ptr//boost_smart_ptr : $(HERE)/timer/input_script.txt ]
|
||||
[ regex-test-run grep/grep.cpp /boost/program_options//boost_program_options/<link>static : -n -b -E include $(HERE)/../include/boost/regex.hpp : test_grep ]
|
||||
[ regex-test-run snippets/credit_card_example.cpp ]
|
||||
[ regex-test-run snippets/mfc_example.cpp ]
|
||||
[ regex-test-run snippets/icu_example.cpp ]
|
||||
[ regex-test-run snippets/partial_regex_grep.cpp : $(BOOST_ROOT)/libs/regex/index.htm ]
|
||||
[ regex-test-run snippets/partial_regex_iterate.cpp : $(BOOST_ROOT)/libs/regex/index.htm ]
|
||||
[ regex-test-run snippets/partial_regex_grep.cpp : $(HERE)/../index.htm ]
|
||||
[ regex-test-run snippets/partial_regex_iterate.cpp : $(HERE)/../index.htm ]
|
||||
[ regex-test-run snippets/partial_regex_match.cpp : 1234-5678-8765-4 ]
|
||||
[ regex-test-run snippets/regex_grep_example_1.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_2.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_3.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_4.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_1.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_2.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_3.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_4.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_match_example.cpp : -auto ]
|
||||
[ regex-test-run snippets/regex_merge_example.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_replace_example.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_search_example.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_merge_example.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_replace_example.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_search_example.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_split_example_1.cpp : -auto ]
|
||||
[ regex-test-run snippets/regex_split_example_2.cpp : $(BOOST_ROOT)/libs/regex/doc/html/index.html ]
|
||||
[ regex-test-run snippets/regex_split_example_2.cpp : $(HERE)/../doc/html/index.html ]
|
||||
[ regex-test-run snippets/regex_token_iterator_eg_1.cpp : -auto ]
|
||||
[ regex-test-run snippets/regex_token_iterator_eg_2.cpp : $(BOOST_ROOT)/libs/regex/doc/html/index.html ]
|
||||
[ regex-test-run snippets/regex_iterator_example.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_token_iterator_eg_2.cpp : $(HERE)/../doc/html/index.html ]
|
||||
[ regex-test-run snippets/regex_iterator_example.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ run snippets/captures_example.cpp
|
||||
../test/captures//boost_regex_extra
|
||||
: : : <threading>multi <define>BOOST_REGEX_MATCH_EXTRA=1 ]
|
||||
|
||||
;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/type_traits/is_base_and_derived.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#ifndef BOOST_TEST_TR1_REGEX
|
||||
#if !defined(BOOST_TEST_TR1_REGEX) && !defined(BOOST_REGEX_TEST_MODULE)
|
||||
#include <boost/regex.hpp>
|
||||
#endif
|
||||
#include <bitset>
|
||||
@ -37,6 +37,16 @@
|
||||
#define RW_NS std
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// alter this to std::tr1, to test a std implementation:
|
||||
//
|
||||
#ifndef BOOST_TEST_TR1_REGEX
|
||||
namespace global_regex_namespace = ::boost;
|
||||
#else
|
||||
namespace global_regex_namespace = ::std::tr1;
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
//
|
||||
@ -178,15 +188,6 @@ private:
|
||||
regex_traits_architype& operator=(const regex_traits_architype&){ return *this; }
|
||||
};
|
||||
|
||||
//
|
||||
// alter this to std::tr1, to test a std implementation:
|
||||
//
|
||||
#ifndef BOOST_TEST_TR1_REGEX
|
||||
namespace global_regex_namespace = ::boost;
|
||||
#else
|
||||
namespace global_regex_namespace = ::std::tr1;
|
||||
#endif
|
||||
|
||||
template <class Bitmask>
|
||||
struct BitmaskConcept
|
||||
{
|
||||
@ -273,7 +274,7 @@ template <class Regex>
|
||||
struct regex_traits_computer;
|
||||
|
||||
template <class charT, class traits>
|
||||
struct regex_traits_computer< global_regex_namespace::basic_regex<charT, traits> >
|
||||
struct regex_traits_computer< ::boost::basic_regex<charT, traits> >
|
||||
{
|
||||
typedef traits type;
|
||||
};
|
||||
|
@ -29,6 +29,22 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_MODULE_EXPORT
|
||||
#define BOOST_REGEX_MODULE_EXPORT
|
||||
#define BOOST_REGEX_STATIC_CONST static const
|
||||
#else
|
||||
#define BOOST_REGEX_STATIC_CONST inline constexpr
|
||||
#define BOOST_REGEX_STANDALONE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Borland C++ Fix/error check
|
||||
* this has to go *before* we include any std lib headers:
|
||||
*/
|
||||
#if defined(__BORLANDC__) && !defined(__clang__)
|
||||
# include <boost/regex/config/borland.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
#include <boost/version.hpp>
|
||||
#endif
|
||||
@ -40,9 +56,13 @@
|
||||
*************************************************************************/
|
||||
|
||||
#ifdef BOOST_REGEX_STANDALONE
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <cassert>
|
||||
# define BOOST_REGEX_ASSERT(x) assert(x)
|
||||
#else
|
||||
# define BOOST_REGEX_ASSERT(x) do{ if(x == 0) { std::printf("%s:%d Assertion Failed", __FILE__, __LINE__); std::abort(); } }while(0)
|
||||
#endif
|
||||
#else
|
||||
#include <boost/assert.hpp>
|
||||
# define BOOST_REGEX_ASSERT(x) BOOST_ASSERT(x)
|
||||
#endif
|
||||
@ -284,8 +304,6 @@
|
||||
* If there are no exceptions then we must report critical-errors
|
||||
* the only way we know how; by terminating.
|
||||
*/
|
||||
#include <cassert>
|
||||
|
||||
# define BOOST_REGEX_NOEH_ASSERT(x) assert(x);
|
||||
#else
|
||||
/*
|
||||
|
@ -19,7 +19,18 @@
|
||||
#ifndef BOOST_REGEX_V5_BASIC_REGEX_HPP
|
||||
#define BOOST_REGEX_V5_BASIC_REGEX_HPP
|
||||
|
||||
#include <boost/regex/v5/regbase.hpp>
|
||||
#include <boost/regex/v5/syntax_type.hpp>
|
||||
#include <boost/regex/v5/regex_traits.hpp>
|
||||
#include <boost/regex/v5/states.hpp>
|
||||
#include <boost/regex/v5/regex_raw_buffer.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
@ -58,7 +69,12 @@ void bubble_down_one(I first, I last)
|
||||
}
|
||||
}
|
||||
|
||||
static const int hash_value_mask = 1 << (std::numeric_limits<int>::digits - 1);
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
static
|
||||
#else
|
||||
inline
|
||||
#endif
|
||||
const int hash_value_mask = 1 << (std::numeric_limits<int>::digits - 1);
|
||||
|
||||
template <class Iterator>
|
||||
inline int hash_value_from_capture_name(Iterator i, Iterator j)
|
||||
@ -306,7 +322,7 @@ public:
|
||||
// represents the compiled
|
||||
// regular expression:
|
||||
//
|
||||
|
||||
BOOST_REGEX_MODULE_EXPORT
|
||||
#ifdef BOOST_REGEX_NO_FWD
|
||||
template <class charT, class traits = regex_traits<charT> >
|
||||
#else
|
||||
@ -643,22 +659,38 @@ private:
|
||||
// and are designed to provide the strong exception guarantee
|
||||
// (in the event of a throw, the state of the object remains unchanged).
|
||||
//
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <class charT, class F, class Traits>
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits> > create_implemenation(const charT* p1, const charT* p2, F f, std::shared_ptr<boost::regex_traits_wrapper<Traits> > ptraits)
|
||||
{
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits> > result;
|
||||
if (!ptraits.get())
|
||||
{
|
||||
result = std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits>());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, Traits>(ptraits));
|
||||
}
|
||||
result->assign(p1, p2, f);
|
||||
return result;
|
||||
}
|
||||
#ifdef BOOST_REGEX_AS_MODULE
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<char, basic_regex<char>::traits_type> >
|
||||
create_implemenation(const char* p1, const char* p2, basic_regex<char>::flag_type f, std::shared_ptr<boost::regex_traits_wrapper<basic_regex<char>::traits_type> > ptraits);
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<wchar_t, basic_regex<wchar_t>::traits_type> >
|
||||
create_implemenation(const wchar_t* p1, const wchar_t* p2, basic_regex<wchar_t>::flag_type f, std::shared_ptr<boost::regex_traits_wrapper<basic_regex<wchar_t>::traits_type> > ptraits);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class charT, class traits>
|
||||
basic_regex<charT, traits>& basic_regex<charT, traits>::do_assign(const charT* p1,
|
||||
const charT* p2,
|
||||
flag_type f)
|
||||
{
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> > temp;
|
||||
if(!m_pimpl.get())
|
||||
{
|
||||
temp = std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits>());
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits>(m_pimpl->m_ptraits));
|
||||
}
|
||||
temp->assign(p1, p2, f);
|
||||
temp.swap(m_pimpl);
|
||||
m_pimpl = detail::create_implemenation(p1, p2, f, m_pimpl.get() ? m_pimpl->m_ptraits : std::shared_ptr<boost::regex_traits_wrapper<traits> >());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -674,13 +706,13 @@ typename basic_regex<charT, traits>::locale_type basic_regex<charT, traits>::im
|
||||
//
|
||||
// non-members:
|
||||
//
|
||||
template <class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits>
|
||||
void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2)
|
||||
{
|
||||
e1.swap(e2);
|
||||
}
|
||||
|
||||
template <class charT, class traits, class traits2>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits, class traits2>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator << (std::basic_ostream<charT, traits>& os,
|
||||
const basic_regex<charT, traits2>& e)
|
||||
|
@ -28,7 +28,12 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
@ -217,8 +222,10 @@ public:
|
||||
m_icase = static_cast<bool>(f & regbase::icase);
|
||||
}
|
||||
}
|
||||
re_syntax_base* append_state(syntax_element_type t, std::size_t s = sizeof(re_syntax_base));
|
||||
re_syntax_base* insert_state(std::ptrdiff_t pos, syntax_element_type t, std::size_t s = sizeof(re_syntax_base));
|
||||
re_syntax_base* append_state(syntax_element_type t, std::size_t s);
|
||||
re_syntax_base* append_state(syntax_element_type t) { return append_state(t, sizeof(re_syntax_base)); }
|
||||
re_syntax_base* insert_state(std::ptrdiff_t pos, syntax_element_type t, std::size_t s);
|
||||
re_syntax_base* insert_state(std::ptrdiff_t pos, syntax_element_type t) { return insert_state(pos, t, sizeof(re_syntax_base)); }
|
||||
re_literal* append_literal(charT c);
|
||||
re_syntax_base* append_set(const basic_char_set<charT, traits>& char_set);
|
||||
re_syntax_base* append_set(const basic_char_set<charT, traits>& char_set, std::integral_constant<bool, false>*);
|
||||
@ -971,7 +978,12 @@ template <class charT, class traits>
|
||||
int basic_regex_creator<charT, traits>::calculate_backstep(re_syntax_base* state)
|
||||
{
|
||||
typedef typename traits::char_class_type m_type;
|
||||
|
||||
int result = 0;
|
||||
int last_alternative_result = -1;
|
||||
|
||||
std::vector<std::tuple<int, re_syntax_base*>> stack;
|
||||
|
||||
while(state)
|
||||
{
|
||||
switch(state->type)
|
||||
@ -990,9 +1002,28 @@ int basic_regex_creator<charT, traits>::calculate_backstep(re_syntax_base* state
|
||||
}
|
||||
break;
|
||||
case syntax_element_endmark:
|
||||
if((static_cast<re_brace*>(state)->index == -1)
|
||||
if ((static_cast<re_brace*>(state)->index == -1)
|
||||
|| (static_cast<re_brace*>(state)->index == -2))
|
||||
return result;
|
||||
{
|
||||
// We've finished the calculation, check against any previous alternatives:
|
||||
if (last_alternative_result >= 0)
|
||||
{
|
||||
if (last_alternative_result != result)
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
last_alternative_result = result;
|
||||
|
||||
if (stack.size())
|
||||
{
|
||||
// Skip to next alternative and calculate that as well:
|
||||
std::tie(result, state) = stack.back();
|
||||
stack.pop_back();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
case syntax_element_literal:
|
||||
result += static_cast<re_literal*>(state)->length;
|
||||
@ -1048,11 +1079,13 @@ int basic_regex_creator<charT, traits>::calculate_backstep(re_syntax_base* state
|
||||
continue;
|
||||
case syntax_element_alt:
|
||||
{
|
||||
int r1 = calculate_backstep(state->next.p);
|
||||
int r2 = calculate_backstep(static_cast<re_alt*>(state)->alt.p);
|
||||
if((r1 < 0) || (r1 != r2))
|
||||
// Push the alternative if we haven't pushed too many already:
|
||||
if(stack.size() > BOOST_REGEX_MAX_BLOCKS)
|
||||
return -1;
|
||||
return result + r1;
|
||||
stack.push_back(std::make_tuple(result, static_cast<re_alt*>(state)->alt.p));
|
||||
// and take the first one:
|
||||
state = state->next.p;
|
||||
continue;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -19,6 +19,15 @@
|
||||
#ifndef BOOST_REGEX_V5_BASIC_REGEX_PARSER_HPP
|
||||
#define BOOST_REGEX_V5_BASIC_REGEX_PARSER_HPP
|
||||
|
||||
#include <boost/regex/v5/basic_regex_creator.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
|
@ -19,9 +19,16 @@
|
||||
#ifndef BOOST_C_REGEX_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_C_REGEX_TRAITS_HPP_INCLUDED
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
#include <cwctype>
|
||||
#endif
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
#include <boost/regex/v5/regex_workaround.hpp>
|
||||
#include <cctype>
|
||||
#include <boost/regex/v5/primary_transform.hpp>
|
||||
#include <boost/regex/v5/regex_traits_defaults.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
@ -49,10 +56,10 @@ namespace boost{
|
||||
|
||||
}
|
||||
|
||||
template <class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT>
|
||||
struct c_regex_traits;
|
||||
|
||||
template<>
|
||||
BOOST_REGEX_MODULE_EXPORT template<>
|
||||
struct c_regex_traits<char>
|
||||
{
|
||||
c_regex_traits(){}
|
||||
@ -97,7 +104,7 @@ private:
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
template<>
|
||||
BOOST_REGEX_MODULE_EXPORT template<>
|
||||
struct c_regex_traits<wchar_t>
|
||||
{
|
||||
c_regex_traits(){}
|
||||
|
@ -20,6 +20,8 @@
|
||||
#ifndef BOOST_REGEX_V5_CHAR_REGEX_TRAITS_HPP
|
||||
#define BOOST_REGEX_V5_CHAR_REGEX_TRAITS_HPP
|
||||
|
||||
#include <boost/regex/v5/regex_traits.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace deprecated{
|
||||
|
@ -20,22 +20,25 @@
|
||||
#define BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <cstdint>
|
||||
#include <locale>
|
||||
#include <type_traits>
|
||||
#include <climits>
|
||||
#include <ios>
|
||||
#include <istream>
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
#include <mutex>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <boost/regex/pattern_except.hpp>
|
||||
#include <boost/regex/v5/regex_traits_defaults.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
#include <mutex>
|
||||
#endif
|
||||
#include <boost/regex/v5/primary_transform.hpp>
|
||||
#include <boost/regex/v5/object_cache.hpp>
|
||||
|
||||
#include <climits>
|
||||
#include <ios>
|
||||
#include <istream>
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
#pragma warning(push)
|
||||
@ -47,7 +50,7 @@ namespace boost{
|
||||
//
|
||||
// forward declaration is needed by some compilers:
|
||||
//
|
||||
template <class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT>
|
||||
class cpp_regex_traits;
|
||||
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
@ -731,7 +734,7 @@ inline std::shared_ptr<const cpp_regex_traits_implementation<charT> > create_cpp
|
||||
|
||||
} // BOOST_REGEX_DETAIL_NS
|
||||
|
||||
template <class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT>
|
||||
class cpp_regex_traits
|
||||
{
|
||||
private:
|
||||
|
@ -38,11 +38,13 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#ifdef __cplusplus
|
||||
#include <cstddef>
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* include these defs only for POSIX compatablity */
|
||||
#ifdef __cplusplus
|
||||
|
@ -26,7 +26,7 @@ namespace boost{
|
||||
#ifdef __cplusplus
|
||||
namespace regex_constants{
|
||||
|
||||
enum error_type{
|
||||
BOOST_REGEX_MODULE_EXPORT enum error_type{
|
||||
|
||||
error_ok = 0, /* not used */
|
||||
error_no_match = 1, /* not used */
|
||||
|
@ -19,11 +19,13 @@
|
||||
#ifndef BOOST_REGEX_ICU_V5_HPP
|
||||
#define BOOST_REGEX_ICU_V5_HPP
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <unicode/utypes.h>
|
||||
#include <unicode/uchar.h>
|
||||
#include <unicode/coll.h>
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
#endif
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/regex/v5/unicode_iterator.hpp>
|
||||
|
||||
@ -835,7 +837,7 @@ bool do_regex_match(BidiIterator first, BidiIterator last,
|
||||
}
|
||||
} // namespace BOOST_REGEX_DETAIL_NS
|
||||
|
||||
template <class BidiIterator, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator, class Allocator>
|
||||
inline bool u32regex_match(BidiIterator first, BidiIterator last,
|
||||
match_results<BidiIterator, Allocator>& m,
|
||||
const u32regex& e,
|
||||
@ -843,7 +845,7 @@ inline bool u32regex_match(BidiIterator first, BidiIterator last,
|
||||
{
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(first, last, m, e, flags, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0));
|
||||
}
|
||||
inline bool u32regex_match(const UChar* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const UChar* p,
|
||||
match_results<const UChar*>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -851,7 +853,7 @@ inline bool u32regex_match(const UChar* p,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast<std::integral_constant<int, 2> const*>(0));
|
||||
}
|
||||
#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX)
|
||||
inline bool u32regex_match(const wchar_t* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const wchar_t* p,
|
||||
match_results<const wchar_t*>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -859,21 +861,21 @@ inline bool u32regex_match(const wchar_t* p,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0));
|
||||
}
|
||||
#endif
|
||||
inline bool u32regex_match(const char* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const char* p,
|
||||
match_results<const char*>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
inline bool u32regex_match(const unsigned char* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const unsigned char* p,
|
||||
match_results<const unsigned char*>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
inline bool u32regex_match(const std::string& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const std::string& s,
|
||||
match_results<std::string::const_iterator>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -881,7 +883,7 @@ inline bool u32regex_match(const std::string& s,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
inline bool u32regex_match(const std::wstring& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const std::wstring& s,
|
||||
match_results<std::wstring::const_iterator>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -889,7 +891,7 @@ inline bool u32regex_match(const std::wstring& s,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0));
|
||||
}
|
||||
#endif
|
||||
inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s,
|
||||
match_results<const UChar*>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -899,7 +901,7 @@ inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s,
|
||||
//
|
||||
// regex_match overloads that do not return what matched:
|
||||
//
|
||||
template <class BidiIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator>
|
||||
inline bool u32regex_match(BidiIterator first, BidiIterator last,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -907,7 +909,7 @@ inline bool u32regex_match(BidiIterator first, BidiIterator last,
|
||||
match_results<BidiIterator> m;
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(first, last, m, e, flags, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0));
|
||||
}
|
||||
inline bool u32regex_match(const UChar* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const UChar* p,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
@ -915,7 +917,7 @@ inline bool u32regex_match(const UChar* p,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast<std::integral_constant<int, 2> const*>(0));
|
||||
}
|
||||
#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX)
|
||||
inline bool u32regex_match(const wchar_t* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const wchar_t* p,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
@ -923,21 +925,21 @@ inline bool u32regex_match(const wchar_t* p,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0));
|
||||
}
|
||||
#endif
|
||||
inline bool u32regex_match(const char* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const char* p,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
match_results<const char*> m;
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
inline bool u32regex_match(const unsigned char* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const unsigned char* p,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
match_results<const unsigned char*> m;
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
inline bool u32regex_match(const std::string& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const std::string& s,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
@ -945,7 +947,7 @@ inline bool u32regex_match(const std::string& s,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
inline bool u32regex_match(const std::wstring& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const std::wstring& s,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
@ -953,7 +955,7 @@ inline bool u32regex_match(const std::wstring& s,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0));
|
||||
}
|
||||
#endif
|
||||
inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
@ -1011,7 +1013,7 @@ bool do_regex_search(BidiIterator first, BidiIterator last,
|
||||
}
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator, class Allocator>
|
||||
inline bool u32regex_search(BidiIterator first, BidiIterator last,
|
||||
match_results<BidiIterator, Allocator>& m,
|
||||
const u32regex& e,
|
||||
@ -1019,7 +1021,7 @@ inline bool u32regex_search(BidiIterator first, BidiIterator last,
|
||||
{
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, first, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0));
|
||||
}
|
||||
template <class BidiIterator, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator, class Allocator>
|
||||
inline bool u32regex_search(BidiIterator first, BidiIterator last,
|
||||
match_results<BidiIterator, Allocator>& m,
|
||||
const u32regex& e,
|
||||
@ -1028,7 +1030,7 @@ inline bool u32regex_search(BidiIterator first, BidiIterator last,
|
||||
{
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, base, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0));
|
||||
}
|
||||
inline bool u32regex_search(const UChar* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const UChar* p,
|
||||
match_results<const UChar*>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -1036,7 +1038,7 @@ inline bool u32regex_search(const UChar* p,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast<std::integral_constant<int, 2> const*>(0));
|
||||
}
|
||||
#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX)
|
||||
inline bool u32regex_search(const wchar_t* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const wchar_t* p,
|
||||
match_results<const wchar_t*>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -1044,21 +1046,21 @@ inline bool u32regex_search(const wchar_t* p,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0));
|
||||
}
|
||||
#endif
|
||||
inline bool u32regex_search(const char* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const char* p,
|
||||
match_results<const char*>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
inline bool u32regex_search(const unsigned char* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const unsigned char* p,
|
||||
match_results<const unsigned char*>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
inline bool u32regex_search(const std::string& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const std::string& s,
|
||||
match_results<std::string::const_iterator>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -1066,7 +1068,7 @@ inline bool u32regex_search(const std::string& s,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
inline bool u32regex_search(const std::wstring& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const std::wstring& s,
|
||||
match_results<std::wstring::const_iterator>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -1074,14 +1076,14 @@ inline bool u32regex_search(const std::wstring& s,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0));
|
||||
}
|
||||
#endif
|
||||
inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s,
|
||||
match_results<const UChar*>& m,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast<std::integral_constant<int, 2> const*>(0));
|
||||
}
|
||||
template <class BidiIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator>
|
||||
inline bool u32regex_search(BidiIterator first, BidiIterator last,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -1089,7 +1091,7 @@ inline bool u32regex_search(BidiIterator first, BidiIterator last,
|
||||
match_results<BidiIterator> m;
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, first, static_cast<std::integral_constant<int, sizeof(*first)> const*>(0));
|
||||
}
|
||||
inline bool u32regex_search(const UChar* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const UChar* p,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
@ -1097,7 +1099,7 @@ inline bool u32regex_search(const UChar* p,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast<std::integral_constant<int, 2> const*>(0));
|
||||
}
|
||||
#if !BOOST_REGEX_UCHAR_IS_WCHAR_T && !defined(BOOST_NO_WREGEX)
|
||||
inline bool u32regex_search(const wchar_t* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const wchar_t* p,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
@ -1105,21 +1107,21 @@ inline bool u32regex_search(const wchar_t* p,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0));
|
||||
}
|
||||
#endif
|
||||
inline bool u32regex_search(const char* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const char* p,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
match_results<const char*> m;
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
inline bool u32regex_search(const unsigned char* p,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const unsigned char* p,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
match_results<const unsigned char*> m;
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
inline bool u32regex_search(const std::string& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const std::string& s,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
@ -1127,7 +1129,7 @@ inline bool u32regex_search(const std::string& s,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<std::integral_constant<int, 1> const*>(0));
|
||||
}
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
inline bool u32regex_search(const std::wstring& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const std::wstring& s,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
@ -1135,7 +1137,7 @@ inline bool u32regex_search(const std::wstring& s,
|
||||
return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<std::integral_constant<int, sizeof(wchar_t)> const*>(0));
|
||||
}
|
||||
#endif
|
||||
inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s,
|
||||
BOOST_REGEX_MODULE_EXPORT inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s,
|
||||
const u32regex& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
@ -1258,7 +1260,7 @@ inline BaseIterator extract_output_base(const utf16_output_iterator<BaseIterator
|
||||
}
|
||||
} // BOOST_REGEX_DETAIL_NS
|
||||
|
||||
template <class OutputIterator, class BidirectionalIterator, class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class OutputIterator, class BidirectionalIterator, class charT>
|
||||
inline OutputIterator u32regex_replace(OutputIterator out,
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
@ -1277,7 +1279,7 @@ inline OutputIterator u32regex_replace(OutputIterator out,
|
||||
);
|
||||
}
|
||||
|
||||
template <class OutputIterator, class Iterator, class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class OutputIterator, class Iterator, class charT>
|
||||
inline OutputIterator u32regex_replace(OutputIterator out,
|
||||
Iterator first,
|
||||
Iterator last,
|
||||
@ -1296,7 +1298,7 @@ inline OutputIterator u32regex_replace(OutputIterator out,
|
||||
);
|
||||
}
|
||||
|
||||
template <class OutputIterator, class Iterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class OutputIterator, class Iterator>
|
||||
inline OutputIterator u32regex_replace(OutputIterator out,
|
||||
Iterator first,
|
||||
Iterator last,
|
||||
@ -1315,7 +1317,7 @@ inline OutputIterator u32regex_replace(OutputIterator out,
|
||||
);
|
||||
}
|
||||
|
||||
template <class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT>
|
||||
std::basic_string<charT> u32regex_replace(const std::basic_string<charT>& s,
|
||||
const u32regex& e,
|
||||
const charT* fmt,
|
||||
@ -1327,7 +1329,7 @@ std::basic_string<charT> u32regex_replace(const std::basic_string<charT>& s,
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT>
|
||||
std::basic_string<charT> u32regex_replace(const std::basic_string<charT>& s,
|
||||
const u32regex& e,
|
||||
const std::basic_string<charT>& fmt,
|
||||
|
@ -21,8 +21,10 @@
|
||||
#ifndef BOOST_REGEX_ITERATOR_CATEGORY_HPP
|
||||
#define BOOST_REGEX_ITERATOR_CATEGORY_HPP
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
namespace detail{
|
||||
|
@ -19,6 +19,10 @@
|
||||
#ifndef BOOST_REGEX_V5_ITERATOR_TRAITS_HPP
|
||||
#define BOOST_REGEX_V5_ITERATOR_TRAITS_HPP
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <iterator>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
|
@ -19,9 +19,11 @@
|
||||
#ifndef BOOST_REGEX_V5_MATCH_FLAGS
|
||||
#define BOOST_REGEX_V5_MATCH_FLAGS
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#ifdef __cplusplus
|
||||
# include <cstdint>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace boost{
|
||||
@ -35,7 +37,7 @@ namespace boost{
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef enum _match_flags
|
||||
BOOST_REGEX_MODULE_EXPORT typedef enum _match_flags
|
||||
{
|
||||
match_default = 0,
|
||||
match_not_bol = 1, /* first is not start of line */
|
||||
@ -89,22 +91,22 @@ typedef enum _match_flags
|
||||
|
||||
} match_flags;
|
||||
|
||||
typedef match_flags match_flag_type;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef match_flags match_flag_type;
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline match_flags operator&(match_flags m1, match_flags m2)
|
||||
BOOST_REGEX_MODULE_EXPORT inline match_flags operator&(match_flags m1, match_flags m2)
|
||||
{ return static_cast<match_flags>(static_cast<std::int32_t>(m1) & static_cast<std::int32_t>(m2)); }
|
||||
inline match_flags operator|(match_flags m1, match_flags m2)
|
||||
BOOST_REGEX_MODULE_EXPORT inline match_flags operator|(match_flags m1, match_flags m2)
|
||||
{ return static_cast<match_flags>(static_cast<std::int32_t>(m1) | static_cast<std::int32_t>(m2)); }
|
||||
inline match_flags operator^(match_flags m1, match_flags m2)
|
||||
BOOST_REGEX_MODULE_EXPORT inline match_flags operator^(match_flags m1, match_flags m2)
|
||||
{ return static_cast<match_flags>(static_cast<std::int32_t>(m1) ^ static_cast<std::int32_t>(m2)); }
|
||||
inline match_flags operator~(match_flags m1)
|
||||
BOOST_REGEX_MODULE_EXPORT inline match_flags operator~(match_flags m1)
|
||||
{ return static_cast<match_flags>(~static_cast<std::int32_t>(m1)); }
|
||||
inline match_flags& operator&=(match_flags& m1, match_flags m2)
|
||||
BOOST_REGEX_MODULE_EXPORT inline match_flags& operator&=(match_flags& m1, match_flags m2)
|
||||
{ m1 = m1&m2; return m1; }
|
||||
inline match_flags& operator|=(match_flags& m1, match_flags m2)
|
||||
BOOST_REGEX_MODULE_EXPORT inline match_flags& operator|=(match_flags& m1, match_flags m2)
|
||||
{ m1 = m1|m2; return m1; }
|
||||
inline match_flags& operator^=(match_flags& m1, match_flags m2)
|
||||
BOOST_REGEX_MODULE_EXPORT inline match_flags& operator^=(match_flags& m1, match_flags m2)
|
||||
{ m1 = m1^m2; return m1; }
|
||||
#endif
|
||||
|
||||
@ -113,36 +115,36 @@ inline match_flags& operator^=(match_flags& m1, match_flags m2)
|
||||
/*
|
||||
* import names into boost for backwards compatibility:
|
||||
*/
|
||||
using regex_constants::match_flag_type;
|
||||
using regex_constants::match_default;
|
||||
using regex_constants::match_not_bol;
|
||||
using regex_constants::match_not_eol;
|
||||
using regex_constants::match_not_bob;
|
||||
using regex_constants::match_not_eob;
|
||||
using regex_constants::match_not_bow;
|
||||
using regex_constants::match_not_eow;
|
||||
using regex_constants::match_not_dot_newline;
|
||||
using regex_constants::match_not_dot_null;
|
||||
using regex_constants::match_prev_avail;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_flag_type;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_default;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_not_bol;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_not_eol;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_not_bob;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_not_eob;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_not_bow;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_not_eow;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_not_dot_newline;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_not_dot_null;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_prev_avail;
|
||||
/* using regex_constants::match_init; */
|
||||
using regex_constants::match_any;
|
||||
using regex_constants::match_not_null;
|
||||
using regex_constants::match_continuous;
|
||||
using regex_constants::match_partial;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_any;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_not_null;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_continuous;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_partial;
|
||||
/*using regex_constants::match_stop; */
|
||||
using regex_constants::match_all;
|
||||
using regex_constants::match_perl;
|
||||
using regex_constants::match_posix;
|
||||
using regex_constants::match_nosubs;
|
||||
using regex_constants::match_extra;
|
||||
using regex_constants::match_single_line;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_all;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_perl;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_posix;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_nosubs;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_extra;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::match_single_line;
|
||||
/*using regex_constants::match_max; */
|
||||
using regex_constants::format_all;
|
||||
using regex_constants::format_sed;
|
||||
using regex_constants::format_perl;
|
||||
using regex_constants::format_default;
|
||||
using regex_constants::format_no_copy;
|
||||
using regex_constants::format_first_only;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::format_all;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::format_sed;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::format_perl;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::format_default;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::format_no_copy;
|
||||
BOOST_REGEX_MODULE_EXPORT using regex_constants::format_first_only;
|
||||
/*using regex_constants::format_is_if;*/
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
|
@ -19,6 +19,16 @@
|
||||
#ifndef BOOST_REGEX_V5_MATCH_RESULTS_HPP
|
||||
#define BOOST_REGEX_V5_MATCH_RESULTS_HPP
|
||||
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/sub_match.hpp>
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/regex_format.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
#pragma warning(push)
|
||||
@ -37,7 +47,7 @@ class named_subexpressions;
|
||||
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator, class Allocator>
|
||||
class match_results
|
||||
{
|
||||
private:
|
||||
@ -553,7 +563,7 @@ public:
|
||||
|
||||
void set_named_subs(std::shared_ptr<named_sub_type> subs)
|
||||
{
|
||||
m_named_subs = subs;
|
||||
m_named_subs = std::move(subs);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -666,13 +676,13 @@ void match_results<BidiIterator, Allocator>::maybe_assign(const match_results<B
|
||||
*this = m;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator, class Allocator>
|
||||
void swap(match_results<BidiIterator, Allocator>& a, match_results<BidiIterator, Allocator>& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
template <class charT, class traits, class BidiIterator, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits, class BidiIterator, class Allocator>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator << (std::basic_ostream<charT, traits>& os,
|
||||
const match_results<BidiIterator, Allocator>& s)
|
||||
|
@ -18,6 +18,8 @@
|
||||
#ifndef BOOST_REGEX_V5_MEM_BLOCK_CACHE_HPP
|
||||
#define BOOST_REGEX_V5_MEM_BLOCK_CACHE_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <new>
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
#include <mutex>
|
||||
@ -30,6 +32,8 @@
|
||||
#define BOOST_REGEX_ATOMIC_POINTER std::atomic
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define BOOST_REGEX_OBJECT_CACHE_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <list>
|
||||
@ -28,6 +29,7 @@
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
#include <mutex>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
|
@ -23,8 +23,10 @@
|
||||
#include <boost/regex/config.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
#endif
|
||||
#include <boost/regex/v5/error_type.hpp>
|
||||
#include <boost/regex/v5/regex_traits_defaults.hpp>
|
||||
|
||||
@ -37,7 +39,7 @@ namespace boost{
|
||||
#pragma warning(disable : 26812 4459)
|
||||
#endif
|
||||
#endif
|
||||
class regex_error : public std::runtime_error
|
||||
BOOST_REGEX_MODULE_EXPORT class regex_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0)
|
||||
@ -72,8 +74,8 @@ private:
|
||||
std::ptrdiff_t m_position;
|
||||
};
|
||||
|
||||
typedef regex_error bad_pattern;
|
||||
typedef regex_error bad_expression;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef regex_error bad_pattern;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef regex_error bad_expression;
|
||||
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
|
@ -12,7 +12,20 @@
|
||||
#ifndef BOOST_REGEX_MATCHER_HPP
|
||||
#define BOOST_REGEX_MATCHER_HPP
|
||||
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
#include <boost/regex/v5/regbase.hpp>
|
||||
#include <boost/regex/v5/iterator_category.hpp>
|
||||
#include <boost/regex/v5/states.hpp>
|
||||
#include <boost/regex/v5/regex_traits.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
#include <boost/throw_exception.hpp>
|
||||
#endif
|
||||
|
||||
#include <climits>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
# pragma warning(push)
|
||||
@ -28,25 +41,34 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
# define BOOST_REGEX_DETAIL_THROW(ex) boost::throw_exception(ex)
|
||||
#else
|
||||
# define BOOST_REGEX_DETAIL_THROW(ex) throw ex
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
//
|
||||
// error checking API:
|
||||
//
|
||||
inline void verify_options(boost::regex_constants::syntax_option_type, match_flag_type mf)
|
||||
inline void verify_options(boost::regex_constants::syntax_option_type, match_flag_type mf)
|
||||
{
|
||||
auto is_perl = (mf & match_perl);
|
||||
auto is_posix = (mf & match_posix);
|
||||
|
||||
if (is_perl && is_posix)
|
||||
{
|
||||
BOOST_REGEX_DETAIL_THROW(std::logic_error("Usage Error: Can't mix Perl and POSIX matching rules"));
|
||||
}
|
||||
|
||||
//
|
||||
// can't mix match_extra with POSIX matching rules:
|
||||
//
|
||||
if ((mf & match_extra) && (mf & match_posix))
|
||||
if ((mf & match_extra) && is_posix)
|
||||
{
|
||||
std::logic_error msg("Usage Error: Can't mix regular expression captures with POSIX matching rules");
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
throw_exception(msg);
|
||||
#else
|
||||
throw msg;
|
||||
#endif
|
||||
BOOST_REGEX_DETAIL_THROW(std::logic_error("Usage Error: Can't mix regular expression captures with POSIX matching rules"));
|
||||
}
|
||||
}
|
||||
//
|
||||
@ -558,6 +580,33 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class Matcher>
|
||||
inline bool factory_match(Matcher& m)
|
||||
{
|
||||
return m.match();
|
||||
}
|
||||
template <class Matcher>
|
||||
inline bool factory_find(Matcher& m)
|
||||
{
|
||||
return m.find();
|
||||
}
|
||||
|
||||
#ifdef BOOST_REGEX_AS_MODULE
|
||||
bool factory_match(perl_matcher<const char*, match_results<const char*>::allocator_type, regex::traits_type>& m);
|
||||
bool factory_match(perl_matcher<const wchar_t*, match_results<const wchar_t*>::allocator_type, wregex::traits_type>& m);
|
||||
bool factory_match(perl_matcher<std::string::const_iterator, match_results<std::string::const_iterator>::allocator_type, regex::traits_type>& m);
|
||||
bool factory_match(perl_matcher<std::wstring::const_iterator, match_results<std::wstring::const_iterator>::allocator_type, wregex::traits_type>& m);
|
||||
bool factory_match(perl_matcher<std::string::iterator, match_results<std::string::iterator>::allocator_type, regex::traits_type>& m);
|
||||
bool factory_match(perl_matcher<std::wstring::iterator, match_results<std::wstring::iterator>::allocator_type, wregex::traits_type>& m);
|
||||
|
||||
bool factory_find(perl_matcher<const char*, match_results<const char*>::allocator_type, regex::traits_type>& m);
|
||||
bool factory_find(perl_matcher<const wchar_t*, match_results<const wchar_t*>::allocator_type, wregex::traits_type>& m);
|
||||
bool factory_find(perl_matcher<std::string::const_iterator, match_results<std::string::const_iterator>::allocator_type, regex::traits_type>& m);
|
||||
bool factory_find(perl_matcher<std::wstring::const_iterator, match_results<std::wstring::const_iterator>::allocator_type, wregex::traits_type>& m);
|
||||
bool factory_find(perl_matcher<std::string::iterator, match_results<std::string::iterator>::allocator_type, regex::traits_type>& m);
|
||||
bool factory_find(perl_matcher<std::wstring::iterator, match_results<std::wstring::iterator>::allocator_type, wregex::traits_type>& m);
|
||||
#endif
|
||||
|
||||
} // namespace BOOST_REGEX_DETAIL_NS
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
|
@ -20,6 +20,22 @@
|
||||
#ifndef BOOST_REGEX_V5_PERL_MATCHER_COMMON_HPP
|
||||
#define BOOST_REGEX_V5_PERL_MATCHER_COMMON_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#include <boost/regex/v5/perl_matcher.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
# pragma warning(push)
|
||||
#pragma warning(disable:4459)
|
||||
@ -44,12 +60,7 @@ void perl_matcher<BidiIterator, Allocator, traits>::construct_init(const basic_r
|
||||
if(e.empty())
|
||||
{
|
||||
// precondition failure: e is not a valid regex.
|
||||
std::invalid_argument ex("Invalid regular expression object");
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
boost::throw_exception(ex);
|
||||
#else
|
||||
throw e;
|
||||
#endif
|
||||
BOOST_REGEX_DETAIL_THROW(std::invalid_argument("Invalid regular expression object"));
|
||||
}
|
||||
pstate = 0;
|
||||
m_match_flags = f;
|
||||
@ -82,7 +93,11 @@ void perl_matcher<BidiIterator, Allocator, traits>::construct_init(const basic_r
|
||||
match_any_mask = static_cast<unsigned char>((f & match_not_dot_newline) ? BOOST_REGEX_DETAIL_NS::test_not_newline : BOOST_REGEX_DETAIL_NS::test_newline);
|
||||
// Disable match_any if requested in the state machine:
|
||||
if(e.get_data().m_disable_match_any)
|
||||
{
|
||||
if (m_match_flags & match_posix)
|
||||
BOOST_REGEX_DETAIL_THROW(std::logic_error("Invalid regex for POSIX-style matching"));
|
||||
m_match_flags &= regex_constants::match_not_any;
|
||||
}
|
||||
}
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
# pragma warning(pop)
|
||||
|
@ -20,6 +20,18 @@
|
||||
#ifndef BOOST_REGEX_V5_PERL_MATCHER_NON_RECURSIVE_HPP
|
||||
#define BOOST_REGEX_V5_PERL_MATCHER_NON_RECURSIVE_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#include <boost/regex/v5/perl_matcher.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/regex/v5/mem_block_cache.hpp>
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
@ -1204,7 +1216,10 @@ bool perl_matcher<BidiIterator, Allocator, traits>::skip_until_paren(int index,
|
||||
else if(pstate->type == syntax_element_startmark)
|
||||
{
|
||||
int idx = static_cast<const re_brace*>(pstate)->index;
|
||||
pstate = pstate->next.p;
|
||||
if(idx > 0)
|
||||
match_startmark();
|
||||
else
|
||||
pstate = pstate->next.p;
|
||||
skip_until_paren(idx, false);
|
||||
continue;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
//
|
||||
namespace regex_constants{
|
||||
|
||||
enum flag_type_
|
||||
BOOST_REGEX_MODULE_EXPORT enum flag_type_
|
||||
{
|
||||
|
||||
no_except = ::boost::regbase::no_except,
|
||||
@ -148,7 +148,7 @@ namespace regex_constants{
|
||||
JavaScript = normal,
|
||||
JScript = normal
|
||||
};
|
||||
typedef ::boost::regbase::flag_type syntax_option_type;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef ::boost::regbase::flag_type syntax_option_type;
|
||||
|
||||
} // namespace regex_constants
|
||||
|
||||
|
@ -46,17 +46,17 @@
|
||||
|
||||
namespace boost{
|
||||
#ifdef BOOST_REGEX_NO_FWD
|
||||
typedef basic_regex<char, regex_traits<char> > regex;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef basic_regex<char, regex_traits<char> > regex;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
typedef basic_regex<wchar_t, regex_traits<wchar_t> > wregex;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef basic_regex<wchar_t, regex_traits<wchar_t> > wregex;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef match_results<const char*> cmatch;
|
||||
typedef match_results<std::string::const_iterator> smatch;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef match_results<const char*> cmatch;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef match_results<std::string::const_iterator> smatch;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
typedef match_results<const wchar_t*> wcmatch;
|
||||
typedef match_results<std::wstring::const_iterator> wsmatch;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef match_results<const wchar_t*> wcmatch;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef match_results<std::wstring::const_iterator> wsmatch;
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
@ -21,15 +21,20 @@
|
||||
#ifndef BOOST_REGEX_FORMAT_HPP
|
||||
#define BOOST_REGEX_FORMAT_HPP
|
||||
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/sub_match.hpp>
|
||||
#include <boost/regex/v5/regex_traits_defaults.hpp>
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
//
|
||||
// Forward declaration:
|
||||
//
|
||||
template <class BidiIterator, class Allocator = typename std::vector<sub_match<BidiIterator> >::allocator_type >
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator, class Allocator = typename std::vector<sub_match<BidiIterator> >::allocator_type >
|
||||
class match_results;
|
||||
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
@ -1095,7 +1100,7 @@ struct compute_functor_type
|
||||
|
||||
} // namespace BOOST_REGEX_DETAIL_NS
|
||||
|
||||
template <class OutputIterator, class Iterator, class Allocator, class Functor>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class OutputIterator, class Iterator, class Allocator, class Functor>
|
||||
inline OutputIterator regex_format(OutputIterator out,
|
||||
const match_results<Iterator, Allocator>& m,
|
||||
Functor fmt,
|
||||
@ -1105,7 +1110,7 @@ inline OutputIterator regex_format(OutputIterator out,
|
||||
return m.format(out, fmt, flags);
|
||||
}
|
||||
|
||||
template <class Iterator, class Allocator, class Functor>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class Iterator, class Allocator, class Functor>
|
||||
inline std::basic_string<typename match_results<Iterator, Allocator>::char_type> regex_format(const match_results<Iterator, Allocator>& m,
|
||||
Functor fmt,
|
||||
match_flag_type flags = format_all)
|
||||
|
@ -36,30 +36,30 @@
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT>
|
||||
class cpp_regex_traits;
|
||||
template <class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT>
|
||||
struct c_regex_traits;
|
||||
template <class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT>
|
||||
class w32_regex_traits;
|
||||
|
||||
#ifdef BOOST_REGEX_USE_WIN32_LOCALE
|
||||
template <class charT, class implementationT = w32_regex_traits<charT> >
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class implementationT = w32_regex_traits<charT> >
|
||||
struct regex_traits;
|
||||
#elif defined(BOOST_REGEX_USE_CPP_LOCALE)
|
||||
template <class charT, class implementationT = cpp_regex_traits<charT> >
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class implementationT = cpp_regex_traits<charT> >
|
||||
struct regex_traits;
|
||||
#else
|
||||
template <class charT, class implementationT = c_regex_traits<charT> >
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class implementationT = c_regex_traits<charT> >
|
||||
struct regex_traits;
|
||||
#endif
|
||||
|
||||
template <class charT, class traits = regex_traits<charT> >
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits = regex_traits<charT> >
|
||||
class basic_regex;
|
||||
|
||||
typedef basic_regex<char, regex_traits<char> > regex;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef basic_regex<char, regex_traits<char> > regex;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
typedef basic_regex<wchar_t, regex_traits<wchar_t> > wregex;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef basic_regex<wchar_t, regex_traits<wchar_t> > wregex;
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
@ -19,6 +19,10 @@
|
||||
#ifndef BOOST_REGEX_V5_REGEX_GREP_HPP
|
||||
#define BOOST_REGEX_V5_REGEX_GREP_HPP
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
#include <boost/regex/v5/perl_matcher.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
@ -26,7 +30,7 @@ namespace boost{
|
||||
// regex_grep:
|
||||
// find all non-overlapping matches within the sequence first last:
|
||||
//
|
||||
template <class Predicate, class BidiIterator, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class Predicate, class BidiIterator, class charT, class traits>
|
||||
inline unsigned int regex_grep(Predicate foo,
|
||||
BidiIterator first,
|
||||
BidiIterator last,
|
||||
@ -41,7 +45,7 @@ inline unsigned int regex_grep(Predicate foo,
|
||||
match_results<BidiIterator> m;
|
||||
BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, match_allocator_type, traits> matcher(first, last, m, e, flags, first);
|
||||
unsigned int count = 0;
|
||||
while(matcher.find())
|
||||
while(BOOST_REGEX_DETAIL_NS::factory_find(matcher))
|
||||
{
|
||||
++count;
|
||||
if(0 == foo(m))
|
||||
@ -56,7 +60,7 @@ inline unsigned int regex_grep(Predicate foo,
|
||||
// a non-NULL one at the same position:
|
||||
match_results<BidiIterator, match_allocator_type> m2(m);
|
||||
matcher.setf(match_not_null | match_continuous);
|
||||
if(matcher.find())
|
||||
if(BOOST_REGEX_DETAIL_NS::factory_find(matcher))
|
||||
{
|
||||
++count;
|
||||
if(0 == foo(m))
|
||||
@ -76,7 +80,7 @@ inline unsigned int regex_grep(Predicate foo,
|
||||
//
|
||||
// regex_grep convenience interfaces:
|
||||
//
|
||||
template <class Predicate, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class Predicate, class charT, class traits>
|
||||
inline unsigned int regex_grep(Predicate foo, const charT* str,
|
||||
const basic_regex<charT, traits>& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -84,7 +88,7 @@ inline unsigned int regex_grep(Predicate foo, const charT* str,
|
||||
return regex_grep(foo, str, str + traits::length(str), e, flags);
|
||||
}
|
||||
|
||||
template <class Predicate, class ST, class SA, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class Predicate, class ST, class SA, class charT, class traits>
|
||||
inline unsigned int regex_grep(Predicate foo, const std::basic_string<charT, ST, SA>& s,
|
||||
const basic_regex<charT, traits>& e,
|
||||
match_flag_type flags = match_default)
|
||||
|
@ -19,7 +19,11 @@
|
||||
#ifndef BOOST_REGEX_V5_REGEX_ITERATOR_HPP
|
||||
#define BOOST_REGEX_V5_REGEX_ITERATOR_HPP
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
@ -72,7 +76,7 @@ private:
|
||||
regex_iterator_implementation& operator=(const regex_iterator_implementation&);
|
||||
};
|
||||
|
||||
template <class BidirectionalIterator,
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidirectionalIterator,
|
||||
class charT = typename std::iterator_traits<BidirectionalIterator>::value_type,
|
||||
class traits = regex_traits<charT> >
|
||||
class regex_iterator
|
||||
@ -148,20 +152,20 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
typedef regex_iterator<const char*> cregex_iterator;
|
||||
typedef regex_iterator<std::string::const_iterator> sregex_iterator;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef regex_iterator<const char*> cregex_iterator;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef regex_iterator<std::string::const_iterator> sregex_iterator;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
typedef regex_iterator<const wchar_t*> wcregex_iterator;
|
||||
typedef regex_iterator<std::wstring::const_iterator> wsregex_iterator;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef regex_iterator<const wchar_t*> wcregex_iterator;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef regex_iterator<std::wstring::const_iterator> wsregex_iterator;
|
||||
#endif
|
||||
|
||||
// make_regex_iterator:
|
||||
template <class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits>
|
||||
inline regex_iterator<const charT*, charT, traits> make_regex_iterator(const charT* p, const basic_regex<charT, traits>& e, regex_constants::match_flag_type m = regex_constants::match_default)
|
||||
{
|
||||
return regex_iterator<const charT*, charT, traits>(p, p+traits::length(p), e, m);
|
||||
}
|
||||
template <class charT, class traits, class ST, class SA>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits, class ST, class SA>
|
||||
inline regex_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits> make_regex_iterator(const std::basic_string<charT, ST, SA>& p, const basic_regex<charT, traits>& e, regex_constants::match_flag_type m = regex_constants::match_default)
|
||||
{
|
||||
return regex_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits>(p.begin(), p.end(), e, m);
|
||||
|
@ -22,6 +22,9 @@
|
||||
#ifndef BOOST_REGEX_MATCH_HPP
|
||||
#define BOOST_REGEX_MATCH_HPP
|
||||
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
#include <boost/regex/v5/perl_matcher.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
//
|
||||
@ -29,16 +32,16 @@ namespace boost{
|
||||
// returns true if the specified regular expression matches
|
||||
// the whole of the input. Fills in what matched in m.
|
||||
//
|
||||
template <class BidiIterator, class Allocator, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator, class Allocator, class charT, class traits>
|
||||
bool regex_match(BidiIterator first, BidiIterator last,
|
||||
match_results<BidiIterator, Allocator>& m,
|
||||
const basic_regex<charT, traits>& e,
|
||||
match_flag_type flags = match_default)
|
||||
{
|
||||
BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, first);
|
||||
return matcher.match();
|
||||
return BOOST_REGEX_DETAIL_NS::factory_match(matcher);
|
||||
}
|
||||
template <class iterator, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class iterator, class charT, class traits>
|
||||
bool regex_match(iterator first, iterator last,
|
||||
const basic_regex<charT, traits>& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -49,7 +52,7 @@ bool regex_match(iterator first, iterator last,
|
||||
//
|
||||
// query_match convenience interfaces:
|
||||
//
|
||||
template <class charT, class Allocator, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class Allocator, class traits>
|
||||
inline bool regex_match(const charT* str,
|
||||
match_results<const charT*, Allocator>& m,
|
||||
const basic_regex<charT, traits>& e,
|
||||
@ -58,7 +61,7 @@ inline bool regex_match(const charT* str,
|
||||
return regex_match(str, str + traits::length(str), m, e, flags);
|
||||
}
|
||||
|
||||
template <class ST, class SA, class Allocator, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class ST, class SA, class Allocator, class charT, class traits>
|
||||
inline bool regex_match(const std::basic_string<charT, ST, SA>& s,
|
||||
match_results<typename std::basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
|
||||
const basic_regex<charT, traits>& e,
|
||||
@ -66,7 +69,7 @@ inline bool regex_match(const std::basic_string<charT, ST, SA>& s,
|
||||
{
|
||||
return regex_match(s.begin(), s.end(), m, e, flags);
|
||||
}
|
||||
template <class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits>
|
||||
inline bool regex_match(const charT* str,
|
||||
const basic_regex<charT, traits>& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -75,7 +78,7 @@ inline bool regex_match(const charT* str,
|
||||
return regex_match(str, str + traits::length(str), m, e, flags | regex_constants::match_any);
|
||||
}
|
||||
|
||||
template <class ST, class SA, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class ST, class SA, class charT, class traits>
|
||||
inline bool regex_match(const std::basic_string<charT, ST, SA>& s,
|
||||
const basic_regex<charT, traits>& e,
|
||||
match_flag_type flags = match_default)
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <class OutputIterator, class Iterator, class traits, class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class OutputIterator, class Iterator, class traits, class charT>
|
||||
inline OutputIterator regex_merge(OutputIterator out,
|
||||
Iterator first,
|
||||
Iterator last,
|
||||
@ -35,7 +35,7 @@ inline OutputIterator regex_merge(OutputIterator out,
|
||||
return regex_replace(out, first, last, e, fmt, flags);
|
||||
}
|
||||
|
||||
template <class OutputIterator, class Iterator, class traits, class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class OutputIterator, class Iterator, class traits, class charT>
|
||||
inline OutputIterator regex_merge(OutputIterator out,
|
||||
Iterator first,
|
||||
Iterator last,
|
||||
@ -46,7 +46,7 @@ inline OutputIterator regex_merge(OutputIterator out,
|
||||
return regex_merge(out, first, last, e, fmt.c_str(), flags);
|
||||
}
|
||||
|
||||
template <class traits, class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class traits, class charT>
|
||||
inline std::basic_string<charT> regex_merge(const std::basic_string<charT>& s,
|
||||
const basic_regex<charT, traits>& e,
|
||||
const charT* fmt,
|
||||
@ -55,7 +55,7 @@ inline std::basic_string<charT> regex_merge(const std::basic_string<charT>& s,
|
||||
return regex_replace(s, e, fmt, flags);
|
||||
}
|
||||
|
||||
template <class traits, class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class traits, class charT>
|
||||
inline std::basic_string<charT> regex_merge(const std::basic_string<charT>& s,
|
||||
const basic_regex<charT, traits>& e,
|
||||
const std::basic_string<charT>& fmt,
|
||||
|
@ -25,8 +25,11 @@
|
||||
#include <boost/regex/config.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
@ -22,9 +22,13 @@
|
||||
#define BOOST_REGEX_V5_REGEX_REPLACE_HPP
|
||||
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/regex_iterator.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <class OutputIterator, class BidirectionalIterator, class traits, class charT, class Formatter>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class OutputIterator, class BidirectionalIterator, class traits, class charT, class Formatter>
|
||||
OutputIterator regex_replace(OutputIterator out,
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
@ -58,7 +62,7 @@ OutputIterator regex_replace(OutputIterator out,
|
||||
return out;
|
||||
}
|
||||
|
||||
template <class traits, class charT, class Formatter>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class traits, class charT, class Formatter>
|
||||
std::basic_string<charT> regex_replace(const std::basic_string<charT>& s,
|
||||
const basic_regex<charT, traits>& e,
|
||||
Formatter fmt,
|
||||
|
@ -20,9 +20,12 @@
|
||||
#define BOOST_REGEX_V5_REGEX_SEARCH_HPP
|
||||
|
||||
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
#include <boost/regex/v5/perl_matcher.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <class BidiIterator, class Allocator, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator, class Allocator, class charT, class traits>
|
||||
bool regex_search(BidiIterator first, BidiIterator last,
|
||||
match_results<BidiIterator, Allocator>& m,
|
||||
const basic_regex<charT, traits>& e,
|
||||
@ -31,7 +34,7 @@ bool regex_search(BidiIterator first, BidiIterator last,
|
||||
return regex_search(first, last, m, e, flags, first);
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator, class Allocator, class charT, class traits>
|
||||
bool regex_search(BidiIterator first, BidiIterator last,
|
||||
match_results<BidiIterator, Allocator>& m,
|
||||
const basic_regex<charT, traits>& e,
|
||||
@ -42,13 +45,13 @@ bool regex_search(BidiIterator first, BidiIterator last,
|
||||
return false;
|
||||
|
||||
BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, base);
|
||||
return matcher.find();
|
||||
return BOOST_REGEX_DETAIL_NS::factory_find(matcher);
|
||||
}
|
||||
|
||||
//
|
||||
// regex_search convenience interfaces:
|
||||
//
|
||||
template <class charT, class Allocator, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class Allocator, class traits>
|
||||
inline bool regex_search(const charT* str,
|
||||
match_results<const charT*, Allocator>& m,
|
||||
const basic_regex<charT, traits>& e,
|
||||
@ -57,7 +60,7 @@ inline bool regex_search(const charT* str,
|
||||
return regex_search(str, str + traits::length(str), m, e, flags);
|
||||
}
|
||||
|
||||
template <class ST, class SA, class Allocator, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class ST, class SA, class Allocator, class charT, class traits>
|
||||
inline bool regex_search(const std::basic_string<charT, ST, SA>& s,
|
||||
match_results<typename std::basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
|
||||
const basic_regex<charT, traits>& e,
|
||||
@ -66,7 +69,7 @@ inline bool regex_search(const std::basic_string<charT, ST, SA>& s,
|
||||
return regex_search(s.begin(), s.end(), m, e, flags);
|
||||
}
|
||||
|
||||
template <class BidiIterator, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator, class charT, class traits>
|
||||
bool regex_search(BidiIterator first, BidiIterator last,
|
||||
const basic_regex<charT, traits>& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -77,10 +80,10 @@ bool regex_search(BidiIterator first, BidiIterator last,
|
||||
match_results<BidiIterator> m;
|
||||
typedef typename match_results<BidiIterator>::allocator_type match_alloc_type;
|
||||
BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, match_alloc_type, traits> matcher(first, last, m, e, flags | regex_constants::match_any, first);
|
||||
return matcher.find();
|
||||
return BOOST_REGEX_DETAIL_NS::factory_find(matcher);
|
||||
}
|
||||
|
||||
template <class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits>
|
||||
inline bool regex_search(const charT* str,
|
||||
const basic_regex<charT, traits>& e,
|
||||
match_flag_type flags = match_default)
|
||||
@ -88,7 +91,7 @@ inline bool regex_search(const charT* str,
|
||||
return regex_search(str, str + traits::length(str), e, flags);
|
||||
}
|
||||
|
||||
template <class ST, class SA, class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class ST, class SA, class charT, class traits>
|
||||
inline bool regex_search(const std::basic_string<charT, ST, SA>& s,
|
||||
const basic_regex<charT, traits>& e,
|
||||
match_flag_type flags = match_default)
|
||||
|
@ -21,6 +21,9 @@
|
||||
#ifndef BOOST_REGEX_SPLIT_HPP
|
||||
#define BOOST_REGEX_SPLIT_HPP
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
@ -90,7 +93,7 @@ bool split_pred<OutputIterator, charT, Traits1, Alloc1>::operator()
|
||||
|
||||
} // namespace BOOST_REGEX_DETAIL_NS
|
||||
|
||||
template <class OutputIterator, class charT, class Traits1, class Alloc1, class Traits2>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class OutputIterator, class charT, class Traits1, class Alloc1, class Traits2>
|
||||
std::size_t regex_split(OutputIterator out,
|
||||
std::basic_string<charT, Traits1, Alloc1>& s,
|
||||
const basic_regex<charT, Traits2>& e,
|
||||
@ -125,7 +128,7 @@ std::size_t regex_split(OutputIterator out,
|
||||
return init_size - max_split;
|
||||
}
|
||||
|
||||
template <class OutputIterator, class charT, class Traits1, class Alloc1, class Traits2>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class OutputIterator, class charT, class Traits1, class Alloc1, class Traits2>
|
||||
inline std::size_t regex_split(OutputIterator out,
|
||||
std::basic_string<charT, Traits1, Alloc1>& s,
|
||||
const basic_regex<charT, Traits2>& e,
|
||||
@ -134,7 +137,7 @@ inline std::size_t regex_split(OutputIterator out,
|
||||
return regex_split(out, s, e, flags, UINT_MAX);
|
||||
}
|
||||
|
||||
template <class OutputIterator, class charT, class Traits1, class Alloc1>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class OutputIterator, class charT, class Traits1, class Alloc1>
|
||||
inline std::size_t regex_split(OutputIterator out,
|
||||
std::basic_string<charT, Traits1, Alloc1>& s)
|
||||
{
|
||||
|
@ -19,7 +19,12 @@
|
||||
#ifndef BOOST_REGEX_V5_REGEX_TOKEN_ITERATOR_HPP
|
||||
#define BOOST_REGEX_V5_REGEX_TOKEN_ITERATOR_HPP
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
#include <boost/regex/v5/sub_match.hpp>
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
@ -120,7 +125,7 @@ private:
|
||||
regex_token_iterator_implementation& operator=(const regex_token_iterator_implementation&);
|
||||
};
|
||||
|
||||
template <class BidirectionalIterator,
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidirectionalIterator,
|
||||
class charT = typename std::iterator_traits<BidirectionalIterator>::value_type,
|
||||
class traits = regex_traits<charT> >
|
||||
class regex_token_iterator
|
||||
@ -208,39 +213,39 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
typedef regex_token_iterator<const char*> cregex_token_iterator;
|
||||
typedef regex_token_iterator<std::string::const_iterator> sregex_token_iterator;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef regex_token_iterator<const char*> cregex_token_iterator;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef regex_token_iterator<std::string::const_iterator> sregex_token_iterator;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
|
||||
typedef regex_token_iterator<std::wstring::const_iterator> wsregex_token_iterator;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef regex_token_iterator<std::wstring::const_iterator> wsregex_token_iterator;
|
||||
#endif
|
||||
|
||||
template <class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits>
|
||||
inline regex_token_iterator<const charT*, charT, traits> make_regex_token_iterator(const charT* p, const basic_regex<charT, traits>& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default)
|
||||
{
|
||||
return regex_token_iterator<const charT*, charT, traits>(p, p+traits::length(p), e, submatch, m);
|
||||
}
|
||||
template <class charT, class traits, class ST, class SA>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits, class ST, class SA>
|
||||
inline regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string<charT, ST, SA>& p, const basic_regex<charT, traits>& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default)
|
||||
{
|
||||
return regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m);
|
||||
}
|
||||
template <class charT, class traits, std::size_t N>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits, std::size_t N>
|
||||
inline regex_token_iterator<const charT*, charT, traits> make_regex_token_iterator(const charT* p, const basic_regex<charT, traits>& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
|
||||
{
|
||||
return regex_token_iterator<const charT*, charT, traits>(p, p+traits::length(p), e, submatch, m);
|
||||
}
|
||||
template <class charT, class traits, class ST, class SA, std::size_t N>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits, class ST, class SA, std::size_t N>
|
||||
inline regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string<charT, ST, SA>& p, const basic_regex<charT, traits>& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
|
||||
{
|
||||
return regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m);
|
||||
}
|
||||
template <class charT, class traits>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits>
|
||||
inline regex_token_iterator<const charT*, charT, traits> make_regex_token_iterator(const charT* p, const basic_regex<charT, traits>& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
|
||||
{
|
||||
return regex_token_iterator<const charT*, charT, traits>(p, p+traits::length(p), e, submatch, m);
|
||||
}
|
||||
template <class charT, class traits, class ST, class SA>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits, class ST, class SA>
|
||||
inline regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string<charT, ST, SA>& p, const basic_regex<charT, traits>& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
|
||||
{
|
||||
return regex_token_iterator<typename std::basic_string<charT, ST, SA>::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m);
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <class charT, class implementationT >
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class implementationT >
|
||||
struct regex_traits : public implementationT
|
||||
{
|
||||
regex_traits() : implementationT() {}
|
||||
|
@ -24,12 +24,14 @@
|
||||
#include <boost/regex/v5/syntax_type.hpp>
|
||||
#include <boost/regex/v5/error_type.hpp>
|
||||
#include <boost/regex/v5/regex_workaround.hpp>
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <type_traits>
|
||||
#include <cstdint>
|
||||
#include <cctype>
|
||||
#include <locale>
|
||||
#include <cwctype>
|
||||
#include <limits>
|
||||
#endif
|
||||
|
||||
namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
|
@ -20,9 +20,11 @@
|
||||
#define BOOST_REGEX_WORKAROUND_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
@ -19,6 +19,13 @@
|
||||
#ifndef BOOST_REGEX_V5_STATES_HPP
|
||||
#define BOOST_REGEX_V5_STATES_HPP
|
||||
|
||||
#include <boost/regex/v5/regex_raw_buffer.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <climits>
|
||||
#include <cstddef>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
|
@ -19,9 +19,14 @@
|
||||
#ifndef BOOST_REGEX_V5_SUB_MATCH_HPP
|
||||
#define BOOST_REGEX_V5_SUB_MATCH_HPP
|
||||
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <class BidiIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator>
|
||||
struct sub_match : public std::pair<BidiIterator, BidiIterator>
|
||||
{
|
||||
typedef typename std::iterator_traits<BidiIterator>::value_type value_type;
|
||||
@ -145,167 +150,167 @@ public:
|
||||
BidiIterator end()const { return this->second; }
|
||||
};
|
||||
|
||||
typedef sub_match<const char*> csub_match;
|
||||
typedef sub_match<std::string::const_iterator> ssub_match;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef sub_match<const char*> csub_match;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef sub_match<std::string::const_iterator> ssub_match;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
typedef sub_match<const wchar_t*> wcsub_match;
|
||||
typedef sub_match<std::wstring::const_iterator> wssub_match;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef sub_match<const wchar_t*> wcsub_match;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef sub_match<std::wstring::const_iterator> wssub_match;
|
||||
#endif
|
||||
|
||||
// comparison to std::basic_string<> part 1:
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator == (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return s.compare(m.str()) == 0; }
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator != (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return s.compare(m.str()) != 0; }
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator < (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return s.compare(m.str()) < 0; }
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator <= (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return s.compare(m.str()) <= 0; }
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator >= (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return s.compare(m.str()) >= 0; }
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator > (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return s.compare(m.str()) > 0; }
|
||||
// comparison to std::basic_string<> part 2:
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator == (const sub_match<RandomAccessIterator>& m,
|
||||
const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
|
||||
{ return m.str().compare(s) == 0; }
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator != (const sub_match<RandomAccessIterator>& m,
|
||||
const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
|
||||
{ return m.str().compare(s) != 0; }
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator < (const sub_match<RandomAccessIterator>& m,
|
||||
const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
|
||||
{ return m.str().compare(s) < 0; }
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator > (const sub_match<RandomAccessIterator>& m,
|
||||
const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
|
||||
{ return m.str().compare(s) > 0; }
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator <= (const sub_match<RandomAccessIterator>& m,
|
||||
const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
|
||||
{ return m.str().compare(s) <= 0; }
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline bool operator >= (const sub_match<RandomAccessIterator>& m,
|
||||
const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
|
||||
{ return m.str().compare(s) >= 0; }
|
||||
// comparison to const charT* part 1:
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator == (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
|
||||
{ return m.str().compare(s) == 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator != (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
|
||||
{ return m.str().compare(s) != 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator > (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
|
||||
{ return m.str().compare(s) > 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator < (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
|
||||
{ return m.str().compare(s) < 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator >= (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
|
||||
{ return m.str().compare(s) >= 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator <= (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
|
||||
{ return m.str().compare(s) <= 0; }
|
||||
// comparison to const charT* part 2:
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator == (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(s) == 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator != (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(s) != 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator < (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(s) > 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator > (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(s) < 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator <= (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(s) >= 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator >= (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(s) <= 0; }
|
||||
|
||||
// comparison to const charT& part 1:
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator == (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) == 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator != (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) != 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator > (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) > 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator < (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) < 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator >= (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) >= 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator <= (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) <= 0; }
|
||||
// comparison to const charT* part 2:
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator == (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) == 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator != (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) != 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator < (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) > 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator > (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) < 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator <= (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) >= 0; }
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline bool operator >= (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
{ return m.str().compare(0, m.length(), &s, 1) <= 0; }
|
||||
|
||||
// addition operators:
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
|
||||
operator + (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
@ -314,7 +319,7 @@ operator + (const std::basic_string<typename std::iterator_traits<RandomAccessIt
|
||||
result.reserve(s.size() + m.length() + 1);
|
||||
return result.append(s).append(m.first, m.second);
|
||||
}
|
||||
template <class RandomAccessIterator, class traits, class Allocator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
|
||||
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
|
||||
operator + (const sub_match<RandomAccessIterator>& m,
|
||||
const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
|
||||
@ -323,7 +328,7 @@ operator + (const sub_match<RandomAccessIterator>& m,
|
||||
result.reserve(s.size() + m.length() + 1);
|
||||
return result.append(m.first, m.second).append(s);
|
||||
}
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type>
|
||||
operator + (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
@ -332,7 +337,7 @@ operator + (typename std::iterator_traits<RandomAccessIterator>::value_type cons
|
||||
result.reserve(std::char_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1);
|
||||
return result.append(s).append(m.first, m.second);
|
||||
}
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type>
|
||||
operator + (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const * s)
|
||||
@ -341,7 +346,7 @@ operator + (const sub_match<RandomAccessIterator>& m,
|
||||
result.reserve(std::char_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1);
|
||||
return result.append(m.first, m.second).append(s);
|
||||
}
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type>
|
||||
operator + (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
|
||||
const sub_match<RandomAccessIterator>& m)
|
||||
@ -350,7 +355,7 @@ operator + (typename std::iterator_traits<RandomAccessIterator>::value_type cons
|
||||
result.reserve(m.length() + 2);
|
||||
return result.append(1, s).append(m.first, m.second);
|
||||
}
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type>
|
||||
operator + (const sub_match<RandomAccessIterator>& m,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
|
||||
@ -359,7 +364,7 @@ operator + (const sub_match<RandomAccessIterator>& m,
|
||||
result.reserve(m.length() + 2);
|
||||
return result.append(m.first, m.second).append(1, s);
|
||||
}
|
||||
template <class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
|
||||
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type>
|
||||
operator + (const sub_match<RandomAccessIterator>& m1,
|
||||
const sub_match<RandomAccessIterator>& m2)
|
||||
@ -368,7 +373,7 @@ operator + (const sub_match<RandomAccessIterator>& m1,
|
||||
result.reserve(m1.length() + m2.length() + 1);
|
||||
return result.append(m1.first, m1.second).append(m2.first, m2.second);
|
||||
}
|
||||
template <class charT, class traits, class RandomAccessIterator>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits, class RandomAccessIterator>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator << (std::basic_ostream<charT, traits>& os,
|
||||
const sub_match<RandomAccessIterator>& s)
|
||||
|
@ -22,81 +22,81 @@
|
||||
namespace boost{
|
||||
namespace regex_constants{
|
||||
|
||||
typedef unsigned char syntax_type;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef unsigned char syntax_type;
|
||||
|
||||
//
|
||||
// values chosen are binary compatible with previous version:
|
||||
//
|
||||
static const syntax_type syntax_char = 0;
|
||||
static const syntax_type syntax_open_mark = 1;
|
||||
static const syntax_type syntax_close_mark = 2;
|
||||
static const syntax_type syntax_dollar = 3;
|
||||
static const syntax_type syntax_caret = 4;
|
||||
static const syntax_type syntax_dot = 5;
|
||||
static const syntax_type syntax_star = 6;
|
||||
static const syntax_type syntax_plus = 7;
|
||||
static const syntax_type syntax_question = 8;
|
||||
static const syntax_type syntax_open_set = 9;
|
||||
static const syntax_type syntax_close_set = 10;
|
||||
static const syntax_type syntax_or = 11;
|
||||
static const syntax_type syntax_escape = 12;
|
||||
static const syntax_type syntax_dash = 14;
|
||||
static const syntax_type syntax_open_brace = 15;
|
||||
static const syntax_type syntax_close_brace = 16;
|
||||
static const syntax_type syntax_digit = 17;
|
||||
static const syntax_type syntax_comma = 27;
|
||||
static const syntax_type syntax_equal = 37;
|
||||
static const syntax_type syntax_colon = 36;
|
||||
static const syntax_type syntax_not = 53;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_char = 0;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_open_mark = 1;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_close_mark = 2;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_dollar = 3;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_caret = 4;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_dot = 5;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_star = 6;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_plus = 7;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_question = 8;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_open_set = 9;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_close_set = 10;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_or = 11;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_escape = 12;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_dash = 14;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_open_brace = 15;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_close_brace = 16;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_digit = 17;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_comma = 27;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_equal = 37;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_colon = 36;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_not = 53;
|
||||
|
||||
// extensions:
|
||||
|
||||
static const syntax_type syntax_hash = 13;
|
||||
static const syntax_type syntax_newline = 26;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_hash = 13;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST syntax_type syntax_newline = 26;
|
||||
|
||||
// escapes:
|
||||
|
||||
typedef syntax_type escape_syntax_type;
|
||||
BOOST_REGEX_MODULE_EXPORT typedef syntax_type escape_syntax_type;
|
||||
|
||||
static const escape_syntax_type escape_type_word_assert = 18;
|
||||
static const escape_syntax_type escape_type_not_word_assert = 19;
|
||||
static const escape_syntax_type escape_type_control_f = 29;
|
||||
static const escape_syntax_type escape_type_control_n = 30;
|
||||
static const escape_syntax_type escape_type_control_r = 31;
|
||||
static const escape_syntax_type escape_type_control_t = 32;
|
||||
static const escape_syntax_type escape_type_control_v = 33;
|
||||
static const escape_syntax_type escape_type_ascii_control = 35;
|
||||
static const escape_syntax_type escape_type_hex = 34;
|
||||
static const escape_syntax_type escape_type_unicode = 0; // not used
|
||||
static const escape_syntax_type escape_type_identity = 0; // not used
|
||||
static const escape_syntax_type escape_type_backref = syntax_digit;
|
||||
static const escape_syntax_type escape_type_decimal = syntax_digit; // not used
|
||||
static const escape_syntax_type escape_type_class = 22;
|
||||
static const escape_syntax_type escape_type_not_class = 23;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_word_assert = 18;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_not_word_assert = 19;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_control_f = 29;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_control_n = 30;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_control_r = 31;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_control_t = 32;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_control_v = 33;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_ascii_control = 35;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_hex = 34;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_unicode = 0; // not used
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_identity = 0; // not used
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_backref = syntax_digit;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_decimal = syntax_digit; // not used
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_class = 22;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_not_class = 23;
|
||||
|
||||
// extensions:
|
||||
|
||||
static const escape_syntax_type escape_type_left_word = 20;
|
||||
static const escape_syntax_type escape_type_right_word = 21;
|
||||
static const escape_syntax_type escape_type_start_buffer = 24; // for \`
|
||||
static const escape_syntax_type escape_type_end_buffer = 25; // for \'
|
||||
static const escape_syntax_type escape_type_control_a = 28; // for \a
|
||||
static const escape_syntax_type escape_type_e = 38; // for \e
|
||||
static const escape_syntax_type escape_type_E = 47; // for \Q\E
|
||||
static const escape_syntax_type escape_type_Q = 48; // for \Q\E
|
||||
static const escape_syntax_type escape_type_X = 49; // for \X
|
||||
static const escape_syntax_type escape_type_C = 50; // for \C
|
||||
static const escape_syntax_type escape_type_Z = 51; // for \Z
|
||||
static const escape_syntax_type escape_type_G = 52; // for \G
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_left_word = 20;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_right_word = 21;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_start_buffer = 24; // for \`
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_end_buffer = 25; // for \'
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_control_a = 28; // for \a
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_e = 38; // for \e
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_E = 47; // for \Q\E
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_Q = 48; // for \Q\E
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_X = 49; // for \X
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_C = 50; // for \C
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_Z = 51; // for \Z
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_G = 52; // for \G
|
||||
|
||||
static const escape_syntax_type escape_type_property = 54; // for \p
|
||||
static const escape_syntax_type escape_type_not_property = 55; // for \P
|
||||
static const escape_syntax_type escape_type_named_char = 56; // for \N
|
||||
static const escape_syntax_type escape_type_extended_backref = 57; // for \g
|
||||
static const escape_syntax_type escape_type_reset_start_mark = 58; // for \K
|
||||
static const escape_syntax_type escape_type_line_ending = 59; // for \R
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_property = 54; // for \p
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_not_property = 55; // for \P
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_named_char = 56; // for \N
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_extended_backref = 57; // for \g
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_reset_start_mark = 58; // for \K
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type escape_type_line_ending = 59; // for \R
|
||||
|
||||
static const escape_syntax_type syntax_max = 60;
|
||||
BOOST_REGEX_MODULE_EXPORT BOOST_REGEX_STATIC_CONST escape_syntax_type syntax_max = 60;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,21 @@
|
||||
#ifndef BOOST_REGEX_V5_U32REGEX_ITERATOR_HPP
|
||||
#define BOOST_REGEX_V5_U32REGEX_ITERATOR_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#include <boost/regex/v5/icu.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <class BidirectionalIterator>
|
||||
|
@ -19,6 +19,18 @@
|
||||
#ifndef BOOST_REGEX_V5_U32REGEX_TOKEN_ITERATOR_HPP
|
||||
#define BOOST_REGEX_V5_U32REGEX_TOKEN_ITERATOR_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#include <boost/regex/v5/icu.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
|
@ -60,12 +60,14 @@ Accepts UTF-32 code points and forwards them on as UTF-16 code points.
|
||||
|
||||
#ifndef BOOST_REGEX_UNICODE_ITERATOR_HPP
|
||||
#define BOOST_REGEX_UNICODE_ITERATOR_HPP
|
||||
#include <cstdint>
|
||||
#include <boost/regex/config.hpp>
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#include <cstdint>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <ios>
|
||||
#include <limits.h> // CHAR_BIT
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
#include <boost/throw_exception.hpp>
|
||||
@ -75,9 +77,9 @@ namespace boost{
|
||||
|
||||
namespace detail{
|
||||
|
||||
static const std::uint16_t high_surrogate_base = 0xD7C0u;
|
||||
static const std::uint16_t low_surrogate_base = 0xDC00u;
|
||||
static const std::uint32_t ten_bit_mask = 0x3FFu;
|
||||
BOOST_REGEX_STATIC_CONST std::uint16_t high_surrogate_base = 0xD7C0u;
|
||||
BOOST_REGEX_STATIC_CONST std::uint16_t low_surrogate_base = 0xDC00u;
|
||||
BOOST_REGEX_STATIC_CONST std::uint32_t ten_bit_mask = 0x3FFu;
|
||||
|
||||
inline bool is_high_surrogate(std::uint16_t v)
|
||||
{
|
||||
|
@ -23,9 +23,11 @@
|
||||
|
||||
#include <boost/regex/pattern_except.hpp>
|
||||
#include <boost/regex/v5/regex_traits_defaults.hpp>
|
||||
#ifndef BOOST_REGEX_AS_MODULE
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
#include <mutex>
|
||||
#endif
|
||||
#endif
|
||||
#include <boost/regex/v5/primary_transform.hpp>
|
||||
#include <boost/regex/v5/object_cache.hpp>
|
||||
|
||||
@ -652,7 +654,7 @@ std::shared_ptr<const w32_regex_traits_implementation<charT> > create_w32_regex_
|
||||
|
||||
} // BOOST_REGEX_DETAIL_NS
|
||||
|
||||
template <class charT>
|
||||
BOOST_REGEX_MODULE_EXPORT template <class charT>
|
||||
class w32_regex_traits
|
||||
{
|
||||
public:
|
||||
|
103
module/regex.cxx
Normal file
103
module/regex.cxx
Normal file
@ -0,0 +1,103 @@
|
||||
|
||||
module;
|
||||
|
||||
#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))
|
||||
#define BOOST_REGEX_USE_STD_MODULE
|
||||
#endif
|
||||
|
||||
#if __has_include(<unicode/utypes.h>)
|
||||
|
||||
#if !defined(BOOST_REGEX_WITH_ICU)
|
||||
|
||||
#if defined(_MSC_FULL_VER)
|
||||
#pragma message "ICU headers are available but building the Regex module with ICU support is turned OFF. Build with BOOST_REGEX_WITH_ICU=1 to turn it on, or BOOST_REGEX_WITH_ICU=0 to disable this message"
|
||||
#else
|
||||
# warning "ICU headers are available but building the Regex module with ICU support is turned OFF. Build with BOOST_REGEX_WITH_ICU=1 to turn it on, or BOOST_REGEX_WITH_ICU=0 to disable this message"
|
||||
#endif
|
||||
|
||||
#elif BOOST_REGEX_WITH_ICU
|
||||
# define BOOST_REGEX_HAS_ICU_HEADERS
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && __has_include(<windows.h>)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <climits>
|
||||
#include <cctype>
|
||||
#include <cstddef>
|
||||
#include <cwctype>
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <locale>
|
||||
#include <type_traits>
|
||||
#include <ios>
|
||||
#include <istream>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <new>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
#include <limits>
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
#include <ios>
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
#include <mutex>
|
||||
#endif
|
||||
#include <cwctype>
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <cwchar>
|
||||
#include <cwctype>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_REGEX_HAS_ICU_HEADERS
|
||||
#include <unicode/utypes.h>
|
||||
#include <unicode/uchar.h>
|
||||
#include <unicode/coll.h>
|
||||
#endif
|
||||
|
||||
#define BOOST_REGEX_AS_MODULE
|
||||
#define BOOST_REGEX_STANDALONE
|
||||
#define BOOST_REGEX_MODULE_EXPORT export
|
||||
|
||||
export module boost.regex;
|
||||
|
||||
#if defined(BOOST_REGEX_USE_STD_MODULE)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
import std.core;
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_FULL_VER
|
||||
#pragma warning(disable:5244)
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Winclude-angled-in-module-purview"
|
||||
#endif
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#ifdef BOOST_REGEX_HAS_ICU_HEADERS
|
||||
#include <boost/regex/icu.hpp>
|
||||
#endif
|
11
module/regex_cfind.cpp
Normal file
11
module/regex_cfind.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
module boost.regex;
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_find(perl_matcher<const char*, match_results<const char*>::allocator_type, regex::traits_type>& m)
|
||||
{
|
||||
return m.find();
|
||||
}
|
||||
|
||||
}
|
11
module/regex_cmatch.cpp
Normal file
11
module/regex_cmatch.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
module boost.regex;
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_match(perl_matcher<const char*, match_results<const char*>::allocator_type, regex::traits_type>& m)
|
||||
{
|
||||
return m.match();
|
||||
}
|
||||
|
||||
}
|
30
module/regex_create_char.cpp
Normal file
30
module/regex_create_char.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
module;
|
||||
|
||||
#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))
|
||||
#define BOOST_REGEX_USE_STD_MODULE
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_DETAIL_NS
|
||||
#define BOOST_REGEX_DETAIL_NS re_detail_600
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
module boost.regex;
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
import std.core;
|
||||
#endif
|
||||
|
||||
namespace boost::detail {
|
||||
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<char, basic_regex<char>::traits_type> >
|
||||
create_implemenation(const char* p1, const char* p2, basic_regex<char>::flag_type f, std::shared_ptr<boost::regex_traits_wrapper<basic_regex<char>::traits_type> > ptraits)
|
||||
{
|
||||
return create_implemenation<char, basic_regex<char>::flag_type, basic_regex<char>::traits_type>(p1, p2, f, ptraits);
|
||||
}
|
||||
|
||||
}
|
30
module/regex_create_wchar_t.cpp
Normal file
30
module/regex_create_wchar_t.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
module;
|
||||
|
||||
#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))
|
||||
#define BOOST_REGEX_USE_STD_MODULE
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_DETAIL_NS
|
||||
#define BOOST_REGEX_DETAIL_NS re_detail_600
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
module boost.regex;
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
import std.core;
|
||||
#endif
|
||||
|
||||
namespace boost::detail {
|
||||
|
||||
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<wchar_t, basic_regex<wchar_t>::traits_type> >
|
||||
create_implemenation(const wchar_t* p1, const wchar_t* p2, basic_regex<wchar_t>::flag_type f, std::shared_ptr<boost::regex_traits_wrapper<basic_regex<wchar_t>::traits_type> > ptraits)
|
||||
{
|
||||
return create_implemenation<wchar_t, basic_regex<wchar_t>::flag_type, basic_regex<wchar_t>::traits_type>(p1, p2, f, ptraits);
|
||||
}
|
||||
|
||||
}
|
25
module/regex_nc_sfind.cpp
Normal file
25
module/regex_nc_sfind.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
module;
|
||||
|
||||
#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))
|
||||
#define BOOST_REGEX_USE_STD_MODULE
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
module boost.regex;
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
import std.core;
|
||||
#endif
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_find(perl_matcher<std::string::iterator, match_results<std::string::iterator>::allocator_type, regex::traits_type>& m)
|
||||
{
|
||||
return m.find();
|
||||
}
|
||||
|
||||
}
|
25
module/regex_nc_smatch.cpp
Normal file
25
module/regex_nc_smatch.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
module;
|
||||
|
||||
#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))
|
||||
#define BOOST_REGEX_USE_STD_MODULE
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
module boost.regex;
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
import std.core;
|
||||
#endif
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_match(perl_matcher<std::string::iterator, match_results<std::string::iterator>::allocator_type, regex::traits_type>& m)
|
||||
{
|
||||
return m.match();
|
||||
}
|
||||
|
||||
}
|
25
module/regex_nc_wsfind.cpp
Normal file
25
module/regex_nc_wsfind.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
module;
|
||||
|
||||
#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))
|
||||
#define BOOST_REGEX_USE_STD_MODULE
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
module boost.regex;
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
import std.core;
|
||||
#endif
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_find(perl_matcher<std::wstring::iterator, match_results<std::wstring::iterator>::allocator_type, wregex::traits_type>& m)
|
||||
{
|
||||
return m.find();
|
||||
}
|
||||
|
||||
}
|
25
module/regex_nc_wsmatch.cpp
Normal file
25
module/regex_nc_wsmatch.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
module;
|
||||
|
||||
#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))
|
||||
#define BOOST_REGEX_USE_STD_MODULE
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
module boost.regex;
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
import std.core;
|
||||
#endif
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_match(perl_matcher<std::wstring::iterator, match_results<std::wstring::iterator>::allocator_type, wregex::traits_type>& m)
|
||||
{
|
||||
return m.match();
|
||||
}
|
||||
|
||||
}
|
25
module/regex_sfind.cpp
Normal file
25
module/regex_sfind.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
module;
|
||||
|
||||
#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))
|
||||
#define BOOST_REGEX_USE_STD_MODULE
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
module boost.regex;
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
import std.core;
|
||||
#endif
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_find(perl_matcher<std::string::const_iterator, match_results<std::string::const_iterator>::allocator_type, regex::traits_type>& m)
|
||||
{
|
||||
return m.find();
|
||||
}
|
||||
|
||||
}
|
25
module/regex_smatch.cpp
Normal file
25
module/regex_smatch.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
module;
|
||||
|
||||
#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))
|
||||
#define BOOST_REGEX_USE_STD_MODULE
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
module boost.regex;
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
import std.core;
|
||||
#endif
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_match(perl_matcher<std::string::const_iterator, match_results<std::string::const_iterator>::allocator_type, regex::traits_type>& m)
|
||||
{
|
||||
return m.match();
|
||||
}
|
||||
|
||||
}
|
11
module/regex_wcfind.cpp
Normal file
11
module/regex_wcfind.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
module boost.regex;
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_find(perl_matcher<const wchar_t*, match_results<const wchar_t*>::allocator_type, wregex::traits_type>& m)
|
||||
{
|
||||
return m.find();
|
||||
}
|
||||
|
||||
}
|
11
module/regex_wcmatch.cpp
Normal file
11
module/regex_wcmatch.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
module boost.regex;
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_match(perl_matcher<const wchar_t*, match_results<const wchar_t*>::allocator_type, wregex::traits_type>& m)
|
||||
{
|
||||
return m.match();
|
||||
}
|
||||
|
||||
}
|
25
module/regex_wsfind.cpp
Normal file
25
module/regex_wsfind.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
module;
|
||||
|
||||
#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))
|
||||
#define BOOST_REGEX_USE_STD_MODULE
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
module boost.regex;
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
import std.core;
|
||||
#endif
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_find(perl_matcher<std::wstring::const_iterator, match_results<std::wstring::const_iterator>::allocator_type, wregex::traits_type>& m)
|
||||
{
|
||||
return m.find();
|
||||
}
|
||||
|
||||
}
|
25
module/regex_wsmatch.cpp
Normal file
25
module/regex_wsmatch.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
module;
|
||||
|
||||
#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))
|
||||
#define BOOST_REGEX_USE_STD_MODULE
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
module boost.regex;
|
||||
|
||||
#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE)
|
||||
import std.core;
|
||||
#endif
|
||||
|
||||
namespace boost::re_detail_600 {
|
||||
|
||||
bool factory_match(perl_matcher<std::wstring::const_iterator, match_results<std::wstring::const_iterator>::allocator_type, wregex::traits_type>& m)
|
||||
{
|
||||
return m.match();
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
* DESCRIPTION: Implements the wide character POSIX API wrappers.
|
||||
*/
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS // for std::wcscpy
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
@ -169,11 +170,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
{
|
||||
result = std::wcslen(wnames[code]) + 1;
|
||||
if(buf_size >= result)
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
|
||||
::wcscpy_s(buf, buf_size, wnames[code]);
|
||||
#else
|
||||
std::wcscpy(buf, wnames[code]);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
@ -193,11 +190,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
(boost::core::swprintf)(localbuf, 5, L"%d", i);
|
||||
#endif
|
||||
if(std::wcslen(localbuf) < buf_size)
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
|
||||
::wcscpy_s(buf, buf_size, localbuf);
|
||||
#else
|
||||
std::wcscpy(buf, localbuf);
|
||||
#endif
|
||||
return std::wcslen(localbuf) + 1;
|
||||
}
|
||||
}
|
||||
@ -207,11 +200,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
(boost::core::swprintf)(localbuf, 5, L"%d", 0);
|
||||
#endif
|
||||
if(std::wcslen(localbuf) < buf_size)
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
|
||||
::wcscpy_s(buf, buf_size, localbuf);
|
||||
#else
|
||||
std::wcscpy(buf, localbuf);
|
||||
#endif
|
||||
return std::wcslen(localbuf) + 1;
|
||||
}
|
||||
if(code <= (int)REG_E_UNKNOWN)
|
||||
|
@ -1,15 +1,16 @@
|
||||
# copyright John Maddock 2003
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt.
|
||||
|
||||
project
|
||||
: requirements
|
||||
<threading>multi
|
||||
<link>shared:<define>BOOST_REGEX_DYN_LINK=1
|
||||
<toolset>msvc-7.1:<define>TEST_MFC=1
|
||||
: requirements
|
||||
<library>/boost/regex//boost_regex
|
||||
<library>/boost/detail//boost_detail
|
||||
<threading>multi
|
||||
<link>shared:<define>BOOST_REGEX_DYN_LINK=1
|
||||
<toolset>msvc-7.1:<define>TEST_MFC=1
|
||||
<toolset>msvc-7.0:<define>TEST_MFC=1
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
# There are unidentified linker problems on these platforms:
|
||||
<toolset>mipspro-7.4:<link>static
|
||||
<toolset>sun-5.9:<link>static
|
||||
@ -21,6 +22,8 @@ project
|
||||
#<toolset>gcc-mingw:<link>static
|
||||
#<toolset>gcc-cygwin:<link>static
|
||||
<toolset>sun:<link>static
|
||||
<include>../src
|
||||
<include>.
|
||||
;
|
||||
|
||||
#
|
||||
@ -28,14 +31,14 @@ project
|
||||
#
|
||||
rule regex-test ( name : sources + : requirements * : input-files * )
|
||||
{
|
||||
return [ run $(sources) ../build//boost_regex
|
||||
return [ run $(sources) /boost/regex//boost_regex
|
||||
:
|
||||
: $(input-files)
|
||||
: $(requirements)
|
||||
: $(name) ] ;
|
||||
}
|
||||
|
||||
R_SOURCE =
|
||||
R_SOURCE =
|
||||
basic_tests.cpp
|
||||
main.cpp
|
||||
wmain.cpp
|
||||
@ -70,7 +73,7 @@ run regress/$(R_SOURCE) ../build//boost_regex ../build//icu_options
|
||||
: regex_regress ;
|
||||
|
||||
run regress/$(R_SOURCE) ../build//boost_regex
|
||||
../../thread/build//boost_thread ../build//icu_options
|
||||
/boost/thread//boost_thread ../build//icu_options
|
||||
: # command line
|
||||
: # input files
|
||||
: # requirements
|
||||
@ -78,7 +81,7 @@ run regress/$(R_SOURCE) ../build//boost_regex
|
||||
: regex_regress_threaded ;
|
||||
|
||||
run regress/$(R_SOURCE) ../build//boost_regex
|
||||
../../thread/build//boost_thread ../build//icu_options
|
||||
/boost/thread//boost_thread ../build//icu_options
|
||||
: # command line
|
||||
: # input files
|
||||
: # requirements
|
||||
@ -98,15 +101,15 @@ run unicode/unicode_iterator_test.cpp : : : release <define>TEST_UTF16 : unicode
|
||||
run unicode/unicode_casefold_test.cpp ../build//boost_regex ../build//icu_options ;
|
||||
run object_cache/object_cache_test.cpp ;
|
||||
run config_info/regex_config_info.cpp ../build//boost_regex/<link>static : : : <test-info>always_show_run_output ;
|
||||
run config_info/regex_config_info.cpp ../build//boost_regex : : : <test-info>always_show_run_output : regex_dll_config_info ;
|
||||
run config_info/regex_config_info.cpp ../build//boost_regex : : : <test-info>always_show_run_output : regex_dll_config_info ;
|
||||
run collate_info/collate_info.cpp ../build//boost_regex : : : <test-info>always_show_run_output : test_collate_info ;
|
||||
link concepts/concept_check.cpp : <toolset>gcc:<cxxflags>-Wno-deprecated-copy ;
|
||||
link concepts/concept_check.cpp /boost/range//boost_range : <toolset>gcc:<cxxflags>-Wno-deprecated-copy ;
|
||||
link concepts/concept_check.cpp : <define>BOOST_REGEX_STANDALONE <toolset>gcc:<cxxflags>-Wno-deprecated-copy : standalone_concept_check ;
|
||||
link concepts/icu_concept_check.cpp : <define>BOOST_REGEX_STANDALONE <toolset>gcc:<cxxflags>-Wno-deprecated-copy ;
|
||||
link concepts/icu_concept_check.cpp : <toolset>gcc:<cxxflags>-Wno-deprecated-copy : standalone_icu_concept_check ;
|
||||
link concepts/range_concept_check.cpp : <toolset>gcc:<cxxflags>-Wno-deprecated-copy ;
|
||||
run concepts/test_bug_11988.cpp ;
|
||||
run captures/captures_test.cpp ../build//icu_options : : : <threading>multi <define>BOOST_REGEX_MATCH_EXTRA=1 <define>BOOST_REGEX_NO_LIB=1 : captures_test ;
|
||||
link concepts/range_concept_check.cpp : <toolset>gcc:<cxxflags>-Wno-deprecated-copy <library>/boost/range//boost_range ;
|
||||
run concepts/test_bug_11988.cpp ;
|
||||
run captures/captures_test.cpp ../build//icu_options /boost/array//boost_array : : : <threading>multi <define>BOOST_REGEX_MATCH_EXTRA=1 <define>BOOST_REGEX_NO_LIB=1 : captures_test ;
|
||||
run regress/$(R_SOURCE) ./noeh_test//boost_regex_noeh ../build//icu_options : : : <define>BOOST_NO_EXCEPTIONS=1 <exception-handling>off <link>static <runtime-link>shared : regex_regress_noeh ;
|
||||
compile test_consolidated.cpp ;
|
||||
|
||||
@ -114,12 +117,12 @@ build-project ../example ;
|
||||
|
||||
# `quick` target (for CI)
|
||||
run quick.cpp ../build//boost_regex ;
|
||||
compile test_warnings.cpp
|
||||
compile test_warnings.cpp
|
||||
: <toolset>msvc:<warnings>all <toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings>all <toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings>all <toolset>clang:<warnings-as-errors>on ;
|
||||
|
||||
compile test_warnings.cpp
|
||||
compile test_warnings.cpp
|
||||
: <toolset>msvc:<warnings>all <toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings>all <toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings>all <toolset>clang:<warnings-as-errors>on
|
||||
@ -131,4 +134,8 @@ compile test_windows_defs_2.cpp ;
|
||||
compile test_windows_defs_3.cpp ;
|
||||
compile test_windows_defs_4.cpp ;
|
||||
|
||||
run issue153.cpp : : : <toolset>msvc:<linkflags>-STACK:2097152 ;
|
||||
run issue153.cpp : : : "<toolset>msvc:<linkflags>-STACK:2097152" ;
|
||||
run issue227.cpp ;
|
||||
run issue232.cpp ;
|
||||
run lookbehind_recursion_stress_test.cpp ;
|
||||
|
||||
|
@ -15,4 +15,4 @@ target_link_libraries(quick Boost::regex Boost::core)
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
@ -20,4 +20,4 @@ target_link_libraries(quick Boost::regex Boost::core)
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
@ -19,4 +19,4 @@ target_link_libraries(quick_icu Boost::regex_icu)
|
||||
enable_testing()
|
||||
add_test(quick_icu quick_icu)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
99
test/concepts/module_concept_check.cpp
Normal file
99
test/concepts/module_concept_check.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
//
|
||||
// For some reason, GCC chokes unless all std lib includes appear
|
||||
// before module imports:
|
||||
//
|
||||
#include <boost/concept_archetype.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/type_traits/is_base_and_derived.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <bitset>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
#endif
|
||||
|
||||
import boost.regex;
|
||||
|
||||
#define BOOST_REGEX_TEST_MODULE
|
||||
|
||||
#include <boost/regex/concepts.hpp>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::function_requires<
|
||||
boost::RegexTraitsConcept<
|
||||
boost::regex_traits<char>
|
||||
>
|
||||
>();
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
boost::function_requires<
|
||||
boost::BoostRegexConcept<
|
||||
boost::basic_regex<char, boost::cpp_regex_traits<char> >
|
||||
>
|
||||
>();
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
boost::function_requires<
|
||||
boost::BoostRegexConcept<
|
||||
boost::basic_regex<wchar_t, boost::cpp_regex_traits<wchar_t> >
|
||||
>
|
||||
>();
|
||||
#endif
|
||||
#endif
|
||||
boost::function_requires<
|
||||
boost::BoostRegexConcept<
|
||||
boost::basic_regex<char, boost::c_regex_traits<char> >
|
||||
>
|
||||
>();
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
boost::function_requires<
|
||||
boost::BoostRegexConcept<
|
||||
boost::basic_regex<wchar_t, boost::c_regex_traits<wchar_t> >
|
||||
>
|
||||
>();
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
|
||||
boost::function_requires<
|
||||
boost::BoostRegexConcept<
|
||||
boost::basic_regex<char, boost::w32_regex_traits<char> >
|
||||
>
|
||||
>();
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
boost::function_requires<
|
||||
boost::BoostRegexConcept<
|
||||
boost::basic_regex<wchar_t, boost::w32_regex_traits<wchar_t> >
|
||||
>
|
||||
>();
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
// now test the regex_traits concepts:
|
||||
//
|
||||
typedef boost::basic_regex<char, boost::regex_traits_architype<char> > regex_traits_tester_type1;
|
||||
boost::function_requires<
|
||||
boost::BoostRegexConcept<
|
||||
regex_traits_tester_type1
|
||||
>
|
||||
>();
|
||||
typedef boost::basic_regex<boost::char_architype, boost::regex_traits_architype<boost::char_architype> > regex_traits_tester_type2;
|
||||
boost::function_requires<
|
||||
boost::BaseRegexConcept<
|
||||
regex_traits_tester_type2
|
||||
>
|
||||
>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
1569
test/config_info.cpp
Normal file
1569
test/config_info.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,7 +19,7 @@
|
||||
#endif
|
||||
|
||||
#define main OLD_MAIN
|
||||
#include <libs/config/test/config_info.cpp>
|
||||
#include <config_info.cpp>
|
||||
#undef main
|
||||
#ifndef NEW_MAIN
|
||||
# define NEW_MAIN main
|
||||
|
19
test/issue227.cpp
Normal file
19
test/issue227.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2024
|
||||
* Christian Mazakas
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <string>
|
||||
|
||||
int main() {
|
||||
boost::regex rx("(*ACCEPT)*+\\1((*ACCEPT)*+\\K)");
|
||||
std::string str = "Z";
|
||||
boost::smatch what;
|
||||
boost::regex_search(str, what, rx, boost::match_default | boost::match_partial);
|
||||
}
|
71
test/issue232.cpp
Normal file
71
test/issue232.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
template<std::size_t N0, std::size_t N = N0 - 1>
|
||||
void tester( char const (&str)[ N0 ] )
|
||||
{
|
||||
std::vector<char> s(N, '\0');
|
||||
std::memcpy(s.data(), str, N);
|
||||
boost::regex rx(s.begin(), s.end());
|
||||
|
||||
std::vector<std::string> wheres;
|
||||
wheres.push_back(std::string(15, 'H'));
|
||||
wheres.push_back("");
|
||||
wheres.push_back(" ");
|
||||
|
||||
// Perl-style matching
|
||||
for (auto const& where : wheres) {
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
bool match = boost::regex_match(where, what, rx, boost::match_default | boost::match_partial | boost::match_any | boost::match_perl);
|
||||
(void) match;
|
||||
}
|
||||
|
||||
// POSIX-style matching
|
||||
for (auto const& where : wheres) {
|
||||
try {
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
bool match = boost::regex_match(where, what, rx, boost::match_default | boost::match_partial | boost::match_any | boost::match_posix);
|
||||
(void) match;
|
||||
} catch(...) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// test strings derived from fuzzing
|
||||
// we keep a simple human-readable version
|
||||
char const str1[] = "(Y(*COMMIT)|\\K\\D|.)+";
|
||||
char const str2[] = "(Y(*COMMIT){||\\K\\D|||||||||\\K|||ss|||||.|\232*(?(50)\027\0204657|H)\020}\031\000.* 6.'?-i)+[L??.\000\000\000\004\000\000\000\000?..<[\000\024R]*+";
|
||||
char const str3[] = "(Y(*COMMIT)\xFF\x80|\\L\\K||||||||||.|||||\x84|||||\x00\x00\x10||||||.* .'?-i)[L??...-i)[L??...[\x00\x14R]*+";
|
||||
char const str4[] = "(Y(*COMMIT)\x96||.* .* .\\K|||\x9F||||\x9C|.|||||\x84\x99|||\x01\x00\x00\x00|||'?-i#PL\x00\x01.\x86??OMMIT)?...[\x00\x14R]*+";
|
||||
|
||||
tester(str1);
|
||||
tester(str2);
|
||||
tester(str3);
|
||||
tester(str4);
|
||||
|
||||
// prove that we catch certain impossible scenarios
|
||||
|
||||
{
|
||||
char const* str = "abcd";
|
||||
boost::regex rx(str);
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
std::string where(15, 'H');
|
||||
BOOST_TEST_THROWS(boost::regex_match(where, rx, boost::match_posix | boost::match_perl), std::logic_error);
|
||||
}
|
||||
|
||||
{
|
||||
char const* str = "ab(*COMMIT)cd";
|
||||
boost::regex rx(str);
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
std::string where(15, 'H');
|
||||
BOOST_TEST_THROWS(boost::regex_match(where, rx, boost::match_posix), std::logic_error);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
28
test/lookbehind_recursion_stress_test.cpp
Normal file
28
test/lookbehind_recursion_stress_test.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2024
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string s("(?<=(");
|
||||
s.append(1000, '|');
|
||||
s += "))";
|
||||
boost::regex rx(s);
|
||||
|
||||
s = "(?<=(a";
|
||||
for (unsigned i = 0; i < 1000; ++i)
|
||||
{
|
||||
s += "|a";
|
||||
}
|
||||
s += "))";
|
||||
boost::regex rx2(s);
|
||||
}
|
33
test/module/Jamfile.v2
Normal file
33
test/module/Jamfile.v2
Normal file
@ -0,0 +1,33 @@
|
||||
# copyright John Maddock 2022
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt.
|
||||
|
||||
project
|
||||
: requirements
|
||||
<threading>multi
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
<toolset>msvc:<cxxstd>latest
|
||||
<toolset>gcc:<cxxflags>-fmodules-ts
|
||||
;
|
||||
|
||||
obj regex : ../../module/regex.cxx : <toolset>msvc:<cxxflags>-interface [ check-target-builds ./config//test_has_module_support : : <build>no ] ;
|
||||
|
||||
exe credit_card_example : credit_card_example.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe partial_regex_grep : partial_regex_grep.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe partial_regex_iterate : partial_regex_iterate.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe partial_regex_match : partial_regex_match.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_grep_example_1 : regex_grep_example_1.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_grep_example_2 : regex_grep_example_2.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_grep_example_3 : regex_grep_example_3.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_iterator_example : regex_iterator_example.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_match_example : regex_match_example.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_merge_example : regex_merge_example.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_replace_example : regex_replace_example.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_search_example : regex_search_example.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_split_example_1 : regex_split_example_1.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_split_example_2 : regex_split_example_2.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_token_iterator_eg_1 : regex_token_iterator_eg_1.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
exe regex_token_iterator_eg_2 : regex_token_iterator_eg_2.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
||||
|
||||
compile ../concepts/module_concept_check.cpp regex : [ check-target-builds ./config//test_has_module_support : : <build>no ] <dependency>regex ;
|
79
test/module/credit_card_example.cpp
Normal file
79
test/module/credit_card_example.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2002
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE credit_card_example.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Credit card number formatting code.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
|
||||
bool validate_card_format(const std::string& s)
|
||||
{
|
||||
static const boost::regex e("(\\d{4}[- ]){3}\\d{4}");
|
||||
return boost::regex_match(s, e);
|
||||
}
|
||||
|
||||
const boost::regex e("\\A(\\d{3,4})[- ]?(\\d{4})[- ]?(\\d{4})[- ]?(\\d{4})\\z");
|
||||
const std::string machine_format("\\1\\2\\3\\4");
|
||||
const std::string human_format("\\1-\\2-\\3-\\4");
|
||||
|
||||
std::string machine_readable_card_number(const std::string& s)
|
||||
{
|
||||
return boost::regex_replace(s, e, machine_format, boost::match_default | boost::format_sed);
|
||||
}
|
||||
|
||||
std::string human_readable_card_number(const std::string& s)
|
||||
{
|
||||
return boost::regex_replace(s, e, human_format, boost::match_default | boost::format_sed);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
string s[4] = { "0000111122223333", "0000 1111 2222 3333",
|
||||
"0000-1111-2222-3333", "000-1111-2222-3333", };
|
||||
int i;
|
||||
for(i = 0; i < 4; ++i)
|
||||
{
|
||||
cout << "validate_card_format(\"" << s[i] << "\") returned " << validate_card_format(s[i]) << endl;
|
||||
}
|
||||
for(i = 0; i < 4; ++i)
|
||||
{
|
||||
cout << "machine_readable_card_number(\"" << s[i] << "\") returned " << machine_readable_card_number(s[i]) << endl;
|
||||
}
|
||||
for(i = 0; i < 4; ++i)
|
||||
{
|
||||
cout << "human_readable_card_number(\"" << s[i] << "\") returned " << human_readable_card_number(s[i]) << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
27
test/module/msvc_test.bat
Normal file
27
test/module/msvc_test.bat
Normal file
@ -0,0 +1,27 @@
|
||||
REM Basic command line to build everything with msvc:
|
||||
|
||||
rem del *.obj
|
||||
rem del *.exe
|
||||
rem del *.lib
|
||||
|
||||
cl /std:c++latest /EHsc /nologo /W4 /c "%VCToolsInstallDir%\modules\std.ixx" || exit 1
|
||||
cl /std:c++latest /EHsc /nologo /W4 /c /interface /I ..\..\..\.. ..\..\module\regex.cxx || exit 1
|
||||
cl /std:c++latest /EHsc /nologo /W4 /c /I ..\..\..\.. ..\..\module\*.cpp || exit 1
|
||||
|
||||
lib *.obj /OUT:regex.lib || exit 1
|
||||
|
||||
rem time < nul
|
||||
|
||||
for %%f in (*.cpp) do (
|
||||
cl /std:c++latest /EHsc /nologo /W4 /I ..\..\..\.. %%f regex.lib || exit 1
|
||||
)
|
||||
|
||||
rem time < nul
|
||||
|
||||
rem uncomment this section to test/time non-module build:
|
||||
rem for %%f in (*.cpp) do (
|
||||
rem cl /DTEST_HEADERS /std:c++latest /EHsc /nologo /W4 /I ..\..\..\.. %%f || exit 1
|
||||
rem )
|
||||
|
||||
rem time < nul
|
||||
|
113
test/module/partial_regex_grep.cpp
Normal file
113
test/module/partial_regex_grep.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE partial_regex_grep.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Search example using partial matches.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
// match some kind of html tag:
|
||||
boost::regex e("<[^>]*>");
|
||||
// count how many:
|
||||
unsigned int tags = 0;
|
||||
// saved position of partial match:
|
||||
const char* next_pos = 0;
|
||||
|
||||
bool grep_callback(const boost::match_results<const char*>& m)
|
||||
{
|
||||
if(m[0].matched == false)
|
||||
{
|
||||
// save position and return:
|
||||
next_pos = m[0].first;
|
||||
}
|
||||
else
|
||||
++tags;
|
||||
return true;
|
||||
}
|
||||
|
||||
void search(std::istream& is)
|
||||
{
|
||||
char buf[4096];
|
||||
next_pos = buf + sizeof(buf);
|
||||
bool have_more = true;
|
||||
while(have_more)
|
||||
{
|
||||
// how much do we copy forward from last try:
|
||||
std::ptrdiff_t leftover = (buf + sizeof(buf)) - next_pos;
|
||||
// and how much is left to fill:
|
||||
std::ptrdiff_t size = next_pos - buf;
|
||||
// copy forward whatever we have left:
|
||||
std::memmove(buf, next_pos, leftover);
|
||||
// fill the rest from the stream:
|
||||
is.read(buf + leftover, size);
|
||||
std::streamsize read = is.gcount();
|
||||
// check to see if we've run out of text:
|
||||
have_more = read == size;
|
||||
// reset next_pos:
|
||||
next_pos = buf + sizeof(buf);
|
||||
// and then grep:
|
||||
boost::regex_grep<bool(*)(const boost::cmatch&), const char*>(grep_callback,
|
||||
static_cast<const char*>(buf),
|
||||
static_cast<const char*>(buf + read + leftover),
|
||||
e,
|
||||
boost::match_default | boost::match_partial);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if(argc > 1)
|
||||
{
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
std::ifstream fs(argv[i]);
|
||||
if(fs.bad()) continue;
|
||||
search(fs);
|
||||
fs.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string one("<META NAME=\"keywords\" CONTENT=\"regex++, regular expressions, regular expression library, C++\">");
|
||||
std::string what;
|
||||
while(what.size() < 10000)
|
||||
{
|
||||
what.append(one);
|
||||
what.append(13, ' ');
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss.str(what);
|
||||
search(ss);
|
||||
}
|
||||
std::cout << "total tag count was " << tags << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
129
test/module/partial_regex_iterate.cpp
Normal file
129
test/module/partial_regex_iterate.cpp
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE partial_regex_iterate.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Search example using partial matches.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std{ using ::memmove; }
|
||||
#endif
|
||||
|
||||
// match some kind of html tag:
|
||||
boost::regex e("<[^>]*>");
|
||||
// count how many:
|
||||
unsigned int tags = 0;
|
||||
|
||||
void search(std::istream& is)
|
||||
{
|
||||
// buffer we'll be searching in:
|
||||
char buf[4096];
|
||||
// saved position of end of partial match:
|
||||
const char* next_pos = buf + sizeof(buf);
|
||||
// flag to indicate whether there is more input to come:
|
||||
bool have_more = true;
|
||||
|
||||
while(have_more)
|
||||
{
|
||||
// how much do we copy forward from last try:
|
||||
std::ptrdiff_t leftover = (buf + sizeof(buf)) - next_pos;
|
||||
// and how much is left to fill:
|
||||
std::ptrdiff_t size = next_pos - buf;
|
||||
// copy forward whatever we have left:
|
||||
std::memmove(buf, next_pos, leftover);
|
||||
// fill the rest from the stream:
|
||||
is.read(buf + leftover, size);
|
||||
std::streamsize read = is.gcount();
|
||||
// check to see if we've run out of text:
|
||||
have_more = read == size;
|
||||
// reset next_pos:
|
||||
next_pos = buf + sizeof(buf);
|
||||
// and then iterate:
|
||||
boost::cregex_iterator a(
|
||||
buf,
|
||||
buf + read + leftover,
|
||||
e,
|
||||
boost::match_default | boost::match_partial);
|
||||
boost::cregex_iterator b;
|
||||
|
||||
while(a != b)
|
||||
{
|
||||
if((*a)[0].matched == false)
|
||||
{
|
||||
// Partial match, save position and break:
|
||||
next_pos = (*a)[0].first;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// full match:
|
||||
++tags;
|
||||
}
|
||||
|
||||
// move to next match:
|
||||
++a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if(argc > 1)
|
||||
{
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
std::ifstream fs(argv[i]);
|
||||
if(fs.bad()) continue;
|
||||
search(fs);
|
||||
fs.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string one("<META NAME=\"keywords\" CONTENT=\"regex++, regular expressions, regular expression library, C++\">");
|
||||
std::string what;
|
||||
while(what.size() < 10000)
|
||||
{
|
||||
what.append(one);
|
||||
what.append(13, ' ');
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss.str(what);
|
||||
search(ss);
|
||||
}
|
||||
std::cout << "total tag count was " << tags << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
81
test/module/partial_regex_match.cpp
Normal file
81
test/module/partial_regex_match.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE partial_regex_match.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_match example using partial matches.
|
||||
*/
|
||||
|
||||
|
||||
//#include <version>
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
boost::regex e("(\\d{3,4})[- ]?(\\d{4})[- ]?(\\d{4})[- ]?(\\d{4})");
|
||||
|
||||
bool is_possible_card_number(const std::string& input)
|
||||
{
|
||||
//
|
||||
// return false for partial match, true for full match, or throw for
|
||||
// impossible match based on what we have so far...
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
if(0 == boost::regex_match(input, what, e, boost::match_default | boost::match_partial))
|
||||
{
|
||||
// the input so far could not possibly be valid so reject it:
|
||||
throw std::runtime_error("Invalid data entered - this could not possibly be a valid card number");
|
||||
}
|
||||
// OK so far so good, but have we finished?
|
||||
if(what[0].matched)
|
||||
{
|
||||
// excellent, we have a result:
|
||||
return true;
|
||||
}
|
||||
// what we have so far is only a partial match...
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
try{
|
||||
std::string input;
|
||||
if(argc > 1)
|
||||
input = argv[1];
|
||||
else
|
||||
std::cin >> input;
|
||||
if(is_possible_card_number(input))
|
||||
{
|
||||
std::cout << "Matched OK..." << std::endl;
|
||||
}
|
||||
else
|
||||
std::cout << "Got a partial match..." << std::endl;
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cout << e.what() << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
142
test/module/regex_grep_example_1.cpp
Normal file
142
test/module/regex_grep_example_1.cpp
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_grep_example_1.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_grep example 1: searches a cpp file for class definitions.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
// purpose:
|
||||
// takes the contents of a file in the form of a string
|
||||
// and searches for all the C++ class definitions, storing
|
||||
// their locations in a map of strings/int's
|
||||
|
||||
typedef std::map<std::string, std::string::difference_type, std::less<std::string> > map_type;
|
||||
|
||||
const char* re =
|
||||
// possibly leading whitespace:
|
||||
"^[[:space:]]*"
|
||||
// possible template declaration:
|
||||
"(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
||||
// class or struct:
|
||||
"(class|struct)[[:space:]]*"
|
||||
// leading declspec macros etc:
|
||||
"("
|
||||
"\\<\\w+\\>"
|
||||
"("
|
||||
"[[:blank:]]*\\([^)]*\\)"
|
||||
")?"
|
||||
"[[:space:]]*"
|
||||
")*"
|
||||
// the class name
|
||||
"(\\<\\w*\\>)[[:space:]]*"
|
||||
// template specialisation parameters
|
||||
"(<[^;:{]+>)?[[:space:]]*"
|
||||
// terminate in { or :
|
||||
"(\\{|:[^;\\{()]*\\{)";
|
||||
|
||||
boost::regex expression(re);
|
||||
|
||||
class IndexClassesPred
|
||||
{
|
||||
map_type& m;
|
||||
std::string::const_iterator base;
|
||||
public:
|
||||
IndexClassesPred(map_type& a, std::string::const_iterator b) : m(a), base(b) {}
|
||||
bool operator()(const boost::match_results<std::string::const_iterator>& what)
|
||||
{
|
||||
// what[0] contains the whole string
|
||||
// what[5] contains the class name.
|
||||
// what[6] contains the template specialisation if any.
|
||||
// add class name and position to map:
|
||||
m[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
|
||||
what[5].first - base;
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
IndexClassesPred& operator=(const IndexClassesPred&);
|
||||
};
|
||||
|
||||
void IndexClasses(map_type& m, const std::string& file)
|
||||
{
|
||||
std::string::const_iterator start, end;
|
||||
start = file.begin();
|
||||
end = file.end();
|
||||
boost::regex_grep(IndexClassesPred(m, start), start, end, expression);
|
||||
}
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
void load_file(std::string& s, std::istream& is)
|
||||
{
|
||||
s.erase();
|
||||
if(is.bad()) return;
|
||||
s.reserve(static_cast<std::string::size_type>(is.rdbuf()->in_avail()));
|
||||
char c;
|
||||
while(is.get(c))
|
||||
{
|
||||
if(s.capacity() == s.size())
|
||||
s.reserve(s.capacity() * 3);
|
||||
s.append(1, c);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
std::string text;
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
cout << "Processing file " << argv[i] << endl;
|
||||
map_type m;
|
||||
std::ifstream fs(argv[i]);
|
||||
load_file(text, fs);
|
||||
fs.close();
|
||||
IndexClasses(m, text);
|
||||
cout << m.size() << " matches found" << endl;
|
||||
map_type::iterator c, d;
|
||||
c = m.begin();
|
||||
d = m.end();
|
||||
while(c != d)
|
||||
{
|
||||
cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
|
||||
++c;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
132
test/module/regex_grep_example_2.cpp
Normal file
132
test/module/regex_grep_example_2.cpp
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_grep_example_2.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_grep example 2: searches a cpp file for class definitions,
|
||||
* using a global callback function.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
// purpose:
|
||||
// takes the contents of a file in the form of a string
|
||||
// and searches for all the C++ class definitions, storing
|
||||
// their locations in a map of strings/int's
|
||||
|
||||
typedef std::map<std::string, std::string::difference_type, std::less<std::string> > map_type;
|
||||
|
||||
const char* re =
|
||||
// possibly leading whitespace:
|
||||
"^[[:space:]]*"
|
||||
// possible template declaration:
|
||||
"(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
||||
// class or struct:
|
||||
"(class|struct)[[:space:]]*"
|
||||
// leading declspec macros etc:
|
||||
"("
|
||||
"\\<\\w+\\>"
|
||||
"("
|
||||
"[[:blank:]]*\\([^)]*\\)"
|
||||
")?"
|
||||
"[[:space:]]*"
|
||||
")*"
|
||||
// the class name
|
||||
"(\\<\\w*\\>)[[:space:]]*"
|
||||
// template specialisation parameters
|
||||
"(<[^;:{]+>)?[[:space:]]*"
|
||||
// terminate in { or :
|
||||
"(\\{|:[^;\\{()]*\\{)";
|
||||
|
||||
|
||||
boost::regex expression(re);
|
||||
map_type class_index;
|
||||
std::string::const_iterator base;
|
||||
|
||||
bool grep_callback(const boost::match_results<std::string::const_iterator>& what)
|
||||
{
|
||||
// what[0] contains the whole string
|
||||
// what[5] contains the class name.
|
||||
// what[6] contains the template specialisation if any.
|
||||
// add class name and position to map:
|
||||
class_index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
|
||||
what[5].first - base;
|
||||
return true;
|
||||
}
|
||||
|
||||
void IndexClasses(const std::string& file)
|
||||
{
|
||||
std::string::const_iterator start, end;
|
||||
start = file.begin();
|
||||
end = file.end();
|
||||
base = start;
|
||||
boost::regex_grep(grep_callback, start, end, expression);
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
|
||||
void load_file(std::string& s, std::istream& is)
|
||||
{
|
||||
s.erase();
|
||||
if(is.bad()) return;
|
||||
s.reserve(static_cast<std::string::size_type>(is.rdbuf()->in_avail()));
|
||||
char c;
|
||||
while(is.get(c))
|
||||
{
|
||||
if(s.capacity() == s.size())
|
||||
s.reserve(s.capacity() * 3);
|
||||
s.append(1, c);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
std::string text;
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
cout << "Processing file " << argv[i] << endl;
|
||||
std::ifstream fs(argv[i]);
|
||||
load_file(text, fs);
|
||||
fs.close();
|
||||
IndexClasses(text);
|
||||
cout << class_index.size() << " matches found" << endl;
|
||||
map_type::iterator c, d;
|
||||
c = class_index.begin();
|
||||
d = class_index.end();
|
||||
while(c != d)
|
||||
{
|
||||
cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
|
||||
++c;
|
||||
}
|
||||
class_index.erase(class_index.begin(), class_index.end());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
144
test/module/regex_grep_example_3.cpp
Normal file
144
test/module/regex_grep_example_3.cpp
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_grep_example_3.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_grep example 3: searches a cpp file for class definitions,
|
||||
* using a bound member function callback.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
// purpose:
|
||||
// takes the contents of a file in the form of a string
|
||||
// and searches for all the C++ class definitions, storing
|
||||
// their locations in a map of strings/int's
|
||||
|
||||
typedef std::map<std::string, std::string::difference_type, std::less<std::string> > map_type;
|
||||
|
||||
const char* re =
|
||||
// possibly leading whitespace:
|
||||
"^[[:space:]]*"
|
||||
// possible template declaration:
|
||||
"(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
||||
// class or struct:
|
||||
"(class|struct)[[:space:]]*"
|
||||
// leading declspec macros etc:
|
||||
"("
|
||||
"\\<\\w+\\>"
|
||||
"("
|
||||
"[[:blank:]]*\\([^)]*\\)"
|
||||
")?"
|
||||
"[[:space:]]*"
|
||||
")*"
|
||||
// the class name
|
||||
"(\\<\\w*\\>)[[:space:]]*"
|
||||
// template specialisation parameters
|
||||
"(<[^;:{]+>)?[[:space:]]*"
|
||||
// terminate in { or :
|
||||
"(\\{|:[^;\\{()]*\\{)";
|
||||
|
||||
|
||||
class class_index
|
||||
{
|
||||
boost::regex expression;
|
||||
map_type index;
|
||||
std::string::const_iterator base;
|
||||
|
||||
bool grep_callback(boost::match_results<std::string::const_iterator> what);
|
||||
public:
|
||||
map_type& get_map() { return index; }
|
||||
void IndexClasses(const std::string& file);
|
||||
class_index()
|
||||
: expression(re) {}
|
||||
};
|
||||
|
||||
bool class_index::grep_callback(boost::match_results<std::string::const_iterator> what)
|
||||
{
|
||||
// what[0] contains the whole string
|
||||
// what[5] contains the class name.
|
||||
// what[6] contains the template specialisation if any.
|
||||
// add class name and position to map:
|
||||
index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
|
||||
what[5].first - base;
|
||||
return true;
|
||||
}
|
||||
|
||||
void class_index::IndexClasses(const std::string& file)
|
||||
{
|
||||
std::string::const_iterator start, end;
|
||||
start = file.begin();
|
||||
end = file.end();
|
||||
base = start;
|
||||
boost::regex_grep([&](boost::match_results<std::string::const_iterator>const & what)->bool { return this->grep_callback(what); },
|
||||
start,
|
||||
end,
|
||||
expression);
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
|
||||
void load_file(std::string& s, std::istream& is)
|
||||
{
|
||||
s.erase();
|
||||
if(is.bad()) return;
|
||||
s.reserve(static_cast<std::string::size_type>(is.rdbuf()->in_avail()));
|
||||
char c;
|
||||
while(is.get(c))
|
||||
{
|
||||
if(s.capacity() == s.size())
|
||||
s.reserve(s.capacity() * 3);
|
||||
s.append(1, c);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
std::string text;
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
cout << "Processing file " << argv[i] << endl;
|
||||
std::ifstream fs(argv[i]);
|
||||
load_file(text, fs);
|
||||
fs.close();
|
||||
class_index idx;
|
||||
idx.IndexClasses(text);
|
||||
cout << idx.get_map().size() << " matches found" << endl;
|
||||
map_type::iterator c, d;
|
||||
c = idx.get_map().begin();
|
||||
d = idx.get_map().end();
|
||||
while(c != d)
|
||||
{
|
||||
cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
|
||||
++c;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
126
test/module/regex_iterator_example.cpp
Normal file
126
test/module/regex_iterator_example.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2003-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_iterator_example_2.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_iterator example 2: searches a cpp file for class definitions,
|
||||
* using global data.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
// purpose:
|
||||
// takes the contents of a file in the form of a string
|
||||
// and searches for all the C++ class definitions, storing
|
||||
// their locations in a map of strings/int's
|
||||
|
||||
typedef std::map<std::string, std::string::difference_type, std::less<std::string> > map_type;
|
||||
|
||||
const char* re =
|
||||
// possibly leading whitespace:
|
||||
"^[[:space:]]*"
|
||||
// possible template declaration:
|
||||
"(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
||||
// class or struct:
|
||||
"(class|struct)[[:space:]]*"
|
||||
// leading declspec macros etc:
|
||||
"("
|
||||
"\\<\\w+\\>"
|
||||
"("
|
||||
"[[:blank:]]*\\([^)]*\\)"
|
||||
")?"
|
||||
"[[:space:]]*"
|
||||
")*"
|
||||
// the class name
|
||||
"(\\<\\w*\\>)[[:space:]]*"
|
||||
// template specialisation parameters
|
||||
"(<[^;:{]+>)?[[:space:]]*"
|
||||
// terminate in { or :
|
||||
"(\\{|:[^;\\{()]*\\{)";
|
||||
|
||||
|
||||
boost::regex expression(re);
|
||||
map_type class_index;
|
||||
|
||||
bool regex_callback(const boost::match_results<std::string::const_iterator>& what)
|
||||
{
|
||||
// what[0] contains the whole string
|
||||
// what[5] contains the class name.
|
||||
// what[6] contains the template specialisation if any.
|
||||
// add class name and position to map:
|
||||
class_index[what[5].str() + what[6].str()] = what.position(5);
|
||||
return true;
|
||||
}
|
||||
|
||||
void load_file(std::string& s, std::istream& is)
|
||||
{
|
||||
s.erase();
|
||||
if(is.bad()) return;
|
||||
s.reserve(static_cast<std::string::size_type>(is.rdbuf()->in_avail()));
|
||||
char c;
|
||||
while(is.get(c))
|
||||
{
|
||||
if(s.capacity() == s.size())
|
||||
s.reserve(s.capacity() * 3);
|
||||
s.append(1, c);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
std::string text;
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
cout << "Processing file " << argv[i] << endl;
|
||||
std::ifstream fs(argv[i]);
|
||||
load_file(text, fs);
|
||||
fs.close();
|
||||
// construct our iterators:
|
||||
boost::sregex_iterator m1(text.begin(), text.end(), expression);
|
||||
boost::sregex_iterator m2;
|
||||
std::for_each(m1, m2, ®ex_callback);
|
||||
// copy results:
|
||||
cout << class_index.size() << " matches found" << endl;
|
||||
map_type::iterator c, d;
|
||||
c = class_index.begin();
|
||||
d = class_index.end();
|
||||
while(c != d)
|
||||
{
|
||||
cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
|
||||
++c;
|
||||
}
|
||||
class_index.erase(class_index.begin(), class_index.end());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
93
test/module/regex_match_example.cpp
Normal file
93
test/module/regex_match_example.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_match_example.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: ftp based regex_match example.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <cstdlib>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
using namespace boost;
|
||||
|
||||
regex expression("^([0-9]+)(\\-| |$)(.*)$");
|
||||
|
||||
// process_ftp:
|
||||
// on success returns the ftp response code, and fills
|
||||
// msg with the ftp response message.
|
||||
int process_ftp(const char* response, std::string* msg)
|
||||
{
|
||||
cmatch what;
|
||||
if(regex_match(response, what, expression))
|
||||
{
|
||||
// what[0] contains the whole string
|
||||
// what[1] contains the response code
|
||||
// what[2] contains the separator character
|
||||
// what[3] contains the text message.
|
||||
if(msg)
|
||||
msg->assign(what[3].first, what[3].second);
|
||||
return std::atoi(what[1].first);
|
||||
}
|
||||
// failure did not match
|
||||
if(msg)
|
||||
msg->erase();
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(int argc, const char*[])
|
||||
{
|
||||
using namespace std;
|
||||
std::string in, out;
|
||||
do
|
||||
{
|
||||
if(argc == 1)
|
||||
{
|
||||
cout << "enter test string" << endl;
|
||||
getline(cin, in);
|
||||
if(in == "quit")
|
||||
break;
|
||||
}
|
||||
else
|
||||
in = "100 this is an ftp message text";
|
||||
int result;
|
||||
result = process_ftp(in.c_str(), &out);
|
||||
if(result != -1)
|
||||
{
|
||||
cout << "Match found:" << endl;
|
||||
cout << "Response code: " << result << endl;
|
||||
cout << "Message text: " << out << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Match not found" << endl;
|
||||
}
|
||||
cout << endl;
|
||||
} while(argc == 1);
|
||||
return 0;
|
||||
}
|
||||
|
138
test/module/regex_merge_example.cpp
Normal file
138
test/module/regex_merge_example.cpp
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_merge_example.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_merge example:
|
||||
* converts a C++ file to syntax highlighted HTML.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
// purpose:
|
||||
// takes the contents of a file and transform to
|
||||
// syntax highlighted code in html format
|
||||
|
||||
boost::regex e1, e2;
|
||||
extern const char* expression_text;
|
||||
extern const char* format_string;
|
||||
extern const char* pre_expression;
|
||||
extern const char* pre_format;
|
||||
extern const char* header_text;
|
||||
extern const char* footer_text;
|
||||
|
||||
void load_file(std::string& s, std::istream& is)
|
||||
{
|
||||
s.erase();
|
||||
if(is.bad()) return;
|
||||
s.reserve(static_cast<std::string::size_type>(is.rdbuf()->in_avail()));
|
||||
char c;
|
||||
while(is.get(c))
|
||||
{
|
||||
if(s.capacity() == s.size())
|
||||
s.reserve(s.capacity() * 3);
|
||||
s.append(1, c);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
try{
|
||||
e1.assign(expression_text);
|
||||
e2.assign(pre_expression);
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
std::cout << "Processing file " << argv[i] << std::endl;
|
||||
std::ifstream fs(argv[i]);
|
||||
std::string in;
|
||||
load_file(in, fs);
|
||||
fs.close();
|
||||
std::string out_name = std::string(argv[i]) + std::string(".htm");
|
||||
std::ofstream os(out_name.c_str());
|
||||
os << header_text;
|
||||
// strip '<' and '>' first by outputting to a
|
||||
// temporary string stream
|
||||
std::ostringstream t(std::ios::out | std::ios::binary);
|
||||
std::ostream_iterator<char> oi(t);
|
||||
boost::regex_merge(oi, in.begin(), in.end(), e2, pre_format, boost::match_default | boost::format_all);
|
||||
// then output to final output stream
|
||||
// adding syntax highlighting:
|
||||
std::string s(t.str());
|
||||
std::ostream_iterator<char> out(os);
|
||||
boost::regex_merge(out, s.begin(), s.end(), e1, format_string, boost::match_default | boost::format_all);
|
||||
os << footer_text;
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{ return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* pre_expression = "(<)|(>)|\\r";
|
||||
const char* pre_format = "(?1<)(?2>)";
|
||||
|
||||
|
||||
const char* expression_text = // preprocessor directives: index 1
|
||||
"(^[[:blank:]]*#(?:[^\\\\\\n]|\\\\[^\\n[:punct:][:word:]]*[\\n[:punct:][:word:]])*)|"
|
||||
// comment: index 2
|
||||
"(//[^\\n]*|/\\*.*?\\*/)|"
|
||||
// literals: index 3
|
||||
"\\<([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\\>|"
|
||||
// string literals: index 4
|
||||
"('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|"
|
||||
// keywords: index 5
|
||||
"\\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import"
|
||||
"|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall"
|
||||
"|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool"
|
||||
"|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete"
|
||||
"|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto"
|
||||
"|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected"
|
||||
"|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast"
|
||||
"|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned"
|
||||
"|using|virtual|void|volatile|wchar_t|while)\\>"
|
||||
;
|
||||
|
||||
const char* format_string = "(?1<font color=\"#008040\">$&</font>)"
|
||||
"(?2<I><font color=\"#000080\">$&</font></I>)"
|
||||
"(?3<font color=\"#0000A0\">$&</font>)"
|
||||
"(?4<font color=\"#0000FF\">$&</font>)"
|
||||
"(?5<B>$&</B>)";
|
||||
|
||||
const char* header_text = "<HTML>\n<HEAD>\n"
|
||||
"<TITLE>Auto-generated html formated source</TITLE>\n"
|
||||
"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1252\">\n"
|
||||
"</HEAD>\n"
|
||||
"<BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffffff\">\n"
|
||||
"<P> </P>\n<PRE>";
|
||||
|
||||
const char* footer_text = "</PRE>\n</BODY>\n\n";
|
||||
|
149
test/module/regex_replace_example.cpp
Normal file
149
test/module/regex_replace_example.cpp
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_replace_example.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_replace example:
|
||||
* converts a C++ file to syntax highlighted HTML.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
// purpose:
|
||||
// takes the contents of a file and transform to
|
||||
// syntax highlighted code in html format
|
||||
|
||||
boost::regex e1, e2;
|
||||
extern const char* expression_text;
|
||||
extern const char* format_string;
|
||||
extern const char* pre_expression;
|
||||
extern const char* pre_format;
|
||||
extern const char* header_text;
|
||||
extern const char* footer_text;
|
||||
|
||||
void load_file(std::string& s, std::istream& is)
|
||||
{
|
||||
s.erase();
|
||||
if(is.bad()) return;
|
||||
s.reserve(static_cast<std::string::size_type>(is.rdbuf()->in_avail()));
|
||||
char c;
|
||||
while(is.get(c))
|
||||
{
|
||||
if(s.capacity() == s.size())
|
||||
s.reserve(s.capacity() * 3);
|
||||
s.append(1, c);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
try{
|
||||
e1.assign(expression_text);
|
||||
e2.assign(pre_expression);
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
std::cout << "Processing file " << argv[i] << std::endl;
|
||||
std::ifstream fs(argv[i]);
|
||||
std::string in;
|
||||
load_file(in, fs);
|
||||
fs.close();
|
||||
std::string out_name = std::string(argv[i]) + std::string(".htm");
|
||||
std::ofstream os(out_name.c_str());
|
||||
os << header_text;
|
||||
// strip '<' and '>' first by outputting to a
|
||||
// temporary string stream
|
||||
std::ostringstream t(std::ios::out | std::ios::binary);
|
||||
std::ostream_iterator<char> oi(t);
|
||||
boost::regex_replace(oi, in.begin(), in.end(), e2, pre_format, boost::match_default | boost::format_all);
|
||||
// then output to final output stream
|
||||
// adding syntax highlighting:
|
||||
std::string s(t.str());
|
||||
std::ostream_iterator<char> out(os);
|
||||
boost::regex_replace(out, s.begin(), s.end(), e1, format_string, boost::match_default | boost::format_all);
|
||||
os << footer_text;
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{ return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* pre_expression = "(<)|(>)|(&)|\\r";
|
||||
const char* pre_format = "(?1<)(?2>)(?3&)";
|
||||
|
||||
|
||||
const char* expression_text = // preprocessor directives: index 1
|
||||
"(^[[:blank:]]*#(?:[^\\\\\\n]|\\\\[^\\n[:punct:][:word:]]*[\\n[:punct:][:word:]])*)|"
|
||||
// comment: index 2
|
||||
"(//[^\\n]*|/\\*.*?\\*/)|"
|
||||
// literals: index 3
|
||||
"\\<([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\\>|"
|
||||
// string literals: index 4
|
||||
"('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|"
|
||||
// keywords: index 5
|
||||
"\\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import"
|
||||
"|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall"
|
||||
"|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool"
|
||||
"|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete"
|
||||
"|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto"
|
||||
"|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected"
|
||||
"|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast"
|
||||
"|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned"
|
||||
"|using|virtual|void|volatile|wchar_t|while)\\>"
|
||||
;
|
||||
|
||||
const char* format_string = "(?1<font color=\"#008040\">$&</font>)"
|
||||
"(?2<I><font color=\"#000080\">$&</font></I>)"
|
||||
"(?3<font color=\"#0000A0\">$&</font>)"
|
||||
"(?4<font color=\"#0000FF\">$&</font>)"
|
||||
"(?5<B>$&</B>)";
|
||||
|
||||
const char* header_text = "<HTML>\n<HEAD>\n"
|
||||
"<TITLE>Auto-generated html formated source</TITLE>\n"
|
||||
"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1252\">\n"
|
||||
"</HEAD>\n"
|
||||
"<BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffffff\">\n"
|
||||
"<P> </P>\n<PRE>";
|
||||
|
||||
const char* footer_text = "</PRE>\n</BODY>\n\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
139
test/module/regex_search_example.cpp
Normal file
139
test/module/regex_search_example.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_search_example.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_search example: searches a cpp file for class definitions.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
// purpose:
|
||||
// takes the contents of a file in the form of a string
|
||||
// and searches for all the C++ class definitions, storing
|
||||
// their locations in a map of strings/int's
|
||||
|
||||
typedef std::map<std::string, std::string::difference_type, std::less<std::string> > map_type;
|
||||
|
||||
const char* re =
|
||||
// possibly leading whitespace:
|
||||
"^[[:space:]]*"
|
||||
// possible template declaration:
|
||||
"(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
||||
// class or struct:
|
||||
"(class|struct)[[:space:]]*"
|
||||
// leading declspec macros etc:
|
||||
"("
|
||||
"\\<\\w+\\>"
|
||||
"("
|
||||
"[[:blank:]]*\\([^)]*\\)"
|
||||
")?"
|
||||
"[[:space:]]*"
|
||||
")*"
|
||||
// the class name
|
||||
"(\\<\\w*\\>)[[:space:]]*"
|
||||
// template specialisation parameters
|
||||
"(<[^;:{]+>)?[[:space:]]*"
|
||||
// terminate in { or :
|
||||
"(\\{|:[^;\\{()]*\\{)";
|
||||
|
||||
|
||||
boost::regex expression(re);
|
||||
|
||||
void IndexClasses(map_type& m, const std::string& file)
|
||||
{
|
||||
std::string::const_iterator start, end;
|
||||
start = file.begin();
|
||||
end = file.end();
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
boost::match_flag_type flags = boost::match_default;
|
||||
while(boost::regex_search(start, end, what, expression, flags))
|
||||
{
|
||||
// what[0] contains the whole string
|
||||
// what[5] contains the class name.
|
||||
// what[6] contains the template specialisation if any.
|
||||
// add class name and position to map:
|
||||
m[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
|
||||
what[5].first - file.begin();
|
||||
// update search position:
|
||||
start = what[0].second;
|
||||
// update flags:
|
||||
flags |= boost::match_prev_avail;
|
||||
flags |= boost::match_not_bob;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
void load_file(std::string& s, std::istream& is)
|
||||
{
|
||||
s.erase();
|
||||
if(is.bad()) return;
|
||||
s.reserve(static_cast<std::string::size_type>(is.rdbuf()->in_avail()));
|
||||
char c;
|
||||
while(is.get(c))
|
||||
{
|
||||
if(s.capacity() == s.size())
|
||||
s.reserve(s.capacity() * 3);
|
||||
s.append(1, c);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
std::string text;
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
cout << "Processing file " << argv[i] << endl;
|
||||
map_type m;
|
||||
std::ifstream fs(argv[i]);
|
||||
load_file(text, fs);
|
||||
fs.close();
|
||||
IndexClasses(m, text);
|
||||
cout << m.size() << " matches found" << endl;
|
||||
map_type::iterator c, d;
|
||||
c = m.begin();
|
||||
d = m.end();
|
||||
while(c != d)
|
||||
{
|
||||
cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
|
||||
++c;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
69
test/module/regex_split_example_1.cpp
Normal file
69
test/module/regex_split_example_1.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_split_example_1.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_split example: split a string into tokens.
|
||||
*/
|
||||
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
Simport std.core;
|
||||
#else
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
unsigned tokenise(std::list<std::string>& l, std::string& s)
|
||||
{
|
||||
return boost::regex_split(std::back_inserter(l), s);
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, const char*[])
|
||||
{
|
||||
string s;
|
||||
list<string> l;
|
||||
do{
|
||||
if(argc == 1)
|
||||
{
|
||||
cout << "Enter text to split (or \"quit\" to exit): ";
|
||||
getline(cin, s);
|
||||
if(s == "quit") break;
|
||||
}
|
||||
else
|
||||
s = "This is a string of tokens";
|
||||
unsigned result = tokenise(l, s);
|
||||
cout << result << " tokens found" << endl;
|
||||
cout << "The remaining text is: \"" << s << "\"" << endl;
|
||||
while(l.size())
|
||||
{
|
||||
s = *(l.begin());
|
||||
l.pop_front();
|
||||
cout << s << endl;
|
||||
}
|
||||
}while(argc == 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
97
test/module/regex_split_example_2.cpp
Normal file
97
test/module/regex_split_example_2.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_split_example_2.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_split example: spit out linked URL's.
|
||||
*/
|
||||
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <list>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
boost::regex e("<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)\"",
|
||||
boost::regex::normal | boost::regex::icase);
|
||||
|
||||
void load_file(std::string& s, std::istream& is)
|
||||
{
|
||||
s.erase();
|
||||
if(is.bad()) return;
|
||||
//
|
||||
// attempt to grow string buffer to match file size,
|
||||
// this doesn't always work...
|
||||
s.reserve(static_cast<std::string::size_type>(is.rdbuf()->in_avail()));
|
||||
char c;
|
||||
while(is.get(c))
|
||||
{
|
||||
// use logarithmic growth stategy, in case
|
||||
// in_avail (above) returned zero:
|
||||
if(s.capacity() == s.size())
|
||||
s.reserve(s.capacity() * 3);
|
||||
s.append(1, c);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::string s;
|
||||
std::list<std::string> l;
|
||||
int i;
|
||||
for(i = 1; i < argc; ++i)
|
||||
{
|
||||
std::cout << "Findings URL's in " << argv[i] << ":" << std::endl;
|
||||
s.erase();
|
||||
std::ifstream is(argv[i]);
|
||||
load_file(s, is);
|
||||
is.close();
|
||||
boost::regex_split(std::back_inserter(l), s, e);
|
||||
while(l.size())
|
||||
{
|
||||
s = *(l.begin());
|
||||
l.pop_front();
|
||||
std::cout << s << std::endl;
|
||||
}
|
||||
}
|
||||
//
|
||||
// alternative method:
|
||||
// split one match at a time and output direct to
|
||||
// cout via ostream_iterator<std::string>....
|
||||
//
|
||||
for(i = 1; i < argc; ++i)
|
||||
{
|
||||
std::cout << "Findings URL's in " << argv[i] << ":" << std::endl;
|
||||
s.erase();
|
||||
std::ifstream is(argv[i]);
|
||||
load_file(s, is);
|
||||
is.close();
|
||||
while(boost::regex_split(std::ostream_iterator<std::string>(std::cout), s, e, boost::match_default, 1)) std::cout << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
66
test/module/regex_token_iterator_eg_1.cpp
Normal file
66
test/module/regex_token_iterator_eg_1.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2003-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_token_iterator_example_1.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_token_iterator example: split a string into tokens.
|
||||
*/
|
||||
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, const char*[])
|
||||
{
|
||||
string s;
|
||||
do{
|
||||
if(argc == 1)
|
||||
{
|
||||
cout << "Enter text to split (or \"quit\" to exit): ";
|
||||
getline(cin, s);
|
||||
if(s == "quit") break;
|
||||
}
|
||||
else
|
||||
s = "This is a string of tokens";
|
||||
|
||||
boost::regex re("\\s+");
|
||||
boost::sregex_token_iterator i(s.begin(), s.end(), re, -1);
|
||||
boost::sregex_token_iterator j;
|
||||
|
||||
unsigned count = 0;
|
||||
while(i != j)
|
||||
{
|
||||
cout << *i++ << endl;
|
||||
count++;
|
||||
}
|
||||
cout << "There were " << count << " tokens found." << endl;
|
||||
|
||||
}while(argc == 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
99
test/module/regex_token_iterator_eg_2.cpp
Normal file
99
test/module/regex_token_iterator_eg_2.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2003-2022
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_token_iterator_example_2.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: regex_token_iterator example: spit out linked URL's.
|
||||
*/
|
||||
|
||||
#if (defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193833135))) && !defined(TEST_HEADERS)
|
||||
import std;
|
||||
#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) && !defined(TEST_HEADERS)
|
||||
import std.core;
|
||||
#else
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#endif
|
||||
|
||||
#ifdef TEST_HEADERS
|
||||
#include <boost/regex.hpp>
|
||||
#else
|
||||
import boost.regex;
|
||||
#endif
|
||||
|
||||
boost::regex e("<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)\"",
|
||||
boost::regex::normal | boost::regex::icase);
|
||||
|
||||
void load_file(std::string& s, std::istream& is)
|
||||
{
|
||||
s.erase();
|
||||
if(is.bad()) return;
|
||||
//
|
||||
// attempt to grow string buffer to match file size,
|
||||
// this doesn't always work...
|
||||
s.reserve(static_cast<std::string::size_type>(is.rdbuf()->in_avail()));
|
||||
char c;
|
||||
while(is.get(c))
|
||||
{
|
||||
// use logarithmic growth stategy, in case
|
||||
// in_avail (above) returned zero:
|
||||
if(s.capacity() == s.size())
|
||||
s.reserve(s.capacity() * 3);
|
||||
s.append(1, c);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::string s;
|
||||
int i;
|
||||
for(i = 1; i < argc; ++i)
|
||||
{
|
||||
std::cout << "Findings URL's in " << argv[i] << ":" << std::endl;
|
||||
s.erase();
|
||||
std::ifstream is(argv[i]);
|
||||
load_file(s, is);
|
||||
is.close();
|
||||
boost::sregex_token_iterator i(s.begin(), s.end(), e, 1);
|
||||
boost::sregex_token_iterator j;
|
||||
while(i != j)
|
||||
{
|
||||
std::cout << *i++ << std::endl;
|
||||
}
|
||||
}
|
||||
//
|
||||
// alternative method:
|
||||
// test the array-literal constructor, and split out the whole
|
||||
// match as well as $1....
|
||||
//
|
||||
for(i = 1; i < argc; ++i)
|
||||
{
|
||||
std::cout << "Findings URL's in " << argv[i] << ":" << std::endl;
|
||||
s.erase();
|
||||
std::ifstream is(argv[i]);
|
||||
load_file(s, is);
|
||||
is.close();
|
||||
const int subs[] = {1, 0,};
|
||||
boost::sregex_token_iterator i(s.begin(), s.end(), e, subs);
|
||||
boost::sregex_token_iterator j;
|
||||
while(i != j)
|
||||
{
|
||||
std::cout << *i++ << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
28
test/module/test_clang.sh
Executable file
28
test/module/test_clang.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Builds all of the tests in this folder using clang modules
|
||||
#
|
||||
: ${CXX:="clang++"}
|
||||
: ${CXXFLAGS:="-std=c++20 -g -I../../../.."}
|
||||
|
||||
rm *.o *.pcm *.exe
|
||||
|
||||
cmd="$CXX $CXXFLAGS -x c++-module ../../module/regex.cxx --precompile -o boost.regex.pcm"
|
||||
echo $cmd
|
||||
$cmd || exit 1
|
||||
cmd="$CXX $CXXFLAGS boost.regex.pcm -c -o regex.o"
|
||||
echo $cmd
|
||||
$cmd || exit 1
|
||||
cmd="$CXX $CXXFLAGS -fprebuilt-module-path=. -c ../../module/*.cpp"
|
||||
echo $cmd
|
||||
$cmd || exit 1
|
||||
|
||||
|
||||
for file in *.cpp; do
|
||||
|
||||
cmd="$CXX $CXXFLAGS -fprebuilt-module-path=. $file *.o -o ${file%.*}.exe"
|
||||
echo $cmd
|
||||
$cmd || exit 1
|
||||
|
||||
done
|
@ -3,12 +3,12 @@
|
||||
* Copyright (c) 2011
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <libs/regex/src/posix_api.cpp>
|
||||
#include <libs/regex/src/wide_posix_api.cpp>
|
||||
#include <posix_api.cpp>
|
||||
#include <wide_posix_api.cpp>
|
||||
|
Reference in New Issue
Block a user