Merge branch 'develop'

Fixed Conflicts:
	doc/html/index.html
This commit is contained in:
jzmaddock
2021-02-25 19:27:04 +00:00
138 changed files with 25865 additions and 8278 deletions

311
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,311 @@
# Copyright 2020 Evan Miller
# Copyright 2020 Matt Borland
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
name: CI
on: [ push, pull_request ]
jobs:
ubuntu-focal:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
compiler: [ g++-9, g++-10, clang++-9, clang++-10 ]
standard: [ c++11, c++14, c++17, c++2a ]
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: Set TOOLSET
run: echo ${{ matrix.compiler }} | awk '/^g/ { print "TOOLSET=gcc" } /^clang/ { print "TOOLSET=clang" }' >> $GITHUB_ENV
- name: Add repository
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Install packages
run: sudo apt install g++-9 g++-10 clang-9 clang-10
- 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: Generate user config
run: 'echo "using $TOOLSET : : ${{ matrix.compiler }} : <cxxflags>-std=${{ matrix.standard }} ;" > ~/user-config.jam'
working-directory: ../boost-root
- name: Config info install
run: ../../../b2 config_info_travis_install toolset=$TOOLSET
working-directory: ../boost-root/libs/config/test
- name: Config info
run: ./config_info_travis
working-directory: ../boost-root/libs/config/test
- name: Test
run: ../../../b2 toolset=$TOOLSET
working-directory: ../boost-root/libs/regex/test
ubuntu-bionic:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
compiler: [ g++-7, g++-8, clang++-7, clang++-8 ]
standard: [ c++11, c++14, c++17 ]
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: Set TOOLSET
run: echo ${{ matrix.compiler }} | awk '/^g/ { print "TOOLSET=gcc" } /^clang/ { print "TOOLSET=clang" }' >> $GITHUB_ENV
- name: Add repository
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Install packages
run: sudo apt install g++-7 g++-8 clang-7 clang-8
- 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: Generate user config
run: 'echo "using $TOOLSET : : ${{ matrix.compiler }} : <cxxflags>-std=${{ matrix.standard }} ;" > ~/user-config.jam'
working-directory: ../boost-root
- name: Config info install
run: ../../../b2 config_info_travis_install toolset=$TOOLSET
working-directory: ../boost-root/libs/config/test
- name: Config info
run: ./config_info_travis
working-directory: ../boost-root/libs/config/test
- name: Test
run: ../../../b2 toolset=$TOOLSET define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER
working-directory: ../boost-root/libs/regex/test
ubuntu-xenial:
runs-on: ubuntu-16.04
strategy:
fail-fast: false
matrix:
compiler: [ g++-5, g++-6, clang++-5.0, clang++-6.0 ]
standard: [ c++03 c++11, c++14, c++1z ]
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: Set TOOLSET
run: echo ${{ matrix.compiler }} | awk '/^g/ { print "TOOLSET=gcc" } /^clang/ { print "TOOLSET=clang" }' >> $GITHUB_ENV
- name: Add repository
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Install packages
run: sudo apt install g++-5 g++-6 clang-5.0 clang-6.0
- 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: Generate user config
run: 'echo "using $TOOLSET : : ${{ matrix.compiler }} : <cxxflags>-std=${{ matrix.standard }} ;" > ~/user-config.jam'
working-directory: ../boost-root
- name: Config info install
run: ../../../b2 config_info_travis_install toolset=$TOOLSET
working-directory: ../boost-root/libs/config/test
- name: Config info
run: ./config_info_travis
working-directory: ../boost-root/libs/config/test
- name: Test
run: ../../../b2 toolset=$TOOLSET
working-directory: ../boost-root/libs/regex/test
macos:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
toolset: [ clang ]
standard: [ 11, 14, 17, 2a ]
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];[linux];[Linux];[LINUX]'
commit-filter-separator: ';'
fail-fast: true
- 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: Config info install
run: ../../../b2 config_info_travis_install toolset=${{ matrix.toolset }} cxxstd=${{ matrix.standard }}
working-directory: ../boost-root/libs/config/test
- name: Config info
run: ./config_info_travis
working-directory: ../boost-root/libs/config/test
- name: Test
run: ../../../b2 toolset=${{ matrix.toolset }} cxxstd=${{ matrix.standard }}
working-directory: ../boost-root/libs/regex/test
windows:
runs-on: windows-latest
defaults:
run:
shell: cmd
env:
ARGS: toolset=${{ matrix.toolset }} address-model=64 cxxstd=${{ matrix.standard }}
strategy:
fail-fast: false
matrix:
toolset: [ gcc, msvc-14.0, msvc-14.2 ]
standard: [ 11, 14, 17 ]
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***;[apple];[Apple];[APPLE];[linux];[Linux];[LINUX]'
commit-filter-separator: ';'
fail-fast: true
- 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: xcopy /s /e /q %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
working-directory: ../boost-root
- name: Generate headers
run: b2 headers
working-directory: ../boost-root
- name: Config info install
run: ..\..\..\b2 config_info_travis_install %ARGS%
working-directory: ../boost-root/libs/config/test
- name: Config info
run: config_info_travis
working-directory: ../boost-root/libs/config/test
- name: Test
run: ..\..\..\b2 --hash %ARGS%
working-directory: ../boost-root/libs/regex/test
ubuntu-cmake-install:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- 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: CMake Test
working-directory: ../boost-root
run: |
mkdir __build__ && cd __build__
cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES="regex;core" -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build . --target install
cd ../libs/regex/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
cmake --build . --target check
ubuntu-cmake-check:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- 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: CMake Test
working-directory: ../boost-root/libs/regex/test
run: |
cd cmake_subdir_test && mkdir __build__ && cd __build__
cmake ..
cmake --build .
cmake --build . --target check

View File

@ -1,285 +0,0 @@
# Copyright 2016, 2017 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
branches:
only:
- master
- develop
- /feature\/.*/
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
env: TEST_CMAKE=true # variables unused - just for identification in travis ci gui
script:
- mkdir __build__ && cd __build__
- cmake .. -DBOOST_ENABLE_CMAKE=ON -DBOOST_INCLUDE_LIBRARIES=regex -DBOOST_REGEX_INCLUDE_EXAMPLES=ON
- cmake --build .
- os: linux
env: TEST_CMAKE=true BUILD_SHARED_LIBS=On # variables unused - just for identification in travis ci gui
script:
- mkdir __build__ && cd __build__
- cmake .. -DBUILD_SHARED_LIBS=ON -DBOOST_ENABLE_CMAKE=ON -DBOOST_INCLUDE_LIBRARIES=regex -DBOOST_REGEX_INCLUDE_EXAMPLES=ON
- cmake --build .
- os: linux
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03
- os: linux
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.7
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11 CXXSTD_DIALECT=cxxstd-dialect=gnu
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=14,1z CXXSTD_DIALECT=cxxstd-dialect=gnu
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11 CXXSTD_DIALECT=cxxstd-dialect=gnu
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=14,1z CXXSTD_DIALECT=cxxstd-dialect=gnu
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11 CXXSTD_DIALECT=cxxstd-dialect=gnu
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=14,1z CXXSTD_DIALECT=cxxstd-dialect=gnu
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.5
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
- os: linux
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.6
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- os: linux
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
- os: linux
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
- os: linux
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=14,1z
addons:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
- os: linux
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9
- os: linux
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=14,1z
addons:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
osx_image: xcode8.3
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=14,1z
osx_image: xcode8.3
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=11
osx_image: xcode8.2
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=11
osx_image: xcode8.1
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=11
osx_image: xcode8.0
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=11
osx_image: xcode7.3
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=11
osx_image: xcode6.4
# On this image, git doesn't support --jobs 3
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/regex
- python tools/boostdep/depinst/depinst.py -I example regex
- ./bootstrap.sh
- ./b2 headers
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/regex
- python tools/boostdep/depinst/depinst.py -I example -g "--jobs 3" regex
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- IFS=','
- for CXXLOCAL in $CXXSTD; do (cd libs/config/test && ../../../b2 config_info_travis_install toolset=$TOOLSET cxxstd=$CXXLOCAL $CXXSTD_DIALECT && echo With Standard Version $CXXLOCAL && ./config_info_travis && rm ./config_info_travis) done
- unset IFS
- ./b2 -j3 libs/regex/test toolset=$TOOLSET cxxstd=$CXXSTD $CXXSTD_DIALECT
notifications:
email:
on_success: always

View File

@ -1,103 +1,23 @@
# Copyright 2018-2019 Mike Dev
# Copyright 2018 Mike Dev
# Copyright 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
#
# NOTE: CMake support for Boost.Regex is currently experimental at best
# and the interface is likely to change in the future
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
# We support CMake 3.5, but prefer 3.16 policies and behavior
cmake_minimum_required(VERSION 3.5...3.16)
##### How-To:
#
# If you have a cmake project that wants to use and compile
# boost_regex, as part of a single build system run, do the following:
# 1) clone the boost project and all its sub-projects:
#
# git clone --branch develop --depth 1 --recursive --shallow-submodules https://github.com/boostorg/boost.git boost-root
#
# 2) add to your cmake script:
#
# add_subdirectory( <path-to-boost-root> [<build-dir-for-boost-libs>])
# target_link_libraries( <my-exec> PUBLIC Boost::regex)
#
# 3) run your cmake build as usual
#
# ## Explanation:
#
# Currently this file does not work standalone. It is expected to be
# invoked from a parent script via add_subdirectory. That parent script
# is responsible for providing targets for direct and indirect dependencies,
# such as Boost::assert, Boost::concept_check, e.g. by also adding those
# libraries via add_submodule (order doesn't matter).
# The parent script can be your own cmake script, but it is easier to just
# use add the CMakeLists in the root of the boost super project, which
# will in turn add all boost libraries usable with the add_subdirectory
# Workflow.
#
# Note: You don't need to actually clone all boost libraries. E.g. look
# into the travis ci file to see on which libraries boost_regex actually
# depends or use boostdep https://github.com/boostorg/boostdep
project(boost_regex VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_regex INTERFACE)
add_library(Boost::regex ALIAS boost_regex)
##### Current Limitations:
#
# - Doesn't compile or run tests
#
target_include_directories(boost_regex INTERFACE include)
cmake_minimum_required( VERSION 3.5...3.16 )
project( boost_regex VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX )
option( BOOST_REGEX_INCLUDE_EXAMPLES "Also build (some) boost regex examples" OFF )
option( BOOST_REGEX_USE_ICU "Enable ICU support in boost regex" OFF )
file( GLOB BOOST_REGEX_SRC ./src/*.cpp )
add_library( boost_regex ${BOOST_REGEX_SRC} )
add_library( Boost::regex ALIAS boost_regex )
target_include_directories( boost_regex PUBLIC include )
target_compile_definitions( boost_regex
PUBLIC
# No need for autolink
BOOST_REGEX_NO_LIB
$<$<STREQUAL:$<TARGET_PROPERTY:boost_regex,TYPE>,SHARED_LIBRARY>:BOOST_REGEX_DYN_LINK=1>
$<$<STREQUAL:$<TARGET_PROPERTY:boost_regex,TYPE>,STATIC_LIBRARY>:BOOST_REGEX_STATIC_LINK=1>
target_link_libraries(boost_regex
INTERFACE
Boost::config
Boost::throw_exception
Boost::predef
Boost::assert
)
# Specify dependencies (including header-only libraries)
target_link_libraries( boost_regex
PUBLIC
Boost::assert
Boost::concept_check
Boost::config
Boost::container_hash
Boost::core
Boost::integer
Boost::iterator
Boost::mpl
Boost::predef
Boost::smart_ptr
Boost::static_assert
Boost::throw_exception
Boost::type_traits
)
if( BOOST_REGEX_USE_ICU )
# ICU Targets could be provided by parent project,
# if not, look for them ourselves
if( NOT TARGET ICU::dt )
# components need to be listed explicitly
find_package( ICU COMPONENTS dt in uc REQUIRED )
endif()
target_link_libraries( boost_regex
PRIVATE
ICU::dt ICU::in ICU::uc
)
target_compile_definitions( boost_regex PRIVATE BOOST_HAS_ICU=1 )
endif()
if( BOOST_REGEX_INCLUDE_EXAMPLES )
add_subdirectory( example/snippets )
endif()

View File

@ -1,111 +0,0 @@
# Copyright 2016 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
platform:
- x64
environment:
matrix:
- ARGS: --toolset=msvc-9.0 address-model=32
- ARGS: --toolset=msvc-10.0 address-model=32
- ARGS: --toolset=msvc-11.0 address-model=32
- ARGS: --toolset=msvc-12.0 address-model=32
- ARGS: --toolset=msvc-14.0 address-model=32
- ARGS: --toolset=msvc-12.0 address-model=64
- ARGS: --toolset=msvc-14.0 address-model=64
- ARGS: --toolset=msvc-14.0 address-model=64 cxxstd=latest
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARGS: --toolset=msvc-14.1 address-model=64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARGS: --toolset=msvc-14.1 address-model=32
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARGS: --toolset=msvc-14.1 address-model=64 cxxstd=17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARGS: --toolset=msvc-14.1 address-model=64 cxxstd=latest cxxflags=-permissive-
- ARGS: --toolset=gcc address-model=64
PATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
- ARGS: --toolset=gcc address-model=64 cxxflags=-std=gnu++1z
PATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
- ARGS: --toolset=gcc address-model=32
PATH: C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin;%PATH%
- ARGS: --toolset=gcc address-model=32 linkflags=-Wl,-allow-multiple-definition
PATH: C:\MinGW\bin;%PATH%
- ARGS: --toolset=gcc address-model=32 define=_POSIX_C_SOURCE=200112L threadapi=pthread link=static
PATH: C:\cygwin\bin;%PATH%
- ARGS: --toolset=gcc address-model=64 define=_POSIX_C_SOURCE=200112L define=__USE_ISOC99 threadapi=pthread link=static
PATH: C:\cygwin64\bin;%PATH%
install:
- cd ..
- git clone -b %APPVEYOR_REPO_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init tools/boost_install
- git submodule update --init libs/headers
- git submodule update --init libs/config
- git submodule update --init libs/core
- git submodule update --init libs/container_hash
- git submodule update --init libs/detail
- git submodule update --init libs/smart_ptr
- git submodule update --init libs/predef
- git submodule update --init libs/assert
- git submodule update --init libs/throw_exception
- git submodule update --init libs/mpl
- git submodule update --init libs/type_traits
- git submodule update --init libs/static_assert
- git submodule update --init libs/integer
- git submodule update --init libs/preprocessor
- git submodule update --init libs/functional
- git submodule update --init libs/program_options
- git submodule update --init libs/chrono
- git submodule update --init libs/system
- git submodule update --init libs/thread
- git submodule update --init libs/winapi
- git submodule update --init libs/move
- git submodule update --init libs/date_time
- git submodule update --init libs/ratio
- git submodule update --init libs/iterator
- git submodule update --init libs/range
- git submodule update --init libs/any
- git submodule update --init libs/concept_check
- git submodule update --init libs/array
- git submodule update --init libs/timer
- git submodule update --init libs/bind
- git submodule update --init libs/utility
- git submodule update --init libs/io
- git submodule update --init libs/intrusive
- git submodule update --init libs/container
- git submodule update --init libs/tuple
- git submodule update --init libs/exception
- git submodule update --init libs/function
- git submodule update --init libs/type_index
- git submodule update --init libs/lexical_cast
- git submodule update --init libs/numeric
- git submodule update --init libs/math
- git submodule update --init libs/tokenizer
- git submodule update --init libs/optional
- git submodule update --init libs/atomic
- git submodule update --init libs/rational
- git submodule update --init libs/algorithm
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\regex
- bootstrap
- b2 headers
build: off
test_script:
- cd libs\config\test
- ..\..\..\b2 config_info_travis_install %ARGS%
- config_info_travis
- cd ..\..\regex\test
- ..\..\..\b2 -j3 %ARGS% define=CI_SUPPRESS_KNOWN_ISSUES

View File

@ -119,27 +119,18 @@ if ! $(disable-icu)
exe has_icu : has_icu_test.cpp : $(ICU_OPTS) ;
explicit has_icu ;
obj is_legacy_03 : is_legacy_03.cpp ;
explicit is_legacy_03 ;
alias icu_options : : : : [ check-target-builds has_icu : $(ICU_OPTS) : ] ;
SOURCES =
c_regex_traits.cpp
cpp_regex_traits.cpp
cregex.cpp
fileiter.cpp
icu.cpp
instances.cpp
posix_api.cpp
regex.cpp
regex_debug.cpp
regex_raw_buffer.cpp
regex_traits_defaults.cpp
static_mutex.cpp
w32_regex_traits.cpp
wc_regex_traits.cpp
wide_posix_api.cpp
winstances.cpp
usinstances.cpp ;
;
lib boost_regex : ../src/$(SOURCES) icu_options
:
@ -149,10 +140,3 @@ lib boost_regex : ../src/$(SOURCES) icu_options
boost-install boost_regex ;

16
build/is_legacy_03.cpp Normal file
View File

@ -0,0 +1,16 @@
/*
*
* Copyright (c) 2020
* 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/config.hpp>
#ifdef BOOST_REGEX_CXX03
#error "Legacy mode"
#endif

View File

@ -17,6 +17,22 @@ or platform) then [@../../../config/index.html Boost.Config] has a configure scr
[endsect]
[section:standalone Use in Standalone Mode (without the rest of Boost)]
This library may now be used in "standalone" mode without the rest of the Boost C++ libraries,
in order to do this you must either:
* Have a C++17 compiler that supports `__has_include`, in this case if `<boost/config.hpp>` is *not* present
then the library will automoatically enter standalone mode. Or:
* Define BOOST_REGEX_STANDALONE when building.
The main difference between the 2 modes, is that when Boost.Config is present the library will automatically
configure itself around various compiler defects. In particular in order to use the library with exception support
turned off, you will either need a copy of Boost.Config in your include path, or else manually define BOOST_NO_EXCEPTIONS
when building.
[endsect]
[section:locale Locale and traits class selection]
The following macros (see [@../../../../boost/regex/user.hpp user.hpp]) control how Boost.Regex interacts with
@ -31,43 +47,11 @@ the user's locale:
[endsect]
[section:linkage Linkage Options]
[table
[[macro][description]]
[[BOOST_REGEX_DYN_LINK][For Microsoft and Borland C++ builds, this tells Boost.Regex that it should link to the dll build of the Boost.Regex. By default boost.regex will link to its static library build, even if the dynamic C runtime library is in use.]]
[[BOOST_REGEX_NO_LIB][For Microsoft and Borland C++ builds, this tells Boost.Regex that it should not automatically select the library to link to.]]
[[BOOST_REGEX_NO_FASTCALL][For Microsoft builds, this tells Boost.Regex to use the `__cdecl` calling convention rather than `__fastcall`. Useful if you want to use the same library from both managed and unmanaged code.]]
]
[endsect]
[section:algorithm Algorithm Selection]
[table
[[macro][description]]
[[BOOST_REGEX_RECURSIVE][Tells Boost.Regex to use a stack-recursive matching algorithm. This is generally the fastest option (although there is very little in it), but can cause stack overflow in extreme cases, on Win32 this can be handled safely, but this is not the case on other platforms.]]
[[BOOST_REGEX_NON_RECURSIVE][Tells Boost.Regex to use a non-stack recursive matching algorithm, this can be slightly slower than the alternative, but is always safe no matter how pathological the regular expression. This is the default on non-Win32 platforms.]]
]
[endsect]
[section:tuning Algorithm Tuning]
The following option applies only if BOOST_REGEX_RECURSIVE is set.
[table
[[macro][description]]
[[BOOST_REGEX_HAS_MS_STACK_GUARD][Tells Boost.Regex that Microsoft style __try - __except blocks are supported, and can be used to safely trap stack overflow.]]
]
The following options apply only if BOOST_REGEX_NON_RECURSIVE is set.
[table
[[macro][description]]
[[BOOST_REGEX_BLOCKSIZE][In non-recursive mode, Boost.Regex uses largish blocks of memory to act as a stack for the state machine, the larger the block size then the fewer allocations that will take place. This defaults to 4096 bytes, which is large enough to match the vast majority of regular expressions without further allocations, however, you can choose smaller or larger values depending upon your platforms characteristics.]]
[[BOOST_REGEX_BLOCKSIZE][Boost.Regex uses largish blocks of memory to act as a stack for the state machine, the larger the block size then the fewer allocations that will take place. This defaults to 4096 bytes, which is large enough to match the vast majority of regular expressions without further allocations, however, you can choose smaller or larger values depending upon your platforms characteristics.]]
[[BOOST_REGEX_MAX_BLOCKS][Tells Boost.Regex how many blocks of size BOOST_REGEX_BLOCKSIZE it is permitted to use. If this value is exceeded then Boost.Regex will stop trying to find a match and throw a std::runtime_error. Defaults to 1024, don't forget to tweak this value if you alter BOOST_REGEX_BLOCKSIZE by much.]]
[[BOOST_REGEX_MAX_CACHE_BLOCKS][Tells Boost.Regex how many memory blocks to store in
it's internal cache - memory blocks are taken from this cache rather than by calling

View File

@ -30,8 +30,6 @@
<dt><span class="section"><a href="configuration/compiler.html">Compiler Setup</a></span></dt>
<dt><span class="section"><a href="configuration/locale.html">Locale and traits class
selection</a></span></dt>
<dt><span class="section"><a href="configuration/linkage.html">Linkage Options</a></span></dt>
<dt><span class="section"><a href="configuration/algorithm.html">Algorithm Selection</a></span></dt>
<dt><span class="section"><a href="configuration/tuning.html">Algorithm Tuning</a></span></dt>
</dl></div>
</div>

View File

@ -7,7 +7,7 @@
<link rel="home" href="../../index.html" title="Boost.Regex 5.1.4">
<link rel="up" href="../configuration.html" title="Configuration">
<link rel="prev" href="compiler.html" title="Compiler Setup">
<link rel="next" href="linkage.html" title="Linkage Options">
<link rel="next" href="tuning.html" title="Algorithm Tuning">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="compiler.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../configuration.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="linkage.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="compiler.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../configuration.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="tuning.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
@ -103,7 +103,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="compiler.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../configuration.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="linkage.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="compiler.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../configuration.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="tuning.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@ -6,7 +6,7 @@
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Boost.Regex 5.1.4">
<link rel="up" href="../configuration.html" title="Configuration">
<link rel="prev" href="algorithm.html" title="Algorithm Selection">
<link rel="prev" href="locale.html" title="Locale and traits class selection">
<link rel="next" href="../install.html" title="Building and Installing the Library">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@ -20,49 +20,12 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="algorithm.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../configuration.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="../install.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="locale.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../configuration.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="../install.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_regex.configuration.tuning"></a><a class="link" href="tuning.html" title="Algorithm Tuning">Algorithm Tuning</a>
</h3></div></div></div>
<p>
The following option applies only if BOOST_REGEX_RECURSIVE is set.
</p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
macro
</p>
</th>
<th>
<p>
description
</p>
</th>
</tr></thead>
<tbody><tr>
<td>
<p>
BOOST_REGEX_HAS_MS_STACK_GUARD
</p>
</td>
<td>
<p>
Tells Boost.Regex that Microsoft style __try - __except blocks
are supported, and can be used to safely trap stack overflow.
</p>
</td>
</tr></tbody>
</table></div>
<p>
The following options apply only if BOOST_REGEX_NON_RECURSIVE is set.
</p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
@ -89,13 +52,12 @@
</td>
<td>
<p>
In non-recursive mode, Boost.Regex uses largish blocks of memory
to act as a stack for the state machine, the larger the block size
then the fewer allocations that will take place. This defaults
to 4096 bytes, which is large enough to match the vast majority
of regular expressions without further allocations, however, you
can choose smaller or larger values depending upon your platforms
characteristics.
Boost.Regex uses largish blocks of memory to act as a stack for
the state machine, the larger the block size then the fewer allocations
that will take place. This defaults to 4096 bytes, which is large
enough to match the vast majority of regular expressions without
further allocations, however, you can choose smaller or larger
values depending upon your platforms characteristics.
</p>
</td>
</tr>
@ -150,7 +112,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="algorithm.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../configuration.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="../install.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="locale.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../configuration.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="../install.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@ -43,15 +43,39 @@
The library will encase all code inside namespace boost.
</p>
<p>
Unlike some other template libraries, this library consists of a mixture of
template code (in the headers) and static code and data (in cpp files). Consequently
it is necessary to build the library's support code into a library or archive
file before you can use it, instructions for specific platforms are as follows:
This is a header only library provided your compiler supports C++11 or later.
Support for C++03 compilers is still present, but is now deprecated and may
be removed without further notice!
</p>
<p>
The only people that still need to build the external libboost_regex library
are those that are either:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Using the library in C++03 mode, or,
</li>
<li class="listitem">
Using the deprecated POSIX C API's
</li>
</ul></div>
<p>
Further, this library may now be used in "standalone" mode without
the rest of the Boost C++ libraries, in order to do this you must either:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Have a C++17 compiler that supports <code class="computeroutput"><span class="identifier">__has_include</span></code>,
in this case if <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code> is not present then the library will
automoatically enter standalone mode. Or:
</li>
<li class="listitem">
Define BOOST_REGEX_STANDALONE when building.
</li>
</ul></div>
<h5>
<a name="boost_regex.install.h0"></a>
<span class="phrase"><a name="boost_regex.install.building_with_bjam"></a></span><a class="link" href="install.html#boost_regex.install.building_with_bjam">Building
with bjam</a>
<span class="phrase"><a name="boost_regex.install.c_03_users_only_deprecated_build"></a></span><a class="link" href="install.html#boost_regex.install.c_03_users_only_deprecated_build"><span class="bold"><strong>C++03 users only (Deprecated)</strong></span> Building with bjam</a>
</h5>
<p>
This is now the preferred method for building and installing this library,

View File

@ -231,9 +231,9 @@ cab
sets:</a>
</h5>
<p>
A character set is a bracket-expression starting with [ and ending with ],
it defines a set of characters, and matches any single character that is
a member of that set.
A character set is a bracket-expression starting with <code class="literal">[</code>
and ending with <code class="literal">]</code>, it defines a set of characters, and
matches any single character that is a member of that set.
</p>
<p>
A bracket expression may contain any combination of the following:

View File

@ -176,9 +176,9 @@ aaaa
sets:</a>
</h5>
<p>
A character set is a bracket-expression starting with [ and ending with ],
it defines a set of characters, and matches any single character that is
a member of that set.
A character set is a bracket-expression starting with <code class="literal">[</code>
and ending with <code class="literal">]</code>, it defines a set of characters, and
matches any single character that is a member of that set.
</p>
<p>
A bracket expression may contain any combination of the following:

View File

@ -402,9 +402,9 @@
sets</a>
</h5>
<p>
A character set is a bracket-expression starting with <code class="literal">[] and ending
with <code class="literal"></code></code>, it defines a set of characters, and matches
any single character that is a member of that set.
A character set is a bracket-expression starting with <code class="literal">[</code>
and ending with <code class="literal">]</code>, it defines a set of characters, and
matches any single character that is a member of that set.
</p>
<p>
A bracket expression may contain any combination of the following:

View File

@ -44,8 +44,6 @@
<dt><span class="section"><a href="boost_regex/configuration/compiler.html">Compiler Setup</a></span></dt>
<dt><span class="section"><a href="boost_regex/configuration/locale.html">Locale and traits class
selection</a></span></dt>
<dt><span class="section"><a href="boost_regex/configuration/linkage.html">Linkage Options</a></span></dt>
<dt><span class="section"><a href="boost_regex/configuration/algorithm.html">Algorithm Selection</a></span></dt>
<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>
@ -215,7 +213,7 @@
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: November 23, 2020 at 18:11:11 GMT</small></p></td>
<td align="left"><p><small>Last revised: January 25, 2021 at 11:08:05 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>

View File

@ -20,13 +20,22 @@ process is the same as for all of boost; see the
The library will encase all code inside namespace boost.
Unlike some other template libraries, this library consists of a mixture of
template code (in the headers) and static code and data (in cpp files).
Consequently it is necessary to build the library's support code into a
library or archive file before you can use it, instructions for specific
platforms are as follows:
This is a header only library provided your compiler supports C++11 or later. Support for
C++03 compilers is still present, but is now deprecated and may be removed without further notice!
[h4 Building with bjam]
The only people that still need to build the external libboost_regex library are those that are either:
* Using the library in C++03 mode, or,
* Using the deprecated POSIX C API's
Further, this library may now be used in "standalone" mode without the rest of the Boost C++ libraries,
in order to do this you must either:
* Have a C++17 compiler that supports `__has_include`, in this case if `<boost/config.hpp>` is not present
then the library will automoatically enter standalone mode. Or:
* Define BOOST_REGEX_STANDALONE when building.
[h4 [*C++03 users only (Deprecated)] Building with bjam]
This is now the preferred method for building and installing this library,
please refer to the

View File

@ -118,7 +118,7 @@ But not the string:
[h4 Character sets:]
A character set is a bracket-expression starting with \[ and ending with \],
A character set is a bracket-expression starting with [^\[] and ending with [^\]],
it defines a set of characters, and matches any single character that is a
member of that set.

View File

@ -151,7 +151,7 @@ will match either of "abd" or "abef".
[h4 Character sets:]
A character set is a bracket-expression starting with \[ and ending with \],
A character set is a bracket-expression starting with [^\[] and ending with [^\]],
it defines a set of characters, and matches any single character that is
a member of that set.

View File

@ -217,7 +217,7 @@ if you really want an empty alternative use [^(?:)] as a placeholder, for exampl
[h4 Character sets]
A character set is a bracket-expression starting with [^[] and ending with [^]],
A character set is a bracket-expression starting with [^\[] and ending with [^\]],
it defines a set of characters, and matches any single character that is a
member of that set.

View File

@ -1,6 +1,6 @@
/*
*
* Copyright (c) 12003
* Copyright (c) 2003
* John Maddock
*
* Use, modification and distribution are subject to the

View File

@ -24,7 +24,11 @@
#include <boost/regex/config.hpp>
#endif
#ifdef BOOST_REGEX_CXX03
#include <boost/regex/v4/cregex.hpp>
#else
#include <boost/regex/v5/cregex.hpp>
#endif
#endif /* include guard */

View File

@ -28,7 +28,11 @@
#include <boost/regex/config.hpp>
#endif
#ifdef BOOST_REGEX_CXX03
#include <boost/regex/v4/regex.hpp>
#else
#include <boost/regex/v5/regex.hpp>
#endif
#endif // include

View File

@ -31,6 +31,12 @@
#include <vector>
#include <iostream>
#ifdef BOOST_REGEX_CXX03
#define RW_NS boost
#else
#define RW_NS std
#endif
namespace boost{
//
@ -996,37 +1002,36 @@ struct BoostRegexConcept
out = regex_format(out, m_cresults, func2b);
out = regex_format(out, m_cresults, func1b, f);
out = regex_format(out, m_cresults, func1b);
out = regex_format(out, m_cresults, boost::ref(func3b), f);
out = regex_format(out, m_cresults, boost::ref(func3b));
out = regex_format(out, m_cresults, boost::ref(func2b), f);
out = regex_format(out, m_cresults, boost::ref(func2b));
out = regex_format(out, m_cresults, boost::ref(func1b), f);
out = regex_format(out, m_cresults, boost::ref(func1b));
out = regex_format(out, m_cresults, boost::cref(func3b), f);
out = regex_format(out, m_cresults, boost::cref(func3b));
out = regex_format(out, m_cresults, boost::cref(func2b), f);
out = regex_format(out, m_cresults, boost::cref(func2b));
out = regex_format(out, m_cresults, boost::cref(func1b), f);
out = regex_format(out, m_cresults, boost::cref(func1b));
out = regex_format(out, m_cresults, RW_NS::ref(func3b), f);
out = regex_format(out, m_cresults, RW_NS::ref(func3b));
out = regex_format(out, m_cresults, RW_NS::ref(func2b), f);
out = regex_format(out, m_cresults, RW_NS::ref(func2b));
out = regex_format(out, m_cresults, RW_NS::ref(func1b), f);
out = regex_format(out, m_cresults, RW_NS::ref(func1b));
out = regex_format(out, m_cresults, RW_NS::cref(func3b), f);
out = regex_format(out, m_cresults, RW_NS::cref(func3b));
out = regex_format(out, m_cresults, RW_NS::cref(func2b), f);
out = regex_format(out, m_cresults, RW_NS::cref(func2b));
out = regex_format(out, m_cresults, RW_NS::cref(func1b), f);
out = regex_format(out, m_cresults, RW_NS::cref(func1b));
m_string += regex_format(m_cresults, func3b, f);
m_string += regex_format(m_cresults, func3b);
m_string += regex_format(m_cresults, func2b, f);
m_string += regex_format(m_cresults, func2b);
m_string += regex_format(m_cresults, func1b, f);
m_string += regex_format(m_cresults, func1b);
m_string += regex_format(m_cresults, boost::ref(func3b), f);
m_string += regex_format(m_cresults, boost::ref(func3b));
m_string += regex_format(m_cresults, boost::ref(func2b), f);
m_string += regex_format(m_cresults, boost::ref(func2b));
m_string += regex_format(m_cresults, boost::ref(func1b), f);
m_string += regex_format(m_cresults, boost::ref(func1b));
m_string += regex_format(m_cresults, boost::cref(func3b), f);
m_string += regex_format(m_cresults, boost::cref(func3b));
m_string += regex_format(m_cresults, boost::cref(func2b), f);
m_string += regex_format(m_cresults, boost::cref(func2b));
m_string += regex_format(m_cresults, boost::cref(func1b), f);
m_string += regex_format(m_cresults, boost::cref(func1b));
m_string += regex_format(m_cresults, RW_NS::ref(func3b), f);
m_string += regex_format(m_cresults, RW_NS::ref(func3b));
m_string += regex_format(m_cresults, RW_NS::ref(func2b), f);
m_string += regex_format(m_cresults, RW_NS::ref(func2b));
m_string += regex_format(m_cresults, RW_NS::ref(func1b), f);
m_string += regex_format(m_cresults, RW_NS::ref(func1b));
m_string += regex_format(m_cresults, RW_NS::cref(func3b), f);
m_string += regex_format(m_cresults, RW_NS::cref(func3b));
m_string += regex_format(m_cresults, RW_NS::cref(func2b), f);
m_string += regex_format(m_cresults, RW_NS::cref(func2b));
m_string += regex_format(m_cresults, RW_NS::cref(func1b), f);
m_string += regex_format(m_cresults, RW_NS::cref(func1b));
out = m_cresults.format(out, func3b, f);
out = m_cresults.format(out, func3b);
@ -1034,18 +1039,18 @@ struct BoostRegexConcept
out = m_cresults.format(out, func2b);
out = m_cresults.format(out, func1b, f);
out = m_cresults.format(out, func1b);
out = m_cresults.format(out, boost::ref(func3b), f);
out = m_cresults.format(out, boost::ref(func3b));
out = m_cresults.format(out, boost::ref(func2b), f);
out = m_cresults.format(out, boost::ref(func2b));
out = m_cresults.format(out, boost::ref(func1b), f);
out = m_cresults.format(out, boost::ref(func1b));
out = m_cresults.format(out, boost::cref(func3b), f);
out = m_cresults.format(out, boost::cref(func3b));
out = m_cresults.format(out, boost::cref(func2b), f);
out = m_cresults.format(out, boost::cref(func2b));
out = m_cresults.format(out, boost::cref(func1b), f);
out = m_cresults.format(out, boost::cref(func1b));
out = m_cresults.format(out, RW_NS::ref(func3b), f);
out = m_cresults.format(out, RW_NS::ref(func3b));
out = m_cresults.format(out, RW_NS::ref(func2b), f);
out = m_cresults.format(out, RW_NS::ref(func2b));
out = m_cresults.format(out, RW_NS::ref(func1b), f);
out = m_cresults.format(out, RW_NS::ref(func1b));
out = m_cresults.format(out, RW_NS::cref(func3b), f);
out = m_cresults.format(out, RW_NS::cref(func3b));
out = m_cresults.format(out, RW_NS::cref(func2b), f);
out = m_cresults.format(out, RW_NS::cref(func2b));
out = m_cresults.format(out, RW_NS::cref(func1b), f);
out = m_cresults.format(out, RW_NS::cref(func1b));
m_string += m_cresults.format(func3b, f);
m_string += m_cresults.format(func3b);
@ -1053,18 +1058,18 @@ struct BoostRegexConcept
m_string += m_cresults.format(func2b);
m_string += m_cresults.format(func1b, f);
m_string += m_cresults.format(func1b);
m_string += m_cresults.format(boost::ref(func3b), f);
m_string += m_cresults.format(boost::ref(func3b));
m_string += m_cresults.format(boost::ref(func2b), f);
m_string += m_cresults.format(boost::ref(func2b));
m_string += m_cresults.format(boost::ref(func1b), f);
m_string += m_cresults.format(boost::ref(func1b));
m_string += m_cresults.format(boost::cref(func3b), f);
m_string += m_cresults.format(boost::cref(func3b));
m_string += m_cresults.format(boost::cref(func2b), f);
m_string += m_cresults.format(boost::cref(func2b));
m_string += m_cresults.format(boost::cref(func1b), f);
m_string += m_cresults.format(boost::cref(func1b));
m_string += m_cresults.format(RW_NS::ref(func3b), f);
m_string += m_cresults.format(RW_NS::ref(func3b));
m_string += m_cresults.format(RW_NS::ref(func2b), f);
m_string += m_cresults.format(RW_NS::ref(func2b));
m_string += m_cresults.format(RW_NS::ref(func1b), f);
m_string += m_cresults.format(RW_NS::ref(func1b));
m_string += m_cresults.format(RW_NS::cref(func3b), f);
m_string += m_cresults.format(RW_NS::cref(func3b));
m_string += m_cresults.format(RW_NS::cref(func2b), f);
m_string += m_cresults.format(RW_NS::cref(func2b));
m_string += m_cresults.format(RW_NS::cref(func1b), f);
m_string += m_cresults.format(RW_NS::cref(func1b));
out = regex_replace(out, m_in, m_in, ce, func3, f);
out = regex_replace(out, m_in, m_in, ce, func3);
@ -1072,18 +1077,18 @@ struct BoostRegexConcept
out = regex_replace(out, m_in, m_in, ce, func2);
out = regex_replace(out, m_in, m_in, ce, func1, f);
out = regex_replace(out, m_in, m_in, ce, func1);
out = regex_replace(out, m_in, m_in, ce, boost::ref(func3), f);
out = regex_replace(out, m_in, m_in, ce, boost::ref(func3));
out = regex_replace(out, m_in, m_in, ce, boost::ref(func2), f);
out = regex_replace(out, m_in, m_in, ce, boost::ref(func2));
out = regex_replace(out, m_in, m_in, ce, boost::ref(func1), f);
out = regex_replace(out, m_in, m_in, ce, boost::ref(func1));
out = regex_replace(out, m_in, m_in, ce, boost::cref(func3), f);
out = regex_replace(out, m_in, m_in, ce, boost::cref(func3));
out = regex_replace(out, m_in, m_in, ce, boost::cref(func2), f);
out = regex_replace(out, m_in, m_in, ce, boost::cref(func2));
out = regex_replace(out, m_in, m_in, ce, boost::cref(func1), f);
out = regex_replace(out, m_in, m_in, ce, boost::cref(func1));
out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func3), f);
out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func3));
out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func2), f);
out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func2));
out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func1), f);
out = regex_replace(out, m_in, m_in, ce, RW_NS::ref(func1));
out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func3), f);
out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func3));
out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func2), f);
out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func2));
out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func1), f);
out = regex_replace(out, m_in, m_in, ce, RW_NS::cref(func1));
functor3<match_results<typename string_type::const_iterator> > func3s;
functor2<match_results<typename string_type::const_iterator> > func2s;
@ -1094,18 +1099,18 @@ struct BoostRegexConcept
m_string += regex_replace(m_string, ce, func2s);
m_string += regex_replace(m_string, ce, func1s, f);
m_string += regex_replace(m_string, ce, func1s);
m_string += regex_replace(m_string, ce, boost::ref(func3s), f);
m_string += regex_replace(m_string, ce, boost::ref(func3s));
m_string += regex_replace(m_string, ce, boost::ref(func2s), f);
m_string += regex_replace(m_string, ce, boost::ref(func2s));
m_string += regex_replace(m_string, ce, boost::ref(func1s), f);
m_string += regex_replace(m_string, ce, boost::ref(func1s));
m_string += regex_replace(m_string, ce, boost::cref(func3s), f);
m_string += regex_replace(m_string, ce, boost::cref(func3s));
m_string += regex_replace(m_string, ce, boost::cref(func2s), f);
m_string += regex_replace(m_string, ce, boost::cref(func2s));
m_string += regex_replace(m_string, ce, boost::cref(func1s), f);
m_string += regex_replace(m_string, ce, boost::cref(func1s));
m_string += regex_replace(m_string, ce, RW_NS::ref(func3s), f);
m_string += regex_replace(m_string, ce, RW_NS::ref(func3s));
m_string += regex_replace(m_string, ce, RW_NS::ref(func2s), f);
m_string += regex_replace(m_string, ce, RW_NS::ref(func2s));
m_string += regex_replace(m_string, ce, RW_NS::ref(func1s), f);
m_string += regex_replace(m_string, ce, RW_NS::ref(func1s));
m_string += regex_replace(m_string, ce, RW_NS::cref(func3s), f);
m_string += regex_replace(m_string, ce, RW_NS::cref(func3s));
m_string += regex_replace(m_string, ce, RW_NS::cref(func2s), f);
m_string += regex_replace(m_string, ce, RW_NS::cref(func2s));
m_string += regex_replace(m_string, ce, RW_NS::cref(func1s), f);
m_string += regex_replace(m_string, ce, RW_NS::cref(func1s));
}
std::basic_ostream<value_type> m_stream;

View File

@ -18,6 +18,21 @@
#ifndef BOOST_REGEX_CONFIG_HPP
#define BOOST_REGEX_CONFIG_HPP
#if !((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) || defined(BOOST_REGEX_CXX03))
# define BOOST_REGEX_CXX03
#endif
#if defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_CXX03)
# define BOOST_REGEX_CXX03
#endif
#if defined(__has_include)
#if !defined(BOOST_REGEX_STANDALONE) && !__has_include(<boost/version.hpp>)
#define BOOST_REGEX_STANDALONE
#endif
#endif
/*
* Borland C++ Fix/error check
* this has to go *before* we include any std lib headers:
@ -25,7 +40,23 @@
#if defined(__BORLANDC__) && !defined(__clang__)
# include <boost/regex/config/borland.hpp>
#endif
#ifndef BOOST_REGEX_STANDALONE
#include <boost/version.hpp>
#endif
/*************************************************************************
*
* Asserts:
*
*************************************************************************/
#ifdef BOOST_REGEX_STANDALONE
#include <cassert>
# define BOOST_REGEX_ASSERT(x) assert(x)
#else
#include <boost/assert.hpp>
# define BOOST_REGEX_ASSERT(x) BOOST_ASSERT(x)
#endif
/*****************************************************************************
*
@ -41,8 +72,10 @@
# include BOOST_REGEX_USER_CONFIG
#ifndef BOOST_REGEX_STANDALONE
# include <boost/config.hpp>
# include <boost/predef.h>
#endif
#else
/*
@ -57,6 +90,21 @@
# endif
#endif
/****************************************************************************
*
* Legacy support:
*
*******************************************************************************/
#if defined(BOOST_NO_STD_LOCALE) || defined(BOOST_NO_CXX11_HDR_MUTEX) || defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) \
|| defined(BOOST_NO_CXX11_HDR_ATOMIC) || defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_CXX11_SMART_PTR) \
|| defined(BOOST_NO_CXX11_STATIC_ASSERT) || defined(BOOST_NO_NOEXCEPT)
#ifndef BOOST_REGEX_CXX03
# define BOOST_REGEX_CXX03
#endif
#endif
/*****************************************************************************
*
* Boilerplate regex config options:
@ -64,19 +112,50 @@
****************************************************************************/
/* Obsolete macro, use BOOST_VERSION instead: */
#define BOOST_RE_VERSION 320
#define BOOST_RE_VERSION 500
/* fix: */
#if defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
#define BOOST_REGEX_JOIN(X, Y) BOOST_REGEX_DO_JOIN(X, Y)
#define BOOST_REGEX_DO_JOIN(X, Y) BOOST_REGEX_DO_JOIN2(X,Y)
#define BOOST_REGEX_DO_JOIN2(X, Y) X##Y
#ifdef BOOST_FALLTHROUGH
# define BOOST_REGEX_FALLTHROUGH BOOST_FALLTHROUGH
#else
#if defined(__clang__) && (__cplusplus >= 201103L) && defined(__has_warning)
# if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
# define BOOST_REGEX_FALLTHROUGH [[clang::fallthrough]]
# endif
#endif
#if !defined(BOOST_REGEX_FALLTHROUGH) && defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1800) && (__cplusplus >= 201703)
# define BOOST_REGEX_FALLTHROUGH [[fallthrough]]
#endif
#if !defined(BOOST_REGEX_FALLTHROUGH) && defined(__GNUC__) && (__GNUC__ >= 7)
# define BOOST_REGEX_FALLTHROUGH __attribute__((fallthrough))
#endif
#if !defined(BOOST_REGEX_FALLTHROUGH)
# define BOOST_REGEX_FALLTHROUGH
#endif
#endif
#ifdef BOOST_NORETURN
# define BOOST_REGEX_NORETURN BOOST_NORETURN
#else
# define BOOST_REGEX_NORETURN
#endif
/*
* Define a macro for the namespace that details are placed in, this includes the Boost
* version number to avoid mismatched header and library versions:
*/
#define BOOST_REGEX_DETAIL_NS BOOST_JOIN(re_detail_, BOOST_VERSION)
#define BOOST_REGEX_DETAIL_NS BOOST_REGEX_JOIN(re_detail_, BOOST_RE_VERSION)
/*
* Fix for gcc prior to 3.4: std::ctype<wchar_t> doesn't allow
@ -84,47 +163,10 @@
* std::use_facet<std::ctype<wchar_t> >.is(std::ctype_base::lower|std::ctype_base::upper, L'a');
* returns *false*.
*/
#ifdef __GLIBCPP__
#if defined(__GLIBCPP__) && defined(BOOST_REGEX_CXX03)
# define BOOST_REGEX_BUGGY_CTYPE_FACET
#endif
/*
* Intel C++ before 8.0 ends up with unresolved externals unless we turn off
* extern template support:
*/
#if defined(BOOST_INTEL) && defined(__cplusplus) && (BOOST_INTEL <= 800)
# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
#endif
/*
* Visual C++ doesn't support external templates with C++ extensions turned off:
*/
#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
#endif
/*
* Oracle compiler in C++11 mode doesn't like external templates for some reason:
*/
#ifdef __SUNPRO_CC
# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
#endif
/*
* Shared regex lib will crash without this, frankly it looks a lot like a gcc bug:
*/
#if defined(__MINGW32__)
# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
#endif
/*
* Clang fails to export template instances with -fvisibility=hidden, see
* https://github.com/boostorg/regex/issues/49
*/
#ifdef __clang__
# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
#endif
#ifdef __CYGWIN__
/* We get multiply defined symbols without this: */
# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
#endif
/*
* If there isn't good enough wide character support then there will
* be no wide character regular expressions:
@ -143,7 +185,7 @@
# define _STLP_CWCTYPE
# endif
#ifdef __cplusplus
#if defined(__cplusplus) && defined(BOOST_REGEX_CXX03)
# include <boost/regex/config/cwchar.hpp>
#endif
@ -183,50 +225,12 @@
# define BOOST_REGEX_NO_W32
#endif
/*****************************************************************************
*
* Wide character workarounds:
*
****************************************************************************/
/*
* define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users
* code may be built with wchar_t as unsigned short: basically when we're building
* with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
* of the non-inline functions in the library, so that users can still link to the lib,
* irrespective of whether their own code is built with /Zc:wchar_t.
* Note that this does NOT WORK with VC10 and VC14 when the C++ locale is in effect as
* the locale's <unsigned short> facets simply do not compile in that case.
* As we default to the C++ locale when compiling for the windows runtime we
* skip in this case aswell.
*/
#if defined(__cplusplus) && \
(defined(BOOST_MSVC) || defined(__ICL)) && \
!defined(BOOST_NO_INTRINSIC_WCHAR_T) && \
defined(BOOST_WINDOWS) && \
!defined(__SGI_STL_PORT) && \
!defined(_STLPORT_VERSION) && \
!defined(BOOST_RWSTD_VER) && \
((_MSC_VER < 1600) || !defined(BOOST_REGEX_USE_CPP_LOCALE)) && \
!BOOST_PLAT_WINDOWS_RUNTIME
# define BOOST_REGEX_HAS_OTHER_WCHAR_T
# ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4251)
#if BOOST_MSVC < 1700
# pragma warning(disable : 4231)
#ifdef BOOST_REGEX_STANDALONE
# if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__)
# define BOOST_REGEX_MSVC _MSC_VER
#endif
# if BOOST_MSVC < 1600
# pragma warning(disable : 4660)
# endif
# endif
# if defined(_DLL) && defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
# include <string>
extern template class __declspec(dllimport) std::basic_string<unsigned short>;
# endif
# ifdef BOOST_MSVC
# pragma warning(pop)
# endif
#elif defined(BOOST_MSVC)
# define BOOST_REGEX_MSVC BOOST_MSVC
#endif
@ -236,15 +240,10 @@
*
****************************************************************************/
#ifndef BOOST_SYMBOL_EXPORT
# define BOOST_SYMBOL_EXPORT
# define BOOST_SYMBOL_IMPORT
#endif
#if (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK)
#if (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK) && defined(BOOST_SYMBOL_IMPORT)
# if defined(BOOST_REGEX_SOURCE)
# define BOOST_REGEX_DECL BOOST_SYMBOL_EXPORT
# define BOOST_REGEX_BUILD_DLL
# define BOOST_REGEX_DECL BOOST_SYMBOL_EXPORT
# else
# define BOOST_REGEX_DECL BOOST_SYMBOL_IMPORT
# endif
@ -252,6 +251,7 @@
# define BOOST_REGEX_DECL
#endif
#ifdef BOOST_REGEX_CXX03
#if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
# define BOOST_LIB_NAME boost_regex
# if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
@ -262,6 +262,7 @@
# endif
# include <boost/config/auto_link.hpp>
#endif
#endif
/*****************************************************************************
*
@ -333,7 +334,7 @@
#if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
# define BOOST_REGEX_USE_CPP_LOCALE
#endif
/* otherwise use C+ locale: */
/* otherwise use C locale: */
#if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
# define BOOST_REGEX_USE_C_LOCALE
#endif
@ -407,12 +408,13 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
/*****************************************************************************
*
* Algorithm selection and configuration:
* Algorithm selection and configuration.
* These options are now obsolete for C++11 and later (regex v5).
*
****************************************************************************/
#if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
# if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(_MSC_VER) && (_MSC_VER >= 1400))
# if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(_MSC_VER) && (_MSC_VER >= 1400)) && defined(BOOST_REGEX_CXX03)
# define BOOST_REGEX_RECURSIVE
# else
# define BOOST_REGEX_NON_RECURSIVE
@ -441,21 +443,6 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
#endif
/*****************************************************************************
*
* helper memory allocation functions:
*
****************************************************************************/
#if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
}} /* namespaces */
#endif
/*****************************************************************************
*
* Diagnostics:
@ -491,6 +478,3 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
#endif

File diff suppressed because it is too large Load Diff

View File

@ -23,81 +23,10 @@
#include <boost/regex/config.hpp>
#endif
#include <stdexcept>
#include <cstddef>
#include <boost/regex/v4/error_type.hpp>
namespace boost{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4103)
#endif
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
#ifdef BOOST_MSVC
#pragma warning(pop)
#ifdef BOOST_REGEX_CXX03
#include <boost/regex/v4/pattern_except.hpp>
#else
#include <boost/regex/v5/pattern_except.hpp>
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable : 4275)
#if BOOST_MSVC >= 1800
#pragma warning(disable : 26812)
#endif
#endif
class BOOST_REGEX_DECL 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);
explicit regex_error(regex_constants::error_type err);
~regex_error() BOOST_NOEXCEPT_OR_NOTHROW;
regex_constants::error_type code()const
{ return m_error_code; }
std::ptrdiff_t position()const
{ return m_position; }
void raise()const;
private:
regex_constants::error_type m_error_code;
std::ptrdiff_t m_position;
};
typedef regex_error bad_pattern;
typedef regex_error bad_expression;
namespace BOOST_REGEX_DETAIL_NS{
BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex);
template <class traits>
void raise_error(const traits& t, regex_constants::error_type code)
{
(void)t; // warning suppression
std::runtime_error e(t.error_string(code));
::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(e);
}
}
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4103)
#endif
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_SUFFIX
#endif
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
} // namespace boost
#endif

View File

@ -19,14 +19,24 @@
#ifndef BOOST_REGEX_OBJECT_CACHE_HPP
#define BOOST_REGEX_OBJECT_CACHE_HPP
#include <boost/config.hpp>
#include <boost/regex/config.hpp>
#ifdef BOOST_REGEX_CXX03
#include <boost/shared_ptr.hpp>
#define BOOST_REGEX_SHARED_PTR_NS boost
#else
#include <memory>
#define BOOST_REGEX_SHARED_PTR_NS std
#endif
#include <map>
#include <list>
#include <stdexcept>
#include <string>
#ifdef BOOST_HAS_THREADS
#ifdef BOOST_REGEX_CXX03
#include <boost/regex/pending/static_mutex.hpp>
#else
#include <mutex>
#endif
#endif
namespace boost{
@ -35,16 +45,16 @@ template <class Key, class Object>
class object_cache
{
public:
typedef std::pair< ::boost::shared_ptr<Object const>, Key const*> value_type;
typedef std::pair< BOOST_REGEX_SHARED_PTR_NS::shared_ptr<Object const>, Key const*> value_type;
typedef std::list<value_type> list_type;
typedef typename list_type::iterator list_iterator;
typedef std::map<Key, list_iterator> map_type;
typedef typename map_type::iterator map_iterator;
typedef typename list_type::size_type size_type;
static boost::shared_ptr<Object const> get(const Key& k, size_type l_max_cache_size);
static BOOST_REGEX_SHARED_PTR_NS::shared_ptr<Object const> get(const Key& k, size_type l_max_cache_size);
private:
static boost::shared_ptr<Object const> do_get(const Key& k, size_type l_max_cache_size);
static BOOST_REGEX_SHARED_PTR_NS::shared_ptr<Object const> do_get(const Key& k, size_type l_max_cache_size);
struct data
{
@ -62,13 +72,13 @@ private:
#pragma warning(disable: 4702)
#endif
template <class Key, class Object>
boost::shared_ptr<Object const> object_cache<Key, Object>::get(const Key& k, size_type l_max_cache_size)
BOOST_REGEX_SHARED_PTR_NS::shared_ptr<Object const> object_cache<Key, Object>::get(const Key& k, size_type l_max_cache_size)
{
#ifdef BOOST_HAS_THREADS
#ifdef BOOST_REGEX_CXX03
static boost::static_mutex mut = BOOST_STATIC_MUTEX_INIT;
boost::static_mutex::scoped_lock l(mut);
if(l)
if (l)
{
return do_get(k, l_max_cache_size);
}
@ -78,7 +88,12 @@ boost::shared_ptr<Object const> object_cache<Key, Object>::get(const Key& k, siz
//
::boost::throw_exception(std::runtime_error("Error in thread safety code: could not acquire a lock"));
#if defined(BOOST_NO_UNREACHABLE_RETURN_DETECTION) || defined(BOOST_NO_EXCEPTIONS)
return boost::shared_ptr<Object>();
return BOOST_REGEX_SHARED_PTR_NS::shared_ptr<Object>();
#endif
#else
static std::mutex mut;
std::lock_guard<std::mutex> l(mut);
return do_get(k, l_max_cache_size);
#endif
#else
return do_get(k, l_max_cache_size);
@ -89,7 +104,7 @@ boost::shared_ptr<Object const> object_cache<Key, Object>::get(const Key& k, siz
#endif
template <class Key, class Object>
boost::shared_ptr<Object const> object_cache<Key, Object>::do_get(const Key& k, size_type l_max_cache_size)
BOOST_REGEX_SHARED_PTR_NS::shared_ptr<Object const> object_cache<Key, Object>::do_get(const Key& k, size_type l_max_cache_size)
{
typedef typename object_cache<Key, Object>::data object_data;
typedef typename map_type::size_type map_size_type;
@ -112,11 +127,11 @@ boost::shared_ptr<Object const> object_cache<Key, Object>::do_get(const Key& k,
temp.splice(temp.end(), s_data.cont, mpos->second);
// and now place it at the end of the list:
s_data.cont.splice(s_data.cont.end(), temp, temp.begin());
BOOST_ASSERT(*(s_data.cont.back().second) == k);
BOOST_REGEX_ASSERT(*(s_data.cont.back().second) == k);
// update index with new position:
mpos->second = --(s_data.cont.end());
BOOST_ASSERT(&(mpos->first) == mpos->second->second);
BOOST_ASSERT(&(mpos->first) == s_data.cont.back().second);
BOOST_REGEX_ASSERT(&(mpos->first) == mpos->second->second);
BOOST_REGEX_ASSERT(&(mpos->first) == s_data.cont.back().second);
}
return s_data.cont.back().first;
}
@ -124,7 +139,7 @@ boost::shared_ptr<Object const> object_cache<Key, Object>::do_get(const Key& k,
// if we get here then the item is not in the cache,
// so create it:
//
boost::shared_ptr<Object const> result(new Object(k));
BOOST_REGEX_SHARED_PTR_NS::shared_ptr<Object const> result(new Object(k));
//
// Add it to the list, and index it:
//
@ -132,9 +147,9 @@ boost::shared_ptr<Object const> object_cache<Key, Object>::do_get(const Key& k,
s_data.index.insert(std::make_pair(k, --(s_data.cont.end())));
s_data.cont.back().second = &(s_data.index.find(k)->first);
map_size_type s = s_data.index.size();
BOOST_ASSERT(s_data.index[k]->first.get() == result.get());
BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second);
BOOST_ASSERT(s_data.index.find(k)->first == k);
BOOST_REGEX_ASSERT(s_data.index[k]->first.get() == result.get());
BOOST_REGEX_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second);
BOOST_REGEX_ASSERT(s_data.index.find(k)->first == k);
if(s > l_max_cache_size)
{
//
@ -152,7 +167,7 @@ boost::shared_ptr<Object const> object_cache<Key, Object>::do_get(const Key& k,
++pos;
// now remove the items from our containers,
// then order has to be as follows:
BOOST_ASSERT(s_data.index.find(*(condemmed->second)) != s_data.index.end());
BOOST_REGEX_ASSERT(s_data.index.find(*(condemmed->second)) != s_data.index.end());
s_data.index.erase(*(condemmed->second));
s_data.cont.erase(condemmed);
--s;
@ -160,13 +175,13 @@ boost::shared_ptr<Object const> object_cache<Key, Object>::do_get(const Key& k,
else
++pos;
}
BOOST_ASSERT(s_data.index[k]->first.get() == result.get());
BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second);
BOOST_ASSERT(s_data.index.find(k)->first == k);
BOOST_REGEX_ASSERT(s_data.index[k]->first.get() == result.get());
BOOST_REGEX_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second);
BOOST_REGEX_ASSERT(s_data.index.find(k)->first == k);
}
return result;
}
}
#undef BOOST_REGEX_SHARED_PTR_NS
#endif

View File

@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2004
* Copyright (c) 2020
* John Maddock
*
* Use, modification and distribution are subject to the
@ -16,770 +16,17 @@
* DESCRIPTION: Iterator adapters for converting between different Unicode encodings.
*/
/****************************************************************************
#ifndef BOOST_REGEX_PENDING_UNICODE_ITERATOR_HPP
#define BOOST_REGEX_PENDING_UNICODE_ITERATOR_HPP
Contents:
~~~~~~~~~
#include <boost/regex/config.hpp>
1) Read Only, Input Adapters:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class BaseIterator, class U8Type = ::boost::uint8_t>
class u32_to_u8_iterator;
Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-8.
template <class BaseIterator, class U32Type = ::boost::uint32_t>
class u8_to_u32_iterator;
Adapts sequence of UTF-8 code points to "look like" a sequence of UTF-32.
template <class BaseIterator, class U16Type = ::boost::uint16_t>
class u32_to_u16_iterator;
Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-16.
template <class BaseIterator, class U32Type = ::boost::uint32_t>
class u16_to_u32_iterator;
Adapts sequence of UTF-16 code points to "look like" a sequence of UTF-32.
2) Single pass output iterator adapters:
template <class BaseIterator>
class utf8_output_iterator;
Accepts UTF-32 code points and forwards them on as UTF-8 code points.
template <class BaseIterator>
class utf16_output_iterator;
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 <boost/cstdint.hpp>
#include <boost/assert.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp>
#include <stdexcept>
#ifndef BOOST_NO_STD_LOCALE
#include <sstream>
#include <ios>
#endif
#include <limits.h> // CHAR_BIT
namespace boost{
namespace detail{
static const ::boost::uint16_t high_surrogate_base = 0xD7C0u;
static const ::boost::uint16_t low_surrogate_base = 0xDC00u;
static const ::boost::uint32_t ten_bit_mask = 0x3FFu;
inline bool is_high_surrogate(::boost::uint16_t v)
{
return (v & 0xFFFFFC00u) == 0xd800u;
}
inline bool is_low_surrogate(::boost::uint16_t v)
{
return (v & 0xFFFFFC00u) == 0xdc00u;
}
template <class T>
inline bool is_surrogate(T v)
{
return (v & 0xFFFFF800u) == 0xd800;
}
inline unsigned utf8_byte_count(boost::uint8_t c)
{
// if the most significant bit with a zero in it is in position
// 8-N then there are N bytes in this UTF-8 sequence:
boost::uint8_t mask = 0x80u;
unsigned result = 0;
while(c & mask)
{
++result;
mask >>= 1;
}
return (result == 0) ? 1 : ((result > 4) ? 4 : result);
}
inline unsigned utf8_trailing_byte_count(boost::uint8_t c)
{
return utf8_byte_count(c) - 1;
}
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4100)
#endif
#ifndef BOOST_NO_EXCEPTIONS
BOOST_NORETURN
#endif
inline void invalid_utf32_code_point(::boost::uint32_t val)
{
#ifndef BOOST_NO_STD_LOCALE
std::stringstream ss;
ss << "Invalid UTF-32 code point U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-16 sequence";
std::out_of_range e(ss.str());
#if defined(BOOST_REGEX_CXX03)
#include <boost/regex/v4/unicode_iterator.hpp>
#else
std::out_of_range e("Invalid UTF-32 code point encountered while trying to encode UTF-16 sequence");
#endif
boost::throw_exception(e);
}
#ifdef BOOST_MSVC
#pragma warning(pop)
#include <boost/regex/v5/unicode_iterator.hpp>
#endif
} // namespace detail
template <class BaseIterator, class U16Type = ::boost::uint16_t>
class u32_to_u16_iterator
: public boost::iterator_facade<u32_to_u16_iterator<BaseIterator, U16Type>, U16Type, std::bidirectional_iterator_tag, const U16Type>
{
typedef boost::iterator_facade<u32_to_u16_iterator<BaseIterator, U16Type>, U16Type, std::bidirectional_iterator_tag, const U16Type> base_type;
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type;
BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 32);
BOOST_STATIC_ASSERT(sizeof(U16Type)*CHAR_BIT == 16);
#endif
public:
typename base_type::reference
dereference()const
{
if(m_current == 2)
extract_current();
return m_values[m_current];
}
bool equal(const u32_to_u16_iterator& that)const
{
if(m_position == that.m_position)
{
// Both m_currents must be equal, or both even
// this is the same as saying their sum must be even:
return (m_current + that.m_current) & 1u ? false : true;
}
return false;
}
void increment()
{
// if we have a pending read then read now, so that we know whether
// to skip a position, or move to a low-surrogate:
if(m_current == 2)
{
// pending read:
extract_current();
}
// move to the next surrogate position:
++m_current;
// if we've reached the end skip a position:
if(m_values[m_current] == 0)
{
m_current = 2;
++m_position;
}
}
void decrement()
{
if(m_current != 1)
{
// decrementing an iterator always leads to a valid position:
--m_position;
extract_current();
m_current = m_values[1] ? 1 : 0;
}
else
{
m_current = 0;
}
}
BaseIterator base()const
{
return m_position;
}
// construct:
u32_to_u16_iterator() : m_position(), m_current(0)
{
m_values[0] = 0;
m_values[1] = 0;
m_values[2] = 0;
}
u32_to_u16_iterator(BaseIterator b) : m_position(b), m_current(2)
{
m_values[0] = 0;
m_values[1] = 0;
m_values[2] = 0;
}
private:
void extract_current()const
{
// begin by checking for a code point out of range:
::boost::uint32_t v = *m_position;
if(v >= 0x10000u)
{
if(v > 0x10FFFFu)
detail::invalid_utf32_code_point(*m_position);
// split into two surrogates:
m_values[0] = static_cast<U16Type>(v >> 10) + detail::high_surrogate_base;
m_values[1] = static_cast<U16Type>(v & detail::ten_bit_mask) + detail::low_surrogate_base;
m_current = 0;
BOOST_ASSERT(detail::is_high_surrogate(m_values[0]));
BOOST_ASSERT(detail::is_low_surrogate(m_values[1]));
}
else
{
// 16-bit code point:
m_values[0] = static_cast<U16Type>(*m_position);
m_values[1] = 0;
m_current = 0;
// value must not be a surrogate:
if(detail::is_surrogate(m_values[0]))
detail::invalid_utf32_code_point(*m_position);
}
}
BaseIterator m_position;
mutable U16Type m_values[3];
mutable unsigned m_current;
};
template <class BaseIterator, class U32Type = ::boost::uint32_t>
class u16_to_u32_iterator
: public boost::iterator_facade<u16_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type>
{
typedef boost::iterator_facade<u16_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type> base_type;
// special values for pending iterator reads:
BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu);
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type;
BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 16);
BOOST_STATIC_ASSERT(sizeof(U32Type)*CHAR_BIT == 32);
#endif
public:
typename base_type::reference
dereference()const
{
if(m_value == pending_read)
extract_current();
return m_value;
}
bool equal(const u16_to_u32_iterator& that)const
{
return m_position == that.m_position;
}
void increment()
{
// skip high surrogate first if there is one:
if(detail::is_high_surrogate(*m_position)) ++m_position;
++m_position;
m_value = pending_read;
}
void decrement()
{
--m_position;
// if we have a low surrogate then go back one more:
if(detail::is_low_surrogate(*m_position))
--m_position;
m_value = pending_read;
}
BaseIterator base()const
{
return m_position;
}
// construct:
u16_to_u32_iterator() : m_position()
{
m_value = pending_read;
}
u16_to_u32_iterator(BaseIterator b) : m_position(b)
{
m_value = pending_read;
}
//
// Range checked version:
//
u16_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b)
{
m_value = pending_read;
//
// The range must not start with a low surrogate, or end in a high surrogate,
// otherwise we run the risk of running outside the underlying input range.
// Likewise b must not be located at a low surrogate.
//
boost::uint16_t val;
if(start != end)
{
if((b != start) && (b != end))
{
val = *b;
if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u))
invalid_code_point(val);
}
val = *start;
if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u))
invalid_code_point(val);
val = *--end;
if(detail::is_high_surrogate(val))
invalid_code_point(val);
}
}
private:
static void invalid_code_point(::boost::uint16_t val)
{
#ifndef BOOST_NO_STD_LOCALE
std::stringstream ss;
ss << "Misplaced UTF-16 surrogate U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-32 sequence";
std::out_of_range e(ss.str());
#else
std::out_of_range e("Misplaced UTF-16 surrogate encountered while trying to encode UTF-32 sequence");
#endif
boost::throw_exception(e);
}
void extract_current()const
{
m_value = static_cast<U32Type>(static_cast< ::boost::uint16_t>(*m_position));
// if the last value is a high surrogate then adjust m_position and m_value as needed:
if(detail::is_high_surrogate(*m_position))
{
// precondition; next value must have be a low-surrogate:
BaseIterator next(m_position);
::boost::uint16_t t = *++next;
if((t & 0xFC00u) != 0xDC00u)
invalid_code_point(t);
m_value = (m_value - detail::high_surrogate_base) << 10;
m_value |= (static_cast<U32Type>(static_cast< ::boost::uint16_t>(t)) & detail::ten_bit_mask);
}
// postcondition; result must not be a surrogate:
if(detail::is_surrogate(m_value))
invalid_code_point(static_cast< ::boost::uint16_t>(m_value));
}
BaseIterator m_position;
mutable U32Type m_value;
};
template <class BaseIterator, class U8Type = ::boost::uint8_t>
class u32_to_u8_iterator
: public boost::iterator_facade<u32_to_u8_iterator<BaseIterator, U8Type>, U8Type, std::bidirectional_iterator_tag, const U8Type>
{
typedef boost::iterator_facade<u32_to_u8_iterator<BaseIterator, U8Type>, U8Type, std::bidirectional_iterator_tag, const U8Type> base_type;
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type;
BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 32);
BOOST_STATIC_ASSERT(sizeof(U8Type)*CHAR_BIT == 8);
#endif
public:
typename base_type::reference
dereference()const
{
if(m_current == 4)
extract_current();
return m_values[m_current];
}
bool equal(const u32_to_u8_iterator& that)const
{
if(m_position == that.m_position)
{
// either the m_current's must be equal, or one must be 0 and
// the other 4: which means neither must have bits 1 or 2 set:
return (m_current == that.m_current)
|| (((m_current | that.m_current) & 3) == 0);
}
return false;
}
void increment()
{
// if we have a pending read then read now, so that we know whether
// to skip a position, or move to a low-surrogate:
if(m_current == 4)
{
// pending read:
extract_current();
}
// move to the next surrogate position:
++m_current;
// if we've reached the end skip a position:
if(m_values[m_current] == 0)
{
m_current = 4;
++m_position;
}
}
void decrement()
{
if((m_current & 3) == 0)
{
--m_position;
extract_current();
m_current = 3;
while(m_current && (m_values[m_current] == 0))
--m_current;
}
else
--m_current;
}
BaseIterator base()const
{
return m_position;
}
// construct:
u32_to_u8_iterator() : m_position(), m_current(0)
{
m_values[0] = 0;
m_values[1] = 0;
m_values[2] = 0;
m_values[3] = 0;
m_values[4] = 0;
}
u32_to_u8_iterator(BaseIterator b) : m_position(b), m_current(4)
{
m_values[0] = 0;
m_values[1] = 0;
m_values[2] = 0;
m_values[3] = 0;
m_values[4] = 0;
}
private:
void extract_current()const
{
boost::uint32_t c = *m_position;
if(c > 0x10FFFFu)
detail::invalid_utf32_code_point(c);
if(c < 0x80u)
{
m_values[0] = static_cast<unsigned char>(c);
m_values[1] = static_cast<unsigned char>(0u);
m_values[2] = static_cast<unsigned char>(0u);
m_values[3] = static_cast<unsigned char>(0u);
}
else if(c < 0x800u)
{
m_values[0] = static_cast<unsigned char>(0xC0u + (c >> 6));
m_values[1] = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
m_values[2] = static_cast<unsigned char>(0u);
m_values[3] = static_cast<unsigned char>(0u);
}
else if(c < 0x10000u)
{
m_values[0] = static_cast<unsigned char>(0xE0u + (c >> 12));
m_values[1] = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu));
m_values[2] = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
m_values[3] = static_cast<unsigned char>(0u);
}
else
{
m_values[0] = static_cast<unsigned char>(0xF0u + (c >> 18));
m_values[1] = static_cast<unsigned char>(0x80u + ((c >> 12) & 0x3Fu));
m_values[2] = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu));
m_values[3] = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
}
m_current= 0;
}
BaseIterator m_position;
mutable U8Type m_values[5];
mutable unsigned m_current;
};
template <class BaseIterator, class U32Type = ::boost::uint32_t>
class u8_to_u32_iterator
: public boost::iterator_facade<u8_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type>
{
typedef boost::iterator_facade<u8_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type> base_type;
// special values for pending iterator reads:
BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu);
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type;
BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 8);
BOOST_STATIC_ASSERT(sizeof(U32Type)*CHAR_BIT == 32);
#endif
public:
typename base_type::reference
dereference()const
{
if(m_value == pending_read)
extract_current();
return m_value;
}
bool equal(const u8_to_u32_iterator& that)const
{
return m_position == that.m_position;
}
void increment()
{
// We must not start with a continuation character:
if((static_cast<boost::uint8_t>(*m_position) & 0xC0) == 0x80)
invalid_sequence();
// skip high surrogate first if there is one:
unsigned c = detail::utf8_byte_count(*m_position);
if(m_value == pending_read)
{
// Since we haven't read in a value, we need to validate the code points:
for(unsigned i = 0; i < c; ++i)
{
++m_position;
// We must have a continuation byte:
if((i != c - 1) && ((static_cast<boost::uint8_t>(*m_position) & 0xC0) != 0x80))
invalid_sequence();
}
}
else
{
std::advance(m_position, c);
}
m_value = pending_read;
}
void decrement()
{
// Keep backtracking until we don't have a trailing character:
unsigned count = 0;
while((*--m_position & 0xC0u) == 0x80u) ++count;
// now check that the sequence was valid:
if(count != detail::utf8_trailing_byte_count(*m_position))
invalid_sequence();
m_value = pending_read;
}
BaseIterator base()const
{
return m_position;
}
// construct:
u8_to_u32_iterator() : m_position()
{
m_value = pending_read;
}
u8_to_u32_iterator(BaseIterator b) : m_position(b)
{
m_value = pending_read;
}
//
// Checked constructor:
//
u8_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b)
{
m_value = pending_read;
//
// We must not start with a continuation character, or end with a
// truncated UTF-8 sequence otherwise we run the risk of going past
// the start/end of the underlying sequence:
//
if(start != end)
{
unsigned char v = *start;
if((v & 0xC0u) == 0x80u)
invalid_sequence();
if((b != start) && (b != end) && ((*b & 0xC0u) == 0x80u))
invalid_sequence();
BaseIterator pos = end;
do
{
v = *--pos;
}
while((start != pos) && ((v & 0xC0u) == 0x80u));
std::ptrdiff_t extra = detail::utf8_byte_count(v);
if(std::distance(pos, end) < extra)
invalid_sequence();
}
}
private:
static void invalid_sequence()
{
std::out_of_range e("Invalid UTF-8 sequence encountered while trying to encode UTF-32 character");
boost::throw_exception(e);
}
void extract_current()const
{
m_value = static_cast<U32Type>(static_cast< ::boost::uint8_t>(*m_position));
// we must not have a continuation character:
if((m_value & 0xC0u) == 0x80u)
invalid_sequence();
// see how many extra bytes we have:
unsigned extra = detail::utf8_trailing_byte_count(*m_position);
// extract the extra bits, 6 from each extra byte:
BaseIterator next(m_position);
for(unsigned c = 0; c < extra; ++c)
{
++next;
m_value <<= 6;
// We must have a continuation byte:
if((static_cast<boost::uint8_t>(*next) & 0xC0) != 0x80)
invalid_sequence();
m_value += static_cast<boost::uint8_t>(*next) & 0x3Fu;
}
// we now need to remove a few of the leftmost bits, but how many depends
// upon how many extra bytes we've extracted:
static const boost::uint32_t masks[4] =
{
0x7Fu,
0x7FFu,
0xFFFFu,
0x1FFFFFu,
};
m_value &= masks[extra];
// check the result is in range:
if(m_value > static_cast<U32Type>(0x10FFFFu))
invalid_sequence();
// The result must not be a surrogate:
if((m_value >= static_cast<U32Type>(0xD800)) && (m_value <= static_cast<U32Type>(0xDFFF)))
invalid_sequence();
// We should not have had an invalidly encoded UTF8 sequence:
if((extra > 0) && (m_value <= static_cast<U32Type>(masks[extra - 1])))
invalid_sequence();
}
BaseIterator m_position;
mutable U32Type m_value;
};
template <class BaseIterator>
class utf16_output_iterator
{
public:
typedef void difference_type;
typedef void value_type;
typedef boost::uint32_t* pointer;
typedef boost::uint32_t& reference;
typedef std::output_iterator_tag iterator_category;
utf16_output_iterator(const BaseIterator& b)
: m_position(b){}
utf16_output_iterator(const utf16_output_iterator& that)
: m_position(that.m_position){}
utf16_output_iterator& operator=(const utf16_output_iterator& that)
{
m_position = that.m_position;
return *this;
}
const utf16_output_iterator& operator*()const
{
return *this;
}
void operator=(boost::uint32_t val)const
{
push(val);
}
utf16_output_iterator& operator++()
{
return *this;
}
utf16_output_iterator& operator++(int)
{
return *this;
}
BaseIterator base()const
{
return m_position;
}
private:
void push(boost::uint32_t v)const
{
if(v >= 0x10000u)
{
// begin by checking for a code point out of range:
if(v > 0x10FFFFu)
detail::invalid_utf32_code_point(v);
// split into two surrogates:
*m_position++ = static_cast<boost::uint16_t>(v >> 10) + detail::high_surrogate_base;
*m_position++ = static_cast<boost::uint16_t>(v & detail::ten_bit_mask) + detail::low_surrogate_base;
}
else
{
// 16-bit code point:
// value must not be a surrogate:
if(detail::is_surrogate(v))
detail::invalid_utf32_code_point(v);
*m_position++ = static_cast<boost::uint16_t>(v);
}
}
mutable BaseIterator m_position;
};
template <class BaseIterator>
class utf8_output_iterator
{
public:
typedef void difference_type;
typedef void value_type;
typedef boost::uint32_t* pointer;
typedef boost::uint32_t& reference;
typedef std::output_iterator_tag iterator_category;
utf8_output_iterator(const BaseIterator& b)
: m_position(b){}
utf8_output_iterator(const utf8_output_iterator& that)
: m_position(that.m_position){}
utf8_output_iterator& operator=(const utf8_output_iterator& that)
{
m_position = that.m_position;
return *this;
}
const utf8_output_iterator& operator*()const
{
return *this;
}
void operator=(boost::uint32_t val)const
{
push(val);
}
utf8_output_iterator& operator++()
{
return *this;
}
utf8_output_iterator& operator++(int)
{
return *this;
}
BaseIterator base()const
{
return m_position;
}
private:
void push(boost::uint32_t c)const
{
if(c > 0x10FFFFu)
detail::invalid_utf32_code_point(c);
if(c < 0x80u)
{
*m_position++ = static_cast<unsigned char>(c);
}
else if(c < 0x800u)
{
*m_position++ = static_cast<unsigned char>(0xC0u + (c >> 6));
*m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
}
else if(c < 0x10000u)
{
*m_position++ = static_cast<unsigned char>(0xE0u + (c >> 12));
*m_position++ = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu));
*m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
}
else
{
*m_position++ = static_cast<unsigned char>(0xF0u + (c >> 18));
*m_position++ = static_cast<unsigned char>(0x80u + ((c >> 12) & 0x3Fu));
*m_position++ = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu));
*m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
}
}
mutable BaseIterator m_position;
};
} // namespace boost
#endif // BOOST_REGEX_UNICODE_ITERATOR_HPP
#endif // BOOST_REGEX_PENDING_UNICODE_ITERATOR_HPP

View File

@ -24,7 +24,11 @@
#endif
# ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED
#ifdef BOOST_REGEX_CXX03
# include <boost/regex/v4/regex_traits.hpp>
#else
# include <boost/regex/v5/regex_traits.hpp>
#endif
# endif
#endif // include

View File

@ -61,10 +61,12 @@
// define this if you want to use the recursive algorithm
// even if BOOST_REGEX_HAS_MS_STACK_GUARD is not defined.
// NOTE: OBSOLETE!!
// #define BOOST_REGEX_RECURSIVE
// define this if you want to use the non-recursive
// algorithm, even if the recursive version would be the default.
// NOTE: OBSOLETE!!
// #define BOOST_REGEX_NON_RECURSIVE
// define this if you want to set the size of the memory blocks

View File

@ -416,7 +416,7 @@ public:
{
typedef typename traits::string_type seq_type;
seq_type a(arg_first, arg_last);
if(a.size())
if(!a.empty())
assign(static_cast<const charT*>(&*a.begin()), static_cast<const charT*>(&*a.begin() + a.size()), f);
else
assign(static_cast<const charT*>(0), static_cast<const charT*>(0), f);
@ -617,32 +617,32 @@ public:
//
const BOOST_REGEX_DETAIL_NS::re_syntax_base* get_first_state()const
{
BOOST_ASSERT(0 != m_pimpl.get());
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->get_first_state();
}
unsigned get_restart_type()const
{
BOOST_ASSERT(0 != m_pimpl.get());
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->get_restart_type();
}
const unsigned char* get_map()const
{
BOOST_ASSERT(0 != m_pimpl.get());
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->get_map();
}
const ::boost::regex_traits_wrapper<traits>& get_traits()const
{
BOOST_ASSERT(0 != m_pimpl.get());
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->get_traits();
}
bool can_be_null()const
{
BOOST_ASSERT(0 != m_pimpl.get());
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->can_be_null();
}
const BOOST_REGEX_DETAIL_NS::regex_data<charT, traits>& get_data()const
{
BOOST_ASSERT(0 != m_pimpl.get());
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->get_data();
}
boost::shared_ptr<BOOST_REGEX_DETAIL_NS::named_subexpressions > get_named_subs()const
@ -657,7 +657,7 @@ private:
//
// out of line members;
// these are the only members that mutate the basic_regex object,
// and are designed to provide the strong exception guarentee
// and are designed to provide the strong exception guarantee
// (in the event of a throw, the state of the object remains unchanged).
//
template <class charT, class traits>
@ -795,4 +795,3 @@ public:
#endif
#endif

View File

@ -52,11 +52,14 @@ struct digraph : public std::pair<charT, charT>
digraph(charT c1, charT c2) : std::pair<charT, charT>(c1, c2)
{}
digraph(const digraph<charT>& d) : std::pair<charT, charT>(d.first, d.second){}
#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
digraph<charT>& operator=(const digraph<charT>&) = default;
#endif
template <class Seq>
digraph(const Seq& s) : std::pair<charT, charT>()
{
BOOST_ASSERT(s.size() <= 2);
BOOST_ASSERT(s.size());
BOOST_REGEX_ASSERT(s.size() <= 2);
BOOST_REGEX_ASSERT(s.size());
this->first = s[0];
this->second = (s.size() > 1) ? s[1] : 0;
}
@ -243,7 +246,7 @@ protected:
bool m_has_backrefs; // true if there are actually any backrefs
indexed_bit_flag m_backrefs; // bitmask of permitted backrefs
boost::uintmax_t m_bad_repeats; // bitmask of repeats we can't deduce a startmap for;
bool m_has_recursions; // set when we have recursive expresisons to fixup
bool m_has_recursions; // set when we have recursive expressions to fixup
std::vector<unsigned char> m_recursion_checks; // notes which recursions we've followed while analysing this expression
typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character
typename traits::char_class_type m_mask_space; // mask used to determine if a character is a word character
@ -285,11 +288,11 @@ basic_regex_creator<charT, traits>::basic_regex_creator(regex_data<charT, traits
m_upper_mask = m_traits.lookup_classname(u, u + 5);
m_alpha_mask = m_traits.lookup_classname(a, a + 5);
m_pdata->m_word_mask = m_word_mask;
BOOST_ASSERT(m_word_mask != 0);
BOOST_ASSERT(m_mask_space != 0);
BOOST_ASSERT(m_lower_mask != 0);
BOOST_ASSERT(m_upper_mask != 0);
BOOST_ASSERT(m_alpha_mask != 0);
BOOST_REGEX_ASSERT(m_word_mask != 0);
BOOST_REGEX_ASSERT(m_mask_space != 0);
BOOST_REGEX_ASSERT(m_lower_mask != 0);
BOOST_REGEX_ASSERT(m_upper_mask != 0);
BOOST_REGEX_ASSERT(m_alpha_mask != 0);
}
template <class charT, class traits>
@ -303,7 +306,7 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_state(syntax_element_
// set the offset to the next state in our last one:
if(m_last_state)
m_last_state->next.i = m_pdata->m_data.size() - getoffset(m_last_state);
// now actually extent our data:
// now actually extend our data:
m_last_state = static_cast<re_syntax_base*>(m_pdata->m_data.extend(s));
// fill in boilerplate options in the new state:
m_last_state->next.i = 0;
@ -447,9 +450,9 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
charT a2[3] = { c2.first, c2.second, charT(0), };
s1 = this->m_traits.transform(a1, (a1[1] ? a1+2 : a1+1));
s2 = this->m_traits.transform(a2, (a2[1] ? a2+2 : a2+1));
if(s1.size() == 0)
if(s1.empty())
s1 = string_type(1, charT(0));
if(s2.size() == 0)
if(s2.empty())
s2 = string_type(1, charT(0));
}
else
@ -577,7 +580,7 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
// Oops error:
return 0;
}
BOOST_ASSERT(c3[1] == charT(0));
BOOST_REGEX_ASSERT(c3[1] == charT(0));
for(unsigned i = 0; i < (1u << CHAR_BIT); ++i)
{
c3[0] = static_cast<charT>(i);
@ -642,7 +645,7 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
while(sfirst != slast)
{
string_type s;
BOOST_ASSERT(static_cast<charT>(0) == sfirst->second);
BOOST_REGEX_ASSERT(static_cast<charT>(0) == sfirst->second);
s = m_traits.transform_primary(&sfirst->first, &sfirst->first+1);
if(s.empty())
return 0; // invalid or unsupported equivalence class
@ -951,7 +954,7 @@ void basic_regex_creator<charT, traits>::create_startmaps(re_syntax_base* state)
}
// now work through our list, building all the maps as we go:
while(v.size())
while(!v.empty())
{
// Initialize m_recursion_checks if we need it:
if(m_has_recursions)
@ -1035,7 +1038,7 @@ int basic_regex_creator<charT, traits>::calculate_backstep(re_syntax_base* state
}
else if(state->type == syntax_element_long_set_rep)
{
BOOST_ASSERT(rep->next.p->type == syntax_element_long_set);
BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_long_set);
if(static_cast<re_set_long<m_type>*>(rep->next.p)->singleton == 0)
return -1;
if(rep->max != rep->min)
@ -1135,7 +1138,7 @@ void basic_regex_creator<charT, traits>::create_startmap(re_syntax_base* state,
}
case syntax_element_recurse:
{
BOOST_ASSERT(static_cast<const re_jump*>(state)->alt.p->type == syntax_element_startmark);
BOOST_REGEX_ASSERT(static_cast<const re_jump*>(state)->alt.p->type == syntax_element_startmark);
recursion_sub = static_cast<re_brace*>(static_cast<const re_jump*>(state)->alt.p)->index;
if(m_recursion_checks[recursion_sub] & 1u)
{
@ -1516,7 +1519,7 @@ template <class charT, class traits>
void basic_regex_creator<charT, traits>::probe_leading_repeat(re_syntax_base* state)
{
// enumerate our states, and see if we have a leading repeat
// for which failed search restarts can be optimised;
// for which failed search restarts can be optimized;
do
{
switch(state->type)
@ -1573,7 +1576,6 @@ void basic_regex_creator<charT, traits>::probe_leading_repeat(re_syntax_base* st
}while(state);
}
} // namespace BOOST_REGEX_DETAIL_NS
} // namespace boost
@ -1594,4 +1596,3 @@ void basic_regex_creator<charT, traits>::probe_leading_repeat(re_syntax_base* st
#endif
#endif

View File

@ -172,7 +172,7 @@ void basic_regex_parser<charT, traits>::parse(const charT* p1, const charT* p2,
m_parser_proc = &basic_regex_parser<charT, traits>::parse_literal;
break;
default:
// Ooops, someone has managed to set more than one of the main option flags,
// Oops, someone has managed to set more than one of the main option flags,
// so this must be an error:
fail(regex_constants::error_unknown, 0, "An invalid combination of regular expression syntax flags was used.");
return;
@ -981,7 +981,7 @@ template <class charT, class traits>
bool basic_regex_parser<charT, traits>::parse_repeat(std::size_t low, std::size_t high)
{
bool greedy = true;
bool pocessive = false;
bool possessive = false;
std::size_t insert_point;
//
// when we get to here we may have a non-greedy ? mark still to come:
@ -1005,12 +1005,12 @@ bool basic_regex_parser<charT, traits>::parse_repeat(std::size_t low, std::size_
greedy = false;
++m_position;
}
// for perl regexes only check for pocessive ++ repeats.
// for perl regexes only check for possessive ++ repeats.
if((m_position != m_end)
&& (0 == (this->flags() & regbase::main_option_type))
&& (this->m_traits.syntax_type(*m_position) == regex_constants::syntax_plus))
{
pocessive = true;
possessive = true;
++m_position;
}
}
@ -1082,10 +1082,10 @@ bool basic_regex_parser<charT, traits>::parse_repeat(std::size_t low, std::size_
rep = static_cast<re_repeat*>(this->getaddress(rep_off));
rep->alt.i = this->m_pdata->m_data.size() - rep_off;
//
// If the repeat is pocessive then bracket the repeat with a (?>...)
// If the repeat is possessive then bracket the repeat with a (?>...)
// independent sub-expression construct:
//
if(pocessive)
if(possessive)
{
if(m_position != m_end)
{
@ -1542,7 +1542,7 @@ bool basic_regex_parser<charT, traits>::parse_inner_set(basic_char_set<charT, tr
fail(regex_constants::error_ctype, name_first - m_base);
return false;
}
if(negated == false)
if(!negated)
char_set.add_class(m);
else
char_set.add_negated_class(m);
@ -1580,7 +1580,7 @@ bool basic_regex_parser<charT, traits>::parse_inner_set(basic_char_set<charT, tr
return false;
}
string_type m = this->m_traits.lookup_collatename(name_first, name_last);
if((0 == m.size()) || (m.size() > 2))
if(m.empty() || (m.size() > 2))
{
fail(regex_constants::error_collate, name_first - m_base);
return false;
@ -1948,7 +1948,7 @@ charT basic_regex_parser<charT, traits>::unescape_character()
template <class charT, class traits>
bool basic_regex_parser<charT, traits>::parse_backref()
{
BOOST_ASSERT(m_position != m_end);
BOOST_REGEX_ASSERT(m_position != m_end);
const charT* pc = m_position;
boost::intmax_t i = this->m_traits.toi(pc, pc + 1, 10);
if((i == 0) || (((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) && (this->flags() & regbase::no_bk_refs)))
@ -2609,7 +2609,7 @@ option_group_jump:
this->fail(regex_constants::error_paren, ::boost::BOOST_REGEX_DETAIL_NS::distance(m_base, m_end));
return false;
}
BOOST_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark);
BOOST_REGEX_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark);
++m_position;
//
// restore the flags:
@ -3112,7 +3112,7 @@ bool basic_regex_parser<charT, traits>::unwind_alts(std::ptrdiff_t last_paren_st
// alternative then that's an error:
//
if((this->m_alt_insert_point == static_cast<std::ptrdiff_t>(this->m_pdata->m_data.size()))
&& m_alt_jumps.size() && (m_alt_jumps.back() > last_paren_start)
&& (!m_alt_jumps.empty()) && (m_alt_jumps.back() > last_paren_start)
&&
!(
((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group)
@ -3127,7 +3127,7 @@ bool basic_regex_parser<charT, traits>::unwind_alts(std::ptrdiff_t last_paren_st
//
// Fix up our alternatives:
//
while(m_alt_jumps.size() && (m_alt_jumps.back() > last_paren_start))
while((!m_alt_jumps.empty()) && (m_alt_jumps.back() > last_paren_start))
{
//
// fix up the jump to point to the end of the states
@ -3137,7 +3137,7 @@ bool basic_regex_parser<charT, traits>::unwind_alts(std::ptrdiff_t last_paren_st
m_alt_jumps.pop_back();
this->m_pdata->m_data.align();
re_jump* jmp = static_cast<re_jump*>(this->getaddress(jump_offset));
BOOST_ASSERT(jmp->type == syntax_element_jump);
BOOST_REGEX_ASSERT(jmp->type == syntax_element_jump);
jmp->alt.i = this->m_pdata->m_data.size() - jump_offset;
}
return true;

View File

@ -36,7 +36,7 @@ namespace std{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4103)
#pragma warning(disable: 4103 4244)
#endif
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
@ -47,11 +47,35 @@ namespace std{
namespace boost{
namespace BOOST_REGEX_DETAIL_NS {
enum
{
char_class_space = 1 << 0,
char_class_print = 1 << 1,
char_class_cntrl = 1 << 2,
char_class_upper = 1 << 3,
char_class_lower = 1 << 4,
char_class_alpha = 1 << 5,
char_class_digit = 1 << 6,
char_class_punct = 1 << 7,
char_class_xdigit = 1 << 8,
char_class_alnum = char_class_alpha | char_class_digit,
char_class_graph = char_class_alnum | char_class_punct,
char_class_blank = 1 << 9,
char_class_word = 1 << 10,
char_class_unicode = 1 << 11,
char_class_horizontal = 1 << 12,
char_class_vertical = 1 << 13
};
}
template <class charT>
struct c_regex_traits;
template<>
struct BOOST_REGEX_DECL c_regex_traits<char>
struct c_regex_traits<char>
{
c_regex_traits(){}
typedef char char_type;
@ -96,7 +120,7 @@ private:
#ifndef BOOST_NO_WREGEX
template<>
struct BOOST_REGEX_DECL c_regex_traits<wchar_t>
struct c_regex_traits<wchar_t>
{
c_regex_traits(){}
typedef wchar_t char_type;
@ -139,59 +163,335 @@ private:
c_regex_traits& operator=(const c_regex_traits&);
};
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
//
// Provide an unsigned short version as well, so the user can link to this
// no matter whether they build with /Zc:wchar_t or not (MSVC specific).
//
template<>
struct BOOST_REGEX_DECL c_regex_traits<unsigned short>
#endif // BOOST_NO_WREGEX
inline c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform(const char* p1, const char* p2)
{
c_regex_traits(){}
typedef unsigned short char_type;
typedef std::size_t size_type;
typedef std::basic_string<unsigned short> string_type;
struct locale_type{};
typedef boost::uint32_t char_class_type;
static size_type length(const char_type* p)
std::string result(10, ' ');
std::size_t s = result.size();
std::size_t r;
std::string src(p1, p2);
while (s < (r = std::strxfrm(&*result.begin(), src.c_str(), s)))
{
return (std::wcslen)((const wchar_t*)p);
#if defined(_CPPLIB_VER)
//
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
// to std::strxfrm, but only for certain locales :-(
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
//
if (r == INT_MAX)
{
result.erase();
result.insert(result.begin(), static_cast<char>(0));
return result;
}
#endif
result.append(r - s + 3, ' ');
s = result.size();
}
result.erase(r);
return result;
}
unsigned short translate(unsigned short c) const
inline c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform_primary(const char* p1, const char* p2)
{
static char s_delim;
static const int s_collate_type = ::boost::BOOST_REGEX_DETAIL_NS::find_sort_syntax(static_cast<c_regex_traits<char>*>(0), &s_delim);
std::string result;
//
// What we do here depends upon the format of the sort key returned by
// sort key returned by this->transform:
//
switch (s_collate_type)
{
return c;
}
unsigned short translate_nocase(unsigned short c) const
case ::boost::BOOST_REGEX_DETAIL_NS::sort_C:
case ::boost::BOOST_REGEX_DETAIL_NS::sort_unknown:
// the best we can do is translate to lower case, then get a regular sort key:
{
return (std::towlower)((wchar_t)c);
result.assign(p1, p2);
for (std::string::size_type i = 0; i < result.size(); ++i)
result[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(result[i])));
result = transform(&*result.begin(), &*result.begin() + result.size());
break;
}
case ::boost::BOOST_REGEX_DETAIL_NS::sort_fixed:
{
// get a regular sort key, and then truncate it:
result = transform(p1, p2);
result.erase(s_delim);
break;
}
case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim:
// get a regular sort key, and then truncate everything after the delim:
result = transform(p1, p2);
if ((!result.empty()) && (result[0] == s_delim))
break;
std::size_t i;
for (i = 0; i < result.size(); ++i)
{
if (result[i] == s_delim)
break;
}
result.erase(i);
break;
}
if (result.empty())
result = std::string(1, char(0));
return result;
}
static string_type BOOST_REGEX_CALL transform(const unsigned short* p1, const unsigned short* p2);
static string_type BOOST_REGEX_CALL transform_primary(const unsigned short* p1, const unsigned short* p2);
inline c_regex_traits<char>::char_class_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_classname(const char* p1, const char* p2)
{
using namespace BOOST_REGEX_DETAIL_NS;
static const char_class_type masks[] =
{
0,
char_class_alnum,
char_class_alpha,
char_class_blank,
char_class_cntrl,
char_class_digit,
char_class_digit,
char_class_graph,
char_class_horizontal,
char_class_lower,
char_class_lower,
char_class_print,
char_class_punct,
char_class_space,
char_class_space,
char_class_upper,
char_class_unicode,
char_class_upper,
char_class_vertical,
char_class_alnum | char_class_word,
char_class_alnum | char_class_word,
char_class_xdigit,
};
static char_class_type BOOST_REGEX_CALL lookup_classname(const unsigned short* p1, const unsigned short* p2);
static string_type BOOST_REGEX_CALL lookup_collatename(const unsigned short* p1, const unsigned short* p2);
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
if (idx < 0)
{
std::string s(p1, p2);
for (std::string::size_type i = 0; i < s.size(); ++i)
s[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(s[i])));
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
}
BOOST_REGEX_ASSERT(std::size_t(idx) + 1u < sizeof(masks) / sizeof(masks[0]));
return masks[idx + 1];
}
static bool BOOST_REGEX_CALL isctype(unsigned short, char_class_type);
static int BOOST_REGEX_CALL value(unsigned short, int);
inline bool BOOST_REGEX_CALL c_regex_traits<char>::isctype(char c, char_class_type mask)
{
using namespace BOOST_REGEX_DETAIL_NS;
return
((mask & char_class_space) && (std::isspace)(static_cast<unsigned char>(c)))
|| ((mask & char_class_print) && (std::isprint)(static_cast<unsigned char>(c)))
|| ((mask & char_class_cntrl) && (std::iscntrl)(static_cast<unsigned char>(c)))
|| ((mask & char_class_upper) && (std::isupper)(static_cast<unsigned char>(c)))
|| ((mask & char_class_lower) && (std::islower)(static_cast<unsigned char>(c)))
|| ((mask & char_class_alpha) && (std::isalpha)(static_cast<unsigned char>(c)))
|| ((mask & char_class_digit) && (std::isdigit)(static_cast<unsigned char>(c)))
|| ((mask & char_class_punct) && (std::ispunct)(static_cast<unsigned char>(c)))
|| ((mask & char_class_xdigit) && (std::isxdigit)(static_cast<unsigned char>(c)))
|| ((mask & char_class_blank) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c))
|| ((mask & char_class_word) && (c == '_'))
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == '\v')))
|| ((mask & char_class_horizontal) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != '\v'));
}
locale_type imbue(locale_type l)
{ return l; }
locale_type getloc()const
{ return locale_type(); }
inline c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_collatename(const char* p1, const char* p2)
{
std::string s(p1, p2);
s = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(s);
if (s.empty() && (p2 - p1 == 1))
s.append(1, *p1);
return s;
}
private:
// this type is not copyable:
c_regex_traits(const c_regex_traits&);
c_regex_traits& operator=(const c_regex_traits&);
};
inline int BOOST_REGEX_CALL c_regex_traits<char>::value(char c, int radix)
{
char b[2] = { c, '\0', };
char* ep;
int result = std::strtol(b, &ep, radix);
if (ep == b)
return -1;
return result;
}
#ifndef BOOST_NO_WREGEX
inline c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform(const wchar_t* p1, const wchar_t* p2)
{
std::size_t r;
std::size_t s = 10;
std::wstring src(p1, p2);
std::wstring result(s, L' ');
while (s < (r = std::wcsxfrm(&*result.begin(), src.c_str(), s)))
{
#if defined(_CPPLIB_VER)
//
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
// to std::strxfrm, but only for certain locales :-(
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
//
if (r == INT_MAX)
{
result.erase();
result.insert(result.begin(), static_cast<wchar_t>(0));
return result;
}
#endif
result.append(r - s + 3, L' ');
s = result.size();
}
result.erase(r);
return result;
}
inline c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform_primary(const wchar_t* p1, const wchar_t* p2)
{
static wchar_t s_delim;
static const int s_collate_type = ::boost::BOOST_REGEX_DETAIL_NS::find_sort_syntax(static_cast<const c_regex_traits<wchar_t>*>(0), &s_delim);
std::wstring result;
//
// What we do here depends upon the format of the sort key returned by
// sort key returned by this->transform:
//
switch (s_collate_type)
{
case ::boost::BOOST_REGEX_DETAIL_NS::sort_C:
case ::boost::BOOST_REGEX_DETAIL_NS::sort_unknown:
// the best we can do is translate to lower case, then get a regular sort key:
{
result.assign(p1, p2);
for (std::wstring::size_type i = 0; i < result.size(); ++i)
result[i] = (std::towlower)(result[i]);
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
break;
}
case ::boost::BOOST_REGEX_DETAIL_NS::sort_fixed:
{
// get a regular sort key, and then truncate it:
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
result.erase(s_delim);
break;
}
case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim:
// get a regular sort key, and then truncate everything after the delim:
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
if ((!result.empty()) && (result[0] == s_delim))
break;
std::size_t i;
for (i = 0; i < result.size(); ++i)
{
if (result[i] == s_delim)
break;
}
result.erase(i);
break;
}
if (result.empty())
result = std::wstring(1, char(0));
return result;
}
inline c_regex_traits<wchar_t>::char_class_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(const wchar_t* p1, const wchar_t* p2)
{
using namespace BOOST_REGEX_DETAIL_NS;
static const char_class_type masks[] =
{
0,
char_class_alnum,
char_class_alpha,
char_class_blank,
char_class_cntrl,
char_class_digit,
char_class_digit,
char_class_graph,
char_class_horizontal,
char_class_lower,
char_class_lower,
char_class_print,
char_class_punct,
char_class_space,
char_class_space,
char_class_upper,
char_class_unicode,
char_class_upper,
char_class_vertical,
char_class_alnum | char_class_word,
char_class_alnum | char_class_word,
char_class_xdigit,
};
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
if (idx < 0)
{
std::wstring s(p1, p2);
for (std::wstring::size_type i = 0; i < s.size(); ++i)
s[i] = (std::towlower)(s[i]);
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
}
BOOST_REGEX_ASSERT(idx + 1 < static_cast<int>(sizeof(masks) / sizeof(masks[0])));
return masks[idx + 1];
}
inline bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::isctype(wchar_t c, char_class_type mask)
{
using namespace BOOST_REGEX_DETAIL_NS;
return
((mask & char_class_space) && (std::iswspace)(c))
|| ((mask & char_class_print) && (std::iswprint)(c))
|| ((mask & char_class_cntrl) && (std::iswcntrl)(c))
|| ((mask & char_class_upper) && (std::iswupper)(c))
|| ((mask & char_class_lower) && (std::iswlower)(c))
|| ((mask & char_class_alpha) && (std::iswalpha)(c))
|| ((mask & char_class_digit) && (std::iswdigit)(c))
|| ((mask & char_class_punct) && (std::iswpunct)(c))
|| ((mask & char_class_xdigit) && (std::iswxdigit)(c))
|| ((mask & char_class_blank) && (std::iswspace)(c) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c))
|| ((mask & char_class_word) && (c == '_'))
|| ((mask & char_class_unicode) && (c & ~static_cast<wchar_t>(0xff)))
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == L'\v')))
|| ((mask & char_class_horizontal) && (std::iswspace)(c) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != L'\v'));
}
inline c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(const wchar_t* p1, const wchar_t* p2)
{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4244)
#endif
std::string name(p1, p2);
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
name = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(name);
if (!name.empty())
return string_type(name.begin(), name.end());
if (p2 - p1 == 1)
return string_type(1, *p1);
return string_type();
}
inline int BOOST_REGEX_CALL c_regex_traits<wchar_t>::value(wchar_t c, int radix)
{
#ifdef BOOST_BORLANDC
// workaround for broken wcstol:
if ((std::iswxdigit)(c) == 0)
return -1;
#endif
wchar_t b[2] = { c, '\0', };
wchar_t* ep;
int result = std::wcstol(b, &ep, radix);
if (ep == b)
return -1;
return result;
}
#endif
#endif // BOOST_NO_WREGEX
}
#ifdef BOOST_MSVC

View File

@ -38,12 +38,12 @@
#include <boost/regex/v4/primary_transform.hpp>
#endif
#ifndef BOOST_REGEX_OBJECT_CACHE_HPP
#include <boost/regex/pending/object_cache.hpp>
#include <boost/regex/v4/object_cache.hpp>
#endif
#include <istream>
#include <ios>
#include <climits>
#include <ios>
#include <istream>
#ifdef BOOST_MSVC
#pragma warning(push)
@ -89,9 +89,9 @@ public:
parser_buf() : base_type() { setbuf(0, 0); }
const charT* getnext() { return this->gptr(); }
protected:
std::basic_streambuf<charT, traits>* setbuf(char_type* s, streamsize n);
typename parser_buf<charT, traits>::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which);
typename parser_buf<charT, traits>::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which);
std::basic_streambuf<charT, traits>* setbuf(char_type* s, streamsize n) BOOST_OVERRIDE;
typename parser_buf<charT, traits>::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which) BOOST_OVERRIDE;
typename parser_buf<charT, traits>::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) BOOST_OVERRIDE;
private:
parser_buf& operator=(const parser_buf&);
parser_buf(const parser_buf&);
@ -225,7 +225,7 @@ std::locale cpp_regex_traits_base<charT>::imbue(const std::locale& l)
//
// class cpp_regex_traits_char_layer:
// implements methods that require specialisation for narrow characters:
// implements methods that require specialization for narrow characters:
//
template <class charT>
class cpp_regex_traits_char_layer : public cpp_regex_traits_base<charT>
@ -281,7 +281,7 @@ void cpp_regex_traits_char_layer<charT>::init()
typename std::messages<charT>::catalog cat = reinterpret_cast<std::messages<char>::catalog>(-1);
#endif
std::string cat_name(cpp_regex_traits<charT>::get_catalog_name());
if(cat_name.size() && (this->m_pmessages != 0))
if((!cat_name.empty()) && (this->m_pmessages != 0))
{
cat = this->m_pmessages->open(
cat_name,
@ -352,10 +352,10 @@ typename cpp_regex_traits_char_layer<charT>::string_type
}
//
// specialised version for narrow characters:
// specialized version for narrow characters:
//
template <>
class BOOST_REGEX_DECL cpp_regex_traits_char_layer<char> : public cpp_regex_traits_base<char>
class cpp_regex_traits_char_layer<char> : public cpp_regex_traits_base<char>
{
typedef std::string string_type;
public:
@ -508,7 +508,7 @@ typename cpp_regex_traits_implementation<charT>::string_type
// we work around this elsewhere, but just assert here that
// we adhere to gcc's (buggy) preconditions...
//
BOOST_ASSERT(*p2 == 0);
BOOST_REGEX_ASSERT(*p2 == 0);
string_type result;
#if defined(_CPPLIB_VER)
//
@ -566,7 +566,7 @@ typename cpp_regex_traits_implementation<charT>::string_type
#ifndef BOOST_NO_EXCEPTIONS
}catch(...){}
#endif
while(result.size() && (charT(0) == *result.rbegin()))
while((!result.empty()) && (charT(0) == *result.rbegin()))
result.erase(result.size() - 1);
if(result.empty())
{
@ -588,7 +588,7 @@ typename cpp_regex_traits_implementation<charT>::string_type
// we work around this elsewhere, but just assert here that
// we adhere to gcc's (buggy) preconditions...
//
BOOST_ASSERT(*p2 == 0);
BOOST_REGEX_ASSERT(*p2 == 0);
//
// swallowing all exceptions here is a bad idea
// however at least one std lib will always throw
@ -621,7 +621,7 @@ typename cpp_regex_traits_implementation<charT>::string_type
#else
//
// some implementations (Dinkumware) append unnecessary trailing \0's:
while(result.size() && (charT(0) == *result.rbegin()))
while((!result.empty()) && (charT(0) == *result.rbegin()))
result.erase(result.size() - 1);
#endif
//
@ -646,7 +646,7 @@ typename cpp_regex_traits_implementation<charT>::string_type
result2.append(1, static_cast<charT>(1 + static_cast<uchar_type>(result[i]))).append(1, charT('b') - 1);
}
}
BOOST_ASSERT(std::find(result2.begin(), result2.end(), charT(0)) == result2.end());
BOOST_REGEX_ASSERT(std::find(result2.begin(), result2.end(), charT(0)) == result2.end());
#ifndef BOOST_NO_EXCEPTIONS
}
catch(...)
@ -662,7 +662,7 @@ typename cpp_regex_traits_implementation<charT>::string_type
cpp_regex_traits_implementation<charT>::lookup_collatename(const charT* p1, const charT* p2) const
{
typedef typename std::map<string_type, string_type>::const_iterator iter_type;
if(m_custom_collate_names.size())
if(!m_custom_collate_names.empty())
{
iter_type pos = m_custom_collate_names.find(string_type(p1, p2));
if(pos != m_custom_collate_names.end())
@ -680,10 +680,10 @@ typename cpp_regex_traits_implementation<charT>::string_type
name = lookup_default_collate_name(name);
#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
&& !BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x0551)
if(name.size())
if(!name.empty())
return string_type(name.begin(), name.end());
#else
if(name.size())
if(!name.empty())
{
string_type result;
typedef std::string::const_iterator iter;
@ -709,7 +709,7 @@ void cpp_regex_traits_implementation<charT>::init()
typename std::messages<charT>::catalog cat = reinterpret_cast<std::messages<char>::catalog>(-1);
#endif
std::string cat_name(cpp_regex_traits<charT>::get_catalog_name());
if(cat_name.size() && (this->m_pmessages != 0))
if((!cat_name.empty()) && (this->m_pmessages != 0))
{
cat = this->m_pmessages->open(
cat_name,
@ -796,7 +796,7 @@ void cpp_regex_traits_implementation<charT>::init()
for(unsigned int j = 0; j <= 13; ++j)
{
string_type s(this->m_pmessages->get(cat, 0, j+300, null_string));
if(s.size())
if(!s.empty())
this->m_custom_class_names[s] = masks[j];
}
}
@ -864,7 +864,7 @@ typename cpp_regex_traits_implementation<charT>::char_class_type
::boost::BOOST_REGEX_DETAIL_NS::char_class_xdigit,
};
#endif
if(m_custom_class_names.size())
if(!m_custom_class_names.empty())
{
typedef typename std::map<std::basic_string<charT>, char_class_type>::const_iterator map_iter;
map_iter pos = m_custom_class_names.find(string_type(p1, p2));
@ -872,7 +872,7 @@ typename cpp_regex_traits_implementation<charT>::char_class_type
return pos->second;
}
std::size_t state_id = 1 + BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
BOOST_ASSERT(state_id < sizeof(masks) / sizeof(masks[0]));
BOOST_REGEX_ASSERT(state_id < sizeof(masks) / sizeof(masks[0]));
return masks[state_id];
}
@ -1129,6 +1129,91 @@ static_mutex& cpp_regex_traits<charT>::get_mutex_inst()
}
#endif
namespace BOOST_REGEX_DETAIL_NS {
inline void cpp_regex_traits_char_layer<char>::init()
{
// we need to start by initialising our syntax map so we know which
// character is used for which purpose:
std::memset(m_char_map, 0, sizeof(m_char_map));
#ifndef BOOST_NO_STD_MESSAGES
#ifndef __IBMCPP__
std::messages<char>::catalog cat = static_cast<std::messages<char>::catalog>(-1);
#else
std::messages<char>::catalog cat = reinterpret_cast<std::messages<char>::catalog>(-1);
#endif
std::string cat_name(cpp_regex_traits<char>::get_catalog_name());
if ((!cat_name.empty()) && (m_pmessages != 0))
{
cat = this->m_pmessages->open(
cat_name,
this->m_locale);
if ((int)cat < 0)
{
std::string m("Unable to open message catalog: ");
std::runtime_error err(m + cat_name);
boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err);
}
}
//
// if we have a valid catalog then load our messages:
//
if ((int)cat >= 0)
{
#ifndef BOOST_NO_EXCEPTIONS
try {
#endif
for (regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
{
string_type mss = this->m_pmessages->get(cat, 0, i, get_default_syntax(i));
for (string_type::size_type j = 0; j < mss.size(); ++j)
{
m_char_map[static_cast<unsigned char>(mss[j])] = i;
}
}
this->m_pmessages->close(cat);
#ifndef BOOST_NO_EXCEPTIONS
}
catch (...)
{
this->m_pmessages->close(cat);
throw;
}
#endif
}
else
{
#endif
for (regex_constants::syntax_type j = 1; j < regex_constants::syntax_max; ++j)
{
const char* ptr = get_default_syntax(j);
while (ptr && *ptr)
{
m_char_map[static_cast<unsigned char>(*ptr)] = j;
++ptr;
}
}
#ifndef BOOST_NO_STD_MESSAGES
}
#endif
//
// finish off by calculating our escape types:
//
unsigned char i = 'A';
do
{
if (m_char_map[i] == 0)
{
if (this->m_pctype->is(std::ctype_base::lower, i))
m_char_map[i] = regex_constants::escape_type_class;
else if (this->m_pctype->is(std::ctype_base::upper, i))
m_char_map[i] = regex_constants::escape_type_not_class;
}
} while (0xFF != i++);
}
} // namespace detail
} // boost
@ -1150,5 +1235,3 @@ static_mutex& cpp_regex_traits<charT>::get_mutex_inst()
#endif
#endif

View File

@ -200,123 +200,6 @@ BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW*);
} /* namespace */
#endif
#if defined(__cplusplus)
/*
* C++ high level wrapper goes here:
*/
#include <string>
#include <vector>
namespace boost{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4103)
#endif
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
class RegEx;
namespace BOOST_REGEX_DETAIL_NS{
class RegExData;
struct pred1;
struct pred2;
struct pred3;
struct pred4;
} /* namespace BOOST_REGEX_DETAIL_NS */
#if (defined(BOOST_MSVC) || defined(BOOST_BORLANDC)) && !defined(BOOST_DISABLE_WIN32)
typedef bool (__cdecl *GrepCallback)(const RegEx& expression);
typedef bool (__cdecl *GrepFileCallback)(const char* file, const RegEx& expression);
typedef bool (__cdecl *FindFilesCallback)(const char* file);
#else
typedef bool (*GrepCallback)(const RegEx& expression);
typedef bool (*GrepFileCallback)(const char* file, const RegEx& expression);
typedef bool (*FindFilesCallback)(const char* file);
#endif
class BOOST_REGEX_DECL RegEx
{
private:
BOOST_REGEX_DETAIL_NS::RegExData* pdata;
public:
RegEx();
RegEx(const RegEx& o);
~RegEx();
explicit RegEx(const char* c, bool icase = false);
explicit RegEx(const std::string& s, bool icase = false);
RegEx& operator=(const RegEx& o);
RegEx& operator=(const char* p);
RegEx& operator=(const std::string& s){ return this->operator=(s.c_str()); }
unsigned int SetExpression(const char* p, bool icase = false);
unsigned int SetExpression(const std::string& s, bool icase = false){ return SetExpression(s.c_str(), icase); }
std::string Expression()const;
unsigned int error_code()const;
/*
* now matching operators:
*/
bool Match(const char* p, match_flag_type flags = match_default);
bool Match(const std::string& s, match_flag_type flags = match_default) { return Match(s.c_str(), flags); }
bool Search(const char* p, match_flag_type flags = match_default);
bool Search(const std::string& s, match_flag_type flags = match_default) { return Search(s.c_str(), flags); }
unsigned int Grep(GrepCallback cb, const char* p, match_flag_type flags = match_default);
unsigned int Grep(GrepCallback cb, const std::string& s, match_flag_type flags = match_default) { return Grep(cb, s.c_str(), flags); }
unsigned int Grep(std::vector<std::string>& v, const char* p, match_flag_type flags = match_default);
unsigned int Grep(std::vector<std::string>& v, const std::string& s, match_flag_type flags = match_default) { return Grep(v, s.c_str(), flags); }
unsigned int Grep(std::vector<std::size_t>& v, const char* p, match_flag_type flags = match_default);
unsigned int Grep(std::vector<std::size_t>& v, const std::string& s, match_flag_type flags = match_default) { return Grep(v, s.c_str(), flags); }
#ifndef BOOST_REGEX_NO_FILEITER
unsigned int GrepFiles(GrepFileCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default);
unsigned int GrepFiles(GrepFileCallback cb, const std::string& files, bool recurse = false, match_flag_type flags = match_default) { return GrepFiles(cb, files.c_str(), recurse, flags); }
unsigned int FindFiles(FindFilesCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default);
unsigned int FindFiles(FindFilesCallback cb, const std::string& files, bool recurse = false, match_flag_type flags = match_default) { return FindFiles(cb, files.c_str(), recurse, flags); }
#endif
std::string Merge(const std::string& in, const std::string& fmt,
bool copy = true, match_flag_type flags = match_default);
std::string Merge(const char* in, const char* fmt,
bool copy = true, match_flag_type flags = match_default);
std::size_t Split(std::vector<std::string>& v, std::string& s, match_flag_type flags = match_default, unsigned max_count = ~0);
/*
* now operators for returning what matched in more detail:
*/
std::size_t Position(int i = 0)const;
std::size_t Length(int i = 0)const;
bool Matched(int i = 0)const;
std::size_t Marks()const;
std::string What(int i = 0)const;
std::string operator[](int i)const { return What(i); }
static const std::size_t npos;
friend struct BOOST_REGEX_DETAIL_NS::pred1;
friend struct BOOST_REGEX_DETAIL_NS::pred2;
friend struct BOOST_REGEX_DETAIL_NS::pred3;
friend struct BOOST_REGEX_DETAIL_NS::pred4;
};
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4103)
#endif
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_SUFFIX
#endif
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
} /* namespace boost */
#endif /* __cplusplus */
#endif /* include guard */

View File

@ -1,557 +0,0 @@
/*
*
* 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 fileiter.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares various platform independent file and
* directory iterators, plus binary file input in
* the form of class map_file.
*/
#ifndef BOOST_RE_FILEITER_HPP_INCLUDED
#define BOOST_RE_FILEITER_HPP_INCLUDED
#ifndef BOOST_REGEX_CONFIG_HPP
#include <boost/regex/config.hpp>
#endif
#include <boost/assert.hpp>
#ifndef BOOST_REGEX_NO_FILEITER
#if (defined(__CYGWIN__) || defined(__CYGWIN32__)) && !defined(BOOST_REGEX_NO_W32)
#error "Sorry, can't mix <windows.h> with STL code and gcc compiler: if you ran configure, try again with configure --disable-ms-windows"
#define BOOST_REGEX_FI_WIN32_MAP
#define BOOST_REGEX_FI_POSIX_DIR
#elif (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) && !defined(BOOST_REGEX_NO_W32)
#define BOOST_REGEX_FI_WIN32_MAP
#define BOOST_REGEX_FI_WIN32_DIR
#else
#define BOOST_REGEX_FI_POSIX_MAP
#define BOOST_REGEX_FI_POSIX_DIR
#endif
#if defined(BOOST_REGEX_FI_WIN32_MAP)||defined(BOOST_REGEX_FI_WIN32_DIR)
#include <windows.h>
#endif
#if defined(BOOST_REGEX_FI_WIN32_DIR)
#include <cstddef>
namespace boost{
namespace BOOST_REGEX_DETAIL_NS{
#ifndef BOOST_NO_ANSI_APIS
typedef WIN32_FIND_DATAA _fi_find_data;
#else
typedef WIN32_FIND_DATAW _fi_find_data;
#endif
typedef HANDLE _fi_find_handle;
} // namespace BOOST_REGEX_DETAIL_NS
} // namespace boost
#define _fi_invalid_handle INVALID_HANDLE_VALUE
#define _fi_dir FILE_ATTRIBUTE_DIRECTORY
#elif defined(BOOST_REGEX_FI_POSIX_DIR)
#include <cstddef>
#include <cstdio>
#include <cctype>
#include <iterator>
#include <list>
#include <cassert>
#include <dirent.h>
#if defined(__SUNPRO_CC)
using std::list;
#endif
#ifndef MAX_PATH
#define MAX_PATH 256
#endif
namespace boost{
namespace BOOST_REGEX_DETAIL_NS{
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
struct _fi_find_data
{
unsigned dwFileAttributes;
char cFileName[MAX_PATH];
};
struct _fi_priv_data;
typedef _fi_priv_data* _fi_find_handle;
#define _fi_invalid_handle 0
#define _fi_dir 1
_fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindFileData);
bool _fi_FindNextFile(_fi_find_handle hFindFile, _fi_find_data* lpFindFileData);
bool _fi_FindClose(_fi_find_handle hFindFile);
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_SUFFIX
#endif
} // namespace BOOST_REGEX_DETAIL_NS
} // namespace boost
#ifdef FindFirstFile
#undef FindFirstFile
#endif
#ifdef FindNextFile
#undef FindNextFile
#endif
#ifdef FindClose
#undef FindClose
#endif
#define FindFirstFileA _fi_FindFirstFile
#define FindNextFileA _fi_FindNextFile
#define FindClose _fi_FindClose
#endif
namespace boost{
namespace BOOST_REGEX_DETAIL_NS{
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
#ifdef BOOST_REGEX_FI_WIN32_MAP // win32 mapfile
class BOOST_REGEX_DECL mapfile
{
HANDLE hfile;
HANDLE hmap;
const char* _first;
const char* _last;
public:
typedef const char* iterator;
mapfile(){ hfile = hmap = 0; _first = _last = 0; }
mapfile(const char* file){ hfile = hmap = 0; _first = _last = 0; open(file); }
~mapfile(){ close(); }
void open(const char* file);
void close();
const char* begin(){ return _first; }
const char* end(){ return _last; }
size_t size(){ return _last - _first; }
bool valid(){ return (hfile != 0) && (hfile != INVALID_HANDLE_VALUE); }
};
#else
class BOOST_REGEX_DECL mapfile_iterator;
class BOOST_REGEX_DECL mapfile
{
typedef char* pointer;
std::FILE* hfile;
long int _size;
pointer* _first;
pointer* _last;
mutable std::list<pointer*> condemed;
enum sizes
{
buf_size = 4096
};
void lock(pointer* node)const;
void unlock(pointer* node)const;
public:
typedef mapfile_iterator iterator;
mapfile(){ hfile = 0; _size = 0; _first = _last = 0; }
mapfile(const char* file){ hfile = 0; _size = 0; _first = _last = 0; open(file); }
~mapfile(){ close(); }
void open(const char* file);
void close();
iterator begin()const;
iterator end()const;
unsigned long size()const{ return _size; }
bool valid()const{ return hfile != 0; }
friend class mapfile_iterator;
};
class BOOST_REGEX_DECL mapfile_iterator
{
typedef mapfile::pointer internal_pointer;
internal_pointer* node;
const mapfile* file;
unsigned long offset;
long position()const
{
return file ? ((node - file->_first) * mapfile::buf_size + offset) : 0;
}
void position(long pos)
{
if(file)
{
node = file->_first + (pos / mapfile::buf_size);
offset = pos % mapfile::buf_size;
}
}
public:
typedef std::ptrdiff_t difference_type;
typedef char value_type;
typedef const char* pointer;
typedef const char& reference;
typedef std::random_access_iterator_tag iterator_category;
mapfile_iterator() { node = 0; file = 0; offset = 0; }
mapfile_iterator(const mapfile* f, long arg_position)
{
BOOST_ASSERT(f);
file = f;
node = f->_first + arg_position / mapfile::buf_size;
offset = arg_position % mapfile::buf_size;
file->lock(node);
}
mapfile_iterator(const mapfile_iterator& i)
{
file = i.file;
node = i.node;
offset = i.offset;
if(file)
file->lock(node);
}
~mapfile_iterator()
{
if(file && node)
file->unlock(node);
}
mapfile_iterator& operator = (const mapfile_iterator& i);
char operator* ()const
{
BOOST_ASSERT(node >= file->_first);
BOOST_ASSERT(node < file->_last);
return file ? *(*node + sizeof(int) + offset) : char(0);
}
char operator[] (long off)const
{
mapfile_iterator tmp(*this);
tmp += off;
return *tmp;
}
mapfile_iterator& operator++ ();
mapfile_iterator operator++ (int);
mapfile_iterator& operator-- ();
mapfile_iterator operator-- (int);
mapfile_iterator& operator += (long off)
{
position(position() + off);
return *this;
}
mapfile_iterator& operator -= (long off)
{
position(position() - off);
return *this;
}
#if !defined(BOOST_EMBTC)
friend inline bool operator==(const mapfile_iterator& i, const mapfile_iterator& j)
{
return (i.file == j.file) && (i.node == j.node) && (i.offset == j.offset);
}
friend inline bool operator!=(const mapfile_iterator& i, const mapfile_iterator& j)
{
return !(i == j);
}
friend inline bool operator<(const mapfile_iterator& i, const mapfile_iterator& j)
{
return i.position() < j.position();
}
friend inline bool operator>(const mapfile_iterator& i, const mapfile_iterator& j)
{
return i.position() > j.position();
}
friend inline bool operator<=(const mapfile_iterator& i, const mapfile_iterator& j)
{
return i.position() <= j.position();
}
friend inline bool operator>=(const mapfile_iterator& i, const mapfile_iterator& j)
{
return i.position() >= j.position();
}
friend mapfile_iterator operator + (const mapfile_iterator& i, long off);
friend mapfile_iterator operator + (long off, const mapfile_iterator& i)
{
mapfile_iterator tmp(i);
return tmp += off;
}
friend mapfile_iterator operator - (const mapfile_iterator& i, long off);
friend inline long operator - (const mapfile_iterator& i, const mapfile_iterator& j)
{
return i.position() - j.position();
}
#else
friend bool operator==(const mapfile_iterator& i, const mapfile_iterator& j);
friend bool operator!=(const mapfile_iterator& i, const mapfile_iterator& j);
friend bool operator<(const mapfile_iterator& i, const mapfile_iterator& j);
friend bool operator>(const mapfile_iterator& i, const mapfile_iterator& j);
friend bool operator<=(const mapfile_iterator& i, const mapfile_iterator& j);
friend bool operator>=(const mapfile_iterator& i, const mapfile_iterator& j);
friend mapfile_iterator operator + (const mapfile_iterator& i, long off);
friend mapfile_iterator operator + (long off, const mapfile_iterator& i);
friend mapfile_iterator operator - (const mapfile_iterator& i, long off);
friend long operator - (const mapfile_iterator& i, const mapfile_iterator& j);
#endif
};
#if defined(BOOST_EMBTC)
inline bool operator==(const mapfile_iterator& i, const mapfile_iterator& j)
{
return (i.file == j.file) && (i.node == j.node) && (i.offset == j.offset);
}
inline bool operator!=(const mapfile_iterator& i, const mapfile_iterator& j)
{
return !(i == j);
}
inline bool operator<(const mapfile_iterator& i, const mapfile_iterator& j)
{
return i.position() < j.position();
}
inline bool operator>(const mapfile_iterator& i, const mapfile_iterator& j)
{
return i.position() > j.position();
}
inline bool operator<=(const mapfile_iterator& i, const mapfile_iterator& j)
{
return i.position() <= j.position();
}
inline bool operator>=(const mapfile_iterator& i, const mapfile_iterator& j)
{
return i.position() >= j.position();
}
mapfile_iterator operator + (long off, const mapfile_iterator& i)
{
mapfile_iterator tmp(i);
return tmp += off;
}
inline long operator - (const mapfile_iterator& i, const mapfile_iterator& j)
{
return i.position() - j.position();
}
#endif
#endif
// _fi_sep determines the directory separator, either '\\' or '/'
BOOST_REGEX_DECL extern const char* _fi_sep;
struct file_iterator_ref
{
_fi_find_handle hf;
_fi_find_data _data;
long count;
};
class BOOST_REGEX_DECL file_iterator
{
char* _root;
char* _path;
char* ptr;
file_iterator_ref* ref;
public:
typedef std::ptrdiff_t difference_type;
typedef const char* value_type;
typedef const char** pointer;
typedef const char*& reference;
typedef std::input_iterator_tag iterator_category;
file_iterator();
file_iterator(const char* wild);
~file_iterator();
file_iterator(const file_iterator&);
file_iterator& operator=(const file_iterator&);
const char* root()const { return _root; }
const char* path()const { return _path; }
const char* name()const { return ptr; }
_fi_find_data* data() { return &(ref->_data); }
void next();
file_iterator& operator++() { next(); return *this; }
file_iterator operator++(int);
const char* operator*() { return path(); }
#if !defined(BOOST_EMBTC)
friend inline bool operator == (const file_iterator& f1, const file_iterator& f2)
{
return ((f1.ref->hf == _fi_invalid_handle) && (f2.ref->hf == _fi_invalid_handle));
}
friend inline bool operator != (const file_iterator& f1, const file_iterator& f2)
{
return !(f1 == f2);
}
#else
friend bool operator == (const file_iterator& f1, const file_iterator& f2);
friend bool operator != (const file_iterator& f1, const file_iterator& f2);
#endif
};
#if defined(BOOST_EMBTC)
inline bool operator == (const file_iterator& f1, const file_iterator& f2)
{
return ((f1.ref->hf == _fi_invalid_handle) && (f2.ref->hf == _fi_invalid_handle));
}
inline bool operator != (const file_iterator& f1, const file_iterator& f2)
{
return !(f1 == f2);
}
#endif
// dwa 9/13/00 - suppress unused parameter warning
inline bool operator < (const file_iterator&, const file_iterator&)
{
return false;
}
class BOOST_REGEX_DECL directory_iterator
{
char* _root;
char* _path;
char* ptr;
file_iterator_ref* ref;
public:
typedef std::ptrdiff_t difference_type;
typedef const char* value_type;
typedef const char** pointer;
typedef const char*& reference;
typedef std::input_iterator_tag iterator_category;
directory_iterator();
directory_iterator(const char* wild);
~directory_iterator();
directory_iterator(const directory_iterator& other);
directory_iterator& operator=(const directory_iterator& other);
const char* root()const { return _root; }
const char* path()const { return _path; }
const char* name()const { return ptr; }
_fi_find_data* data() { return &(ref->_data); }
void next();
directory_iterator& operator++() { next(); return *this; }
directory_iterator operator++(int);
const char* operator*() { return path(); }
static const char* separator() { return _fi_sep; }
#if !defined(BOOST_EMBTC)
friend inline bool operator == (const directory_iterator& f1, const directory_iterator& f2)
{
return ((f1.ref->hf == _fi_invalid_handle) && (f2.ref->hf == _fi_invalid_handle));
}
friend inline bool operator != (const directory_iterator& f1, const directory_iterator& f2)
{
return !(f1 == f2);
}
#else
friend bool operator == (const directory_iterator& f1, const directory_iterator& f2);
friend bool operator != (const directory_iterator& f1, const directory_iterator& f2);
#endif
};
#if defined(BOOST_EMBTC)
inline bool operator == (const directory_iterator& f1, const directory_iterator& f2)
{
return ((f1.ref->hf == _fi_invalid_handle) && (f2.ref->hf == _fi_invalid_handle));
}
inline bool operator != (const directory_iterator& f1, const directory_iterator& f2)
{
return !(f1 == f2);
}
#endif
inline bool operator < (const directory_iterator&, const directory_iterator&)
{
return false;
}
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_SUFFIX
#endif
} // namespace BOOST_REGEX_DETAIL_NS
using boost::BOOST_REGEX_DETAIL_NS::directory_iterator;
using boost::BOOST_REGEX_DETAIL_NS::file_iterator;
using boost::BOOST_REGEX_DETAIL_NS::mapfile;
} // namespace boost
#endif // BOOST_REGEX_NO_FILEITER
#endif // BOOST_RE_FILEITER_HPP

File diff suppressed because it is too large Load Diff

View File

@ -1,236 +0,0 @@
/*
*
* 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 instances.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Defines those template instances that are placed in the
* library rather than in the users object files.
*/
//
// note no include guard, we may include this multiple times:
//
#ifndef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
namespace boost{
//
// this header can be included multiple times, each time with
// a different character type, BOOST_REGEX_CHAR_T must be defined
// first:
//
#ifndef BOOST_REGEX_CHAR_T
# error "BOOST_REGEX_CHAR_T not defined"
#endif
#ifndef BOOST_REGEX_TRAITS_T
# define BOOST_REGEX_TRAITS_T , boost::regex_traits<BOOST_REGEX_CHAR_T >
#endif
//
// what follows is compiler specific:
//
#if defined(BOOST_BORLANDC) && (BOOST_BORLANDC < 0x600)
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
# ifndef BOOST_REGEX_INSTANTIATE
# pragma option push -Jgx
# endif
template class BOOST_REGEX_DECL basic_regex< BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >;
template class BOOST_REGEX_DECL match_results< const BOOST_REGEX_CHAR_T* >;
#ifndef BOOST_NO_STD_ALLOCATOR
template class BOOST_REGEX_DECL ::boost::BOOST_REGEX_DETAIL_NS::perl_matcher<BOOST_REGEX_CHAR_T const *, match_results< const BOOST_REGEX_CHAR_T* >::allocator_type BOOST_REGEX_TRAITS_T >;
#endif
# ifndef BOOST_REGEX_INSTANTIATE
# pragma option pop
# endif
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_SUFFIX
#endif
#elif defined(BOOST_MSVC) || defined(__ICL)
# ifndef BOOST_REGEX_INSTANTIATE
# ifdef __GNUC__
# define template __extension__ extern template
# else
# if BOOST_MSVC > 1310
# define BOOST_REGEX_TEMPLATE_DECL
# endif
# define template extern template
# endif
# endif
#ifndef BOOST_REGEX_TEMPLATE_DECL
# define BOOST_REGEX_TEMPLATE_DECL BOOST_REGEX_DECL
#endif
# ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4251)
#if BOOST_MSVC < 1700
# pragma warning(disable : 4231)
#endif
# if BOOST_MSVC < 1600
# pragma warning(disable : 4660)
# endif
# endif
template class BOOST_REGEX_TEMPLATE_DECL basic_regex< BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >;
template class BOOST_REGEX_TEMPLATE_DECL match_results< const BOOST_REGEX_CHAR_T* >;
#ifndef BOOST_NO_STD_ALLOCATOR
template class BOOST_REGEX_TEMPLATE_DECL ::boost::BOOST_REGEX_DETAIL_NS::perl_matcher<BOOST_REGEX_CHAR_T const *, match_results< const BOOST_REGEX_CHAR_T* >::allocator_type BOOST_REGEX_TRAITS_T >;
#endif
#if !(defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB <= 1))\
&& !(defined(BOOST_INTEL_CXX_VERSION) && (BOOST_INTEL_CXX_VERSION <= 800))\
&& !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))\
&& !defined(BOOST_REGEX_ICU_INSTANCES)
template class BOOST_REGEX_TEMPLATE_DECL match_results< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator >;
#ifndef BOOST_NO_STD_ALLOCATOR
template class BOOST_REGEX_TEMPLATE_DECL ::boost::BOOST_REGEX_DETAIL_NS::perl_matcher< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator, match_results< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator >::allocator_type, boost::regex_traits<BOOST_REGEX_CHAR_T > >;
#endif
#endif
# ifdef BOOST_MSVC
# pragma warning(pop)
# endif
# ifdef template
# undef template
# endif
#undef BOOST_REGEX_TEMPLATE_DECL
#elif (defined(__GNUC__) && (__GNUC__ >= 3)) || !defined(BOOST_NO_CXX11_EXTERN_TEMPLATE)
#if defined(__clang__)
# pragma clang diagnostic push
# if defined(__APPLE_CC__)
# if (__clang_major__ > 6)
# pragma clang diagnostic ignored "-Wkeyword-macro"
# endif
# else
# if (__clang_major__ > 3) || ((__clang_major__ == 3) && (__clang_minor__ > 5))
# pragma clang diagnostic ignored "-Wkeyword-macro"
# endif
# endif
#endif
# ifndef BOOST_REGEX_INSTANTIATE
# ifdef __GNUC__
# define template __extension__ extern template
# else
# define template extern template
# endif
# endif
#if !defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_REGEX_ICU_INSTANCES)
namespace BOOST_REGEX_DETAIL_NS{
template BOOST_REGEX_DECL
std::locale cpp_regex_traits_base<BOOST_REGEX_CHAR_T>::imbue(const std::locale& l);
template BOOST_REGEX_DECL
cpp_regex_traits_implementation<BOOST_REGEX_CHAR_T>::string_type
cpp_regex_traits_implementation<BOOST_REGEX_CHAR_T>::transform_primary(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const;
template BOOST_REGEX_DECL
cpp_regex_traits_implementation<BOOST_REGEX_CHAR_T>::string_type
cpp_regex_traits_implementation<BOOST_REGEX_CHAR_T>::transform(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const;
template BOOST_REGEX_DECL
cpp_regex_traits_implementation<BOOST_REGEX_CHAR_T>::string_type
cpp_regex_traits_implementation<BOOST_REGEX_CHAR_T>::lookup_collatename(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const;
template BOOST_REGEX_DECL
void cpp_regex_traits_implementation<BOOST_REGEX_CHAR_T>::init();
template BOOST_REGEX_DECL
cpp_regex_traits_implementation<BOOST_REGEX_CHAR_T>::char_class_type
cpp_regex_traits_implementation<BOOST_REGEX_CHAR_T>::lookup_classname_imp(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const;
#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET
template BOOST_REGEX_DECL
bool cpp_regex_traits_implementation<BOOST_REGEX_CHAR_T>::isctype(const BOOST_REGEX_CHAR_T c, char_class_type mask) const;
#endif
} // namespace
template BOOST_REGEX_DECL
boost::intmax_t cpp_regex_traits<BOOST_REGEX_CHAR_T>::toi(const BOOST_REGEX_CHAR_T*& first, const BOOST_REGEX_CHAR_T* last, int radix)const;
template BOOST_REGEX_DECL
std::string cpp_regex_traits<BOOST_REGEX_CHAR_T>::catalog_name(const std::string& name);
template BOOST_REGEX_DECL
std::string& cpp_regex_traits<BOOST_REGEX_CHAR_T>::get_catalog_name_inst();
template BOOST_REGEX_DECL
std::string cpp_regex_traits<BOOST_REGEX_CHAR_T>::get_catalog_name();
#ifdef BOOST_HAS_THREADS
template BOOST_REGEX_DECL
static_mutex& cpp_regex_traits<BOOST_REGEX_CHAR_T>::get_mutex_inst();
#endif
#endif
template BOOST_REGEX_DECL basic_regex<BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >&
basic_regex<BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >::do_assign(
const BOOST_REGEX_CHAR_T* p1,
const BOOST_REGEX_CHAR_T* p2,
flag_type f);
template BOOST_REGEX_DECL basic_regex<BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >::locale_type BOOST_REGEX_CALL
basic_regex<BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >::imbue(locale_type l);
template BOOST_REGEX_DECL void BOOST_REGEX_CALL
match_results<const BOOST_REGEX_CHAR_T*>::maybe_assign(
const match_results<const BOOST_REGEX_CHAR_T*>& m);
namespace BOOST_REGEX_DETAIL_NS{
template BOOST_REGEX_DECL void perl_matcher<BOOST_REGEX_CHAR_T const *, match_results< const BOOST_REGEX_CHAR_T* >::allocator_type BOOST_REGEX_TRAITS_T >::construct_init(
const basic_regex<BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >& e, match_flag_type f);
template BOOST_REGEX_DECL bool perl_matcher<BOOST_REGEX_CHAR_T const *, match_results< const BOOST_REGEX_CHAR_T* >::allocator_type BOOST_REGEX_TRAITS_T >::match();
template BOOST_REGEX_DECL bool perl_matcher<BOOST_REGEX_CHAR_T const *, match_results< const BOOST_REGEX_CHAR_T* >::allocator_type BOOST_REGEX_TRAITS_T >::find();
} // namespace
#if (defined(__GLIBCPP__) || defined(__GLIBCXX__)) \
&& !defined(BOOST_REGEX_ICU_INSTANCES)\
&& !defined(__SGI_STL_PORT)\
&& !defined(_STLPORT_VERSION)
// std:basic_string<>::const_iterator instances as well:
template BOOST_REGEX_DECL void BOOST_REGEX_CALL
match_results<std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator>::maybe_assign(
const match_results<std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator>& m);
namespace BOOST_REGEX_DETAIL_NS{
template BOOST_REGEX_DECL void perl_matcher<std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator, match_results< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator >::allocator_type, boost::regex_traits<BOOST_REGEX_CHAR_T > >::construct_init(
const basic_regex<BOOST_REGEX_CHAR_T>& e, match_flag_type f);
template BOOST_REGEX_DECL bool perl_matcher<std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator, match_results< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator >::allocator_type, boost::regex_traits<BOOST_REGEX_CHAR_T > >::match();
template BOOST_REGEX_DECL bool perl_matcher<std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator, match_results< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator >::allocator_type, boost::regex_traits<BOOST_REGEX_CHAR_T > >::find();
} // namespace
#endif
# ifdef template
# undef template
# endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif
} // namespace boost
#endif // BOOST_REGEX_NO_EXTERNAL_TEMPLATES

View File

@ -51,7 +51,7 @@ typedef enum _match_flags
match_any = match_init << 1, /* don't care what we match */
match_not_null = match_any << 1, /* string can't be null */
match_continuous = match_not_null << 1, /* each grep match must continue from */
/* uninterupted from the previous one */
/* uninterrupted from the previous one */
match_partial = match_continuous << 1, /* find partial matches */
match_stop = match_partial << 1, /* stop after first match (grep) V3 only */
@ -61,7 +61,7 @@ typedef enum _match_flags
match_posix = match_perl << 1, /* Use POSIX matching rules */
match_nosubs = match_posix << 1, /* don't trap marked subs */
match_extra = match_nosubs << 1, /* include full capture information for repeated captures */
match_single_line = match_extra << 1, /* treat text as single line and ignor any \n's when matching ^ and $. */
match_single_line = match_extra << 1, /* treat text as single line and ignore any \n's when matching ^ and $. */
match_unused1 = match_single_line << 1, /* unused */
match_unused2 = match_unused1 << 1, /* unused */
match_unused3 = match_unused2 << 1, /* unused */
@ -70,9 +70,9 @@ typedef enum _match_flags
format_perl = 0, /* perl style replacement */
format_default = 0, /* ditto. */
format_sed = match_max << 1, /* sed style replacement. */
format_all = format_sed << 1, /* enable all extentions to sytax. */
format_all = format_sed << 1, /* enable all extensions to syntax. */
format_no_copy = format_all << 1, /* don't copy non-matching segments. */
format_first_only = format_no_copy << 1, /* Only replace first occurance. */
format_first_only = format_no_copy << 1, /* Only replace first occurrence. */
format_is_if = format_first_only << 1, /* internal use only. */
format_literal = format_is_if << 1, /* treat string as a literal */
@ -116,7 +116,7 @@ inline match_flags& operator^=(match_flags& m1, match_flags m2)
#ifdef __cplusplus
} /* namespace regex_constants */
/*
* import names into boost for backwards compatiblity:
* import names into boost for backwards compatibility:
*/
using regex_constants::match_flag_type;
using regex_constants::match_default;

View File

@ -474,7 +474,7 @@ public:
// private access functions:
void BOOST_REGEX_CALL set_second(BidiIterator i)
{
BOOST_ASSERT(m_subs.size() > 2);
BOOST_REGEX_ASSERT(m_subs.size() > 2);
m_subs[2].second = i;
m_subs[2].matched = true;
m_subs[0].first = i;
@ -490,7 +490,7 @@ public:
if(pos)
m_last_closed_paren = static_cast<int>(pos);
pos += 2;
BOOST_ASSERT(m_subs.size() > pos);
BOOST_REGEX_ASSERT(m_subs.size() > pos);
m_subs[pos].second = i;
m_subs[pos].matched = m;
if((pos == 2) && !escape_k)
@ -531,7 +531,7 @@ public:
}
void BOOST_REGEX_CALL set_first(BidiIterator i)
{
BOOST_ASSERT(m_subs.size() > 2);
BOOST_REGEX_ASSERT(m_subs.size() > 2);
// set up prefix:
m_subs[1].second = i;
m_subs[1].matched = (m_subs[1].first != i);
@ -546,7 +546,7 @@ public:
}
void BOOST_REGEX_CALL set_first(BidiIterator i, size_type pos, bool escape_k = false)
{
BOOST_ASSERT(pos+2 < m_subs.size());
BOOST_REGEX_ASSERT(pos+2 < m_subs.size());
if(pos || escape_k)
{
m_subs[pos+2].first = i;
@ -650,15 +650,15 @@ void BOOST_REGEX_CALL match_results<BidiIterator, Allocator>::maybe_assign(const
}
base1 = ::boost::BOOST_REGEX_DETAIL_NS::distance(l_base, p1->first);
base2 = ::boost::BOOST_REGEX_DETAIL_NS::distance(l_base, p2->first);
BOOST_ASSERT(base1 >= 0);
BOOST_ASSERT(base2 >= 0);
BOOST_REGEX_ASSERT(base1 >= 0);
BOOST_REGEX_ASSERT(base2 >= 0);
if(base1 < base2) return;
if(base2 < base1) break;
len1 = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)p1->first, (BidiIterator)p1->second);
len2 = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)p2->first, (BidiIterator)p2->second);
BOOST_ASSERT(len1 >= 0);
BOOST_ASSERT(len2 >= 0);
BOOST_REGEX_ASSERT(len1 >= 0);
BOOST_REGEX_ASSERT(len2 >= 0);
if((len1 != len2) || ((p1->matched == false) && (p2->matched == true)))
break;
if((p1->matched == true) && (p2->matched == false))

View File

@ -69,6 +69,12 @@ struct mem_block_cache
}
::operator delete(ptr);
}
static mem_block_cache& instance()
{
static mem_block_cache block_cache = { { {nullptr} } };
return block_cache;
}
};
@ -129,11 +135,43 @@ struct mem_block_cache
++cached_blocks;
}
}
static mem_block_cache& instance()
{
#ifdef BOOST_HAS_THREADS
static mem_block_cache block_cache = { 0, 0, BOOST_STATIC_MUTEX_INIT, };
#else
static mem_block_cache block_cache = { 0, 0, };
#endif
return block_cache;
}
};
#endif
extern mem_block_cache block_cache;
#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0
inline void* BOOST_REGEX_CALL get_mem_block()
{
return ::operator new(BOOST_REGEX_BLOCKSIZE);
}
inline void BOOST_REGEX_CALL put_mem_block(void* p)
{
::operator delete(p);
}
#else
inline void* BOOST_REGEX_CALL get_mem_block()
{
return mem_block_cache::instance().get();
}
inline void BOOST_REGEX_CALL put_mem_block(void* p)
{
mem_block_cache::instance().put(p);
}
#endif
}
} // namespace boost

View File

@ -0,0 +1,171 @@
/*
*
* Copyright (c) 2004
* 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 object_cache.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Implements a generic object cache.
*/
#ifndef BOOST_REGEX_OBJECT_CACHE_HPP
#define BOOST_REGEX_OBJECT_CACHE_HPP
#include <boost/regex/config.hpp>
#include <boost/shared_ptr.hpp>
#include <map>
#include <list>
#include <stdexcept>
#include <string>
#ifdef BOOST_HAS_THREADS
#include <boost/regex/pending/static_mutex.hpp>
#endif
namespace boost{
template <class Key, class Object>
class object_cache
{
public:
typedef std::pair< ::boost::shared_ptr<Object const>, Key const*> value_type;
typedef std::list<value_type> list_type;
typedef typename list_type::iterator list_iterator;
typedef std::map<Key, list_iterator> map_type;
typedef typename map_type::iterator map_iterator;
typedef typename list_type::size_type size_type;
static boost::shared_ptr<Object const> get(const Key& k, size_type l_max_cache_size);
private:
static boost::shared_ptr<Object const> do_get(const Key& k, size_type l_max_cache_size);
struct data
{
list_type cont;
map_type index;
};
// Needed by compilers not implementing the resolution to DR45. For reference,
// see http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45.
friend struct data;
};
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4702)
#endif
template <class Key, class Object>
boost::shared_ptr<Object const> object_cache<Key, Object>::get(const Key& k, size_type l_max_cache_size)
{
#ifdef BOOST_HAS_THREADS
static boost::static_mutex mut = BOOST_STATIC_MUTEX_INIT;
boost::static_mutex::scoped_lock l(mut);
if (l)
{
return do_get(k, l_max_cache_size);
}
//
// what do we do if the lock fails?
// for now just throw, but we should never really get here...
//
::boost::throw_exception(std::runtime_error("Error in thread safety code: could not acquire a lock"));
#if defined(BOOST_NO_UNREACHABLE_RETURN_DETECTION) || defined(BOOST_NO_EXCEPTIONS)
return boost::shared_ptr<Object>();
#endif
#else
return do_get(k, l_max_cache_size);
#endif
}
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
template <class Key, class Object>
boost::shared_ptr<Object const> object_cache<Key, Object>::do_get(const Key& k, size_type l_max_cache_size)
{
typedef typename object_cache<Key, Object>::data object_data;
typedef typename map_type::size_type map_size_type;
static object_data s_data;
//
// see if the object is already in the cache:
//
map_iterator mpos = s_data.index.find(k);
if(mpos != s_data.index.end())
{
//
// Eureka!
// We have a cached item, bump it up the list and return it:
//
if(--(s_data.cont.end()) != mpos->second)
{
// splice out the item we want to move:
list_type temp;
temp.splice(temp.end(), s_data.cont, mpos->second);
// and now place it at the end of the list:
s_data.cont.splice(s_data.cont.end(), temp, temp.begin());
BOOST_REGEX_ASSERT(*(s_data.cont.back().second) == k);
// update index with new position:
mpos->second = --(s_data.cont.end());
BOOST_REGEX_ASSERT(&(mpos->first) == mpos->second->second);
BOOST_REGEX_ASSERT(&(mpos->first) == s_data.cont.back().second);
}
return s_data.cont.back().first;
}
//
// if we get here then the item is not in the cache,
// so create it:
//
boost::shared_ptr<Object const> result(new Object(k));
//
// Add it to the list, and index it:
//
s_data.cont.push_back(value_type(result, static_cast<Key const*>(0)));
s_data.index.insert(std::make_pair(k, --(s_data.cont.end())));
s_data.cont.back().second = &(s_data.index.find(k)->first);
map_size_type s = s_data.index.size();
BOOST_REGEX_ASSERT(s_data.index[k]->first.get() == result.get());
BOOST_REGEX_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second);
BOOST_REGEX_ASSERT(s_data.index.find(k)->first == k);
if(s > l_max_cache_size)
{
//
// We have too many items in the list, so we need to start
// popping them off the back of the list, but only if they're
// being held uniquely by us:
//
list_iterator pos = s_data.cont.begin();
list_iterator last = s_data.cont.end();
while((pos != last) && (s > l_max_cache_size))
{
if(pos->first.unique())
{
list_iterator condemmed(pos);
++pos;
// now remove the items from our containers,
// then order has to be as follows:
BOOST_REGEX_ASSERT(s_data.index.find(*(condemmed->second)) != s_data.index.end());
s_data.index.erase(*(condemmed->second));
s_data.cont.erase(condemmed);
--s;
}
else
++pos;
}
BOOST_REGEX_ASSERT(s_data.index[k]->first.get() == result.get());
BOOST_REGEX_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second);
BOOST_REGEX_ASSERT(s_data.index.find(k)->first == k);
}
return result;
}
}
#endif

View File

@ -0,0 +1,127 @@
/*
*
* 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 pattern_except.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares pattern-matching exception classes.
*/
#ifndef BOOST_RE_V4_PAT_EXCEPT_HPP
#define BOOST_RE_V4_PAT_EXCEPT_HPP
#ifndef BOOST_REGEX_CONFIG_HPP
#include <boost/regex/config.hpp>
#endif
#include <cstddef>
#include <stdexcept>
#include <boost/regex/v4/error_type.hpp>
#include <boost/regex/v4/regex_traits_defaults.hpp>
namespace boost{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4103)
#endif
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable : 4275)
#if BOOST_MSVC >= 1800
#pragma warning(disable : 26812)
#endif
#endif
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)
: std::runtime_error(s)
, m_error_code(err)
, m_position(pos)
{
}
explicit regex_error(regex_constants::error_type err)
: std::runtime_error(::boost::BOOST_REGEX_DETAIL_NS::get_default_error_string(err))
, m_error_code(err)
, m_position(0)
{
}
~regex_error() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {}
regex_constants::error_type code()const
{ return m_error_code; }
std::ptrdiff_t position()const
{ return m_position; }
void raise()const
{
#ifndef BOOST_NO_EXCEPTIONS
#ifndef BOOST_REGEX_STANDALONE
::boost::throw_exception(*this);
#else
throw* this;
#endif
#endif
}
private:
regex_constants::error_type m_error_code;
std::ptrdiff_t m_position;
};
typedef regex_error bad_pattern;
typedef regex_error bad_expression;
namespace BOOST_REGEX_DETAIL_NS{
inline void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex)
{
#ifndef BOOST_REGEX_STANDALONE
::boost::throw_exception(ex);
#else
throw ex;
#endif
}
template <class traits>
void raise_error(const traits& t, regex_constants::error_type code)
{
(void)t; // warning suppression
std::runtime_error e(t.error_string(code));
::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(e);
}
}
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4103)
#endif
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_SUFFIX
#endif
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
} // namespace boost
#endif

View File

@ -45,7 +45,17 @@ namespace BOOST_REGEX_DETAIL_NS{
//
// error checking API:
//
BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex_constants::syntax_option_type ef, match_flag_type mf);
inline void BOOST_REGEX_CALL verify_options(boost::regex_constants::syntax_option_type, match_flag_type mf)
{
//
// can't mix match_extra with POSIX matching rules:
//
if ((mf & match_extra) && (mf & match_posix))
{
std::logic_error msg("Usage Error: Can't mix regular expression captures with POSIX matching rules");
throw_exception(msg);
}
}
//
// function can_start:
//
@ -88,7 +98,7 @@ inline bool can_start(unsigned int c, const unsigned char* map, unsigned char ma
//
// Unfortunately Rogue Waves standard library appears to have a bug
// in std::basic_string::compare that results in eroneous answers
// in std::basic_string::compare that results in erroneous answers
// in some cases (tested with Borland C++ 5.1, Rogue Wave lib version
// 0x020101) the test case was:
// {39135,0} < {0xff,0}
@ -375,7 +385,7 @@ class perl_matcher
public:
typedef typename traits::char_type char_type;
typedef perl_matcher<BidiIterator, Allocator, traits> self_type;
typedef bool (self_type::*matcher_proc_type)(void);
typedef bool (self_type::*matcher_proc_type)();
typedef std::size_t traits_size_type;
typedef typename is_byte<char_type>::width_type width_type;
typedef typename regex_iterator_traits<BidiIterator>::difference_type difference_type;
@ -633,4 +643,3 @@ private:
#include <boost/regex/v4/perl_matcher_common.hpp>
#endif

View File

@ -622,7 +622,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_backref()
if(index >= hash_value_mask)
{
named_subexpressions::range_type r = re.get_data().equal_range(index);
BOOST_ASSERT(r.first != r.second);
BOOST_REGEX_ASSERT(r.first != r.second);
do
{
index = r.first->index;

View File

@ -20,7 +20,7 @@
#ifndef BOOST_REGEX_V4_PERL_MATCHER_NON_RECURSIVE_HPP
#define BOOST_REGEX_V4_PERL_MATCHER_NON_RECURSIVE_HPP
#include <new>
#include <boost/regex/v4/mem_block_cache.hpp>
#ifdef BOOST_MSVC
#pragma warning(push)
@ -111,7 +111,7 @@ struct save_state_init
*end = reinterpret_cast<saved_state*>(reinterpret_cast<char*>(*base)+BOOST_REGEX_BLOCKSIZE);
--(*end);
(void) new (*end)saved_state(0);
BOOST_ASSERT(*end > *base);
BOOST_REGEX_ASSERT(*end > *base);
}
~save_state_init()
{
@ -217,7 +217,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states()
bool successful_unwind = unwind(false);
if((m_match_flags & match_partial) && (position == last) && (position != search_base))
m_has_partial_match = true;
if(false == successful_unwind)
if(!successful_unwind)
return m_recursive_result;
}
}
@ -248,7 +248,7 @@ void perl_matcher<BidiIterator, Allocator, traits>::extend_stack()
template <class BidiIterator, class Allocator, class traits>
inline void perl_matcher<BidiIterator, Allocator, traits>::push_matched_paren(int index, const sub_match<BidiIterator>& sub)
{
//BOOST_ASSERT(index);
//BOOST_REGEX_ASSERT(index);
saved_matched_paren<BidiIterator>* pmp = static_cast<saved_matched_paren<BidiIterator>*>(m_backup_state);
--pmp;
if(pmp < m_stack_base)
@ -264,7 +264,7 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_matched_paren(in
template <class BidiIterator, class Allocator, class traits>
inline void perl_matcher<BidiIterator, Allocator, traits>::push_case_change(bool c)
{
//BOOST_ASSERT(index);
//BOOST_REGEX_ASSERT(index);
saved_change_case* pmp = static_cast<saved_change_case*>(m_backup_state);
--pmp;
if(pmp < m_stack_base)
@ -348,7 +348,7 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_repeater_count(i
pmp = static_cast<saved_repeater<BidiIterator>*>(m_backup_state);
--pmp;
}
(void) new (pmp)saved_repeater<BidiIterator>(i, s, position, this->recursion_stack.size() ? this->recursion_stack.back().idx : (INT_MIN + 3));
(void) new (pmp)saved_repeater<BidiIterator>(i, s, position, this->recursion_stack.empty() ? (INT_MIN + 3) : this->recursion_stack.back().idx);
m_backup_state = pmp;
}
@ -492,7 +492,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark()
{
// conditional expression:
const re_alt* alt = static_cast<const re_alt*>(pstate->next.p);
BOOST_ASSERT(alt->type == syntax_element_alt);
BOOST_REGEX_ASSERT(alt->type == syntax_element_alt);
pstate = alt->next.p;
if(pstate->type == syntax_element_assert_backref)
{
@ -503,7 +503,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark()
else
{
// zero width assertion, have to match this recursively:
BOOST_ASSERT(pstate->type == syntax_element_startmark);
BOOST_REGEX_ASSERT(pstate->type == syntax_element_startmark);
bool negated = static_cast<const re_brace*>(pstate)->index == -2;
BidiIterator saved_position = position;
const re_syntax_base* next_pstate = static_cast<const re_jump*>(pstate->next.p)->alt.p->next.p;
@ -543,7 +543,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark()
}
default:
{
BOOST_ASSERT(index > 0);
BOOST_REGEX_ASSERT(index > 0);
if((m_match_flags & match_nosubs) == 0)
{
push_matched_paren(index, (*m_presult)[index]);
@ -705,7 +705,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_dot_repeat_slow()
std::size_t count = 0;
const re_repeat* rep = static_cast<const re_repeat*>(pstate);
re_syntax_base* psingle = rep->next.p;
// match compulsary repeats first:
// match compulsory repeats first:
while(count < rep->min)
{
pstate = psingle;
@ -794,7 +794,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_char_repeat()
#pragma option push -w-8008 -w-8066 -w-8004
#endif
const re_repeat* rep = static_cast<const re_repeat*>(pstate);
BOOST_ASSERT(1 == static_cast<const re_literal*>(rep->next.p)->length);
BOOST_REGEX_ASSERT(1 == static_cast<const re_literal*>(rep->next.p)->length);
const char_type what = *reinterpret_cast<const char_type*>(static_cast<const re_literal*>(rep->next.p) + 1);
std::size_t count = 0;
//
@ -1010,7 +1010,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_long_set_repeat()
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_recursion()
{
BOOST_ASSERT(pstate->type == syntax_element_recurse);
BOOST_REGEX_ASSERT(pstate->type == syntax_element_recurse);
//
// See if we've seen this recursion before at this location, if we have then
// we need to prevent infinite recursion:
@ -1087,7 +1087,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_match()
{
if(!recursion_stack.empty())
{
BOOST_ASSERT(0 == recursion_stack.back().idx);
BOOST_REGEX_ASSERT(0 == recursion_stack.back().idx);
pstate = recursion_stack.back().preturn_address;
push_recursion(recursion_stack.back().idx, recursion_stack.back().preturn_address, m_presult, &recursion_stack.back().results);
*m_presult = recursion_stack.back().results;
@ -1224,7 +1224,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::skip_until_paren(int index,
/****************************************************************************
Unwind and associated proceedures follow, these perform what normal stack
Unwind and associated procedures follow, these perform what normal stack
unwinding does in the recursive implementation.
****************************************************************************/
@ -1296,7 +1296,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_paren(bool have_match
{
saved_matched_paren<BidiIterator>* pmp = static_cast<saved_matched_paren<BidiIterator>*>(m_backup_state);
// restore previous values if no match was found:
if(have_match == false)
if(!have_match)
{
m_presult->set_first(pmp->sub.first, pmp->index, pmp->index == 0);
m_presult->set_second(pmp->sub.second, pmp->index, pmp->sub.matched, pmp->index == 0);
@ -1394,15 +1394,15 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_greedy_single_repeat(
const re_repeat* rep = pmp->rep;
std::size_t count = pmp->count;
BOOST_ASSERT(rep->next.p != 0);
BOOST_ASSERT(rep->alt.p != 0);
BOOST_REGEX_ASSERT(rep->next.p != 0);
BOOST_REGEX_ASSERT(rep->alt.p != 0);
count -= rep->min;
if((m_match_flags & match_partial) && (position == last))
m_has_partial_match = true;
BOOST_ASSERT(count);
BOOST_REGEX_ASSERT(count);
position = pmp->last_position;
// backtrack till we can skip out:
@ -1443,12 +1443,12 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_slow_dot_repeat(bool
const re_repeat* rep = pmp->rep;
std::size_t count = pmp->count;
BOOST_ASSERT(rep->type == syntax_element_dot_rep);
BOOST_ASSERT(rep->next.p != 0);
BOOST_ASSERT(rep->alt.p != 0);
BOOST_ASSERT(rep->next.p->type == syntax_element_wild);
BOOST_REGEX_ASSERT(rep->type == syntax_element_dot_rep);
BOOST_REGEX_ASSERT(rep->next.p != 0);
BOOST_REGEX_ASSERT(rep->alt.p != 0);
BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_wild);
BOOST_ASSERT(count < rep->max);
BOOST_REGEX_ASSERT(count < rep->max);
pstate = rep->next.p;
position = pmp->last_position;
@ -1508,7 +1508,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_fast_dot_repeat(bool
const re_repeat* rep = pmp->rep;
std::size_t count = pmp->count;
BOOST_ASSERT(count < rep->max);
BOOST_REGEX_ASSERT(count < rep->max);
position = pmp->last_position;
if(position != last)
{
@ -1568,11 +1568,11 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_char_repeat(bool r)
const char_type what = *reinterpret_cast<const char_type*>(static_cast<const re_literal*>(pstate) + 1);
position = pmp->last_position;
BOOST_ASSERT(rep->type == syntax_element_char_rep);
BOOST_ASSERT(rep->next.p != 0);
BOOST_ASSERT(rep->alt.p != 0);
BOOST_ASSERT(rep->next.p->type == syntax_element_literal);
BOOST_ASSERT(count < rep->max);
BOOST_REGEX_ASSERT(rep->type == syntax_element_char_rep);
BOOST_REGEX_ASSERT(rep->next.p != 0);
BOOST_REGEX_ASSERT(rep->alt.p != 0);
BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_literal);
BOOST_REGEX_ASSERT(count < rep->max);
if(position != last)
{
@ -1637,11 +1637,11 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_short_set_repeat(bool
const unsigned char* map = static_cast<const re_set*>(rep->next.p)->_map;
position = pmp->last_position;
BOOST_ASSERT(rep->type == syntax_element_short_set_rep);
BOOST_ASSERT(rep->next.p != 0);
BOOST_ASSERT(rep->alt.p != 0);
BOOST_ASSERT(rep->next.p->type == syntax_element_set);
BOOST_ASSERT(count < rep->max);
BOOST_REGEX_ASSERT(rep->type == syntax_element_short_set_rep);
BOOST_REGEX_ASSERT(rep->next.p != 0);
BOOST_REGEX_ASSERT(rep->alt.p != 0);
BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_set);
BOOST_REGEX_ASSERT(count < rep->max);
if(position != last)
{
@ -1707,11 +1707,11 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_long_set_repeat(bool
const re_set_long<m_type>* set = static_cast<const re_set_long<m_type>*>(pstate);
position = pmp->last_position;
BOOST_ASSERT(rep->type == syntax_element_long_set_rep);
BOOST_ASSERT(rep->next.p != 0);
BOOST_ASSERT(rep->alt.p != 0);
BOOST_ASSERT(rep->next.p->type == syntax_element_long_set);
BOOST_ASSERT(count < rep->max);
BOOST_REGEX_ASSERT(rep->type == syntax_element_long_set_rep);
BOOST_REGEX_ASSERT(rep->next.p != 0);
BOOST_REGEX_ASSERT(rep->alt.p != 0);
BOOST_REGEX_ASSERT(rep->next.p->type == syntax_element_long_set);
BOOST_REGEX_ASSERT(count < rep->max);
if(position != last)
{
@ -1944,5 +1944,3 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_parenthesis_push
#endif
#endif

View File

@ -195,7 +195,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark()
{
// conditional expression:
const re_alt* alt = static_cast<const re_alt*>(pstate->next.p);
BOOST_ASSERT(alt->type == syntax_element_alt);
BOOST_REGEX_ASSERT(alt->type == syntax_element_alt);
pstate = alt->next.p;
if(pstate->type == syntax_element_assert_backref)
{
@ -206,7 +206,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark()
else
{
// zero width assertion, have to match this recursively:
BOOST_ASSERT(pstate->type == syntax_element_startmark);
BOOST_REGEX_ASSERT(pstate->type == syntax_element_startmark);
bool negated = static_cast<const re_brace*>(pstate)->index == -2;
BidiIterator saved_position = position;
const re_syntax_base* next_pstate = static_cast<const re_jump*>(pstate->next.p)->alt.p->next.p;
@ -235,7 +235,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark()
}
default:
{
BOOST_ASSERT(index > 0);
BOOST_REGEX_ASSERT(index > 0);
if((m_match_flags & match_nosubs) == 0)
{
backup_subex<BidiIterator> sub(*m_presult, index);
@ -552,7 +552,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_char_repeat()
#pragma option push -w-8008 -w-8066 -w-8004
#endif
const re_repeat* rep = static_cast<const re_repeat*>(pstate);
BOOST_ASSERT(1 == static_cast<const re_literal*>(rep->next.p)->length);
BOOST_REGEX_ASSERT(1 == static_cast<const re_literal*>(rep->next.p)->length);
const char_type what = *reinterpret_cast<const char_type*>(static_cast<const re_literal*>(rep->next.p) + 1);
//
// start by working out how much we can skip:
@ -892,7 +892,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::backtrack_till_match(std::si
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_recursion()
{
BOOST_ASSERT(pstate->type == syntax_element_recurse);
BOOST_REGEX_ASSERT(pstate->type == syntax_element_recurse);
//
// Set new call stack:
//
@ -987,7 +987,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_match()
{
if(!recursion_stack.empty())
{
BOOST_ASSERT(0 == recursion_stack.back().idx);
BOOST_REGEX_ASSERT(0 == recursion_stack.back().idx);
const re_syntax_base* saved_state = pstate = recursion_stack.back().preturn_address;
*m_presult = recursion_stack.back().results;
recursion_stack.pop_back();

View File

@ -46,7 +46,7 @@ template <class S, class charT>
unsigned count_chars(const S& s, charT c)
{
//
// Count how many occurances of character c occur
// Count how many occurrences of character c occur
// in string s: if c is a delimeter between collation
// fields, then this should be the same value for all
// sort keys:

View File

@ -20,6 +20,8 @@
#ifndef BOOST_REGEX_V4_PROTECTED_CALL_HPP
#define BOOST_REGEX_V4_PROTECTED_CALL_HPP
#include <boost/config.hpp>
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4103)
@ -53,7 +55,7 @@ public:
concrete_protected_call(T* o, proc_type p)
: obj(o), proc(p) {}
private:
virtual bool call()const;
bool call()const BOOST_OVERRIDE;
T* obj;
proc_type proc;
};

View File

@ -87,42 +87,6 @@
#ifndef BOOST_REGEX_MATCHER_HPP
#include <boost/regex/v4/perl_matcher.hpp>
#endif
//
// template instances:
//
#define BOOST_REGEX_CHAR_T char
#ifdef BOOST_REGEX_NARROW_INSTANTIATE
# define BOOST_REGEX_INSTANTIATE
#endif
#include <boost/regex/v4/instances.hpp>
#undef BOOST_REGEX_CHAR_T
#ifdef BOOST_REGEX_INSTANTIATE
# undef BOOST_REGEX_INSTANTIATE
#endif
#ifndef BOOST_NO_WREGEX
#define BOOST_REGEX_CHAR_T wchar_t
#ifdef BOOST_REGEX_WIDE_INSTANTIATE
# define BOOST_REGEX_INSTANTIATE
#endif
#include <boost/regex/v4/instances.hpp>
#undef BOOST_REGEX_CHAR_T
#ifdef BOOST_REGEX_INSTANTIATE
# undef BOOST_REGEX_INSTANTIATE
#endif
#endif
#if !defined(BOOST_NO_WREGEX) && defined(BOOST_REGEX_HAS_OTHER_WCHAR_T)
#define BOOST_REGEX_CHAR_T unsigned short
#ifdef BOOST_REGEX_US_INSTANTIATE
# define BOOST_REGEX_INSTANTIATE
#endif
#include <boost/regex/v4/instances.hpp>
#undef BOOST_REGEX_CHAR_T
#ifdef BOOST_REGEX_INSTANTIATE
# undef BOOST_REGEX_INSTANTIATE
#endif
#endif
namespace boost{

View File

@ -251,7 +251,7 @@ void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format
m_have_conditional = have_conditional;
if(m_position == m_end)
return;
BOOST_ASSERT(*m_position == static_cast<char_type>(')'));
BOOST_REGEX_ASSERT(*m_position == static_cast<char_type>(')'));
++m_position; // skip the closing ')'
break;
}
@ -307,7 +307,7 @@ void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format
// On entry *m_position points to a '$' character
// output the information that goes with it:
//
BOOST_ASSERT(*m_position == '$');
BOOST_REGEX_ASSERT(*m_position == '$');
//
// see if this is a trailing '$':
//
@ -656,7 +656,7 @@ void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format
len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end);
len = (std::min)(static_cast<std::ptrdiff_t>(4), len);
v = this->toi(m_position, m_position + len, 8);
BOOST_ASSERT(v >= 0);
BOOST_REGEX_ASSERT(v >= 0);
put(static_cast<char_type>(v));
break;
}

View File

@ -106,7 +106,7 @@ enum{
// this is used by basic_regex for expression storage
//
class BOOST_REGEX_DECL raw_storage
class raw_storage
{
public:
typedef std::size_t size_type;
@ -123,7 +123,29 @@ public:
::operator delete(start);
}
void BOOST_REGEX_CALL resize(size_type n);
void BOOST_REGEX_CALL resize(size_type n)
{
size_type newsize = start ? last - start : 1024;
while (newsize < n)
newsize *= 2;
size_type datasize = end - start;
// extend newsize to WORD/DWORD boundary:
newsize = (newsize + padding_mask) & ~(padding_mask);
// allocate and copy data:
pointer ptr = static_cast<pointer>(::operator new(newsize));
BOOST_REGEX_NOEH_ASSERT(ptr)
if (start)
std::memcpy(ptr, start, datasize);
// get rid of old buffer:
::operator delete(start);
// and set up pointers:
start = ptr;
end = ptr + datasize;
last = ptr + newsize;
}
void* BOOST_REGEX_CALL extend(size_type n)
{
@ -134,7 +156,16 @@ public:
return result;
}
void* BOOST_REGEX_CALL insert(size_type pos, size_type n);
void* BOOST_REGEX_CALL insert(size_type pos, size_type n)
{
BOOST_REGEX_ASSERT(pos <= size_type(end - start));
if (size_type(last - end) < n)
resize(n + (end - start));
void* result = start + pos;
std::memmove(start + pos + n, start + pos, (end - start) - pos);
end += n;
return result;
}
size_type BOOST_REGEX_CALL size()
{

View File

@ -66,6 +66,8 @@ class regex_token_iterator_implementation
std::vector<int> subs; // the sub-expressions to enumerate
public:
regex_token_iterator_implementation(const regex_token_iterator_implementation& other)
: what(other.what), base(other.base), end(other.end), re(other.re), flags(other.flags), result(other.result), N(other.N), subs(other.subs) {}
regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f)
: end(last), re(*p), flags(f), N(0){ subs.push_back(sub); }
regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector<int>& v, match_flag_type f)

View File

@ -31,6 +31,11 @@
#endif
#include <boost/regex/config.hpp>
#include <boost/cstdint.hpp>
#include <cctype>
#include <cwctype>
#include <locale>
#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP
#include <boost/regex/v4/syntax_type.hpp>
@ -38,6 +43,7 @@
#ifndef BOOST_REGEX_ERROR_TYPE_HPP
#include <boost/regex/v4/error_type.hpp>
#endif
#include <boost/regex/v4/regex_workaround.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <boost/utility/enable_if.hpp>
@ -62,14 +68,548 @@ inline bool is_extended(charT c)
inline bool is_extended(char)
{ return false; }
inline const char* BOOST_REGEX_CALL get_default_syntax(regex_constants::syntax_type n)
{
// if the user hasn't supplied a message catalog, then this supplies
// default "messages" for us to load in the range 1-100.
const char* messages[] = {
"",
"(",
")",
"$",
"^",
".",
"*",
"+",
"?",
"[",
"]",
"|",
"\\",
"#",
"-",
"{",
"}",
"0123456789",
"b",
"B",
"<",
">",
"",
"",
"A`",
"z'",
"\n",
",",
"a",
"f",
"n",
"r",
"t",
"v",
"x",
"c",
":",
"=",
"e",
"",
"",
"",
"",
"",
"",
"",
"",
"E",
"Q",
"X",
"C",
"Z",
"G",
"!",
"p",
"P",
"N",
"gk",
"K",
"R",
};
BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_syntax(regex_constants::syntax_type n);
BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_error_string(regex_constants::error_type n);
BOOST_REGEX_DECL regex_constants::syntax_type BOOST_REGEX_CALL get_default_syntax_type(char c);
BOOST_REGEX_DECL regex_constants::escape_syntax_type BOOST_REGEX_CALL get_default_escape_syntax_type(char c);
return ((n >= (sizeof(messages) / sizeof(messages[1]))) ? "" : messages[n]);
}
inline const char* BOOST_REGEX_CALL get_default_error_string(regex_constants::error_type n)
{
static const char* const s_default_error_messages[] = {
"Success", /* REG_NOERROR 0 error_ok */
"No match", /* REG_NOMATCH 1 error_no_match */
"Invalid regular expression.", /* REG_BADPAT 2 error_bad_pattern */
"Invalid collation character.", /* REG_ECOLLATE 3 error_collate */
"Invalid character class name, collating name, or character range.", /* REG_ECTYPE 4 error_ctype */
"Invalid or unterminated escape sequence.", /* REG_EESCAPE 5 error_escape */
"Invalid back reference: specified capturing group does not exist.", /* REG_ESUBREG 6 error_backref */
"Unmatched [ or [^ in character class declaration.", /* REG_EBRACK 7 error_brack */
"Unmatched marking parenthesis ( or \\(.", /* REG_EPAREN 8 error_paren */
"Unmatched quantified repeat operator { or \\{.", /* REG_EBRACE 9 error_brace */
"Invalid content of repeat range.", /* REG_BADBR 10 error_badbrace */
"Invalid range end in character class", /* REG_ERANGE 11 error_range */
"Out of memory.", /* REG_ESPACE 12 error_space NOT USED */
"Invalid preceding regular expression prior to repetition operator.", /* REG_BADRPT 13 error_badrepeat */
"Premature end of regular expression", /* REG_EEND 14 error_end NOT USED */
"Regular expression is too large.", /* REG_ESIZE 15 error_size NOT USED */
"Unmatched ) or \\)", /* REG_ERPAREN 16 error_right_paren NOT USED */
"Empty regular expression.", /* REG_EMPTY 17 error_empty */
"The complexity of matching the regular expression exceeded predefined bounds. "
"Try refactoring the regular expression to make each choice made by the state machine unambiguous. "
"This exception is thrown to prevent \"eternal\" matches that take an "
"indefinite period time to locate.", /* REG_ECOMPLEXITY 18 error_complexity */
"Ran out of stack space trying to match the regular expression.", /* REG_ESTACK 19 error_stack */
"Invalid or unterminated Perl (?...) sequence.", /* REG_E_PERL 20 error_perl */
"Unknown error.", /* REG_E_UNKNOWN 21 error_unknown */
};
return (n > ::boost::regex_constants::error_unknown) ? s_default_error_messages[::boost::regex_constants::error_unknown] : s_default_error_messages[n];
}
inline regex_constants::syntax_type BOOST_REGEX_CALL get_default_syntax_type(char c)
{
//
// char_syntax determines how the compiler treats a given character
// in a regular expression.
//
static regex_constants::syntax_type char_syntax[] = {
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_newline, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /* */ // 32
regex_constants::syntax_not, /*!*/
regex_constants::syntax_char, /*"*/
regex_constants::syntax_hash, /*#*/
regex_constants::syntax_dollar, /*$*/
regex_constants::syntax_char, /*%*/
regex_constants::syntax_char, /*&*/
regex_constants::escape_type_end_buffer, /*'*/
regex_constants::syntax_open_mark, /*(*/
regex_constants::syntax_close_mark, /*)*/
regex_constants::syntax_star, /***/
regex_constants::syntax_plus, /*+*/
regex_constants::syntax_comma, /*,*/
regex_constants::syntax_dash, /*-*/
regex_constants::syntax_dot, /*.*/
regex_constants::syntax_char, /*/*/
regex_constants::syntax_digit, /*0*/
regex_constants::syntax_digit, /*1*/
regex_constants::syntax_digit, /*2*/
regex_constants::syntax_digit, /*3*/
regex_constants::syntax_digit, /*4*/
regex_constants::syntax_digit, /*5*/
regex_constants::syntax_digit, /*6*/
regex_constants::syntax_digit, /*7*/
regex_constants::syntax_digit, /*8*/
regex_constants::syntax_digit, /*9*/
regex_constants::syntax_colon, /*:*/
regex_constants::syntax_char, /*;*/
regex_constants::escape_type_left_word, /*<*/
regex_constants::syntax_equal, /*=*/
regex_constants::escape_type_right_word, /*>*/
regex_constants::syntax_question, /*?*/
regex_constants::syntax_char, /*@*/
regex_constants::syntax_char, /*A*/
regex_constants::syntax_char, /*B*/
regex_constants::syntax_char, /*C*/
regex_constants::syntax_char, /*D*/
regex_constants::syntax_char, /*E*/
regex_constants::syntax_char, /*F*/
regex_constants::syntax_char, /*G*/
regex_constants::syntax_char, /*H*/
regex_constants::syntax_char, /*I*/
regex_constants::syntax_char, /*J*/
regex_constants::syntax_char, /*K*/
regex_constants::syntax_char, /*L*/
regex_constants::syntax_char, /*M*/
regex_constants::syntax_char, /*N*/
regex_constants::syntax_char, /*O*/
regex_constants::syntax_char, /*P*/
regex_constants::syntax_char, /*Q*/
regex_constants::syntax_char, /*R*/
regex_constants::syntax_char, /*S*/
regex_constants::syntax_char, /*T*/
regex_constants::syntax_char, /*U*/
regex_constants::syntax_char, /*V*/
regex_constants::syntax_char, /*W*/
regex_constants::syntax_char, /*X*/
regex_constants::syntax_char, /*Y*/
regex_constants::syntax_char, /*Z*/
regex_constants::syntax_open_set, /*[*/
regex_constants::syntax_escape, /*\*/
regex_constants::syntax_close_set, /*]*/
regex_constants::syntax_caret, /*^*/
regex_constants::syntax_char, /*_*/
regex_constants::syntax_char, /*`*/
regex_constants::syntax_char, /*a*/
regex_constants::syntax_char, /*b*/
regex_constants::syntax_char, /*c*/
regex_constants::syntax_char, /*d*/
regex_constants::syntax_char, /*e*/
regex_constants::syntax_char, /*f*/
regex_constants::syntax_char, /*g*/
regex_constants::syntax_char, /*h*/
regex_constants::syntax_char, /*i*/
regex_constants::syntax_char, /*j*/
regex_constants::syntax_char, /*k*/
regex_constants::syntax_char, /*l*/
regex_constants::syntax_char, /*m*/
regex_constants::syntax_char, /*n*/
regex_constants::syntax_char, /*o*/
regex_constants::syntax_char, /*p*/
regex_constants::syntax_char, /*q*/
regex_constants::syntax_char, /*r*/
regex_constants::syntax_char, /*s*/
regex_constants::syntax_char, /*t*/
regex_constants::syntax_char, /*u*/
regex_constants::syntax_char, /*v*/
regex_constants::syntax_char, /*w*/
regex_constants::syntax_char, /*x*/
regex_constants::syntax_char, /*y*/
regex_constants::syntax_char, /*z*/
regex_constants::syntax_open_brace, /*{*/
regex_constants::syntax_or, /*|*/
regex_constants::syntax_close_brace, /*}*/
regex_constants::syntax_char, /*~*/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
};
return char_syntax[(unsigned char)c];
}
inline regex_constants::escape_syntax_type BOOST_REGEX_CALL get_default_escape_syntax_type(char c)
{
//
// char_syntax determines how the compiler treats a given character
// in a regular expression.
//
static regex_constants::escape_syntax_type char_syntax[] = {
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /* */ // 32
regex_constants::escape_type_identity, /*!*/
regex_constants::escape_type_identity, /*"*/
regex_constants::escape_type_identity, /*#*/
regex_constants::escape_type_identity, /*$*/
regex_constants::escape_type_identity, /*%*/
regex_constants::escape_type_identity, /*&*/
regex_constants::escape_type_end_buffer, /*'*/
regex_constants::syntax_open_mark, /*(*/
regex_constants::syntax_close_mark, /*)*/
regex_constants::escape_type_identity, /***/
regex_constants::syntax_plus, /*+*/
regex_constants::escape_type_identity, /*,*/
regex_constants::escape_type_identity, /*-*/
regex_constants::escape_type_identity, /*.*/
regex_constants::escape_type_identity, /*/*/
regex_constants::escape_type_decimal, /*0*/
regex_constants::escape_type_backref, /*1*/
regex_constants::escape_type_backref, /*2*/
regex_constants::escape_type_backref, /*3*/
regex_constants::escape_type_backref, /*4*/
regex_constants::escape_type_backref, /*5*/
regex_constants::escape_type_backref, /*6*/
regex_constants::escape_type_backref, /*7*/
regex_constants::escape_type_backref, /*8*/
regex_constants::escape_type_backref, /*9*/
regex_constants::escape_type_identity, /*:*/
regex_constants::escape_type_identity, /*;*/
regex_constants::escape_type_left_word, /*<*/
regex_constants::escape_type_identity, /*=*/
regex_constants::escape_type_right_word, /*>*/
regex_constants::syntax_question, /*?*/
regex_constants::escape_type_identity, /*@*/
regex_constants::escape_type_start_buffer, /*A*/
regex_constants::escape_type_not_word_assert, /*B*/
regex_constants::escape_type_C, /*C*/
regex_constants::escape_type_not_class, /*D*/
regex_constants::escape_type_E, /*E*/
regex_constants::escape_type_not_class, /*F*/
regex_constants::escape_type_G, /*G*/
regex_constants::escape_type_not_class, /*H*/
regex_constants::escape_type_not_class, /*I*/
regex_constants::escape_type_not_class, /*J*/
regex_constants::escape_type_reset_start_mark, /*K*/
regex_constants::escape_type_not_class, /*L*/
regex_constants::escape_type_not_class, /*M*/
regex_constants::escape_type_named_char, /*N*/
regex_constants::escape_type_not_class, /*O*/
regex_constants::escape_type_not_property, /*P*/
regex_constants::escape_type_Q, /*Q*/
regex_constants::escape_type_line_ending, /*R*/
regex_constants::escape_type_not_class, /*S*/
regex_constants::escape_type_not_class, /*T*/
regex_constants::escape_type_not_class, /*U*/
regex_constants::escape_type_not_class, /*V*/
regex_constants::escape_type_not_class, /*W*/
regex_constants::escape_type_X, /*X*/
regex_constants::escape_type_not_class, /*Y*/
regex_constants::escape_type_Z, /*Z*/
regex_constants::escape_type_identity, /*[*/
regex_constants::escape_type_identity, /*\*/
regex_constants::escape_type_identity, /*]*/
regex_constants::escape_type_identity, /*^*/
regex_constants::escape_type_identity, /*_*/
regex_constants::escape_type_start_buffer, /*`*/
regex_constants::escape_type_control_a, /*a*/
regex_constants::escape_type_word_assert, /*b*/
regex_constants::escape_type_ascii_control, /*c*/
regex_constants::escape_type_class, /*d*/
regex_constants::escape_type_e, /*e*/
regex_constants::escape_type_control_f, /*f*/
regex_constants::escape_type_extended_backref, /*g*/
regex_constants::escape_type_class, /*h*/
regex_constants::escape_type_class, /*i*/
regex_constants::escape_type_class, /*j*/
regex_constants::escape_type_extended_backref, /*k*/
regex_constants::escape_type_class, /*l*/
regex_constants::escape_type_class, /*m*/
regex_constants::escape_type_control_n, /*n*/
regex_constants::escape_type_class, /*o*/
regex_constants::escape_type_property, /*p*/
regex_constants::escape_type_class, /*q*/
regex_constants::escape_type_control_r, /*r*/
regex_constants::escape_type_class, /*s*/
regex_constants::escape_type_control_t, /*t*/
regex_constants::escape_type_class, /*u*/
regex_constants::escape_type_control_v, /*v*/
regex_constants::escape_type_class, /*w*/
regex_constants::escape_type_hex, /*x*/
regex_constants::escape_type_class, /*y*/
regex_constants::escape_type_end_buffer, /*z*/
regex_constants::syntax_open_brace, /*{*/
regex_constants::syntax_or, /*|*/
regex_constants::syntax_close_brace, /*}*/
regex_constants::escape_type_identity, /*~*/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
};
return char_syntax[(unsigned char)c];
}
// is charT c a combining character?
BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining_implementation(uint_least16_t s);
inline bool BOOST_REGEX_CALL is_combining_implementation(boost::uint_least16_t c)
{
const boost::uint_least16_t combining_ranges[] = { 0x0300, 0x0361,
0x0483, 0x0486,
0x0903, 0x0903,
0x093E, 0x0940,
0x0949, 0x094C,
0x0982, 0x0983,
0x09BE, 0x09C0,
0x09C7, 0x09CC,
0x09D7, 0x09D7,
0x0A3E, 0x0A40,
0x0A83, 0x0A83,
0x0ABE, 0x0AC0,
0x0AC9, 0x0ACC,
0x0B02, 0x0B03,
0x0B3E, 0x0B3E,
0x0B40, 0x0B40,
0x0B47, 0x0B4C,
0x0B57, 0x0B57,
0x0B83, 0x0B83,
0x0BBE, 0x0BBF,
0x0BC1, 0x0BCC,
0x0BD7, 0x0BD7,
0x0C01, 0x0C03,
0x0C41, 0x0C44,
0x0C82, 0x0C83,
0x0CBE, 0x0CBE,
0x0CC0, 0x0CC4,
0x0CC7, 0x0CCB,
0x0CD5, 0x0CD6,
0x0D02, 0x0D03,
0x0D3E, 0x0D40,
0x0D46, 0x0D4C,
0x0D57, 0x0D57,
0x0F7F, 0x0F7F,
0x20D0, 0x20E1,
0x3099, 0x309A,
0xFE20, 0xFE23,
0xffff, 0xffff, };
const boost::uint_least16_t* p = combining_ranges + 1;
while (*p < c) p += 2;
--p;
if ((c >= *p) && (c <= *(p + 1)))
return true;
return false;
}
template <class charT>
inline bool is_combining(charT c)
@ -138,7 +678,77 @@ inline bool is_separator<char>(char c)
//
// get a default collating element:
//
BOOST_REGEX_DECL std::string BOOST_REGEX_CALL lookup_default_collate_name(const std::string& name);
inline std::string BOOST_REGEX_CALL lookup_default_collate_name(const std::string& name)
{
//
// these are the POSIX collating names:
//
static const char* def_coll_names[] = {
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "alert", "backspace", "tab", "newline",
"vertical-tab", "form-feed", "carriage-return", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK",
"SYN", "ETB", "CAN", "EM", "SUB", "ESC", "IS4", "IS3", "IS2", "IS1", "space", "exclamation-mark",
"quotation-mark", "number-sign", "dollar-sign", "percent-sign", "ampersand", "apostrophe",
"left-parenthesis", "right-parenthesis", "asterisk", "plus-sign", "comma", "hyphen",
"period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
"colon", "semicolon", "less-than-sign", "equals-sign", "greater-than-sign",
"question-mark", "commercial-at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "left-square-bracket", "backslash",
"right-square-bracket", "circumflex", "underscore", "grave-accent", "a", "b", "c", "d", "e", "f",
"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "left-curly-bracket",
"vertical-line", "right-curly-bracket", "tilde", "DEL", "",
};
// these multi-character collating elements
// should keep most Western-European locales
// happy - we should really localise these a
// little more - but this will have to do for
// now:
static const char* def_multi_coll[] = {
"ae",
"Ae",
"AE",
"ch",
"Ch",
"CH",
"ll",
"Ll",
"LL",
"ss",
"Ss",
"SS",
"nj",
"Nj",
"NJ",
"dz",
"Dz",
"DZ",
"lj",
"Lj",
"LJ",
"",
};
unsigned int i = 0;
while (*def_coll_names[i])
{
if (def_coll_names[i] == name)
{
return std::string(1, char(i));
}
++i;
}
i = 0;
while (*def_multi_coll[i])
{
if (def_multi_coll[i] == name)
{
return def_multi_coll[i];
}
++i;
}
return std::string();
}
//
// get the state_id of a character classification, the individual
@ -255,15 +865,25 @@ inline charT BOOST_REGEX_CALL global_upper(charT c)
return c;
}
BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_lower(char c);
BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_upper(char c);
inline char BOOST_REGEX_CALL do_global_lower(char c)
{
return static_cast<char>((std::tolower)((unsigned char)c));
}
inline char BOOST_REGEX_CALL do_global_upper(char c)
{
return static_cast<char>((std::toupper)((unsigned char)c));
}
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_lower(wchar_t c);
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_upper(wchar_t c);
#endif
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_lower(unsigned short c);
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_upper(unsigned short c);
inline wchar_t BOOST_REGEX_CALL do_global_lower(wchar_t c)
{
return (std::towlower)(c);
}
inline wchar_t BOOST_REGEX_CALL do_global_upper(wchar_t c)
{
return (std::towupper)(c);
}
#endif
//
// This sucks: declare template specialisations of global_lower/global_upper
@ -275,15 +895,11 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_upper(unsigned short
// otherwise the "local template instantiation" compiler option can pick
// the wrong instantiation when linking:
//
template<> inline char BOOST_REGEX_CALL global_lower<char>(char c){ return do_global_lower(c); }
template<> inline char BOOST_REGEX_CALL global_upper<char>(char c){ return do_global_upper(c); }
template<> inline char BOOST_REGEX_CALL global_lower<char>(char c) { return do_global_lower(c); }
template<> inline char BOOST_REGEX_CALL global_upper<char>(char c) { return do_global_upper(c); }
#ifndef BOOST_NO_WREGEX
template<> inline wchar_t BOOST_REGEX_CALL global_lower<wchar_t>(wchar_t c){ return do_global_lower(c); }
template<> inline wchar_t BOOST_REGEX_CALL global_upper<wchar_t>(wchar_t c){ return do_global_upper(c); }
#endif
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
template<> inline unsigned short BOOST_REGEX_CALL global_lower<unsigned short>(unsigned short c){ return do_global_lower(c); }
template<> inline unsigned short BOOST_REGEX_CALL global_upper<unsigned short>(unsigned short c){ return do_global_upper(c); }
template<> inline wchar_t BOOST_REGEX_CALL global_lower<wchar_t>(wchar_t c) { return do_global_lower(c); }
template<> inline wchar_t BOOST_REGEX_CALL global_upper<wchar_t>(wchar_t c) { return do_global_upper(c); }
#endif
template <class charT>

View File

@ -161,7 +161,7 @@ A marked parenthesis.
struct re_brace : public re_syntax_base
{
// The index to match, can be zero (don't mark the sub-expression)
// or negative (for perl style (?...) extentions):
// or negative (for perl style (?...) extensions):
int index;
bool icase;
};

View File

@ -0,0 +1,790 @@
/*
*
* Copyright (c) 2004
* 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 unicode_iterator.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Iterator adapters for converting between different Unicode encodings.
*/
/****************************************************************************
Contents:
~~~~~~~~~
1) Read Only, Input Adapters:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class BaseIterator, class U8Type = ::boost::uint8_t>
class u32_to_u8_iterator;
Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-8.
template <class BaseIterator, class U32Type = ::boost::uint32_t>
class u8_to_u32_iterator;
Adapts sequence of UTF-8 code points to "look like" a sequence of UTF-32.
template <class BaseIterator, class U16Type = ::boost::uint16_t>
class u32_to_u16_iterator;
Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-16.
template <class BaseIterator, class U32Type = ::boost::uint32_t>
class u16_to_u32_iterator;
Adapts sequence of UTF-16 code points to "look like" a sequence of UTF-32.
2) Single pass output iterator adapters:
template <class BaseIterator>
class utf8_output_iterator;
Accepts UTF-32 code points and forwards them on as UTF-8 code points.
template <class BaseIterator>
class utf16_output_iterator;
Accepts UTF-32 code points and forwards them on as UTF-16 code points.
****************************************************************************/
#ifndef BOOST_REGEX_V4_UNICODE_ITERATOR_HPP
#define BOOST_REGEX_V4_UNICODE_ITERATOR_HPP
#include <boost/cstdint.hpp>
#include <boost/regex/config.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp>
#include <stdexcept>
#ifndef BOOST_NO_STD_LOCALE
#include <sstream>
#include <ios>
#endif
#include <limits.h> // CHAR_BIT
#ifdef BOOST_REGEX_CXX03
#else
#endif
namespace boost{
namespace detail{
static const ::boost::uint16_t high_surrogate_base = 0xD7C0u;
static const ::boost::uint16_t low_surrogate_base = 0xDC00u;
static const ::boost::uint32_t ten_bit_mask = 0x3FFu;
inline bool is_high_surrogate(::boost::uint16_t v)
{
return (v & 0xFFFFFC00u) == 0xd800u;
}
inline bool is_low_surrogate(::boost::uint16_t v)
{
return (v & 0xFFFFFC00u) == 0xdc00u;
}
template <class T>
inline bool is_surrogate(T v)
{
return (v & 0xFFFFF800u) == 0xd800;
}
inline unsigned utf8_byte_count(boost::uint8_t c)
{
// if the most significant bit with a zero in it is in position
// 8-N then there are N bytes in this UTF-8 sequence:
boost::uint8_t mask = 0x80u;
unsigned result = 0;
while(c & mask)
{
++result;
mask >>= 1;
}
return (result == 0) ? 1 : ((result > 4) ? 4 : result);
}
inline unsigned utf8_trailing_byte_count(boost::uint8_t c)
{
return utf8_byte_count(c) - 1;
}
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4100)
#endif
#ifndef BOOST_NO_EXCEPTIONS
BOOST_NORETURN
#endif
inline void invalid_utf32_code_point(::boost::uint32_t val)
{
#ifndef BOOST_NO_STD_LOCALE
std::stringstream ss;
ss << "Invalid UTF-32 code point U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-16 sequence";
std::out_of_range e(ss.str());
#else
std::out_of_range e("Invalid UTF-32 code point encountered while trying to encode UTF-16 sequence");
#endif
boost::throw_exception(e);
}
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
} // namespace detail
template <class BaseIterator, class U16Type = ::boost::uint16_t>
class u32_to_u16_iterator
: public boost::iterator_facade<u32_to_u16_iterator<BaseIterator, U16Type>, U16Type, std::bidirectional_iterator_tag, const U16Type>
{
typedef boost::iterator_facade<u32_to_u16_iterator<BaseIterator, U16Type>, U16Type, std::bidirectional_iterator_tag, const U16Type> base_type;
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type;
BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 32);
BOOST_STATIC_ASSERT(sizeof(U16Type)*CHAR_BIT == 16);
#endif
public:
typename base_type::reference
dereference()const
{
if(m_current == 2)
extract_current();
return m_values[m_current];
}
bool equal(const u32_to_u16_iterator& that)const
{
if(m_position == that.m_position)
{
// Both m_currents must be equal, or both even
// this is the same as saying their sum must be even:
return (m_current + that.m_current) & 1u ? false : true;
}
return false;
}
void increment()
{
// if we have a pending read then read now, so that we know whether
// to skip a position, or move to a low-surrogate:
if(m_current == 2)
{
// pending read:
extract_current();
}
// move to the next surrogate position:
++m_current;
// if we've reached the end skip a position:
if(m_values[m_current] == 0)
{
m_current = 2;
++m_position;
}
}
void decrement()
{
if(m_current != 1)
{
// decrementing an iterator always leads to a valid position:
--m_position;
extract_current();
m_current = m_values[1] ? 1 : 0;
}
else
{
m_current = 0;
}
}
BaseIterator base()const
{
return m_position;
}
// construct:
u32_to_u16_iterator() : m_position(), m_current(0)
{
m_values[0] = 0;
m_values[1] = 0;
m_values[2] = 0;
}
u32_to_u16_iterator(BaseIterator b) : m_position(b), m_current(2)
{
m_values[0] = 0;
m_values[1] = 0;
m_values[2] = 0;
}
private:
void extract_current()const
{
// begin by checking for a code point out of range:
::boost::uint32_t v = *m_position;
if(v >= 0x10000u)
{
if(v > 0x10FFFFu)
detail::invalid_utf32_code_point(*m_position);
// split into two surrogates:
m_values[0] = static_cast<U16Type>(v >> 10) + detail::high_surrogate_base;
m_values[1] = static_cast<U16Type>(v & detail::ten_bit_mask) + detail::low_surrogate_base;
m_current = 0;
BOOST_REGEX_ASSERT(detail::is_high_surrogate(m_values[0]));
BOOST_REGEX_ASSERT(detail::is_low_surrogate(m_values[1]));
}
else
{
// 16-bit code point:
m_values[0] = static_cast<U16Type>(*m_position);
m_values[1] = 0;
m_current = 0;
// value must not be a surrogate:
if(detail::is_surrogate(m_values[0]))
detail::invalid_utf32_code_point(*m_position);
}
}
BaseIterator m_position;
mutable U16Type m_values[3];
mutable unsigned m_current;
};
template <class BaseIterator, class U32Type = ::boost::uint32_t>
class u16_to_u32_iterator
: public boost::iterator_facade<u16_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type>
{
typedef boost::iterator_facade<u16_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type> base_type;
// special values for pending iterator reads:
BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu);
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type;
BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 16);
BOOST_STATIC_ASSERT(sizeof(U32Type)*CHAR_BIT == 32);
#endif
public:
typename base_type::reference
dereference()const
{
if(m_value == pending_read)
extract_current();
return m_value;
}
bool equal(const u16_to_u32_iterator& that)const
{
return m_position == that.m_position;
}
void increment()
{
// skip high surrogate first if there is one:
if(detail::is_high_surrogate(*m_position)) ++m_position;
++m_position;
m_value = pending_read;
}
void decrement()
{
--m_position;
// if we have a low surrogate then go back one more:
if(detail::is_low_surrogate(*m_position))
--m_position;
m_value = pending_read;
}
BaseIterator base()const
{
return m_position;
}
// construct:
u16_to_u32_iterator() : m_position()
{
m_value = pending_read;
}
u16_to_u32_iterator(BaseIterator b) : m_position(b)
{
m_value = pending_read;
}
//
// Range checked version:
//
u16_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b)
{
m_value = pending_read;
//
// The range must not start with a low surrogate, or end in a high surrogate,
// otherwise we run the risk of running outside the underlying input range.
// Likewise b must not be located at a low surrogate.
//
boost::uint16_t val;
if(start != end)
{
if((b != start) && (b != end))
{
val = *b;
if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u))
invalid_code_point(val);
}
val = *start;
if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u))
invalid_code_point(val);
val = *--end;
if(detail::is_high_surrogate(val))
invalid_code_point(val);
}
}
private:
static void invalid_code_point(::boost::uint16_t val)
{
#ifndef BOOST_NO_STD_LOCALE
std::stringstream ss;
ss << "Misplaced UTF-16 surrogate U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-32 sequence";
std::out_of_range e(ss.str());
#else
std::out_of_range e("Misplaced UTF-16 surrogate encountered while trying to encode UTF-32 sequence");
#endif
boost::throw_exception(e);
}
void extract_current()const
{
m_value = static_cast<U32Type>(static_cast< ::boost::uint16_t>(*m_position));
// if the last value is a high surrogate then adjust m_position and m_value as needed:
if(detail::is_high_surrogate(*m_position))
{
// precondition; next value must have be a low-surrogate:
BaseIterator next(m_position);
::boost::uint16_t t = *++next;
if((t & 0xFC00u) != 0xDC00u)
invalid_code_point(t);
m_value = (m_value - detail::high_surrogate_base) << 10;
m_value |= (static_cast<U32Type>(static_cast< ::boost::uint16_t>(t)) & detail::ten_bit_mask);
}
// postcondition; result must not be a surrogate:
if(detail::is_surrogate(m_value))
invalid_code_point(static_cast< ::boost::uint16_t>(m_value));
}
BaseIterator m_position;
mutable U32Type m_value;
};
template <class BaseIterator, class U8Type = ::boost::uint8_t>
class u32_to_u8_iterator
: public boost::iterator_facade<u32_to_u8_iterator<BaseIterator, U8Type>, U8Type, std::bidirectional_iterator_tag, const U8Type>
{
typedef boost::iterator_facade<u32_to_u8_iterator<BaseIterator, U8Type>, U8Type, std::bidirectional_iterator_tag, const U8Type> base_type;
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type;
BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 32);
BOOST_STATIC_ASSERT(sizeof(U8Type)*CHAR_BIT == 8);
#endif
public:
typename base_type::reference
dereference()const
{
if(m_current == 4)
extract_current();
return m_values[m_current];
}
bool equal(const u32_to_u8_iterator& that)const
{
if(m_position == that.m_position)
{
// either the m_current's must be equal, or one must be 0 and
// the other 4: which means neither must have bits 1 or 2 set:
return (m_current == that.m_current)
|| (((m_current | that.m_current) & 3) == 0);
}
return false;
}
void increment()
{
// if we have a pending read then read now, so that we know whether
// to skip a position, or move to a low-surrogate:
if(m_current == 4)
{
// pending read:
extract_current();
}
// move to the next surrogate position:
++m_current;
// if we've reached the end skip a position:
if(m_values[m_current] == 0)
{
m_current = 4;
++m_position;
}
}
void decrement()
{
if((m_current & 3) == 0)
{
--m_position;
extract_current();
m_current = 3;
while(m_current && (m_values[m_current] == 0))
--m_current;
}
else
--m_current;
}
BaseIterator base()const
{
return m_position;
}
// construct:
u32_to_u8_iterator() : m_position(), m_current(0)
{
m_values[0] = 0;
m_values[1] = 0;
m_values[2] = 0;
m_values[3] = 0;
m_values[4] = 0;
}
u32_to_u8_iterator(BaseIterator b) : m_position(b), m_current(4)
{
m_values[0] = 0;
m_values[1] = 0;
m_values[2] = 0;
m_values[3] = 0;
m_values[4] = 0;
}
private:
void extract_current()const
{
boost::uint32_t c = *m_position;
if(c > 0x10FFFFu)
detail::invalid_utf32_code_point(c);
if(c < 0x80u)
{
m_values[0] = static_cast<unsigned char>(c);
m_values[1] = static_cast<unsigned char>(0u);
m_values[2] = static_cast<unsigned char>(0u);
m_values[3] = static_cast<unsigned char>(0u);
}
else if(c < 0x800u)
{
m_values[0] = static_cast<unsigned char>(0xC0u + (c >> 6));
m_values[1] = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
m_values[2] = static_cast<unsigned char>(0u);
m_values[3] = static_cast<unsigned char>(0u);
}
else if(c < 0x10000u)
{
m_values[0] = static_cast<unsigned char>(0xE0u + (c >> 12));
m_values[1] = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu));
m_values[2] = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
m_values[3] = static_cast<unsigned char>(0u);
}
else
{
m_values[0] = static_cast<unsigned char>(0xF0u + (c >> 18));
m_values[1] = static_cast<unsigned char>(0x80u + ((c >> 12) & 0x3Fu));
m_values[2] = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu));
m_values[3] = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
}
m_current= 0;
}
BaseIterator m_position;
mutable U8Type m_values[5];
mutable unsigned m_current;
};
template <class BaseIterator, class U32Type = ::boost::uint32_t>
class u8_to_u32_iterator
: public boost::iterator_facade<u8_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type>
{
typedef boost::iterator_facade<u8_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type> base_type;
// special values for pending iterator reads:
BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu);
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type;
BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 8);
BOOST_STATIC_ASSERT(sizeof(U32Type)*CHAR_BIT == 32);
#endif
public:
typename base_type::reference
dereference()const
{
if(m_value == pending_read)
extract_current();
return m_value;
}
bool equal(const u8_to_u32_iterator& that)const
{
return m_position == that.m_position;
}
void increment()
{
// We must not start with a continuation character:
if((static_cast<boost::uint8_t>(*m_position) & 0xC0) == 0x80)
invalid_sequence();
// skip high surrogate first if there is one:
unsigned c = detail::utf8_byte_count(*m_position);
if(m_value == pending_read)
{
// Since we haven't read in a value, we need to validate the code points:
for(unsigned i = 0; i < c; ++i)
{
++m_position;
// We must have a continuation byte:
if((i != c - 1) && ((static_cast<boost::uint8_t>(*m_position) & 0xC0) != 0x80))
invalid_sequence();
}
}
else
{
std::advance(m_position, c);
}
m_value = pending_read;
}
void decrement()
{
// Keep backtracking until we don't have a trailing character:
unsigned count = 0;
while((*--m_position & 0xC0u) == 0x80u) ++count;
// now check that the sequence was valid:
if(count != detail::utf8_trailing_byte_count(*m_position))
invalid_sequence();
m_value = pending_read;
}
BaseIterator base()const
{
return m_position;
}
// construct:
u8_to_u32_iterator() : m_position()
{
m_value = pending_read;
}
u8_to_u32_iterator(BaseIterator b) : m_position(b)
{
m_value = pending_read;
}
//
// Checked constructor:
//
u8_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b)
{
m_value = pending_read;
//
// We must not start with a continuation character, or end with a
// truncated UTF-8 sequence otherwise we run the risk of going past
// the start/end of the underlying sequence:
//
if(start != end)
{
unsigned char v = *start;
if((v & 0xC0u) == 0x80u)
invalid_sequence();
if((b != start) && (b != end) && ((*b & 0xC0u) == 0x80u))
invalid_sequence();
BaseIterator pos = end;
do
{
v = *--pos;
}
while((start != pos) && ((v & 0xC0u) == 0x80u));
std::ptrdiff_t extra = detail::utf8_byte_count(v);
if(std::distance(pos, end) < extra)
invalid_sequence();
}
}
private:
static void invalid_sequence()
{
std::out_of_range e("Invalid UTF-8 sequence encountered while trying to encode UTF-32 character");
boost::throw_exception(e);
}
void extract_current()const
{
m_value = static_cast<U32Type>(static_cast< ::boost::uint8_t>(*m_position));
// we must not have a continuation character:
if((m_value & 0xC0u) == 0x80u)
invalid_sequence();
// see how many extra bytes we have:
unsigned extra = detail::utf8_trailing_byte_count(*m_position);
// extract the extra bits, 6 from each extra byte:
BaseIterator next(m_position);
for(unsigned c = 0; c < extra; ++c)
{
++next;
m_value <<= 6;
// We must have a continuation byte:
if((static_cast<boost::uint8_t>(*next) & 0xC0) != 0x80)
invalid_sequence();
m_value += static_cast<boost::uint8_t>(*next) & 0x3Fu;
}
// we now need to remove a few of the leftmost bits, but how many depends
// upon how many extra bytes we've extracted:
static const boost::uint32_t masks[4] =
{
0x7Fu,
0x7FFu,
0xFFFFu,
0x1FFFFFu,
};
m_value &= masks[extra];
// check the result is in range:
if(m_value > static_cast<U32Type>(0x10FFFFu))
invalid_sequence();
// The result must not be a surrogate:
if((m_value >= static_cast<U32Type>(0xD800)) && (m_value <= static_cast<U32Type>(0xDFFF)))
invalid_sequence();
// We should not have had an invalidly encoded UTF8 sequence:
if((extra > 0) && (m_value <= static_cast<U32Type>(masks[extra - 1])))
invalid_sequence();
}
BaseIterator m_position;
mutable U32Type m_value;
};
template <class BaseIterator>
class utf16_output_iterator
{
public:
typedef void difference_type;
typedef void value_type;
typedef boost::uint32_t* pointer;
typedef boost::uint32_t& reference;
typedef std::output_iterator_tag iterator_category;
utf16_output_iterator(const BaseIterator& b)
: m_position(b){}
utf16_output_iterator(const utf16_output_iterator& that)
: m_position(that.m_position){}
utf16_output_iterator& operator=(const utf16_output_iterator& that)
{
m_position = that.m_position;
return *this;
}
const utf16_output_iterator& operator*()const
{
return *this;
}
void operator=(boost::uint32_t val)const
{
push(val);
}
utf16_output_iterator& operator++()
{
return *this;
}
utf16_output_iterator& operator++(int)
{
return *this;
}
BaseIterator base()const
{
return m_position;
}
private:
void push(boost::uint32_t v)const
{
if(v >= 0x10000u)
{
// begin by checking for a code point out of range:
if(v > 0x10FFFFu)
detail::invalid_utf32_code_point(v);
// split into two surrogates:
*m_position++ = static_cast<boost::uint16_t>(v >> 10) + detail::high_surrogate_base;
*m_position++ = static_cast<boost::uint16_t>(v & detail::ten_bit_mask) + detail::low_surrogate_base;
}
else
{
// 16-bit code point:
// value must not be a surrogate:
if(detail::is_surrogate(v))
detail::invalid_utf32_code_point(v);
*m_position++ = static_cast<boost::uint16_t>(v);
}
}
mutable BaseIterator m_position;
};
template <class BaseIterator>
class utf8_output_iterator
{
public:
typedef void difference_type;
typedef void value_type;
typedef boost::uint32_t* pointer;
typedef boost::uint32_t& reference;
typedef std::output_iterator_tag iterator_category;
utf8_output_iterator(const BaseIterator& b)
: m_position(b){}
utf8_output_iterator(const utf8_output_iterator& that)
: m_position(that.m_position){}
utf8_output_iterator& operator=(const utf8_output_iterator& that)
{
m_position = that.m_position;
return *this;
}
const utf8_output_iterator& operator*()const
{
return *this;
}
void operator=(boost::uint32_t val)const
{
push(val);
}
utf8_output_iterator& operator++()
{
return *this;
}
utf8_output_iterator& operator++(int)
{
return *this;
}
BaseIterator base()const
{
return m_position;
}
private:
void push(boost::uint32_t c)const
{
if(c > 0x10FFFFu)
detail::invalid_utf32_code_point(c);
if(c < 0x80u)
{
*m_position++ = static_cast<unsigned char>(c);
}
else if(c < 0x800u)
{
*m_position++ = static_cast<unsigned char>(0xC0u + (c >> 6));
*m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
}
else if(c < 0x10000u)
{
*m_position++ = static_cast<unsigned char>(0xE0u + (c >> 12));
*m_position++ = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu));
*m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
}
else
{
*m_position++ = static_cast<unsigned char>(0xF0u + (c >> 18));
*m_position++ = static_cast<unsigned char>(0x80u + ((c >> 12) & 0x3Fu));
*m_position++ = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu));
*m_position++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
}
}
mutable BaseIterator m_position;
};
} // namespace boost
#endif // BOOST_REGEX_UNICODE_ITERATOR_HPP

View File

@ -34,9 +34,18 @@
#include <boost/regex/v4/primary_transform.hpp>
#endif
#ifndef BOOST_REGEX_OBJECT_CACHE_HPP
#include <boost/regex/pending/object_cache.hpp>
#include <boost/regex/v4/object_cache.hpp>
#endif
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
#pragma comment(lib, "user32.lib")
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4103)
@ -75,53 +84,35 @@ typedef ::boost::shared_ptr<void> cat_type; // placeholder for dll HANDLE.
//
// then add wrappers around the actual Win32 API's (ie implementation hiding):
//
BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale();
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char, lcid_type);
lcid_type BOOST_REGEX_CALL w32_get_default_locale();
bool BOOST_REGEX_CALL w32_is_lower(char, lcid_type);
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(wchar_t, lcid_type);
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type state_id);
bool BOOST_REGEX_CALL w32_is_lower(wchar_t, lcid_type);
#endif
#endif
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char, lcid_type);
bool BOOST_REGEX_CALL w32_is_upper(char, lcid_type);
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(wchar_t, lcid_type);
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(unsigned short ca, lcid_type state_id);
bool BOOST_REGEX_CALL w32_is_upper(wchar_t, lcid_type);
#endif
#endif
BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name);
BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type state_id, int i, const std::string& def);
cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name);
std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type state_id, int i, const std::string& def);
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type state_id, int i, const std::wstring& def);
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::basic_string<unsigned short>& def);
std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type state_id, int i, const std::wstring& def);
#endif
#endif
BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type state_id, const char* p1, const char* p2);
std::string BOOST_REGEX_CALL w32_transform(lcid_type state_id, const char* p1, const char* p2);
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type state_id, const wchar_t* p1, const wchar_t* p2);
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_transform(lcid_type state_id, const unsigned short* p1, const unsigned short* p2);
std::wstring BOOST_REGEX_CALL w32_transform(lcid_type state_id, const wchar_t* p1, const wchar_t* p2);
#endif
#endif
BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type);
char BOOST_REGEX_CALL w32_tolower(char c, lcid_type);
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type);
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type state_id);
wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type);
#endif
#endif
BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type);
char BOOST_REGEX_CALL w32_toupper(char c, lcid_type);
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type);
wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type);
#endif
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type, boost::uint32_t mask, char c);
bool BOOST_REGEX_CALL w32_is(lcid_type, boost::uint32_t mask, char c);
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type, boost::uint32_t mask, wchar_t c);
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type state_id, boost::uint32_t m, unsigned short c);
#endif
bool BOOST_REGEX_CALL w32_is(lcid_type, boost::uint32_t mask, wchar_t c);
#endif
//
// class w32_regex_traits_base:
@ -253,14 +244,14 @@ typename w32_regex_traits_char_layer<charT>::string_type
// specialised version for narrow characters:
//
template <>
class BOOST_REGEX_DECL w32_regex_traits_char_layer<char> : public w32_regex_traits_base<char>
class w32_regex_traits_char_layer<char> : public w32_regex_traits_base<char>
{
typedef std::string string_type;
public:
w32_regex_traits_char_layer(::boost::BOOST_REGEX_DETAIL_NS::lcid_type l)
: w32_regex_traits_base<char>(l)
{
init();
init<char>();
}
regex_constants::syntax_type syntax_type(char c)const
@ -284,6 +275,7 @@ private:
regex_constants::syntax_type m_char_map[1u << CHAR_BIT];
char m_lower_map[1u << CHAR_BIT];
boost::uint16_t m_type_map[1u << CHAR_BIT];
template <class U>
void init();
};
@ -722,6 +714,498 @@ static_mutex& w32_regex_traits<charT>::get_mutex_inst()
}
#endif
namespace BOOST_REGEX_DETAIL_NS {
#ifdef BOOST_NO_ANSI_APIS
inline UINT get_code_page_for_locale_id(lcid_type idx)
{
WCHAR code_page_string[7];
if (::GetLocaleInfoW(idx, LOCALE_IDEFAULTANSICODEPAGE, code_page_string, 7) == 0)
return 0;
return static_cast<UINT>(_wtol(code_page_string));
}
#endif
template <class U>
inline void w32_regex_traits_char_layer<char>::init()
{
// we need to start by initialising our syntax map so we know which
// character is used for which purpose:
std::memset(m_char_map, 0, sizeof(m_char_map));
cat_type cat;
std::string cat_name(w32_regex_traits<char>::get_catalog_name());
if (cat_name.size())
{
cat = ::boost::BOOST_REGEX_DETAIL_NS::w32_cat_open(cat_name);
if (!cat)
{
std::string m("Unable to open message catalog: ");
std::runtime_error err(m + cat_name);
::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err);
}
}
//
// if we have a valid catalog then load our messages:
//
if (cat)
{
for (regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
{
string_type mss = ::boost::BOOST_REGEX_DETAIL_NS::w32_cat_get(cat, this->m_locale, i, get_default_syntax(i));
for (string_type::size_type j = 0; j < mss.size(); ++j)
{
m_char_map[static_cast<unsigned char>(mss[j])] = i;
}
}
}
else
{
for (regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
{
const char* ptr = get_default_syntax(i);
while (ptr && *ptr)
{
m_char_map[static_cast<unsigned char>(*ptr)] = i;
++ptr;
}
}
}
//
// finish off by calculating our escape types:
//
unsigned char i = 'A';
do
{
if (m_char_map[i] == 0)
{
if (::boost::BOOST_REGEX_DETAIL_NS::w32_is(this->m_locale, 0x0002u, (char)i))
m_char_map[i] = regex_constants::escape_type_class;
else if (::boost::BOOST_REGEX_DETAIL_NS::w32_is(this->m_locale, 0x0001u, (char)i))
m_char_map[i] = regex_constants::escape_type_not_class;
}
} while (0xFF != i++);
//
// fill in lower case map:
//
char char_map[1 << CHAR_BIT];
for (int ii = 0; ii < (1 << CHAR_BIT); ++ii)
char_map[ii] = static_cast<char>(ii);
#ifndef BOOST_NO_ANSI_APIS
int r = ::LCMapStringA(this->m_locale, LCMAP_LOWERCASE, char_map, 1 << CHAR_BIT, this->m_lower_map, 1 << CHAR_BIT);
BOOST_REGEX_ASSERT(r != 0);
#else
UINT code_page = get_code_page_for_locale_id(this->m_locale);
BOOST_REGEX_ASSERT(code_page != 0);
WCHAR wide_char_map[1 << CHAR_BIT];
int conv_r = ::MultiByteToWideChar(code_page, 0, char_map, 1 << CHAR_BIT, wide_char_map, 1 << CHAR_BIT);
BOOST_REGEX_ASSERT(conv_r != 0);
WCHAR wide_lower_map[1 << CHAR_BIT];
int r = ::LCMapStringW(this->m_locale, LCMAP_LOWERCASE, wide_char_map, 1 << CHAR_BIT, wide_lower_map, 1 << CHAR_BIT);
BOOST_REGEX_ASSERT(r != 0);
conv_r = ::WideCharToMultiByte(code_page, 0, wide_lower_map, r, this->m_lower_map, 1 << CHAR_BIT, NULL, NULL);
BOOST_REGEX_ASSERT(conv_r != 0);
#endif
if (r < (1 << CHAR_BIT))
{
// if we have multibyte characters then not all may have been given
// a lower case mapping:
for (int jj = r; jj < (1 << CHAR_BIT); ++jj)
this->m_lower_map[jj] = static_cast<char>(jj);
}
#ifndef BOOST_NO_ANSI_APIS
r = ::GetStringTypeExA(this->m_locale, CT_CTYPE1, char_map, 1 << CHAR_BIT, this->m_type_map);
#else
r = ::GetStringTypeExW(this->m_locale, CT_CTYPE1, wide_char_map, 1 << CHAR_BIT, this->m_type_map);
#endif
BOOST_REGEX_ASSERT(0 != r);
}
inline lcid_type BOOST_REGEX_CALL w32_get_default_locale()
{
return ::GetUserDefaultLCID();
}
inline bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type idx)
{
#ifndef BOOST_NO_ANSI_APIS
WORD mask;
if (::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
return true;
return false;
#else
UINT code_page = get_code_page_for_locale_id(idx);
if (code_page == 0)
return false;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return false;
WORD mask;
if (::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_LOWER))
return true;
return false;
#endif
}
inline bool BOOST_REGEX_CALL w32_is_lower(wchar_t c, lcid_type idx)
{
WORD mask;
if (::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
return true;
return false;
}
inline bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type idx)
{
#ifndef BOOST_NO_ANSI_APIS
WORD mask;
if (::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
return true;
return false;
#else
UINT code_page = get_code_page_for_locale_id(idx);
if (code_page == 0)
return false;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return false;
WORD mask;
if (::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_UPPER))
return true;
return false;
#endif
}
inline bool BOOST_REGEX_CALL w32_is_upper(wchar_t c, lcid_type idx)
{
WORD mask;
if (::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
return true;
return false;
}
inline void free_module(void* mod)
{
::FreeLibrary(static_cast<HMODULE>(mod));
}
inline cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name)
{
#ifndef BOOST_NO_ANSI_APIS
cat_type result(::LoadLibraryA(name.c_str()), &free_module);
return result;
#else
LPWSTR wide_name = (LPWSTR)_alloca((name.size() + 1) * sizeof(WCHAR));
if (::MultiByteToWideChar(CP_ACP, 0, name.c_str(), name.size(), wide_name, name.size() + 1) == 0)
return cat_type();
cat_type result(::LoadLibraryW(wide_name), &free_module);
return result;
#endif
}
inline std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::string& def)
{
#ifndef BOOST_NO_ANSI_APIS
char buf[256];
if (0 == ::LoadStringA(
static_cast<HMODULE>(cat.get()),
i,
buf,
256
))
{
return def;
}
#else
WCHAR wbuf[256];
int r = ::LoadStringW(
static_cast<HMODULE>(cat.get()),
i,
wbuf,
256
);
if (r == 0)
return def;
int buf_size = 1 + ::WideCharToMultiByte(CP_ACP, 0, wbuf, r, NULL, 0, NULL, NULL);
LPSTR buf = (LPSTR)_alloca(buf_size);
if (::WideCharToMultiByte(CP_ACP, 0, wbuf, r, buf, buf_size, NULL, NULL) == 0)
return def; // failed conversion.
#endif
return std::string(buf);
}
#ifndef BOOST_NO_WREGEX
inline std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::wstring& def)
{
wchar_t buf[256];
if (0 == ::LoadStringW(
static_cast<HMODULE>(cat.get()),
i,
buf,
256
))
{
return def;
}
return std::wstring(buf);
}
#endif
inline std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const char* p1, const char* p2)
{
#ifndef BOOST_NO_ANSI_APIS
int bytes = ::LCMapStringA(
idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string
0, // destination buffer
0 // size of destination buffer
);
if (!bytes)
return std::string(p1, p2);
std::string result(++bytes, '\0');
bytes = ::LCMapStringA(
idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string
&*result.begin(), // destination buffer
bytes // size of destination buffer
);
#else
UINT code_page = get_code_page_for_locale_id(idx);
if (code_page == 0)
return std::string(p1, p2);
int src_len = static_cast<int>(p2 - p1);
LPWSTR wide_p1 = (LPWSTR)_alloca((src_len + 1) * 2);
if (::MultiByteToWideChar(code_page, 0, p1, src_len, wide_p1, src_len + 1) == 0)
return std::string(p1, p2);
int bytes = ::LCMapStringW(
idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
wide_p1, // source string
src_len, // number of characters in source string
0, // destination buffer
0 // size of destination buffer
);
if (!bytes)
return std::string(p1, p2);
std::string result(++bytes, '\0');
bytes = ::LCMapStringW(
idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
wide_p1, // source string
src_len, // number of characters in source string
(LPWSTR) & *result.begin(), // destination buffer
bytes // size of destination buffer
);
#endif
if (bytes > static_cast<int>(result.size()))
return std::string(p1, p2);
while (result.size() && result[result.size() - 1] == '\0')
{
result.erase(result.size() - 1);
}
return result;
}
#ifndef BOOST_NO_WREGEX
inline std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, const wchar_t* p1, const wchar_t* p2)
{
int bytes = ::LCMapStringW(
idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string
0, // destination buffer
0 // size of destination buffer
);
if (!bytes)
return std::wstring(p1, p2);
std::string result(++bytes, '\0');
bytes = ::LCMapStringW(
idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type
p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string
reinterpret_cast<wchar_t*>(&*result.begin()), // destination buffer *of bytes*
bytes // size of destination buffer
);
if (bytes > static_cast<int>(result.size()))
return std::wstring(p1, p2);
while (result.size() && result[result.size() - 1] == L'\0')
{
result.erase(result.size() - 1);
}
std::wstring r2;
for (std::string::size_type i = 0; i < result.size(); ++i)
r2.append(1, static_cast<wchar_t>(static_cast<unsigned char>(result[i])));
return r2;
}
#endif
inline char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx)
{
char result[2];
#ifndef BOOST_NO_ANSI_APIS
int b = ::LCMapStringA(
idx, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type
&c, // source string
1, // number of characters in source string
result, // destination buffer
1); // size of destination buffer
if (b == 0)
return c;
#else
UINT code_page = get_code_page_for_locale_id(idx);
if (code_page == 0)
return c;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return c;
WCHAR wide_result;
int b = ::LCMapStringW(
idx, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type
&wide_c, // source string
1, // number of characters in source string
&wide_result, // destination buffer
1); // size of destination buffer
if (b == 0)
return c;
if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0)
return c; // No single byte lower case equivalent available
#endif
return result[0];
}
#ifndef BOOST_NO_WREGEX
inline wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type idx)
{
wchar_t result[2];
int b = ::LCMapStringW(
idx, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type
&c, // source string
1, // number of characters in source string
result, // destination buffer
1); // size of destination buffer
if (b == 0)
return c;
return result[0];
}
#endif
inline char BOOST_REGEX_CALL w32_toupper(char c, lcid_type idx)
{
char result[2];
#ifndef BOOST_NO_ANSI_APIS
int b = ::LCMapStringA(
idx, // locale identifier
LCMAP_UPPERCASE, // mapping transformation type
&c, // source string
1, // number of characters in source string
result, // destination buffer
1); // size of destination buffer
if (b == 0)
return c;
#else
UINT code_page = get_code_page_for_locale_id(idx);
if (code_page == 0)
return c;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return c;
WCHAR wide_result;
int b = ::LCMapStringW(
idx, // locale identifier
LCMAP_UPPERCASE, // mapping transformation type
&wide_c, // source string
1, // number of characters in source string
&wide_result, // destination buffer
1); // size of destination buffer
if (b == 0)
return c;
if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0)
return c; // No single byte upper case equivalent available.
#endif
return result[0];
}
#ifndef BOOST_NO_WREGEX
inline wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type idx)
{
wchar_t result[2];
int b = ::LCMapStringW(
idx, // locale identifier
LCMAP_UPPERCASE, // mapping transformation type
&c, // source string
1, // number of characters in source string
result, // destination buffer
1); // size of destination buffer
if (b == 0)
return c;
return result[0];
}
#endif
inline bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, char c)
{
WORD mask;
#ifndef BOOST_NO_ANSI_APIS
if (::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base))
return true;
#else
UINT code_page = get_code_page_for_locale_id(idx);
if (code_page == 0)
return false;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return false;
if (::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base))
return true;
#endif
if ((m & w32_regex_traits_implementation<char>::mask_word) && (c == '_'))
return true;
return false;
}
#ifndef BOOST_NO_WREGEX
inline bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, wchar_t c)
{
WORD mask;
if (::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<wchar_t>::mask_base))
return true;
if ((m & w32_regex_traits_implementation<wchar_t>::mask_word) && (c == '_'))
return true;
if ((m & w32_regex_traits_implementation<wchar_t>::mask_unicode) && (c > 0xff))
return true;
return false;
}
#endif
} // BOOST_REGEX_DETAIL_NS
} // boost

View File

@ -0,0 +1,734 @@
/*
*
* Copyright (c) 1998-2004 John Maddock
* Copyright 2011 Garmin Ltd. or its subsidiaries
*
* 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)
*
*/
/*
* LOCATION: see http://www.boost.org/ for most recent version.
* FILE basic_regex.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares template class basic_regex.
*/
#ifndef BOOST_REGEX_V5_BASIC_REGEX_HPP
#define BOOST_REGEX_V5_BASIC_REGEX_HPP
#include <vector>
namespace boost{
#ifdef BOOST_REGEX_MSVC
#pragma warning(push)
#pragma warning(disable : 4251)
#if BOOST_REGEX_MSVC < 1700
# pragma warning(disable : 4231)
#endif
#if BOOST_REGEX_MSVC < 1600
#pragma warning(disable : 4660)
#endif
#if BOOST_REGEX_MSVC < 1910
#pragma warning(disable:4800)
#endif
#endif
namespace BOOST_REGEX_DETAIL_NS{
//
// forward declaration, we will need this one later:
//
template <class charT, class traits>
class basic_regex_parser;
template <class I>
void bubble_down_one(I first, I last)
{
if(first != last)
{
I next = last - 1;
while((next != first) && (*next < *(next-1)))
{
(next-1)->swap(*next);
--next;
}
}
}
static 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)
{
std::size_t r = 0;
while (i != j)
{
r ^= *i + 0x9e3779b9 + (r << 6) + (r >> 2);
++i;
}
r %= ((std::numeric_limits<int>::max)());
return static_cast<int>(r) | hash_value_mask;
}
class named_subexpressions
{
public:
struct name
{
template <class charT>
name(const charT* i, const charT* j, int idx)
: index(idx)
{
hash = hash_value_from_capture_name(i, j);
}
name(int h, int idx)
: index(idx), hash(h)
{
}
int index;
int hash;
bool operator < (const name& other)const
{
return hash < other.hash;
}
bool operator == (const name& other)const
{
return hash == other.hash;
}
void swap(name& other)
{
std::swap(index, other.index);
std::swap(hash, other.hash);
}
};
typedef std::vector<name>::const_iterator const_iterator;
typedef std::pair<const_iterator, const_iterator> range_type;
named_subexpressions(){}
template <class charT>
void set_name(const charT* i, const charT* j, int index)
{
m_sub_names.push_back(name(i, j, index));
bubble_down_one(m_sub_names.begin(), m_sub_names.end());
}
template <class charT>
int get_id(const charT* i, const charT* j)const
{
name t(i, j, 0);
typename std::vector<name>::const_iterator pos = std::lower_bound(m_sub_names.begin(), m_sub_names.end(), t);
if((pos != m_sub_names.end()) && (*pos == t))
{
return pos->index;
}
return -1;
}
template <class charT>
range_type equal_range(const charT* i, const charT* j)const
{
name t(i, j, 0);
return std::equal_range(m_sub_names.begin(), m_sub_names.end(), t);
}
int get_id(int h)const
{
name t(h, 0);
std::vector<name>::const_iterator pos = std::lower_bound(m_sub_names.begin(), m_sub_names.end(), t);
if((pos != m_sub_names.end()) && (*pos == t))
{
return pos->index;
}
return -1;
}
range_type equal_range(int h)const
{
name t(h, 0);
return std::equal_range(m_sub_names.begin(), m_sub_names.end(), t);
}
private:
std::vector<name> m_sub_names;
};
//
// class regex_data:
// represents the data we wish to expose to the matching algorithms.
//
template <class charT, class traits>
struct regex_data : public named_subexpressions
{
typedef regex_constants::syntax_option_type flag_type;
typedef std::size_t size_type;
regex_data(const ::std::shared_ptr<
::boost::regex_traits_wrapper<traits> >& t)
: m_ptraits(t), m_flags(0), m_status(0), m_expression(0), m_expression_len(0),
m_mark_count(0), m_first_state(0), m_restart_type(0),
m_startmap{ 0 },
m_can_be_null(0), m_word_mask(0), m_has_recursions(false), m_disable_match_any(false) {}
regex_data()
: m_ptraits(new ::boost::regex_traits_wrapper<traits>()), m_flags(0), m_status(0), m_expression(0), m_expression_len(0),
m_mark_count(0), m_first_state(0), m_restart_type(0),
m_startmap{ 0 },
m_can_be_null(0), m_word_mask(0), m_has_recursions(false), m_disable_match_any(false) {}
::std::shared_ptr<
::boost::regex_traits_wrapper<traits>
> m_ptraits; // traits class instance
flag_type m_flags; // flags with which we were compiled
int m_status; // error code (0 implies OK).
const charT* m_expression; // the original expression
std::ptrdiff_t m_expression_len; // the length of the original expression
size_type m_mark_count; // the number of marked sub-expressions
BOOST_REGEX_DETAIL_NS::re_syntax_base* m_first_state; // the first state of the machine
unsigned m_restart_type; // search optimisation type
unsigned char m_startmap[1 << CHAR_BIT]; // which characters can start a match
unsigned int m_can_be_null; // whether we can match a null string
BOOST_REGEX_DETAIL_NS::raw_storage m_data; // the buffer in which our states are constructed
typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character
std::vector<
std::pair<
std::size_t, std::size_t> > m_subs; // Position of sub-expressions within the *string*.
bool m_has_recursions; // whether we have recursive expressions;
bool m_disable_match_any; // when set we need to disable the match_any flag as it causes different/buggy behaviour.
};
//
// class basic_regex_implementation
// pimpl implementation class for basic_regex.
//
template <class charT, class traits>
class basic_regex_implementation
: public regex_data<charT, traits>
{
public:
typedef regex_constants::syntax_option_type flag_type;
typedef std::ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef typename traits::locale_type locale_type;
typedef const charT* const_iterator;
basic_regex_implementation(){}
basic_regex_implementation(const ::std::shared_ptr<
::boost::regex_traits_wrapper<traits> >& t)
: regex_data<charT, traits>(t) {}
void assign(const charT* arg_first,
const charT* arg_last,
flag_type f)
{
regex_data<charT, traits>* pdat = this;
basic_regex_parser<charT, traits> parser(pdat);
parser.parse(arg_first, arg_last, f);
}
locale_type imbue(locale_type l)
{
return this->m_ptraits->imbue(l);
}
locale_type getloc()const
{
return this->m_ptraits->getloc();
}
std::basic_string<charT> str()const
{
std::basic_string<charT> result;
if(this->m_status == 0)
result = std::basic_string<charT>(this->m_expression, this->m_expression_len);
return result;
}
const_iterator expression()const
{
return this->m_expression;
}
std::pair<const_iterator, const_iterator> subexpression(std::size_t n)const
{
const std::pair<std::size_t, std::size_t>& pi = this->m_subs.at(n);
std::pair<const_iterator, const_iterator> p(expression() + pi.first, expression() + pi.second);
return p;
}
//
// begin, end:
const_iterator begin()const
{
return (this->m_status ? 0 : this->m_expression);
}
const_iterator end()const
{
return (this->m_status ? 0 : this->m_expression + this->m_expression_len);
}
flag_type flags()const
{
return this->m_flags;
}
size_type size()const
{
return this->m_expression_len;
}
int status()const
{
return this->m_status;
}
size_type mark_count()const
{
return this->m_mark_count - 1;
}
const BOOST_REGEX_DETAIL_NS::re_syntax_base* get_first_state()const
{
return this->m_first_state;
}
unsigned get_restart_type()const
{
return this->m_restart_type;
}
const unsigned char* get_map()const
{
return this->m_startmap;
}
const ::boost::regex_traits_wrapper<traits>& get_traits()const
{
return *(this->m_ptraits);
}
bool can_be_null()const
{
return this->m_can_be_null;
}
const regex_data<charT, traits>& get_data()const
{
basic_regex_implementation<charT, traits> const* p = this;
return *static_cast<const regex_data<charT, traits>*>(p);
}
};
} // namespace BOOST_REGEX_DETAIL_NS
//
// class basic_regex:
// represents the compiled
// regular expression:
//
#ifdef BOOST_REGEX_NO_FWD
template <class charT, class traits = regex_traits<charT> >
#else
template <class charT, class traits >
#endif
class basic_regex : public regbase
{
public:
// typedefs:
typedef std::size_t traits_size_type;
typedef typename traits::string_type traits_string_type;
typedef charT char_type;
typedef traits traits_type;
typedef charT value_type;
typedef charT& reference;
typedef const charT& const_reference;
typedef const charT* const_iterator;
typedef const_iterator iterator;
typedef std::ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef regex_constants::syntax_option_type flag_type;
// locale_type
// placeholder for actual locale type used by the
// traits class to localise *this.
typedef typename traits::locale_type locale_type;
public:
explicit basic_regex(){}
explicit basic_regex(const charT* p, flag_type f = regex_constants::normal)
{
assign(p, f);
}
basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal)
{
assign(p1, p2, f);
}
basic_regex(const charT* p, size_type len, flag_type f)
{
assign(p, len, f);
}
basic_regex(const basic_regex& that)
: m_pimpl(that.m_pimpl) {}
~basic_regex(){}
basic_regex& operator=(const basic_regex& that)
{
return assign(that);
}
basic_regex& operator=(const charT* ptr)
{
return assign(ptr);
}
//
// assign:
basic_regex& assign(const basic_regex& that)
{
m_pimpl = that.m_pimpl;
return *this;
}
basic_regex& assign(const charT* p, flag_type f = regex_constants::normal)
{
return assign(p, p + traits::length(p), f);
}
basic_regex& assign(const charT* p, size_type len, flag_type f)
{
return assign(p, p + len, f);
}
private:
basic_regex& do_assign(const charT* p1,
const charT* p2,
flag_type f);
public:
basic_regex& assign(const charT* p1,
const charT* p2,
flag_type f = regex_constants::normal)
{
return do_assign(p1, p2, f);
}
template <class ST, class SA>
unsigned int set_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal)
{
return set_expression(p.data(), p.data() + p.size(), f);
}
template <class ST, class SA>
explicit basic_regex(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal)
{
assign(p, f);
}
template <class InputIterator>
basic_regex(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal)
{
typedef typename traits::string_type seq_type;
seq_type a(arg_first, arg_last);
if(!a.empty())
assign(static_cast<const charT*>(&*a.begin()), static_cast<const charT*>(&*a.begin() + a.size()), f);
else
assign(static_cast<const charT*>(0), static_cast<const charT*>(0), f);
}
template <class ST, class SA>
basic_regex& operator=(const std::basic_string<charT, ST, SA>& p)
{
return assign(p.data(), p.data() + p.size(), regex_constants::normal);
}
template <class string_traits, class A>
basic_regex& assign(
const std::basic_string<charT, string_traits, A>& s,
flag_type f = regex_constants::normal)
{
return assign(s.data(), s.data() + s.size(), f);
}
template <class InputIterator>
basic_regex& assign(InputIterator arg_first,
InputIterator arg_last,
flag_type f = regex_constants::normal)
{
typedef typename traits::string_type seq_type;
seq_type a(arg_first, arg_last);
if(a.size())
{
const charT* p1 = &*a.begin();
const charT* p2 = &*a.begin() + a.size();
return assign(p1, p2, f);
}
return assign(static_cast<const charT*>(0), static_cast<const charT*>(0), f);
}
//
// locale:
locale_type imbue(locale_type l);
locale_type getloc()const
{
return m_pimpl.get() ? m_pimpl->getloc() : locale_type();
}
//
// getflags:
// retained for backwards compatibility only, "flags"
// is now the preferred name:
flag_type getflags()const
{
return flags();
}
flag_type flags()const
{
return m_pimpl.get() ? m_pimpl->flags() : 0;
}
//
// str:
std::basic_string<charT> str()const
{
return m_pimpl.get() ? m_pimpl->str() : std::basic_string<charT>();
}
//
// begin, end, subexpression:
std::pair<const_iterator, const_iterator> subexpression(std::size_t n)const
{
#ifdef BOOST_REGEX_STANDALONE
if (!m_pimpl.get())
throw std::logic_error("Can't access subexpressions in an invalid regex.");
#else
if(!m_pimpl.get())
boost::throw_exception(std::logic_error("Can't access subexpressions in an invalid regex."));
#endif
return m_pimpl->subexpression(n);
}
const_iterator begin()const
{
return (m_pimpl.get() ? m_pimpl->begin() : 0);
}
const_iterator end()const
{
return (m_pimpl.get() ? m_pimpl->end() : 0);
}
//
// swap:
void swap(basic_regex& that)throw()
{
m_pimpl.swap(that.m_pimpl);
}
//
// size:
size_type size()const
{
return (m_pimpl.get() ? m_pimpl->size() : 0);
}
//
// max_size:
size_type max_size()const
{
return UINT_MAX;
}
//
// empty:
bool empty()const
{
return (m_pimpl.get() ? 0 != m_pimpl->status() : true);
}
size_type mark_count()const
{
return (m_pimpl.get() ? m_pimpl->mark_count() : 0);
}
int status()const
{
return (m_pimpl.get() ? m_pimpl->status() : regex_constants::error_empty);
}
int compare(const basic_regex& that) const
{
if(m_pimpl.get() == that.m_pimpl.get())
return 0;
if(!m_pimpl.get())
return -1;
if(!that.m_pimpl.get())
return 1;
if(status() != that.status())
return status() - that.status();
if(flags() != that.flags())
return flags() - that.flags();
return str().compare(that.str());
}
bool operator==(const basic_regex& e)const
{
return compare(e) == 0;
}
bool operator != (const basic_regex& e)const
{
return compare(e) != 0;
}
bool operator<(const basic_regex& e)const
{
return compare(e) < 0;
}
bool operator>(const basic_regex& e)const
{
return compare(e) > 0;
}
bool operator<=(const basic_regex& e)const
{
return compare(e) <= 0;
}
bool operator>=(const basic_regex& e)const
{
return compare(e) >= 0;
}
//
// The following are deprecated as public interfaces
// but are available for compatibility with earlier versions.
const charT* expression()const
{
return (m_pimpl.get() && !m_pimpl->status() ? m_pimpl->expression() : 0);
}
unsigned int set_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal)
{
assign(p1, p2, f | regex_constants::no_except);
return status();
}
unsigned int set_expression(const charT* p, flag_type f = regex_constants::normal)
{
assign(p, f | regex_constants::no_except);
return status();
}
unsigned int error_code()const
{
return status();
}
//
// private access methods:
//
const BOOST_REGEX_DETAIL_NS::re_syntax_base* get_first_state()const
{
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->get_first_state();
}
unsigned get_restart_type()const
{
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->get_restart_type();
}
const unsigned char* get_map()const
{
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->get_map();
}
const ::boost::regex_traits_wrapper<traits>& get_traits()const
{
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->get_traits();
}
bool can_be_null()const
{
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->can_be_null();
}
const BOOST_REGEX_DETAIL_NS::regex_data<charT, traits>& get_data()const
{
BOOST_REGEX_ASSERT(0 != m_pimpl.get());
return m_pimpl->get_data();
}
std::shared_ptr<BOOST_REGEX_DETAIL_NS::named_subexpressions > get_named_subs()const
{
return m_pimpl;
}
private:
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> > m_pimpl;
};
//
// out of line members;
// these are the only members that mutate the basic_regex object,
// and are designed to provide the strong exception guarantee
// (in the event of a throw, the state of the object remains unchanged).
//
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);
return *this;
}
template <class charT, class traits>
typename basic_regex<charT, traits>::locale_type basic_regex<charT, traits>::imbue(locale_type l)
{
std::shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> > temp(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits>());
locale_type result = temp->imbue(l);
temp.swap(m_pimpl);
return result;
}
//
// non-members:
//
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>
std::basic_ostream<charT, traits>&
operator << (std::basic_ostream<charT, traits>& os,
const basic_regex<charT, traits2>& e)
{
return (os << e.str());
}
//
// class reg_expression:
// this is provided for backwards compatibility only,
// it is deprecated, no not use!
//
#ifdef BOOST_REGEX_NO_FWD
template <class charT, class traits = regex_traits<charT> >
#else
template <class charT, class traits >
#endif
class reg_expression : public basic_regex<charT, traits>
{
public:
typedef typename basic_regex<charT, traits>::flag_type flag_type;
typedef typename basic_regex<charT, traits>::size_type size_type;
explicit reg_expression(){}
explicit reg_expression(const charT* p, flag_type f = regex_constants::normal)
: basic_regex<charT, traits>(p, f){}
reg_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal)
: basic_regex<charT, traits>(p1, p2, f){}
reg_expression(const charT* p, size_type len, flag_type f)
: basic_regex<charT, traits>(p, len, f){}
reg_expression(const reg_expression& that)
: basic_regex<charT, traits>(that) {}
~reg_expression(){}
reg_expression& operator=(const reg_expression& that)
{
return this->assign(that);
}
template <class ST, class SA>
explicit reg_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal)
: basic_regex<charT, traits>(p, f)
{
}
template <class InputIterator>
reg_expression(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal)
: basic_regex<charT, traits>(arg_first, arg_last, f)
{
}
template <class ST, class SA>
reg_expression& operator=(const std::basic_string<charT, ST, SA>& p)
{
this->assign(p);
return *this;
}
};
#ifdef BOOST_REGEX_MSVC
#pragma warning (pop)
#endif
} // namespace boost
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,474 @@
/*
*
* Copyright (c) 2004
* 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 c_regex_traits.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares regular expression traits class that wraps the global C locale.
*/
#ifndef BOOST_C_REGEX_TRAITS_HPP_INCLUDED
#define BOOST_C_REGEX_TRAITS_HPP_INCLUDED
#include <boost/regex/config.hpp>
#include <boost/regex/v5/regex_workaround.hpp>
#include <cctype>
namespace boost{
namespace BOOST_REGEX_DETAIL_NS {
enum
{
char_class_space = 1 << 0,
char_class_print = 1 << 1,
char_class_cntrl = 1 << 2,
char_class_upper = 1 << 3,
char_class_lower = 1 << 4,
char_class_alpha = 1 << 5,
char_class_digit = 1 << 6,
char_class_punct = 1 << 7,
char_class_xdigit = 1 << 8,
char_class_alnum = char_class_alpha | char_class_digit,
char_class_graph = char_class_alnum | char_class_punct,
char_class_blank = 1 << 9,
char_class_word = 1 << 10,
char_class_unicode = 1 << 11,
char_class_horizontal = 1 << 12,
char_class_vertical = 1 << 13
};
}
template <class charT>
struct c_regex_traits;
template<>
struct c_regex_traits<char>
{
c_regex_traits(){}
typedef char char_type;
typedef std::size_t size_type;
typedef std::string string_type;
struct locale_type{};
typedef std::uint32_t char_class_type;
static size_type length(const char_type* p)
{
return (std::strlen)(p);
}
char translate(char c) const
{
return c;
}
char translate_nocase(char c) const
{
return static_cast<char>((std::tolower)(static_cast<unsigned char>(c)));
}
static string_type transform(const char* p1, const char* p2);
static string_type transform_primary(const char* p1, const char* p2);
static char_class_type lookup_classname(const char* p1, const char* p2);
static string_type lookup_collatename(const char* p1, const char* p2);
static bool isctype(char, char_class_type);
static int value(char, int);
locale_type imbue(locale_type l)
{ return l; }
locale_type getloc()const
{ return locale_type(); }
private:
// this type is not copyable:
c_regex_traits(const c_regex_traits&);
c_regex_traits& operator=(const c_regex_traits&);
};
#ifndef BOOST_NO_WREGEX
template<>
struct c_regex_traits<wchar_t>
{
c_regex_traits(){}
typedef wchar_t char_type;
typedef std::size_t size_type;
typedef std::wstring string_type;
struct locale_type{};
typedef std::uint32_t char_class_type;
static size_type length(const char_type* p)
{
return (std::wcslen)(p);
}
wchar_t translate(wchar_t c) const
{
return c;
}
wchar_t translate_nocase(wchar_t c) const
{
return (std::towlower)(c);
}
static string_type transform(const wchar_t* p1, const wchar_t* p2);
static string_type transform_primary(const wchar_t* p1, const wchar_t* p2);
static char_class_type lookup_classname(const wchar_t* p1, const wchar_t* p2);
static string_type lookup_collatename(const wchar_t* p1, const wchar_t* p2);
static bool isctype(wchar_t, char_class_type);
static int value(wchar_t, int);
locale_type imbue(locale_type l)
{ return l; }
locale_type getloc()const
{ return locale_type(); }
private:
// this type is not copyable:
c_regex_traits(const c_regex_traits&);
c_regex_traits& operator=(const c_regex_traits&);
};
#endif // BOOST_NO_WREGEX
inline c_regex_traits<char>::string_type c_regex_traits<char>::transform(const char* p1, const char* p2)
{
std::string result(10, ' ');
std::size_t s = result.size();
std::size_t r;
std::string src(p1, p2);
while (s < (r = std::strxfrm(&*result.begin(), src.c_str(), s)))
{
#if defined(_CPPLIB_VER)
//
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
// to std::strxfrm, but only for certain locales :-(
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
//
if (r == INT_MAX)
{
result.erase();
result.insert(result.begin(), static_cast<char>(0));
return result;
}
#endif
result.append(r - s + 3, ' ');
s = result.size();
}
result.erase(r);
return result;
}
inline c_regex_traits<char>::string_type c_regex_traits<char>::transform_primary(const char* p1, const char* p2)
{
static char s_delim;
static const int s_collate_type = ::boost::BOOST_REGEX_DETAIL_NS::find_sort_syntax(static_cast<c_regex_traits<char>*>(0), &s_delim);
std::string result;
//
// What we do here depends upon the format of the sort key returned by
// sort key returned by this->transform:
//
switch (s_collate_type)
{
case ::boost::BOOST_REGEX_DETAIL_NS::sort_C:
case ::boost::BOOST_REGEX_DETAIL_NS::sort_unknown:
// the best we can do is translate to lower case, then get a regular sort key:
{
result.assign(p1, p2);
for (std::string::size_type i = 0; i < result.size(); ++i)
result[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(result[i])));
result = transform(&*result.begin(), &*result.begin() + result.size());
break;
}
case ::boost::BOOST_REGEX_DETAIL_NS::sort_fixed:
{
// get a regular sort key, and then truncate it:
result = transform(p1, p2);
result.erase(s_delim);
break;
}
case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim:
// get a regular sort key, and then truncate everything after the delim:
result = transform(p1, p2);
if ((!result.empty()) && (result[0] == s_delim))
break;
std::size_t i;
for (i = 0; i < result.size(); ++i)
{
if (result[i] == s_delim)
break;
}
result.erase(i);
break;
}
if (result.empty())
result = std::string(1, char(0));
return result;
}
inline c_regex_traits<char>::char_class_type c_regex_traits<char>::lookup_classname(const char* p1, const char* p2)
{
using namespace BOOST_REGEX_DETAIL_NS;
static const char_class_type masks[] =
{
0,
char_class_alnum,
char_class_alpha,
char_class_blank,
char_class_cntrl,
char_class_digit,
char_class_digit,
char_class_graph,
char_class_horizontal,
char_class_lower,
char_class_lower,
char_class_print,
char_class_punct,
char_class_space,
char_class_space,
char_class_upper,
char_class_unicode,
char_class_upper,
char_class_vertical,
char_class_alnum | char_class_word,
char_class_alnum | char_class_word,
char_class_xdigit,
};
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
if (idx < 0)
{
std::string s(p1, p2);
for (std::string::size_type i = 0; i < s.size(); ++i)
s[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(s[i])));
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
}
BOOST_REGEX_ASSERT(std::size_t(idx) + 1u < sizeof(masks) / sizeof(masks[0]));
return masks[idx + 1];
}
inline bool c_regex_traits<char>::isctype(char c, char_class_type mask)
{
using namespace BOOST_REGEX_DETAIL_NS;
return
((mask & char_class_space) && (std::isspace)(static_cast<unsigned char>(c)))
|| ((mask & char_class_print) && (std::isprint)(static_cast<unsigned char>(c)))
|| ((mask & char_class_cntrl) && (std::iscntrl)(static_cast<unsigned char>(c)))
|| ((mask & char_class_upper) && (std::isupper)(static_cast<unsigned char>(c)))
|| ((mask & char_class_lower) && (std::islower)(static_cast<unsigned char>(c)))
|| ((mask & char_class_alpha) && (std::isalpha)(static_cast<unsigned char>(c)))
|| ((mask & char_class_digit) && (std::isdigit)(static_cast<unsigned char>(c)))
|| ((mask & char_class_punct) && (std::ispunct)(static_cast<unsigned char>(c)))
|| ((mask & char_class_xdigit) && (std::isxdigit)(static_cast<unsigned char>(c)))
|| ((mask & char_class_blank) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c))
|| ((mask & char_class_word) && (c == '_'))
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == '\v')))
|| ((mask & char_class_horizontal) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != '\v'));
}
inline c_regex_traits<char>::string_type c_regex_traits<char>::lookup_collatename(const char* p1, const char* p2)
{
std::string s(p1, p2);
s = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(s);
if (s.empty() && (p2 - p1 == 1))
s.append(1, *p1);
return s;
}
inline int c_regex_traits<char>::value(char c, int radix)
{
char b[2] = { c, '\0', };
char* ep;
int result = std::strtol(b, &ep, radix);
if (ep == b)
return -1;
return result;
}
#ifndef BOOST_NO_WREGEX
inline c_regex_traits<wchar_t>::string_type c_regex_traits<wchar_t>::transform(const wchar_t* p1, const wchar_t* p2)
{
std::size_t r;
std::size_t s = 10;
std::wstring src(p1, p2);
std::wstring result(s, L' ');
while (s < (r = std::wcsxfrm(&*result.begin(), src.c_str(), s)))
{
#if defined(_CPPLIB_VER)
//
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
// to std::strxfrm, but only for certain locales :-(
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
//
if (r == INT_MAX)
{
result.erase();
result.insert(result.begin(), static_cast<wchar_t>(0));
return result;
}
#endif
result.append(r - s + 3, L' ');
s = result.size();
}
result.erase(r);
return result;
}
inline c_regex_traits<wchar_t>::string_type c_regex_traits<wchar_t>::transform_primary(const wchar_t* p1, const wchar_t* p2)
{
static wchar_t s_delim;
static const int s_collate_type = ::boost::BOOST_REGEX_DETAIL_NS::find_sort_syntax(static_cast<const c_regex_traits<wchar_t>*>(0), &s_delim);
std::wstring result;
//
// What we do here depends upon the format of the sort key returned by
// sort key returned by this->transform:
//
switch (s_collate_type)
{
case ::boost::BOOST_REGEX_DETAIL_NS::sort_C:
case ::boost::BOOST_REGEX_DETAIL_NS::sort_unknown:
// the best we can do is translate to lower case, then get a regular sort key:
{
result.assign(p1, p2);
for (std::wstring::size_type i = 0; i < result.size(); ++i)
result[i] = (std::towlower)(result[i]);
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
break;
}
case ::boost::BOOST_REGEX_DETAIL_NS::sort_fixed:
{
// get a regular sort key, and then truncate it:
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
result.erase(s_delim);
break;
}
case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim:
// get a regular sort key, and then truncate everything after the delim:
result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size());
if ((!result.empty()) && (result[0] == s_delim))
break;
std::size_t i;
for (i = 0; i < result.size(); ++i)
{
if (result[i] == s_delim)
break;
}
result.erase(i);
break;
}
if (result.empty())
result = std::wstring(1, char(0));
return result;
}
inline c_regex_traits<wchar_t>::char_class_type c_regex_traits<wchar_t>::lookup_classname(const wchar_t* p1, const wchar_t* p2)
{
using namespace BOOST_REGEX_DETAIL_NS;
static const char_class_type masks[] =
{
0,
char_class_alnum,
char_class_alpha,
char_class_blank,
char_class_cntrl,
char_class_digit,
char_class_digit,
char_class_graph,
char_class_horizontal,
char_class_lower,
char_class_lower,
char_class_print,
char_class_punct,
char_class_space,
char_class_space,
char_class_upper,
char_class_unicode,
char_class_upper,
char_class_vertical,
char_class_alnum | char_class_word,
char_class_alnum | char_class_word,
char_class_xdigit,
};
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
if (idx < 0)
{
std::wstring s(p1, p2);
for (std::wstring::size_type i = 0; i < s.size(); ++i)
s[i] = (std::towlower)(s[i]);
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
}
BOOST_REGEX_ASSERT(idx + 1 < static_cast<int>(sizeof(masks) / sizeof(masks[0])));
return masks[idx + 1];
}
inline bool c_regex_traits<wchar_t>::isctype(wchar_t c, char_class_type mask)
{
using namespace BOOST_REGEX_DETAIL_NS;
return
((mask & char_class_space) && (std::iswspace)(c))
|| ((mask & char_class_print) && (std::iswprint)(c))
|| ((mask & char_class_cntrl) && (std::iswcntrl)(c))
|| ((mask & char_class_upper) && (std::iswupper)(c))
|| ((mask & char_class_lower) && (std::iswlower)(c))
|| ((mask & char_class_alpha) && (std::iswalpha)(c))
|| ((mask & char_class_digit) && (std::iswdigit)(c))
|| ((mask & char_class_punct) && (std::iswpunct)(c))
|| ((mask & char_class_xdigit) && (std::iswxdigit)(c))
|| ((mask & char_class_blank) && (std::iswspace)(c) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c))
|| ((mask & char_class_word) && (c == '_'))
|| ((mask & char_class_unicode) && (c & ~static_cast<wchar_t>(0xff)))
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == L'\v')))
|| ((mask & char_class_horizontal) && (std::iswspace)(c) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != L'\v'));
}
inline c_regex_traits<wchar_t>::string_type c_regex_traits<wchar_t>::lookup_collatename(const wchar_t* p1, const wchar_t* p2)
{
std::string name;
// Usual msvc warning suppression does not work here with std::string template constructor.... use a workaround instead:
for (const wchar_t* pos = p1; pos != p2; ++pos)
name.push_back((char)*pos);
name = ::boost::BOOST_REGEX_DETAIL_NS::lookup_default_collate_name(name);
if (!name.empty())
return string_type(name.begin(), name.end());
if (p2 - p1 == 1)
return string_type(1, *p1);
return string_type();
}
inline int c_regex_traits<wchar_t>::value(wchar_t c, int radix)
{
#ifdef BOOST_BORLANDC
// workaround for broken wcstol:
if ((std::iswxdigit)(c) == 0)
return -1;
#endif
wchar_t b[2] = { c, '\0', };
wchar_t* ep;
int result = std::wcstol(b, &ep, radix);
if (ep == b)
return -1;
return result;
}
#endif
}
#endif

View File

@ -0,0 +1,59 @@
/*
*
* Copyright (c) 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 char_regex_traits.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares deprecated traits classes char_regex_traits<>.
*/
#ifndef BOOST_REGEX_V5_CHAR_REGEX_TRAITS_HPP
#define BOOST_REGEX_V5_CHAR_REGEX_TRAITS_HPP
namespace boost{
namespace deprecated{
//
// class char_regex_traits_i
// provides case insensitive traits classes (deprecated):
template <class charT>
class char_regex_traits_i : public regex_traits<charT> {};
template<>
class char_regex_traits_i<char> : public regex_traits<char>
{
public:
typedef char char_type;
typedef unsigned char uchar_type;
typedef unsigned int size_type;
typedef regex_traits<char> base_type;
};
#ifndef BOOST_NO_WREGEX
template<>
class char_regex_traits_i<wchar_t> : public regex_traits<wchar_t>
{
public:
typedef wchar_t char_type;
typedef unsigned short uchar_type;
typedef unsigned int size_type;
typedef regex_traits<wchar_t> base_type;
};
#endif
} // namespace deprecated
} // namespace boost
#endif // include

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,195 @@
/*
*
* 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 cregex.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares POSIX API functions
* + boost::RegEx high level wrapper.
*/
#ifndef BOOST_RE_CREGEX_HPP_INCLUDED
#define BOOST_RE_CREGEX_HPP_INCLUDED
#ifndef BOOST_REGEX_CONFIG_HPP
#include <boost/regex/config.hpp>
#endif
#include <boost/regex/v5/match_flags.hpp>
#include <boost/regex/v5/error_type.hpp>
#ifndef BOOST_REGEX_STANDALONE
#if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
# define BOOST_LIB_NAME boost_regex
# if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
# define BOOST_DYN_LINK
# endif
# ifdef BOOST_REGEX_DIAG
# define BOOST_LIB_DIAGNOSTIC
# endif
# include <boost/config/auto_link.hpp>
#endif
#endif
#ifdef __cplusplus
#include <cstddef>
#else
#include <stddef.h>
#endif
/* include these defs only for POSIX compatablity */
#ifdef __cplusplus
namespace boost{
extern "C" {
#endif
#if defined(__cplusplus)
typedef std::ptrdiff_t regoff_t;
typedef std::size_t regsize_t;
#else
typedef ptrdiff_t regoff_t;
typedef size_t regsize_t;
#endif
typedef struct
{
unsigned int re_magic;
#ifdef __cplusplus
std::size_t re_nsub; /* number of parenthesized subexpressions */
#else
size_t re_nsub;
#endif
const char* re_endp; /* end pointer for REG_PEND */
void* guts; /* none of your business :-) */
match_flag_type eflags; /* none of your business :-) */
} regex_tA;
#ifndef BOOST_NO_WREGEX
typedef struct
{
unsigned int re_magic;
#ifdef __cplusplus
std::size_t re_nsub; /* number of parenthesized subexpressions */
#else
size_t re_nsub;
#endif
const wchar_t* re_endp; /* end pointer for REG_PEND */
void* guts; /* none of your business :-) */
match_flag_type eflags; /* none of your business :-) */
} regex_tW;
#endif
typedef struct
{
regoff_t rm_so; /* start of match */
regoff_t rm_eo; /* end of match */
} regmatch_t;
/* regcomp() flags */
typedef enum{
REG_BASIC = 0000,
REG_EXTENDED = 0001,
REG_ICASE = 0002,
REG_NOSUB = 0004,
REG_NEWLINE = 0010,
REG_NOSPEC = 0020,
REG_PEND = 0040,
REG_DUMP = 0200,
REG_NOCOLLATE = 0400,
REG_ESCAPE_IN_LISTS = 01000,
REG_NEWLINE_ALT = 02000,
REG_PERLEX = 04000,
REG_PERL = REG_EXTENDED | REG_NOCOLLATE | REG_ESCAPE_IN_LISTS | REG_PERLEX,
REG_AWK = REG_EXTENDED | REG_ESCAPE_IN_LISTS,
REG_GREP = REG_BASIC | REG_NEWLINE_ALT,
REG_EGREP = REG_EXTENDED | REG_NEWLINE_ALT,
REG_ASSERT = 15,
REG_INVARG = 16,
REG_ATOI = 255, /* convert name to number (!) */
REG_ITOA = 0400 /* convert number to name (!) */
} reg_comp_flags;
/* regexec() flags */
typedef enum{
REG_NOTBOL = 00001,
REG_NOTEOL = 00002,
REG_STARTEND = 00004
} reg_exec_flags;
/*
* POSIX error codes:
*/
typedef unsigned reg_error_t;
typedef reg_error_t reg_errcode_t; /* backwards compatibility */
static const reg_error_t REG_NOERROR = 0; /* Success. */
static const reg_error_t REG_NOMATCH = 1; /* Didn't find a match (for regexec). */
/* POSIX regcomp return error codes. (In the order listed in the
standard.) */
static const reg_error_t REG_BADPAT = 2; /* Invalid pattern. */
static const reg_error_t REG_ECOLLATE = 3; /* Undefined collating element. */
static const reg_error_t REG_ECTYPE = 4; /* Invalid character class name. */
static const reg_error_t REG_EESCAPE = 5; /* Trailing backslash. */
static const reg_error_t REG_ESUBREG = 6; /* Invalid back reference. */
static const reg_error_t REG_EBRACK = 7; /* Unmatched left bracket. */
static const reg_error_t REG_EPAREN = 8; /* Parenthesis imbalance. */
static const reg_error_t REG_EBRACE = 9; /* Unmatched \{. */
static const reg_error_t REG_BADBR = 10; /* Invalid contents of \{\}. */
static const reg_error_t REG_ERANGE = 11; /* Invalid range end. */
static const reg_error_t REG_ESPACE = 12; /* Ran out of memory. */
static const reg_error_t REG_BADRPT = 13; /* No preceding re for repetition op. */
static const reg_error_t REG_EEND = 14; /* unexpected end of expression */
static const reg_error_t REG_ESIZE = 15; /* expression too big */
static const reg_error_t REG_ERPAREN = 8; /* = REG_EPAREN : unmatched right parenthesis */
static const reg_error_t REG_EMPTY = 17; /* empty expression */
static const reg_error_t REG_E_MEMORY = 15; /* = REG_ESIZE : out of memory */
static const reg_error_t REG_ECOMPLEXITY = 18; /* complexity too high */
static const reg_error_t REG_ESTACK = 19; /* out of stack space */
static const reg_error_t REG_E_PERL = 20; /* Perl (?...) error */
static const reg_error_t REG_E_UNKNOWN = 21; /* unknown error */
static const reg_error_t REG_ENOSYS = 21; /* = REG_E_UNKNOWN : Reserved. */
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA*, const char*, int);
BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int, const regex_tA*, char*, regsize_t);
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA*, const char*, regsize_t, regmatch_t*, int);
BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA*);
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW*, const wchar_t*, int);
BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int, const regex_tW*, wchar_t*, regsize_t);
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW*, const wchar_t*, regsize_t, regmatch_t*, int);
BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW*);
#endif
#ifdef UNICODE
#define regcomp regcompW
#define regerror regerrorW
#define regexec regexecW
#define regfree regfreeW
#define regex_t regex_tW
#else
#define regcomp regcompA
#define regerror regerrorA
#define regexec regexecA
#define regfree regfreeA
#define regex_t regex_tA
#endif
#ifdef __cplusplus
} /* extern "C" */
} /* namespace */
#endif
#endif /* include guard */

View File

@ -0,0 +1,59 @@
/*
*
* Copyright (c) 2003-2005
* 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 error_type.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares regular expression error type enumerator.
*/
#ifndef BOOST_REGEX_ERROR_TYPE_HPP
#define BOOST_REGEX_ERROR_TYPE_HPP
#ifdef __cplusplus
namespace boost{
#endif
#ifdef __cplusplus
namespace regex_constants{
enum error_type{
error_ok = 0, /* not used */
error_no_match = 1, /* not used */
error_bad_pattern = 2,
error_collate = 3,
error_ctype = 4,
error_escape = 5,
error_backref = 6,
error_brack = 7,
error_paren = 8,
error_brace = 9,
error_badbrace = 10,
error_range = 11,
error_space = 12,
error_badrepeat = 13,
error_end = 14, /* not used */
error_size = 15,
error_right_paren = 16, /* not used */
error_empty = 17,
error_complexity = 18,
error_stack = 19,
error_perl_extension = 20,
error_unknown = 21
};
}
}
#endif /* __cplusplus */
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
/*
*
* Copyright (c) 2020
* 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 basic_regex_parser.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares template class basic_regex_parser.
*/
#include <boost/regex/config.hpp>
#include <set>
#ifndef BOOST_REGEX_V5_INDEXED_BIT_FLAG_HPP
#define BOOST_REGEX_V5_INDEXED_BIT_FLAG_HPP
namespace boost{
namespace BOOST_REGEX_DETAIL_NS{
class indexed_bit_flag
{
std::uint64_t low_mask;
std::set<std::size_t> mask_set;
public:
indexed_bit_flag() : low_mask(0) {}
void set(std::size_t i)
{
if (i < std::numeric_limits<std::uint64_t>::digits - 1)
low_mask |= static_cast<std::uint64_t>(1u) << i;
else
mask_set.insert(i);
}
bool test(std::size_t i)
{
if (i < std::numeric_limits<std::uint64_t>::digits - 1)
return low_mask & static_cast<std::uint64_t>(1u) << i ? true : false;
else
return mask_set.find(i) != mask_set.end();
}
};
} // namespace BOOST_REGEX_DETAIL_NS
} // namespace boost
#endif

View File

@ -0,0 +1,84 @@
/*
*
* Copyright (c) 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 regex_match.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Iterator traits for selecting an iterator type as
* an integral constant expression.
*/
#ifndef BOOST_REGEX_ITERATOR_CATEGORY_HPP
#define BOOST_REGEX_ITERATOR_CATEGORY_HPP
#include <iterator>
#include <type_traits>
namespace boost{
namespace detail{
template <class I>
struct is_random_imp
{
private:
typedef typename std::iterator_traits<I>::iterator_category cat;
public:
static const bool value = (std::is_convertible<cat*, std::random_access_iterator_tag*>::value);
};
template <class I>
struct is_random_pointer_imp
{
static const bool value = true;
};
template <bool is_pointer_type>
struct is_random_imp_selector
{
template <class I>
struct rebind
{
typedef is_random_imp<I> type;
};
};
template <>
struct is_random_imp_selector<true>
{
template <class I>
struct rebind
{
typedef is_random_pointer_imp<I> type;
};
};
}
template <class I>
struct is_random_access_iterator
{
private:
typedef detail::is_random_imp_selector< std::is_pointer<I>::value> selector;
typedef typename selector::template rebind<I> bound_type;
typedef typename bound_type::type answer;
public:
static const bool value = answer::value;
};
template <class I>
const bool is_random_access_iterator<I>::value;
}
#endif

View File

@ -0,0 +1,32 @@
/*
*
* 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 iterator_traits.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares iterator traits workarounds.
*/
#ifndef BOOST_REGEX_V5_ITERATOR_TRAITS_HPP
#define BOOST_REGEX_V5_ITERATOR_TRAITS_HPP
namespace boost{
namespace BOOST_REGEX_DETAIL_NS{
template <class T>
struct regex_iterator_traits : public std::iterator_traits<T> {};
} // namespace BOOST_REGEX_DETAIL_NS
} // namespace boost
#endif

View File

@ -0,0 +1,156 @@
/*
*
* 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 match_flags.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares match_flags type.
*/
#ifndef BOOST_REGEX_V5_MATCH_FLAGS
#define BOOST_REGEX_V5_MATCH_FLAGS
#ifdef __cplusplus
# include <cstdint>
#endif
#ifdef __cplusplus
namespace boost{
namespace regex_constants{
#endif
#ifdef BOOST_REGEX_MSVC
#pragma warning(push)
#if BOOST_REGEX_MSVC >= 1800
#pragma warning(disable : 26812)
#endif
#endif
typedef enum _match_flags
{
match_default = 0,
match_not_bol = 1, /* first is not start of line */
match_not_eol = match_not_bol << 1, /* last is not end of line */
match_not_bob = match_not_eol << 1, /* first is not start of buffer */
match_not_eob = match_not_bob << 1, /* last is not end of buffer */
match_not_bow = match_not_eob << 1, /* first is not start of word */
match_not_eow = match_not_bow << 1, /* last is not end of word */
match_not_dot_newline = match_not_eow << 1, /* \n is not matched by '.' */
match_not_dot_null = match_not_dot_newline << 1, /* '\0' is not matched by '.' */
match_prev_avail = match_not_dot_null << 1, /* *--first is a valid expression */
match_init = match_prev_avail << 1, /* internal use */
match_any = match_init << 1, /* don't care what we match */
match_not_null = match_any << 1, /* string can't be null */
match_continuous = match_not_null << 1, /* each grep match must continue from */
/* uninterrupted from the previous one */
match_partial = match_continuous << 1, /* find partial matches */
match_stop = match_partial << 1, /* stop after first match (grep) V3 only */
match_not_initial_null = match_stop, /* don't match initial null, V4 only */
match_all = match_stop << 1, /* must find the whole of input even if match_any is set */
match_perl = match_all << 1, /* Use perl matching rules */
match_posix = match_perl << 1, /* Use POSIX matching rules */
match_nosubs = match_posix << 1, /* don't trap marked subs */
match_extra = match_nosubs << 1, /* include full capture information for repeated captures */
match_single_line = match_extra << 1, /* treat text as single line and ignore any \n's when matching ^ and $. */
match_unused1 = match_single_line << 1, /* unused */
match_unused2 = match_unused1 << 1, /* unused */
match_unused3 = match_unused2 << 1, /* unused */
match_max = match_unused3,
format_perl = 0, /* perl style replacement */
format_default = 0, /* ditto. */
format_sed = match_max << 1, /* sed style replacement. */
format_all = format_sed << 1, /* enable all extensions to syntax. */
format_no_copy = format_all << 1, /* don't copy non-matching segments. */
format_first_only = format_no_copy << 1, /* Only replace first occurrence. */
format_is_if = format_first_only << 1, /* internal use only. */
format_literal = format_is_if << 1, /* treat string as a literal */
match_not_any = match_not_bol | match_not_eol | match_not_bob
| match_not_eob | match_not_bow | match_not_eow | match_not_dot_newline
| match_not_dot_null | match_prev_avail | match_init | match_not_null
| match_continuous | match_partial | match_stop | match_not_initial_null
| match_stop | match_all | match_perl | match_posix | match_nosubs
| match_extra | match_single_line | match_unused1 | match_unused2
| match_unused3 | match_max | format_perl | format_default | format_sed
| format_all | format_no_copy | format_first_only | format_is_if
| format_literal
} match_flags;
typedef match_flags match_flag_type;
#ifdef __cplusplus
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)
{ 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)
{ return static_cast<match_flags>(static_cast<std::int32_t>(m1) ^ static_cast<std::int32_t>(m2)); }
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)
{ m1 = m1&m2; return m1; }
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)
{ m1 = m1^m2; return m1; }
#endif
#ifdef __cplusplus
} /* namespace regex_constants */
/*
* 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;
/* 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;
/*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;
/*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;
/*using regex_constants::format_is_if;*/
#ifdef BOOST_REGEX_MSVC
#pragma warning(pop)
#endif
} /* namespace boost */
#endif /* __cplusplus */
#endif /* include guard */

View File

@ -0,0 +1,667 @@
/*
*
* Copyright (c) 1998-2009
* 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 match_results.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares template class match_results.
*/
#ifndef BOOST_REGEX_V5_MATCH_RESULTS_HPP
#define BOOST_REGEX_V5_MATCH_RESULTS_HPP
namespace boost{
#ifdef BOOST_REGEX_MSVC
#pragma warning(push)
#pragma warning(disable : 4251 4459)
#if BOOST_REGEX_MSVC < 1700
# pragma warning(disable : 4231)
#endif
# if BOOST_REGEX_MSVC < 1600
# pragma warning(disable : 4660)
# endif
#endif
namespace BOOST_REGEX_DETAIL_NS{
class named_subexpressions;
}
template <class BidiIterator, class Allocator>
class match_results
{
private:
typedef std::vector<sub_match<BidiIterator>, Allocator> vector_type;
public:
typedef sub_match<BidiIterator> value_type;
typedef typename std::allocator_traits<Allocator>::value_type const & const_reference;
typedef const_reference reference;
typedef typename vector_type::const_iterator const_iterator;
typedef const_iterator iterator;
typedef typename std::iterator_traits<
BidiIterator>::difference_type difference_type;
typedef typename std::allocator_traits<Allocator>::size_type size_type;
typedef Allocator allocator_type;
typedef typename std::iterator_traits<
BidiIterator>::value_type char_type;
typedef std::basic_string<char_type> string_type;
typedef BOOST_REGEX_DETAIL_NS::named_subexpressions named_sub_type;
// construct/copy/destroy:
explicit match_results(const Allocator& a = Allocator())
: m_subs(a), m_base(), m_null(), m_last_closed_paren(0), m_is_singular(true) {}
//
// IMPORTANT: in the code below, the crazy looking checks around m_is_singular are
// all required because it is illegal to copy a singular iterator.
// See https://svn.boost.org/trac/boost/ticket/3632.
//
match_results(const match_results& m)
: m_subs(m.m_subs), m_base(), m_null(), m_named_subs(m.m_named_subs), m_last_closed_paren(m.m_last_closed_paren), m_is_singular(m.m_is_singular)
{
if(!m_is_singular)
{
m_base = m.m_base;
m_null = m.m_null;
}
}
match_results& operator=(const match_results& m)
{
m_subs = m.m_subs;
m_named_subs = m.m_named_subs;
m_last_closed_paren = m.m_last_closed_paren;
m_is_singular = m.m_is_singular;
if(!m_is_singular)
{
m_base = m.m_base;
m_null = m.m_null;
}
return *this;
}
~match_results(){}
// size:
size_type size() const
{ return empty() ? 0 : m_subs.size() - 2; }
size_type max_size() const
{ return m_subs.max_size(); }
bool empty() const
{ return m_subs.size() < 2; }
// element access:
difference_type length(int sub = 0) const
{
if(m_is_singular)
raise_logic_error();
sub += 2;
if((sub < (int)m_subs.size()) && (sub > 0))
return m_subs[sub].length();
return 0;
}
difference_type length(const char_type* sub) const
{
if(m_is_singular)
raise_logic_error();
const char_type* sub_end = sub;
while(*sub_end) ++sub_end;
return length(named_subexpression_index(sub, sub_end));
}
template <class charT>
difference_type length(const charT* sub) const
{
if(m_is_singular)
raise_logic_error();
const charT* sub_end = sub;
while(*sub_end) ++sub_end;
return length(named_subexpression_index(sub, sub_end));
}
template <class charT, class Traits, class A>
difference_type length(const std::basic_string<charT, Traits, A>& sub) const
{
return length(sub.c_str());
}
difference_type position(size_type sub = 0) const
{
if(m_is_singular)
raise_logic_error();
sub += 2;
if(sub < m_subs.size())
{
const sub_match<BidiIterator>& s = m_subs[sub];
if(s.matched || (sub == 2))
{
return std::distance((BidiIterator)(m_base), (BidiIterator)(s.first));
}
}
return ~static_cast<difference_type>(0);
}
difference_type position(const char_type* sub) const
{
const char_type* sub_end = sub;
while(*sub_end) ++sub_end;
return position(named_subexpression_index(sub, sub_end));
}
template <class charT>
difference_type position(const charT* sub) const
{
const charT* sub_end = sub;
while(*sub_end) ++sub_end;
return position(named_subexpression_index(sub, sub_end));
}
template <class charT, class Traits, class A>
difference_type position(const std::basic_string<charT, Traits, A>& sub) const
{
return position(sub.c_str());
}
string_type str(int sub = 0) const
{
if(m_is_singular)
raise_logic_error();
sub += 2;
string_type result;
if(sub < (int)m_subs.size() && (sub > 0))
{
const sub_match<BidiIterator>& s = m_subs[sub];
if(s.matched)
{
result = s.str();
}
}
return result;
}
string_type str(const char_type* sub) const
{
return (*this)[sub].str();
}
template <class Traits, class A>
string_type str(const std::basic_string<char_type, Traits, A>& sub) const
{
return (*this)[sub].str();
}
template <class charT>
string_type str(const charT* sub) const
{
return (*this)[sub].str();
}
template <class charT, class Traits, class A>
string_type str(const std::basic_string<charT, Traits, A>& sub) const
{
return (*this)[sub].str();
}
const_reference operator[](int sub) const
{
if(m_is_singular && m_subs.empty())
raise_logic_error();
sub += 2;
if(sub < (int)m_subs.size() && (sub >= 0))
{
return m_subs[sub];
}
return m_null;
}
//
// Named sub-expressions:
//
const_reference named_subexpression(const char_type* i, const char_type* j) const
{
//
// Scan for the leftmost *matched* subexpression with the specified named:
//
if(m_is_singular)
raise_logic_error();
BOOST_REGEX_DETAIL_NS::named_subexpressions::range_type r = m_named_subs->equal_range(i, j);
while((r.first != r.second) && ((*this)[r.first->index].matched == false))
++r.first;
return r.first != r.second ? (*this)[r.first->index] : m_null;
}
template <class charT>
const_reference named_subexpression(const charT* i, const charT* j) const
{
static_assert(sizeof(charT) <= sizeof(char_type), "Failed internal logic");
if(i == j)
return m_null;
std::vector<char_type> s;
while(i != j)
s.insert(s.end(), *i++);
return named_subexpression(&*s.begin(), &*s.begin() + s.size());
}
int named_subexpression_index(const char_type* i, const char_type* j) const
{
//
// Scan for the leftmost *matched* subexpression with the specified named.
// If none found then return the leftmost expression with that name,
// otherwise an invalid index:
//
if(m_is_singular)
raise_logic_error();
BOOST_REGEX_DETAIL_NS::named_subexpressions::range_type s, r;
s = r = m_named_subs->equal_range(i, j);
while((r.first != r.second) && ((*this)[r.first->index].matched == false))
++r.first;
if(r.first == r.second)
r = s;
return r.first != r.second ? r.first->index : -20;
}
template <class charT>
int named_subexpression_index(const charT* i, const charT* j) const
{
static_assert(sizeof(charT) <= sizeof(char_type), "Failed internal logic");
if(i == j)
return -20;
std::vector<char_type> s;
while(i != j)
s.insert(s.end(), *i++);
return named_subexpression_index(&*s.begin(), &*s.begin() + s.size());
}
template <class Traits, class A>
const_reference operator[](const std::basic_string<char_type, Traits, A>& s) const
{
return named_subexpression(s.c_str(), s.c_str() + s.size());
}
const_reference operator[](const char_type* p) const
{
const char_type* e = p;
while(*e) ++e;
return named_subexpression(p, e);
}
template <class charT>
const_reference operator[](const charT* p) const
{
static_assert(sizeof(charT) <= sizeof(char_type), "Failed internal logic");
if(*p == 0)
return m_null;
std::vector<char_type> s;
while(*p)
s.insert(s.end(), *p++);
return named_subexpression(&*s.begin(), &*s.begin() + s.size());
}
template <class charT, class Traits, class A>
const_reference operator[](const std::basic_string<charT, Traits, A>& ns) const
{
static_assert(sizeof(charT) <= sizeof(char_type), "Failed internal logic");
if(ns.empty())
return m_null;
std::vector<char_type> s;
for(unsigned i = 0; i < ns.size(); ++i)
s.insert(s.end(), ns[i]);
return named_subexpression(&*s.begin(), &*s.begin() + s.size());
}
const_reference prefix() const
{
if(m_is_singular)
raise_logic_error();
return (*this)[-1];
}
const_reference suffix() const
{
if(m_is_singular)
raise_logic_error();
return (*this)[-2];
}
const_iterator begin() const
{
return (m_subs.size() > 2) ? (m_subs.begin() + 2) : m_subs.end();
}
const_iterator end() const
{
return m_subs.end();
}
// format:
template <class OutputIterator, class Functor>
OutputIterator format(OutputIterator out,
Functor fmt,
match_flag_type flags = format_default) const
{
if(m_is_singular)
raise_logic_error();
typedef typename BOOST_REGEX_DETAIL_NS::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, OutputIterator>::type F;
F func(fmt);
return func(*this, out, flags);
}
template <class Functor>
string_type format(Functor fmt, match_flag_type flags = format_default) const
{
if(m_is_singular)
raise_logic_error();
std::basic_string<char_type> result;
BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<char_type> > i(result);
typedef typename BOOST_REGEX_DETAIL_NS::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<char_type> > >::type F;
F func(fmt);
func(*this, i, flags);
return result;
}
// format with locale:
template <class OutputIterator, class Functor, class RegexT>
OutputIterator format(OutputIterator out,
Functor fmt,
match_flag_type flags,
const RegexT& re) const
{
if(m_is_singular)
raise_logic_error();
typedef ::boost::regex_traits_wrapper<typename RegexT::traits_type> traits_type;
typedef typename BOOST_REGEX_DETAIL_NS::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, OutputIterator, traits_type>::type F;
F func(fmt);
return func(*this, out, flags, re.get_traits());
}
template <class RegexT, class Functor>
string_type format(Functor fmt,
match_flag_type flags,
const RegexT& re) const
{
if(m_is_singular)
raise_logic_error();
typedef ::boost::regex_traits_wrapper<typename RegexT::traits_type> traits_type;
std::basic_string<char_type> result;
BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<char_type> > i(result);
typedef typename BOOST_REGEX_DETAIL_NS::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<char_type> >, traits_type >::type F;
F func(fmt);
func(*this, i, flags, re.get_traits());
return result;
}
const_reference get_last_closed_paren()const
{
if(m_is_singular)
raise_logic_error();
return m_last_closed_paren == 0 ? m_null : (*this)[m_last_closed_paren];
}
allocator_type get_allocator() const
{
return m_subs.get_allocator();
}
void swap(match_results& that)
{
std::swap(m_subs, that.m_subs);
std::swap(m_named_subs, that.m_named_subs);
std::swap(m_last_closed_paren, that.m_last_closed_paren);
if(m_is_singular)
{
if(!that.m_is_singular)
{
m_base = that.m_base;
m_null = that.m_null;
}
}
else if(that.m_is_singular)
{
that.m_base = m_base;
that.m_null = m_null;
}
else
{
std::swap(m_base, that.m_base);
std::swap(m_null, that.m_null);
}
std::swap(m_is_singular, that.m_is_singular);
}
bool operator==(const match_results& that)const
{
if(m_is_singular)
{
return that.m_is_singular;
}
else if(that.m_is_singular)
{
return false;
}
return (m_subs == that.m_subs) && (m_base == that.m_base) && (m_last_closed_paren == that.m_last_closed_paren);
}
bool operator!=(const match_results& that)const
{ return !(*this == that); }
#ifdef BOOST_REGEX_MATCH_EXTRA
typedef typename sub_match<BidiIterator>::capture_sequence_type capture_sequence_type;
const capture_sequence_type& captures(int i)const
{
if(m_is_singular)
raise_logic_error();
return (*this)[i].captures();
}
#endif
//
// private access functions:
void set_second(BidiIterator i)
{
BOOST_REGEX_ASSERT(m_subs.size() > 2);
m_subs[2].second = i;
m_subs[2].matched = true;
m_subs[0].first = i;
m_subs[0].matched = (m_subs[0].first != m_subs[0].second);
m_null.first = i;
m_null.second = i;
m_null.matched = false;
m_is_singular = false;
}
void set_second(BidiIterator i, size_type pos, bool m = true, bool escape_k = false)
{
if(pos)
m_last_closed_paren = static_cast<int>(pos);
pos += 2;
BOOST_REGEX_ASSERT(m_subs.size() > pos);
m_subs[pos].second = i;
m_subs[pos].matched = m;
if((pos == 2) && !escape_k)
{
m_subs[0].first = i;
m_subs[0].matched = (m_subs[0].first != m_subs[0].second);
m_null.first = i;
m_null.second = i;
m_null.matched = false;
m_is_singular = false;
}
}
void set_size(size_type n, BidiIterator i, BidiIterator j)
{
value_type v(j);
size_type len = m_subs.size();
if(len > n + 2)
{
m_subs.erase(m_subs.begin()+n+2, m_subs.end());
std::fill(m_subs.begin(), m_subs.end(), v);
}
else
{
std::fill(m_subs.begin(), m_subs.end(), v);
if(n+2 != len)
m_subs.insert(m_subs.end(), n+2-len, v);
}
m_subs[1].first = i;
m_last_closed_paren = 0;
}
void set_base(BidiIterator pos)
{
m_base = pos;
}
BidiIterator base()const
{
return m_base;
}
void set_first(BidiIterator i)
{
BOOST_REGEX_ASSERT(m_subs.size() > 2);
// set up prefix:
m_subs[1].second = i;
m_subs[1].matched = (m_subs[1].first != i);
// set up $0:
m_subs[2].first = i;
// zero out everything else:
for(size_type n = 3; n < m_subs.size(); ++n)
{
m_subs[n].first = m_subs[n].second = m_subs[0].second;
m_subs[n].matched = false;
}
}
void set_first(BidiIterator i, size_type pos, bool escape_k = false)
{
BOOST_REGEX_ASSERT(pos+2 < m_subs.size());
if(pos || escape_k)
{
m_subs[pos+2].first = i;
if(escape_k)
{
m_subs[1].second = i;
m_subs[1].matched = (m_subs[1].first != m_subs[1].second);
}
}
else
set_first(i);
}
void maybe_assign(const match_results<BidiIterator, Allocator>& m);
void set_named_subs(std::shared_ptr<named_sub_type> subs)
{
m_named_subs = subs;
}
private:
//
// Error handler called when an uninitialized match_results is accessed:
//
static void raise_logic_error()
{
std::logic_error e("Attempt to access an uninitialized boost::match_results<> class.");
#ifndef BOOST_REGEX_STANDALONE
boost::throw_exception(e);
#else
throw e;
#endif
}
vector_type m_subs; // subexpressions
BidiIterator m_base; // where the search started from
sub_match<BidiIterator> m_null; // a null match
std::shared_ptr<named_sub_type> m_named_subs; // Shared copy of named subs in the regex object
int m_last_closed_paren; // Last ) to be seen - used for formatting
bool m_is_singular; // True if our stored iterators are singular
};
template <class BidiIterator, class Allocator>
void match_results<BidiIterator, Allocator>::maybe_assign(const match_results<BidiIterator, Allocator>& m)
{
if(m_is_singular)
{
*this = m;
return;
}
const_iterator p1, p2;
p1 = begin();
p2 = m.begin();
//
// Distances are measured from the start of *this* match, unless this isn't
// a valid match in which case we use the start of the whole sequence. Note that
// no subsequent match-candidate can ever be to the left of the first match found.
// This ensures that when we are using bidirectional iterators, that distances
// measured are as short as possible, and therefore as efficient as possible
// to compute. Finally note that we don't use the "matched" data member to test
// whether a sub-expression is a valid match, because partial matches set this
// to false for sub-expression 0.
//
BidiIterator l_end = this->suffix().second;
BidiIterator l_base = (p1->first == l_end) ? this->prefix().first : (*this)[0].first;
difference_type len1 = 0;
difference_type len2 = 0;
difference_type base1 = 0;
difference_type base2 = 0;
std::size_t i;
for(i = 0; i < size(); ++i, ++p1, ++p2)
{
//
// Leftmost takes priority over longest; handle special cases
// where distances need not be computed first (an optimisation
// for bidirectional iterators: ensure that we don't accidently
// compute the length of the whole sequence, as this can be really
// expensive).
//
if(p1->first == l_end)
{
if(p2->first != l_end)
{
// p2 must be better than p1, and no need to calculate
// actual distances:
base1 = 1;
base2 = 0;
break;
}
else
{
// *p1 and *p2 are either unmatched or match end-of sequence,
// either way no need to calculate distances:
if((p1->matched == false) && (p2->matched == true))
break;
if((p1->matched == true) && (p2->matched == false))
return;
continue;
}
}
else if(p2->first == l_end)
{
// p1 better than p2, and no need to calculate distances:
return;
}
base1 = std::distance(l_base, p1->first);
base2 = std::distance(l_base, p2->first);
BOOST_REGEX_ASSERT(base1 >= 0);
BOOST_REGEX_ASSERT(base2 >= 0);
if(base1 < base2) return;
if(base2 < base1) break;
len1 = std::distance((BidiIterator)p1->first, (BidiIterator)p1->second);
len2 = std::distance((BidiIterator)p2->first, (BidiIterator)p2->second);
BOOST_REGEX_ASSERT(len1 >= 0);
BOOST_REGEX_ASSERT(len2 >= 0);
if((len1 != len2) || ((p1->matched == false) && (p2->matched == true)))
break;
if((p1->matched == true) && (p2->matched == false))
return;
}
if(i == size())
return;
if(base2 < base1)
*this = m;
else if((len2 > len1) || ((p1->matched == false) && (p2->matched == true)) )
*this = m;
}
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>
std::basic_ostream<charT, traits>&
operator << (std::basic_ostream<charT, traits>& os,
const match_results<BidiIterator, Allocator>& s)
{
return (os << s.str());
}
#ifdef BOOST_REGEX_MSVC
#pragma warning(pop)
#endif
} // namespace boost
#endif

View File

@ -0,0 +1,175 @@
/*
* Copyright (c) 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 mem_block_cache.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: memory block cache used by the non-recursive matcher.
*/
#ifndef BOOST_REGEX_V5_MEM_BLOCK_CACHE_HPP
#define BOOST_REGEX_V5_MEM_BLOCK_CACHE_HPP
#include <new>
#ifdef BOOST_HAS_THREADS
#include <mutex>
#endif
#ifndef BOOST_NO_CXX11_HDR_ATOMIC
#include <atomic>
#if ATOMIC_POINTER_LOCK_FREE == 2
#define BOOST_REGEX_MEM_BLOCK_CACHE_LOCK_FREE
#define BOOST_REGEX_ATOMIC_POINTER std::atomic
#endif
#endif
namespace boost{
namespace BOOST_REGEX_DETAIL_NS{
#ifdef BOOST_REGEX_MEM_BLOCK_CACHE_LOCK_FREE /* lock free implementation */
struct mem_block_cache
{
std::atomic<void*> cache[BOOST_REGEX_MAX_CACHE_BLOCKS];
~mem_block_cache()
{
for (size_t i = 0;i < BOOST_REGEX_MAX_CACHE_BLOCKS; ++i) {
if (cache[i].load()) ::operator delete(cache[i].load());
}
}
void* get()
{
for (size_t i = 0;i < BOOST_REGEX_MAX_CACHE_BLOCKS; ++i) {
void* p = cache[i].load();
if (p != NULL) {
if (cache[i].compare_exchange_strong(p, NULL)) return p;
}
}
return ::operator new(BOOST_REGEX_BLOCKSIZE);
}
void put(void* ptr)
{
for (size_t i = 0;i < BOOST_REGEX_MAX_CACHE_BLOCKS; ++i) {
void* p = cache[i].load();
if (p == NULL) {
if (cache[i].compare_exchange_strong(p, ptr)) return;
}
}
::operator delete(ptr);
}
static mem_block_cache& instance()
{
static mem_block_cache block_cache = { { {nullptr} } };
return block_cache;
}
};
#else /* lock-based implementation */
struct mem_block_node
{
mem_block_node* next;
};
struct mem_block_cache
{
// this member has to be statically initialsed:
mem_block_node* next;
unsigned cached_blocks;
#ifdef BOOST_HAS_THREADS
boost::static_mutex mut;
#endif
~mem_block_cache()
{
while(next)
{
mem_block_node* old = next;
next = next->next;
::operator delete(old);
}
}
void* get()
{
#ifdef BOOST_HAS_THREADS
std::lock_guard<std::mutex> g(mut);
#endif
if(next)
{
mem_block_node* result = next;
next = next->next;
--cached_blocks;
return result;
}
return ::operator new(BOOST_REGEX_BLOCKSIZE);
}
void put(void* p)
{
#ifdef BOOST_HAS_THREADS
std::lock_guard<std::mutex> g(mut);
#endif
if(cached_blocks >= BOOST_REGEX_MAX_CACHE_BLOCKS)
{
::operator delete(p);
}
else
{
mem_block_node* old = static_cast<mem_block_node*>(p);
old->next = next;
next = old;
++cached_blocks;
}
}
static mem_block_cache& instance()
{
#ifdef BOOST_HAS_THREADS
static mem_block_cache block_cache = { 0, 0, BOOST_STATIC_MUTEX_INIT, };
#else
static mem_block_cache block_cache = { 0, 0, };
#endif
return block_cache;
}
};
#endif
#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0
inline void* get_mem_block()
{
return ::operator new(BOOST_REGEX_BLOCKSIZE);
}
inline void put_mem_block(void* p)
{
::operator delete(p);
}
#else
inline void* get_mem_block()
{
return mem_block_cache::instance().get();
}
inline void put_mem_block(void* p)
{
mem_block_cache::instance().put(p);
}
#endif
}
} // namespace boost
#endif

View File

@ -0,0 +1,160 @@
/*
*
* Copyright (c) 2004
* 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 object_cache.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Implements a generic object cache.
*/
#ifndef BOOST_REGEX_OBJECT_CACHE_HPP
#define BOOST_REGEX_OBJECT_CACHE_HPP
#include <boost/regex/config.hpp>
#include <memory>
#include <map>
#include <list>
#include <stdexcept>
#include <string>
#ifdef BOOST_HAS_THREADS
#include <mutex>
#endif
namespace boost{
template <class Key, class Object>
class object_cache
{
public:
typedef std::pair< ::std::shared_ptr<Object const>, Key const*> value_type;
typedef std::list<value_type> list_type;
typedef typename list_type::iterator list_iterator;
typedef std::map<Key, list_iterator> map_type;
typedef typename map_type::iterator map_iterator;
typedef typename list_type::size_type size_type;
static std::shared_ptr<Object const> get(const Key& k, size_type l_max_cache_size);
private:
static std::shared_ptr<Object const> do_get(const Key& k, size_type l_max_cache_size);
struct data
{
list_type cont;
map_type index;
};
// Needed by compilers not implementing the resolution to DR45. For reference,
// see http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45.
friend struct data;
};
#ifdef BOOST_REGEX_MSVC
#pragma warning(push)
#pragma warning(disable: 4702)
#endif
template <class Key, class Object>
std::shared_ptr<Object const> object_cache<Key, Object>::get(const Key& k, size_type l_max_cache_size)
{
#ifdef BOOST_HAS_THREADS
static std::mutex mut;
std::lock_guard<std::mutex> l(mut);
return do_get(k, l_max_cache_size);
#else
return do_get(k, l_max_cache_size);
#endif
}
#ifdef BOOST_REGEX_MSVC
#pragma warning(pop)
#endif
template <class Key, class Object>
std::shared_ptr<Object const> object_cache<Key, Object>::do_get(const Key& k, size_type l_max_cache_size)
{
typedef typename object_cache<Key, Object>::data object_data;
typedef typename map_type::size_type map_size_type;
static object_data s_data;
//
// see if the object is already in the cache:
//
map_iterator mpos = s_data.index.find(k);
if(mpos != s_data.index.end())
{
//
// Eureka!
// We have a cached item, bump it up the list and return it:
//
if(--(s_data.cont.end()) != mpos->second)
{
// splice out the item we want to move:
list_type temp;
temp.splice(temp.end(), s_data.cont, mpos->second);
// and now place it at the end of the list:
s_data.cont.splice(s_data.cont.end(), temp, temp.begin());
BOOST_REGEX_ASSERT(*(s_data.cont.back().second) == k);
// update index with new position:
mpos->second = --(s_data.cont.end());
BOOST_REGEX_ASSERT(&(mpos->first) == mpos->second->second);
BOOST_REGEX_ASSERT(&(mpos->first) == s_data.cont.back().second);
}
return s_data.cont.back().first;
}
//
// if we get here then the item is not in the cache,
// so create it:
//
std::shared_ptr<Object const> result(new Object(k));
//
// Add it to the list, and index it:
//
s_data.cont.push_back(value_type(result, static_cast<Key const*>(0)));
s_data.index.insert(std::make_pair(k, --(s_data.cont.end())));
s_data.cont.back().second = &(s_data.index.find(k)->first);
map_size_type s = s_data.index.size();
BOOST_REGEX_ASSERT(s_data.index[k]->first.get() == result.get());
BOOST_REGEX_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second);
BOOST_REGEX_ASSERT(s_data.index.find(k)->first == k);
if(s > l_max_cache_size)
{
//
// We have too many items in the list, so we need to start
// popping them off the back of the list, but only if they're
// being held uniquely by us:
//
list_iterator pos = s_data.cont.begin();
list_iterator last = s_data.cont.end();
while((pos != last) && (s > l_max_cache_size))
{
if(pos->first.use_count() == 1)
{
list_iterator condemmed(pos);
++pos;
// now remove the items from our containers,
// then order has to be as follows:
BOOST_REGEX_ASSERT(s_data.index.find(*(condemmed->second)) != s_data.index.end());
s_data.index.erase(*(condemmed->second));
s_data.cont.erase(condemmed);
--s;
}
else
++pos;
}
BOOST_REGEX_ASSERT(s_data.index[k]->first.get() == result.get());
BOOST_REGEX_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second);
BOOST_REGEX_ASSERT(s_data.index.find(k)->first == k);
}
return result;
}
}
#endif

View File

@ -0,0 +1,105 @@
/*
*
* 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 pattern_except.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares pattern-matching exception classes.
*/
#ifndef BOOST_RE_V5_PAT_EXCEPT_HPP
#define BOOST_RE_V5_PAT_EXCEPT_HPP
#ifndef BOOST_REGEX_CONFIG_HPP
#include <boost/regex/config.hpp>
#endif
#include <cstddef>
#include <stdexcept>
#include <boost/regex/v5/error_type.hpp>
#include <boost/regex/v5/regex_traits_defaults.hpp>
namespace boost{
#ifdef BOOST_REGEX_MSVC
#pragma warning(push)
#pragma warning(disable : 4275)
#if BOOST_REGEX_MSVC >= 1800
#pragma warning(disable : 26812 4459)
#endif
#endif
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)
: std::runtime_error(s)
, m_error_code(err)
, m_position(pos)
{
}
explicit regex_error(regex_constants::error_type err)
: std::runtime_error(::boost::BOOST_REGEX_DETAIL_NS::get_default_error_string(err))
, m_error_code(err)
, m_position(0)
{
}
~regex_error() noexcept override {}
regex_constants::error_type code()const
{ return m_error_code; }
std::ptrdiff_t position()const
{ return m_position; }
void raise()const
{
#ifndef BOOST_NO_EXCEPTIONS
#ifndef BOOST_REGEX_STANDALONE
::boost::throw_exception(*this);
#else
throw* this;
#endif
#endif
}
private:
regex_constants::error_type m_error_code;
std::ptrdiff_t m_position;
};
typedef regex_error bad_pattern;
typedef regex_error bad_expression;
namespace BOOST_REGEX_DETAIL_NS{
inline void raise_runtime_error(const std::runtime_error& ex)
{
#ifndef BOOST_REGEX_STANDALONE
::boost::throw_exception(ex);
#else
throw ex;
#endif
}
template <class traits>
void raise_error(const traits& t, regex_constants::error_type code)
{
(void)t; // warning suppression
std::runtime_error e(t.error_string(code));
::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(e);
}
}
#ifdef BOOST_REGEX_MSVC
#pragma warning(pop)
#endif
} // namespace boost
#endif

View File

@ -0,0 +1,576 @@
/*
*
* Copyright (c) 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)
*
*/
#ifndef BOOST_REGEX_MATCHER_HPP
#define BOOST_REGEX_MATCHER_HPP
#include <boost/regex/v5/iterator_category.hpp>
#ifdef BOOST_REGEX_MSVC
# pragma warning(push)
#pragma warning(disable : 4251 4459)
#if BOOST_REGEX_MSVC < 1700
# pragma warning(disable : 4231)
#endif
# if BOOST_REGEX_MSVC < 1600
# pragma warning(disable : 4660)
# endif
#if BOOST_REGEX_MSVC < 1910
#pragma warning(disable:4800)
#endif
#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)
{
//
// can't mix match_extra with POSIX matching rules:
//
if ((mf & match_extra) && (mf & match_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
}
}
//
// function can_start:
//
template <class charT>
inline bool can_start(charT c, const unsigned char* map, unsigned char mask)
{
return ((c < static_cast<charT>(0)) ? true : ((c >= static_cast<charT>(1 << CHAR_BIT)) ? true : map[c] & mask));
}
inline bool can_start(char c, const unsigned char* map, unsigned char mask)
{
return map[(unsigned char)c] & mask;
}
inline bool can_start(signed char c, const unsigned char* map, unsigned char mask)
{
return map[(unsigned char)c] & mask;
}
inline bool can_start(unsigned char c, const unsigned char* map, unsigned char mask)
{
return map[c] & mask;
}
inline bool can_start(unsigned short c, const unsigned char* map, unsigned char mask)
{
return ((c >= (1 << CHAR_BIT)) ? true : map[c] & mask);
}
#if defined(WCHAR_MIN) && (WCHAR_MIN == 0) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
inline bool can_start(wchar_t c, const unsigned char* map, unsigned char mask)
{
return ((c >= static_cast<wchar_t>(1u << CHAR_BIT)) ? true : map[c] & mask);
}
#endif
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
inline bool can_start(unsigned int c, const unsigned char* map, unsigned char mask)
{
return (((c >= static_cast<unsigned int>(1u << CHAR_BIT)) ? true : map[c] & mask));
}
#endif
template <class C, class T, class A>
inline int string_compare(const std::basic_string<C,T,A>& s, const C* p)
{
if(0 == *p)
{
if(s.empty() || ((s.size() == 1) && (s[0] == 0)))
return 0;
}
return s.compare(p);
}
template <class Seq, class C>
inline int string_compare(const Seq& s, const C* p)
{
std::size_t i = 0;
while((i < s.size()) && (p[i] == s[i]))
{
++i;
}
return (i == s.size()) ? -(int)p[i] : (int)s[i] - (int)p[i];
}
# define STR_COMP(s,p) string_compare(s,p)
template<class charT>
inline const charT* re_skip_past_null(const charT* p)
{
while (*p != static_cast<charT>(0)) ++p;
return ++p;
}
template <class iterator, class charT, class traits_type, class char_classT>
iterator re_is_set_member(iterator next,
iterator last,
const re_set_long<char_classT>* set_,
const regex_data<charT, traits_type>& e, bool icase)
{
const charT* p = reinterpret_cast<const charT*>(set_+1);
iterator ptr;
unsigned int i;
//bool icase = e.m_flags & regex_constants::icase;
if(next == last) return next;
typedef typename traits_type::string_type traits_string_type;
const ::boost::regex_traits_wrapper<traits_type>& traits_inst = *(e.m_ptraits);
// dwa 9/13/00 suppress incorrect MSVC warning - it claims this is never
// referenced
(void)traits_inst;
// try and match a single character, could be a multi-character
// collating element...
for(i = 0; i < set_->csingles; ++i)
{
ptr = next;
if(*p == static_cast<charT>(0))
{
// treat null string as special case:
if(traits_inst.translate(*ptr, icase))
{
++p;
continue;
}
return set_->isnot ? next : (ptr == next) ? ++next : ptr;
}
else
{
while(*p && (ptr != last))
{
if(traits_inst.translate(*ptr, icase) != *p)
break;
++p;
++ptr;
}
if(*p == static_cast<charT>(0)) // if null we've matched
return set_->isnot ? next : (ptr == next) ? ++next : ptr;
p = re_skip_past_null(p); // skip null
}
}
charT col = traits_inst.translate(*next, icase);
if(set_->cranges || set_->cequivalents)
{
traits_string_type s1;
//
// try and match a range, NB only a single character can match
if(set_->cranges)
{
if((e.m_flags & regex_constants::collate) == 0)
s1.assign(1, col);
else
{
charT a[2] = { col, charT(0), };
s1 = traits_inst.transform(a, a + 1);
}
for(i = 0; i < set_->cranges; ++i)
{
if(STR_COMP(s1, p) >= 0)
{
do{ ++p; }while(*p);
++p;
if(STR_COMP(s1, p) <= 0)
return set_->isnot ? next : ++next;
}
else
{
// skip first string
do{ ++p; }while(*p);
++p;
}
// skip second string
do{ ++p; }while(*p);
++p;
}
}
//
// try and match an equivalence class, NB only a single character can match
if(set_->cequivalents)
{
charT a[2] = { col, charT(0), };
s1 = traits_inst.transform_primary(a, a +1);
for(i = 0; i < set_->cequivalents; ++i)
{
if(STR_COMP(s1, p) == 0)
return set_->isnot ? next : ++next;
// skip string
do{ ++p; }while(*p);
++p;
}
}
}
if(traits_inst.isctype(col, set_->cclasses) == true)
return set_->isnot ? next : ++next;
if((set_->cnclasses != 0) && (traits_inst.isctype(col, set_->cnclasses) == false))
return set_->isnot ? next : ++next;
return set_->isnot ? ++next : next;
}
template <class BidiIterator>
class repeater_count
{
repeater_count** stack;
repeater_count* next;
int state_id;
std::size_t count; // the number of iterations so far
BidiIterator start_pos; // where the last repeat started
repeater_count* unwind_until(int n, repeater_count* p, int current_recursion_id)
{
while(p && (p->state_id != n))
{
if(-2 - current_recursion_id == p->state_id)
return 0;
p = p->next;
if(p && (p->state_id < 0))
{
p = unwind_until(p->state_id, p, current_recursion_id);
if(!p)
return p;
p = p->next;
}
}
return p;
}
public:
repeater_count(repeater_count** s) : stack(s), next(0), state_id(-1), count(0), start_pos() {}
repeater_count(int i, repeater_count** s, BidiIterator start, int current_recursion_id)
: start_pos(start)
{
state_id = i;
stack = s;
next = *stack;
*stack = this;
if((state_id > next->state_id) && (next->state_id >= 0))
count = 0;
else
{
repeater_count* p = next;
p = unwind_until(state_id, p, current_recursion_id);
if(p)
{
count = p->count;
start_pos = p->start_pos;
}
else
count = 0;
}
}
~repeater_count()
{
if(next)
*stack = next;
}
std::size_t get_count() { return count; }
int get_id() { return state_id; }
std::size_t operator++() { return ++count; }
bool check_null_repeat(const BidiIterator& pos, std::size_t max)
{
// this is called when we are about to start a new repeat,
// if the last one was NULL move our count to max,
// otherwise save the current position.
bool result = (count == 0) ? false : (pos == start_pos);
if(result)
count = max;
else
start_pos = pos;
return result;
}
};
struct saved_state;
enum saved_state_type
{
saved_type_end = 0,
saved_type_paren = 1,
saved_type_recurse = 2,
saved_type_assertion = 3,
saved_state_alt = 4,
saved_state_repeater_count = 5,
saved_state_extra_block = 6,
saved_state_greedy_single_repeat = 7,
saved_state_rep_slow_dot = 8,
saved_state_rep_fast_dot = 9,
saved_state_rep_char = 10,
saved_state_rep_short_set = 11,
saved_state_rep_long_set = 12,
saved_state_non_greedy_long_repeat = 13,
saved_state_count = 14
};
#ifdef BOOST_REGEX_MSVC
# pragma warning(push)
#if BOOST_REGEX_MSVC >= 1800
#pragma warning(disable:26495)
#endif
#endif
template <class Results>
struct recursion_info
{
typedef typename Results::value_type value_type;
typedef typename value_type::iterator iterator;
int idx;
const re_syntax_base* preturn_address;
Results results;
repeater_count<iterator>* repeater_stack;
iterator location_of_start;
};
#ifdef BOOST_REGEX_MSVC
# pragma warning(pop)
#endif
template <class BidiIterator, class Allocator, class traits>
class perl_matcher
{
public:
typedef typename traits::char_type char_type;
typedef perl_matcher<BidiIterator, Allocator, traits> self_type;
typedef bool (self_type::*matcher_proc_type)();
typedef std::size_t traits_size_type;
typedef typename is_byte<char_type>::width_type width_type;
typedef typename std::iterator_traits<BidiIterator>::difference_type difference_type;
typedef match_results<BidiIterator, Allocator> results_type;
perl_matcher(BidiIterator first, BidiIterator end,
match_results<BidiIterator, Allocator>& what,
const basic_regex<char_type, traits>& e,
match_flag_type f,
BidiIterator l_base)
: m_result(what), base(first), last(end),
position(first), backstop(l_base), re(e), traits_inst(e.get_traits()),
m_independent(false), next_count(&rep_obj), rep_obj(&next_count)
, m_recursions(0)
{
construct_init(e, f);
}
bool match();
bool find();
void setf(match_flag_type f)
{ m_match_flags |= f; }
void unsetf(match_flag_type f)
{ m_match_flags &= ~f; }
private:
void construct_init(const basic_regex<char_type, traits>& e, match_flag_type f);
bool find_imp();
bool match_imp();
void estimate_max_state_count(std::random_access_iterator_tag*);
void estimate_max_state_count(void*);
bool match_prefix();
bool match_all_states();
// match procs, stored in s_match_vtable:
bool match_startmark();
bool match_endmark();
bool match_literal();
bool match_start_line();
bool match_end_line();
bool match_wild();
bool match_match();
bool match_word_boundary();
bool match_within_word();
bool match_word_start();
bool match_word_end();
bool match_buffer_start();
bool match_buffer_end();
bool match_backref();
bool match_long_set();
bool match_set();
bool match_jump();
bool match_alt();
bool match_rep();
bool match_combining();
bool match_soft_buffer_end();
bool match_restart_continue();
bool match_long_set_repeat();
bool match_set_repeat();
bool match_char_repeat();
bool match_dot_repeat_fast();
bool match_dot_repeat_slow();
bool match_dot_repeat_dispatch()
{
return ::boost::is_random_access_iterator<BidiIterator>::value ? match_dot_repeat_fast() : match_dot_repeat_slow();
}
bool match_backstep();
bool match_assert_backref();
bool match_toggle_case();
bool match_recursion();
bool match_fail();
bool match_accept();
bool match_commit();
bool match_then();
bool skip_until_paren(int index, bool match = true);
// find procs stored in s_find_vtable:
bool find_restart_any();
bool find_restart_word();
bool find_restart_line();
bool find_restart_buf();
bool find_restart_lit();
private:
// final result structure to be filled in:
match_results<BidiIterator, Allocator>& m_result;
// temporary result for POSIX matches:
std::unique_ptr<match_results<BidiIterator, Allocator> > m_temp_match;
// pointer to actual result structure to fill in:
match_results<BidiIterator, Allocator>* m_presult;
// start of sequence being searched:
BidiIterator base;
// end of sequence being searched:
BidiIterator last;
// current character being examined:
BidiIterator position;
// where to restart next search after failed match attempt:
BidiIterator restart;
// where the current search started from, acts as base for $` during grep:
BidiIterator search_base;
// how far we can go back when matching lookbehind:
BidiIterator backstop;
// the expression being examined:
const basic_regex<char_type, traits>& re;
// the expression's traits class:
const ::boost::regex_traits_wrapper<traits>& traits_inst;
// the next state in the machine being matched:
const re_syntax_base* pstate;
// matching flags in use:
match_flag_type m_match_flags;
// how many states we have examined so far:
std::ptrdiff_t state_count;
// max number of states to examine before giving up:
std::ptrdiff_t max_state_count;
// whether we should ignore case or not:
bool icase;
// set to true when (position == last), indicates that we may have a partial match:
bool m_has_partial_match;
// set to true whenever we get a match:
bool m_has_found_match;
// set to true whenever we're inside an independent sub-expression:
bool m_independent;
// the current repeat being examined:
repeater_count<BidiIterator>* next_count;
// the first repeat being examined (top of linked list):
repeater_count<BidiIterator> rep_obj;
// the mask to pass when matching word boundaries:
typename traits::char_class_type m_word_mask;
// the bitmask to use when determining whether a match_any matches a newline or not:
unsigned char match_any_mask;
// recursion information:
std::vector<recursion_info<results_type> > recursion_stack;
//
// additional members for non-recursive version:
//
typedef bool (self_type::*unwind_proc_type)(bool);
void extend_stack();
bool unwind(bool);
bool unwind_end(bool);
bool unwind_paren(bool);
bool unwind_recursion_stopper(bool);
bool unwind_assertion(bool);
bool unwind_alt(bool);
bool unwind_repeater_counter(bool);
bool unwind_extra_block(bool);
bool unwind_greedy_single_repeat(bool);
bool unwind_slow_dot_repeat(bool);
bool unwind_fast_dot_repeat(bool);
bool unwind_char_repeat(bool);
bool unwind_short_set_repeat(bool);
bool unwind_long_set_repeat(bool);
bool unwind_non_greedy_repeat(bool);
bool unwind_recursion(bool);
bool unwind_recursion_pop(bool);
bool unwind_commit(bool);
bool unwind_then(bool);
bool unwind_case(bool);
void destroy_single_repeat();
void push_matched_paren(int index, const sub_match<BidiIterator>& sub);
void push_recursion_stopper();
void push_assertion(const re_syntax_base* ps, bool positive);
void push_alt(const re_syntax_base* ps);
void push_repeater_count(int i, repeater_count<BidiIterator>** s);
void push_single_repeat(std::size_t c, const re_repeat* r, BidiIterator last_position, int state_id);
void push_non_greedy_repeat(const re_syntax_base* ps);
void push_recursion(int idx, const re_syntax_base* p, results_type* presults, results_type* presults2);
void push_recursion_pop();
void push_case_change(bool);
// pointer to base of stack:
saved_state* m_stack_base;
// pointer to current stack position:
saved_state* m_backup_state;
// how many memory blocks have we used up?:
unsigned used_block_count;
// determines what value to return when unwinding from recursion,
// allows for mixed recursive/non-recursive algorithm:
bool m_recursive_result;
// We have unwound to a lookahead/lookbehind, used by COMMIT/PRUNE/SKIP:
bool m_unwound_lookahead;
// We have unwound to an alternative, used by THEN:
bool m_unwound_alt;
// We are unwinding a commit - used by independent subs to determine whether to stop there or carry on unwinding:
//bool m_unwind_commit;
// Recursion limit:
unsigned m_recursions;
#ifdef BOOST_REGEX_MSVC
# pragma warning(push)
#if BOOST_REGEX_MSVC >= 1800
#pragma warning(disable:26495)
#endif
#endif
// these operations aren't allowed, so are declared private,
// bodies are provided to keep explicit-instantiation requests happy:
perl_matcher& operator=(const perl_matcher&)
{
return *this;
}
perl_matcher(const perl_matcher& that)
: m_result(that.m_result), re(that.re), traits_inst(that.traits_inst), rep_obj(0) {}
#ifdef BOOST_REGEX_MSVC
# pragma warning(pop)
#endif
};
} // namespace BOOST_REGEX_DETAIL_NS
#ifdef BOOST_REGEX_MSVC
# pragma warning(pop)
#endif
} // namespace boost
//
// include the implementation of perl_matcher:
//
#include <boost/regex/v5/perl_matcher_non_recursive.hpp>
// this one has to be last:
#include <boost/regex/v5/perl_matcher_common.hpp>
#endif

View File

@ -0,0 +1,915 @@
/*
*
* Copyright (c) 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 perl_matcher_common.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Definitions of perl_matcher member functions that are
* common to both the recursive and non-recursive versions.
*/
#ifndef BOOST_REGEX_V5_PERL_MATCHER_COMMON_HPP
#define BOOST_REGEX_V5_PERL_MATCHER_COMMON_HPP
#ifdef BOOST_REGEX_MSVC
# pragma warning(push)
#pragma warning(disable:4459)
#if BOOST_REGEX_MSVC < 1910
#pragma warning(disable:4800)
#endif
#endif
namespace boost{
namespace BOOST_REGEX_DETAIL_NS{
#ifdef BOOST_REGEX_MSVC
# pragma warning(push)
#pragma warning(disable:26812)
#endif
template <class BidiIterator, class Allocator, class traits>
void perl_matcher<BidiIterator, Allocator, traits>::construct_init(const basic_regex<char_type, traits>& e, match_flag_type f)
{
typedef typename std::iterator_traits<BidiIterator>::iterator_category category;
typedef typename basic_regex<char_type, traits>::flag_type expression_flag_type;
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
}
pstate = 0;
m_match_flags = f;
estimate_max_state_count(static_cast<category*>(0));
expression_flag_type re_f = re.flags();
icase = re_f & regex_constants::icase;
if(!(m_match_flags & (match_perl|match_posix)))
{
if((re_f & (regbase::main_option_type|regbase::no_perl_ex)) == 0)
m_match_flags |= match_perl;
else if((re_f & (regbase::main_option_type|regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex))
m_match_flags |= match_perl;
else if((re_f & (regbase::main_option_type|regbase::literal)) == (regbase::literal))
m_match_flags |= match_perl;
else
m_match_flags |= match_posix;
}
if(m_match_flags & match_posix)
{
m_temp_match.reset(new match_results<BidiIterator, Allocator>());
m_presult = m_temp_match.get();
}
else
m_presult = &m_result;
m_stack_base = 0;
m_backup_state = 0;
// find the value to use for matching word boundaries:
m_word_mask = re.get_data().m_word_mask;
// find bitmask to use for matching '.':
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)
m_match_flags &= regex_constants::match_not_any;
}
#ifdef BOOST_REGEX_MSVC
# pragma warning(pop)
#endif
template <class BidiIterator, class Allocator, class traits>
void perl_matcher<BidiIterator, Allocator, traits>::estimate_max_state_count(std::random_access_iterator_tag*)
{
//
// How many states should we allow our machine to visit before giving up?
// This is a heuristic: it takes the greater of O(N^2) and O(NS^2)
// where N is the length of the string, and S is the number of states
// in the machine. It's tempting to up this to O(N^2S) or even O(N^2S^2)
// but these take unreasonably amounts of time to bale out in pathological
// cases.
//
// Calculate NS^2 first:
//
static const std::ptrdiff_t k = 100000;
std::ptrdiff_t dist = std::distance(base, last);
if(dist == 0)
dist = 1;
std::ptrdiff_t states = re.size();
if(states == 0)
states = 1;
if ((std::numeric_limits<std::ptrdiff_t>::max)() / states < states)
{
max_state_count = (std::min)((std::ptrdiff_t)BOOST_REGEX_MAX_STATE_COUNT, (std::numeric_limits<std::ptrdiff_t>::max)() - 2);
return;
}
states *= states;
if((std::numeric_limits<std::ptrdiff_t>::max)() / dist < states)
{
max_state_count = (std::min)((std::ptrdiff_t)BOOST_REGEX_MAX_STATE_COUNT, (std::numeric_limits<std::ptrdiff_t>::max)() - 2);
return;
}
states *= dist;
if((std::numeric_limits<std::ptrdiff_t>::max)() - k < states)
{
max_state_count = (std::min)((std::ptrdiff_t)BOOST_REGEX_MAX_STATE_COUNT, (std::numeric_limits<std::ptrdiff_t>::max)() - 2);
return;
}
states += k;
max_state_count = states;
//
// Now calculate N^2:
//
states = dist;
if((std::numeric_limits<std::ptrdiff_t>::max)() / dist < states)
{
max_state_count = (std::min)((std::ptrdiff_t)BOOST_REGEX_MAX_STATE_COUNT, (std::numeric_limits<std::ptrdiff_t>::max)() - 2);
return;
}
states *= dist;
if((std::numeric_limits<std::ptrdiff_t>::max)() - k < states)
{
max_state_count = (std::min)((std::ptrdiff_t)BOOST_REGEX_MAX_STATE_COUNT, (std::numeric_limits<std::ptrdiff_t>::max)() - 2);
return;
}
states += k;
//
// N^2 can be a very large number indeed, to prevent things getting out
// of control, cap the max states:
//
if(states > BOOST_REGEX_MAX_STATE_COUNT)
states = BOOST_REGEX_MAX_STATE_COUNT;
//
// If (the possibly capped) N^2 is larger than our first estimate,
// use this instead:
//
if(states > max_state_count)
max_state_count = states;
}
template <class BidiIterator, class Allocator, class traits>
inline void perl_matcher<BidiIterator, Allocator, traits>::estimate_max_state_count(void*)
{
// we don't know how long the sequence is:
max_state_count = BOOST_REGEX_MAX_STATE_COUNT;
}
template <class BidiIterator, class Allocator, class traits>
inline bool perl_matcher<BidiIterator, Allocator, traits>::match()
{
return match_imp();
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_imp()
{
// initialise our stack if we are non-recursive:
save_state_init init(&m_stack_base, &m_backup_state);
used_block_count = BOOST_REGEX_MAX_BLOCKS;
#if !defined(BOOST_NO_EXCEPTIONS)
try{
#endif
// reset our state machine:
position = base;
search_base = base;
state_count = 0;
m_match_flags |= regex_constants::match_all;
m_presult->set_size((m_match_flags & match_nosubs) ? 1u : static_cast<typename results_type::size_type>(1u + re.mark_count()), search_base, last);
m_presult->set_base(base);
m_presult->set_named_subs(this->re.get_named_subs());
if(m_match_flags & match_posix)
m_result = *m_presult;
verify_options(re.flags(), m_match_flags);
if(0 == match_prefix())
return false;
return (m_result[0].second == last) && (m_result[0].first == base);
#if !defined(BOOST_NO_EXCEPTIONS)
}
catch(...)
{
// unwind all pushed states, apart from anything else this
// ensures that all the states are correctly destructed
// not just the memory freed.
while(unwind(true)){}
throw;
}
#endif
}
template <class BidiIterator, class Allocator, class traits>
inline bool perl_matcher<BidiIterator, Allocator, traits>::find()
{
return find_imp();
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::find_imp()
{
static matcher_proc_type const s_find_vtable[7] =
{
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_any,
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_word,
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_line,
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_buf,
&perl_matcher<BidiIterator, Allocator, traits>::match_prefix,
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_lit,
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_lit,
};
// initialise our stack if we are non-recursive:
save_state_init init(&m_stack_base, &m_backup_state);
used_block_count = BOOST_REGEX_MAX_BLOCKS;
#if !defined(BOOST_NO_EXCEPTIONS)
try{
#endif
state_count = 0;
if((m_match_flags & regex_constants::match_init) == 0)
{
// reset our state machine:
search_base = position = base;
pstate = re.get_first_state();
m_presult->set_size((m_match_flags & match_nosubs) ? 1u : static_cast<typename results_type::size_type>(1u + re.mark_count()), base, last);
m_presult->set_base(base);
m_presult->set_named_subs(this->re.get_named_subs());
m_match_flags |= regex_constants::match_init;
}
else
{
// start again:
search_base = position = m_result[0].second;
// If last match was null and match_not_null was not set then increment
// our start position, otherwise we go into an infinite loop:
if(((m_match_flags & match_not_null) == 0) && (m_result.length() == 0))
{
if(position == last)
return false;
else
++position;
}
// reset $` start:
m_presult->set_size((m_match_flags & match_nosubs) ? 1u : static_cast<typename results_type::size_type>(1u + re.mark_count()), search_base, last);
//if((base != search_base) && (base == backstop))
// m_match_flags |= match_prev_avail;
}
if(m_match_flags & match_posix)
{
m_result.set_size(static_cast<typename results_type::size_type>(1u + re.mark_count()), base, last);
m_result.set_base(base);
}
verify_options(re.flags(), m_match_flags);
// find out what kind of expression we have:
unsigned type = (m_match_flags & match_continuous) ?
static_cast<unsigned int>(regbase::restart_continue)
: static_cast<unsigned int>(re.get_restart_type());
// call the appropriate search routine:
matcher_proc_type proc = s_find_vtable[type];
return (this->*proc)();
#if !defined(BOOST_NO_EXCEPTIONS)
}
catch(...)
{
// unwind all pushed states, apart from anything else this
// ensures that all the states are correctly destructed
// not just the memory freed.
while(unwind(true)){}
throw;
}
#endif
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_prefix()
{
m_has_partial_match = false;
m_has_found_match = false;
pstate = re.get_first_state();
m_presult->set_first(position);
restart = position;
match_all_states();
if(!m_has_found_match && m_has_partial_match && (m_match_flags & match_partial))
{
m_has_found_match = true;
m_presult->set_second(last, 0, false);
position = last;
if((m_match_flags & match_posix) == match_posix)
{
m_result.maybe_assign(*m_presult);
}
}
#ifdef BOOST_REGEX_MATCH_EXTRA
if(m_has_found_match && (match_extra & m_match_flags))
{
//
// we have a match, reverse the capture information:
//
for(unsigned i = 0; i < m_presult->size(); ++i)
{
typename sub_match<BidiIterator>::capture_sequence_type & seq = ((*m_presult)[i]).get_captures();
std::reverse(seq.begin(), seq.end());
}
}
#endif
if(!m_has_found_match)
position = restart; // reset search postion
return m_has_found_match;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_literal()
{
unsigned int len = static_cast<const re_literal*>(pstate)->length;
const char_type* what = reinterpret_cast<const char_type*>(static_cast<const re_literal*>(pstate) + 1);
//
// compare string with what we stored in
// our records:
for(unsigned int i = 0; i < len; ++i, ++position)
{
if((position == last) || (traits_inst.translate(*position, icase) != what[i]))
return false;
}
pstate = pstate->next.p;
return true;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_start_line()
{
if(position == backstop)
{
if((m_match_flags & match_prev_avail) == 0)
{
if((m_match_flags & match_not_bol) == 0)
{
pstate = pstate->next.p;
return true;
}
return false;
}
}
else if(m_match_flags & match_single_line)
return false;
// check the previous value character:
BidiIterator t(position);
--t;
if(position != last)
{
if(is_separator(*t) && !((*t == static_cast<char_type>('\r')) && (*position == static_cast<char_type>('\n'))) )
{
pstate = pstate->next.p;
return true;
}
}
else if(is_separator(*t))
{
pstate = pstate->next.p;
return true;
}
return false;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_end_line()
{
if(position != last)
{
if(m_match_flags & match_single_line)
return false;
// we're not yet at the end so *first is always valid:
if(is_separator(*position))
{
if((position != backstop) || (m_match_flags & match_prev_avail))
{
// check that we're not in the middle of \r\n sequence
BidiIterator t(position);
--t;
if((*t == static_cast<char_type>('\r')) && (*position == static_cast<char_type>('\n')))
{
return false;
}
}
pstate = pstate->next.p;
return true;
}
}
else if((m_match_flags & match_not_eol) == 0)
{
pstate = pstate->next.p;
return true;
}
return false;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_wild()
{
if(position == last)
return false;
if(is_separator(*position) && ((match_any_mask & static_cast<const re_dot*>(pstate)->mask) == 0))
return false;
if((*position == char_type(0)) && (m_match_flags & match_not_dot_null))
return false;
pstate = pstate->next.p;
++position;
return true;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_word_boundary()
{
bool b; // indcates whether next character is a word character
if(position != last)
{
// prev and this character must be opposites:
b = traits_inst.isctype(*position, m_word_mask);
}
else
{
if (m_match_flags & match_not_eow)
return false;
b = false;
}
if((position == backstop) && ((m_match_flags & match_prev_avail) == 0))
{
if(m_match_flags & match_not_bow)
return false;
else
b ^= false;
}
else
{
--position;
b ^= traits_inst.isctype(*position, m_word_mask);
++position;
}
if(b)
{
pstate = pstate->next.p;
return true;
}
return false; // no match if we get to here...
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_within_word()
{
if(position == last)
return false;
// both prev and this character must be m_word_mask:
bool prev = traits_inst.isctype(*position, m_word_mask);
{
bool b;
if((position == backstop) && ((m_match_flags & match_prev_avail) == 0))
return false;
else
{
--position;
b = traits_inst.isctype(*position, m_word_mask);
++position;
}
if(b == prev)
{
pstate = pstate->next.p;
return true;
}
}
return false;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_word_start()
{
if(position == last)
return false; // can't be starting a word if we're already at the end of input
if(!traits_inst.isctype(*position, m_word_mask))
return false; // next character isn't a word character
if((position == backstop) && ((m_match_flags & match_prev_avail) == 0))
{
if(m_match_flags & match_not_bow)
return false; // no previous input
}
else
{
// otherwise inside buffer:
BidiIterator t(position);
--t;
if(traits_inst.isctype(*t, m_word_mask))
return false; // previous character not non-word
}
// OK we have a match:
pstate = pstate->next.p;
return true;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_word_end()
{
if((position == backstop) && ((m_match_flags & match_prev_avail) == 0))
return false; // start of buffer can't be end of word
BidiIterator t(position);
--t;
if(traits_inst.isctype(*t, m_word_mask) == false)
return false; // previous character wasn't a word character
if(position == last)
{
if(m_match_flags & match_not_eow)
return false; // end of buffer but not end of word
}
else
{
// otherwise inside buffer:
if(traits_inst.isctype(*position, m_word_mask))
return false; // next character is a word character
}
pstate = pstate->next.p;
return true; // if we fall through to here then we've succeeded
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_buffer_start()
{
if((position != backstop) || (m_match_flags & match_not_bob))
return false;
// OK match:
pstate = pstate->next.p;
return true;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_buffer_end()
{
if((position != last) || (m_match_flags & match_not_eob))
return false;
// OK match:
pstate = pstate->next.p;
return true;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_backref()
{
//
// Compare with what we previously matched.
// Note that this succeeds if the backref did not partisipate
// in the match, this is in line with ECMAScript, but not Perl
// or PCRE.
//
int index = static_cast<const re_brace*>(pstate)->index;
if(index >= hash_value_mask)
{
named_subexpressions::range_type r = re.get_data().equal_range(index);
BOOST_REGEX_ASSERT(r.first != r.second);
do
{
index = r.first->index;
++r.first;
}while((r.first != r.second) && ((*m_presult)[index].matched != true));
}
if((m_match_flags & match_perl) && !(*m_presult)[index].matched)
return false;
BidiIterator i = (*m_presult)[index].first;
BidiIterator j = (*m_presult)[index].second;
while(i != j)
{
if((position == last) || (traits_inst.translate(*position, icase) != traits_inst.translate(*i, icase)))
return false;
++i;
++position;
}
pstate = pstate->next.p;
return true;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_long_set()
{
typedef typename traits::char_class_type char_class_type;
// let the traits class do the work:
if(position == last)
return false;
BidiIterator t = re_is_set_member(position, last, static_cast<const re_set_long<char_class_type>*>(pstate), re.get_data(), icase);
if(t != position)
{
pstate = pstate->next.p;
position = t;
return true;
}
return false;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_set()
{
if(position == last)
return false;
if(static_cast<const re_set*>(pstate)->_map[static_cast<unsigned char>(traits_inst.translate(*position, icase))])
{
pstate = pstate->next.p;
++position;
return true;
}
return false;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_jump()
{
pstate = static_cast<const re_jump*>(pstate)->alt.p;
return true;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_combining()
{
if(position == last)
return false;
if(is_combining(traits_inst.translate(*position, icase)))
return false;
++position;
while((position != last) && is_combining(traits_inst.translate(*position, icase)))
++position;
pstate = pstate->next.p;
return true;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_soft_buffer_end()
{
if(m_match_flags & match_not_eob)
return false;
BidiIterator p(position);
while((p != last) && is_separator(traits_inst.translate(*p, icase)))++p;
if(p != last)
return false;
pstate = pstate->next.p;
return true;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_restart_continue()
{
if(position == search_base)
{
pstate = pstate->next.p;
return true;
}
return false;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_backstep()
{
#ifdef BOOST_REGEX_MSVC
#pragma warning(push)
#pragma warning(disable:4127)
#endif
if( ::boost::is_random_access_iterator<BidiIterator>::value)
{
std::ptrdiff_t maxlen = std::distance(backstop, position);
if(maxlen < static_cast<const re_brace*>(pstate)->index)
return false;
std::advance(position, -static_cast<const re_brace*>(pstate)->index);
}
else
{
int c = static_cast<const re_brace*>(pstate)->index;
while(c--)
{
if(position == backstop)
return false;
--position;
}
}
pstate = pstate->next.p;
return true;
#ifdef BOOST_REGEX_MSVC
#pragma warning(pop)
#endif
}
template <class BidiIterator, class Allocator, class traits>
inline bool perl_matcher<BidiIterator, Allocator, traits>::match_assert_backref()
{
// return true if marked sub-expression N has been matched:
int index = static_cast<const re_brace*>(pstate)->index;
bool result = false;
if(index == 9999)
{
// Magic value for a (DEFINE) block:
return false;
}
else if(index > 0)
{
// Have we matched subexpression "index"?
// Check if index is a hash value:
if(index >= hash_value_mask)
{
named_subexpressions::range_type r = re.get_data().equal_range(index);
while(r.first != r.second)
{
if((*m_presult)[r.first->index].matched)
{
result = true;
break;
}
++r.first;
}
}
else
{
result = (*m_presult)[index].matched;
}
pstate = pstate->next.p;
}
else
{
// Have we recursed into subexpression "index"?
// If index == 0 then check for any recursion at all, otherwise for recursion to -index-1.
int idx = -(index+1);
if(idx >= hash_value_mask)
{
named_subexpressions::range_type r = re.get_data().equal_range(idx);
int stack_index = recursion_stack.empty() ? -1 : recursion_stack.back().idx;
while(r.first != r.second)
{
result |= (stack_index == r.first->index);
if(result)break;
++r.first;
}
}
else
{
result = !recursion_stack.empty() && ((recursion_stack.back().idx == idx) || (index == 0));
}
pstate = pstate->next.p;
}
return result;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_fail()
{
// Just force a backtrack:
return false;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_accept()
{
if(!recursion_stack.empty())
{
return skip_until_paren(recursion_stack.back().idx);
}
else
{
return skip_until_paren(INT_MAX);
}
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_any()
{
#ifdef BOOST_REGEX_MSVC
#pragma warning(push)
#pragma warning(disable:4127)
#endif
const unsigned char* _map = re.get_map();
while(true)
{
// skip everything we can't match:
while((position != last) && !can_start(*position, _map, (unsigned char)mask_any) )
++position;
if(position == last)
{
// run out of characters, try a null match if possible:
if(re.can_be_null())
return match_prefix();
break;
}
// now try and obtain a match:
if(match_prefix())
return true;
if(position == last)
return false;
++position;
}
return false;
#ifdef BOOST_REGEX_MSVC
#pragma warning(pop)
#endif
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_word()
{
#ifdef BOOST_REGEX_MSVC
#pragma warning(push)
#pragma warning(disable:4127)
#endif
// do search optimised for word starts:
const unsigned char* _map = re.get_map();
if((m_match_flags & match_prev_avail) || (position != base))
--position;
else if(match_prefix())
return true;
do
{
while((position != last) && traits_inst.isctype(*position, m_word_mask))
++position;
while((position != last) && !traits_inst.isctype(*position, m_word_mask))
++position;
if(position == last)
break;
if(can_start(*position, _map, (unsigned char)mask_any) )
{
if(match_prefix())
return true;
}
if(position == last)
break;
} while(true);
return false;
#ifdef BOOST_REGEX_MSVC
#pragma warning(pop)
#endif
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_line()
{
// do search optimised for line starts:
const unsigned char* _map = re.get_map();
if(match_prefix())
return true;
while(position != last)
{
while((position != last) && !is_separator(*position))
++position;
if(position == last)
return false;
++position;
if(position == last)
{
if(re.can_be_null() && match_prefix())
return true;
return false;
}
if( can_start(*position, _map, (unsigned char)mask_any) )
{
if(match_prefix())
return true;
}
if(position == last)
return false;
//++position;
}
return false;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_buf()
{
if((position == base) && ((m_match_flags & match_not_bob) == 0))
return match_prefix();
return false;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_lit()
{
return false;
}
} // namespace BOOST_REGEX_DETAIL_NS
} // namespace boost
#ifdef BOOST_REGEX_MSVC
# pragma warning(pop)
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,120 @@
/*
*
* 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: primary_transform.hpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: Heuristically determines the sort string format in use
* by the current locale.
*/
#ifndef BOOST_REGEX_PRIMARY_TRANSFORM
#define BOOST_REGEX_PRIMARY_TRANSFORM
namespace boost{
namespace BOOST_REGEX_DETAIL_NS{
enum{
sort_C,
sort_fixed,
sort_delim,
sort_unknown
};
template <class S, class charT>
unsigned count_chars(const S& s, charT c)
{
//
// Count how many occurrences of character c occur
// in string s: if c is a delimeter between collation
// fields, then this should be the same value for all
// sort keys:
//
unsigned int count = 0;
for(unsigned pos = 0; pos < s.size(); ++pos)
{
if(s[pos] == c) ++count;
}
return count;
}
template <class traits, class charT>
unsigned find_sort_syntax(const traits* pt, charT* delim)
{
//
// compare 'a' with 'A' to see how similar they are,
// should really use a-accute but we can't portably do that,
//
typedef typename traits::string_type string_type;
typedef typename traits::char_type char_type;
// Suppress incorrect warning for MSVC
(void)pt;
char_type a[2] = {'a', '\0', };
string_type sa(pt->transform(a, a+1));
if(sa == a)
{
*delim = 0;
return sort_C;
}
char_type A[2] = { 'A', '\0', };
string_type sA(pt->transform(A, A+1));
char_type c[2] = { ';', '\0', };
string_type sc(pt->transform(c, c+1));
int pos = 0;
while((pos <= static_cast<int>(sa.size())) && (pos <= static_cast<int>(sA.size())) && (sa[pos] == sA[pos])) ++pos;
--pos;
if(pos < 0)
{
*delim = 0;
return sort_unknown;
}
//
// at this point sa[pos] is either the end of a fixed width field
// or the character that acts as a delimiter:
//
charT maybe_delim = sa[pos];
if((pos != 0) && (count_chars(sa, maybe_delim) == count_chars(sA, maybe_delim)) && (count_chars(sa, maybe_delim) == count_chars(sc, maybe_delim)))
{
*delim = maybe_delim;
return sort_delim;
}
//
// OK doen't look like a delimiter, try for fixed width field:
//
if((sa.size() == sA.size()) && (sa.size() == sc.size()))
{
// note assumes that the fixed width field is less than
// (numeric_limits<charT>::max)(), should be true for all types
// I can't imagine 127 character fields...
*delim = static_cast<charT>(++pos);
return sort_fixed;
}
//
// don't know what it is:
//
*delim = 0;
return sort_unknown;
}
} // namespace BOOST_REGEX_DETAIL_NS
} // namespace boost
#endif

View File

@ -0,0 +1,158 @@
/*
*
* 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 regbase.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares class regbase.
*/
#ifndef BOOST_REGEX_V5_REGBASE_HPP
#define BOOST_REGEX_V5_REGBASE_HPP
namespace boost{
//
// class regbase
// handles error codes and flags
//
class regbase
{
public:
enum flag_type_
{
//
// Divide the flags up into logical groups:
// bits 0-7 indicate main synatx type.
// bits 8-15 indicate syntax subtype.
// bits 16-31 indicate options that are common to all
// regex syntaxes.
// In all cases the default is 0.
//
// Main synatx group:
//
perl_syntax_group = 0, // default
basic_syntax_group = 1, // POSIX basic
literal = 2, // all characters are literals
main_option_type = literal | basic_syntax_group | perl_syntax_group, // everything!
//
// options specific to perl group:
//
no_bk_refs = 1 << 8, // \d not allowed
no_perl_ex = 1 << 9, // disable perl extensions
no_mod_m = 1 << 10, // disable Perl m modifier
mod_x = 1 << 11, // Perl x modifier
mod_s = 1 << 12, // force s modifier on (overrides match_not_dot_newline)
no_mod_s = 1 << 13, // force s modifier off (overrides match_not_dot_newline)
//
// options specific to basic group:
//
no_char_classes = 1 << 8, // [[:CLASS:]] not allowed
no_intervals = 1 << 9, // {x,y} not allowed
bk_plus_qm = 1 << 10, // uses \+ and \?
bk_vbar = 1 << 11, // use \| for alternatives
emacs_ex = 1 << 12, // enables emacs extensions
//
// options common to all groups:
//
no_escape_in_lists = 1 << 16, // '\' not special inside [...]
newline_alt = 1 << 17, // \n is the same as |
no_except = 1 << 18, // no exception on error
failbit = 1 << 19, // error flag
icase = 1 << 20, // characters are matched regardless of case
nocollate = 0, // don't use locale specific collation (deprecated)
collate = 1 << 21, // use locale specific collation
nosubs = 1 << 22, // don't mark sub-expressions
save_subexpression_location = 1 << 23, // save subexpression locations
no_empty_expressions = 1 << 24, // no empty expressions allowed
optimize = 0, // not really supported
basic = basic_syntax_group | collate | no_escape_in_lists,
extended = no_bk_refs | collate | no_perl_ex | no_escape_in_lists,
normal = 0,
emacs = basic_syntax_group | collate | emacs_ex | bk_vbar,
awk = no_bk_refs | collate | no_perl_ex,
grep = basic | newline_alt,
egrep = extended | newline_alt,
sed = basic,
perl = normal,
ECMAScript = normal,
JavaScript = normal,
JScript = normal
};
typedef unsigned int flag_type;
enum restart_info
{
restart_any = 0,
restart_word = 1,
restart_line = 2,
restart_buf = 3,
restart_continue = 4,
restart_lit = 5,
restart_fixed_lit = 6,
restart_count = 7
};
};
//
// provide std lib proposal compatible constants:
//
namespace regex_constants{
enum flag_type_
{
no_except = ::boost::regbase::no_except,
failbit = ::boost::regbase::failbit,
literal = ::boost::regbase::literal,
icase = ::boost::regbase::icase,
nocollate = ::boost::regbase::nocollate,
collate = ::boost::regbase::collate,
nosubs = ::boost::regbase::nosubs,
optimize = ::boost::regbase::optimize,
bk_plus_qm = ::boost::regbase::bk_plus_qm,
bk_vbar = ::boost::regbase::bk_vbar,
no_intervals = ::boost::regbase::no_intervals,
no_char_classes = ::boost::regbase::no_char_classes,
no_escape_in_lists = ::boost::regbase::no_escape_in_lists,
no_mod_m = ::boost::regbase::no_mod_m,
mod_x = ::boost::regbase::mod_x,
mod_s = ::boost::regbase::mod_s,
no_mod_s = ::boost::regbase::no_mod_s,
save_subexpression_location = ::boost::regbase::save_subexpression_location,
no_empty_expressions = ::boost::regbase::no_empty_expressions,
basic = ::boost::regbase::basic,
extended = ::boost::regbase::extended,
normal = ::boost::regbase::normal,
emacs = ::boost::regbase::emacs,
awk = ::boost::regbase::awk,
grep = ::boost::regbase::grep,
egrep = ::boost::regbase::egrep,
sed = basic,
perl = normal,
ECMAScript = normal,
JavaScript = normal,
JScript = normal
};
typedef ::boost::regbase::flag_type syntax_option_type;
} // namespace regex_constants
} // namespace boost
#endif

View File

@ -0,0 +1,106 @@
/*
*
* 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 regex.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares boost::basic_regex<> and associated
* functions and classes. This header is the main
* entry point for the template regex code.
*/
#ifndef BOOST_RE_REGEX_HPP_INCLUDED
#define BOOST_RE_REGEX_HPP_INCLUDED
#ifdef __cplusplus
// what follows is all C++ don't include in C builds!!
#include <boost/regex/config.hpp>
#include <boost/regex/v5/regex_workaround.hpp>
#include <boost/regex_fwd.hpp>
#include <boost/regex/regex_traits.hpp>
#include <boost/regex/v5/error_type.hpp>
#include <boost/regex/v5/match_flags.hpp>
#include <boost/regex/v5/regex_raw_buffer.hpp>
#include <boost/regex/pattern_except.hpp>
#include <boost/regex/v5/char_regex_traits.hpp>
#include <boost/regex/v5/states.hpp>
#include <boost/regex/v5/regbase.hpp>
#include <boost/regex/v5/basic_regex.hpp>
#include <boost/regex/v5/basic_regex_creator.hpp>
#include <boost/regex/v5/basic_regex_parser.hpp>
#include <boost/regex/v5/sub_match.hpp>
#include <boost/regex/v5/regex_format.hpp>
#include <boost/regex/v5/match_results.hpp>
#include <boost/regex/v5/perl_matcher.hpp>
namespace boost{
#ifdef BOOST_REGEX_NO_FWD
typedef basic_regex<char, regex_traits<char> > regex;
#ifndef BOOST_NO_WREGEX
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;
#ifndef BOOST_NO_WREGEX
typedef match_results<const wchar_t*> wcmatch;
typedef match_results<std::wstring::const_iterator> wsmatch;
#endif
} // namespace boost
#include <boost/regex/v5/regex_match.hpp>
#include <boost/regex/v5/regex_search.hpp>
#include <boost/regex/v5/regex_iterator.hpp>
#include <boost/regex/v5/regex_token_iterator.hpp>
#include <boost/regex/v5/regex_grep.hpp>
#include <boost/regex/v5/regex_replace.hpp>
#include <boost/regex/v5/regex_merge.hpp>
#include <boost/regex/v5/regex_split.hpp>
#endif // __cplusplus
#endif // include

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,73 @@
/*
*
* 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 regex_fwd.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Forward declares boost::basic_regex<> and
* associated typedefs.
*/
#ifndef BOOST_REGEX_FWD_HPP_INCLUDED
#define BOOST_REGEX_FWD_HPP_INCLUDED
#ifndef BOOST_REGEX_CONFIG_HPP
#include <boost/regex/config.hpp>
#endif
//
// define BOOST_REGEX_NO_FWD if this
// header doesn't work!
//
#ifdef BOOST_REGEX_NO_FWD
# ifndef BOOST_RE_REGEX_HPP
# include <boost/regex.hpp>
# endif
#else
namespace boost{
template <class charT>
class cpp_regex_traits;
template <class charT>
struct c_regex_traits;
template <class charT>
class w32_regex_traits;
#ifdef BOOST_REGEX_USE_WIN32_LOCALE
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> >
struct regex_traits;
#else
template <class charT, class implementationT = c_regex_traits<charT> >
struct regex_traits;
#endif
template <class charT, class traits = regex_traits<charT> >
class basic_regex;
typedef basic_regex<char, regex_traits<char> > regex;
#ifndef BOOST_NO_WREGEX
typedef basic_regex<wchar_t, regex_traits<wchar_t> > wregex;
#endif
} // namespace boost
#endif // BOOST_REGEX_NO_FWD
#endif

View File

@ -0,0 +1,98 @@
/*
*
* 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 regex_grep.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Provides regex_grep implementation.
*/
#ifndef BOOST_REGEX_V5_REGEX_GREP_HPP
#define BOOST_REGEX_V5_REGEX_GREP_HPP
namespace boost{
//
// regex_grep:
// find all non-overlapping matches within the sequence first last:
//
template <class Predicate, class BidiIterator, class charT, class traits>
inline unsigned int regex_grep(Predicate foo,
BidiIterator first,
BidiIterator last,
const basic_regex<charT, traits>& e,
match_flag_type flags = match_default)
{
if(e.flags() & regex_constants::failbit)
return false;
typedef typename match_results<BidiIterator>::allocator_type match_allocator_type;
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())
{
++count;
if(0 == foo(m))
return count; // caller doesn't want to go on
if(m[0].second == last)
return count; // we've reached the end, don't try and find an extra null match.
if(m.length() == 0)
{
if(m[0].second == last)
return count;
// we found a NULL-match, now try to find
// 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())
{
++count;
if(0 == foo(m))
return count;
}
else
{
// reset match back to where it was:
m = m2;
}
matcher.unsetf((match_not_null | match_continuous) & ~flags);
}
}
return count;
}
//
// regex_grep convenience interfaces:
//
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)
{
return regex_grep(foo, str, str + traits::length(str), e, flags);
}
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)
{
return regex_grep(foo, s.begin(), s.end(), e, flags);
}
} // namespace boost
#endif // BOOST_REGEX_V5_REGEX_GREP_HPP

View File

@ -0,0 +1,173 @@
/*
*
* Copyright (c) 2003
* 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.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Provides regex_iterator implementation.
*/
#ifndef BOOST_REGEX_V5_REGEX_ITERATOR_HPP
#define BOOST_REGEX_V5_REGEX_ITERATOR_HPP
#include <memory>
namespace boost{
template <class BidirectionalIterator,
class charT,
class traits>
class regex_iterator_implementation
{
typedef basic_regex<charT, traits> regex_type;
match_results<BidirectionalIterator> what; // current match
BidirectionalIterator base; // start of sequence
BidirectionalIterator end; // end of sequence
const regex_type re; // the expression
match_flag_type flags; // flags for matching
public:
regex_iterator_implementation(const regex_type* p, BidirectionalIterator last, match_flag_type f)
: base(), end(last), re(*p), flags(f){}
regex_iterator_implementation(const regex_iterator_implementation& other)
:what(other.what), base(other.base), end(other.end), re(other.re), flags(other.flags){}
bool init(BidirectionalIterator first)
{
base = first;
return regex_search(first, end, what, re, flags);
}
bool compare(const regex_iterator_implementation& that)
{
if(this == &that) return true;
return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second);
}
const match_results<BidirectionalIterator>& get()
{ return what; }
bool next()
{
//if(what.prefix().first != what[0].second)
// flags |= match_prev_avail;
BidirectionalIterator next_start = what[0].second;
match_flag_type f(flags);
if(!what.length() || (f & regex_constants::match_posix))
f |= regex_constants::match_not_initial_null;
//if(base != next_start)
// f |= regex_constants::match_not_bob;
bool result = regex_search(next_start, end, what, re, f, base);
if(result)
what.set_base(base);
return result;
}
private:
regex_iterator_implementation& operator=(const regex_iterator_implementation&);
};
template <class BidirectionalIterator,
class charT = typename std::iterator_traits<BidirectionalIterator>::value_type,
class traits = regex_traits<charT> >
class regex_iterator
{
private:
typedef regex_iterator_implementation<BidirectionalIterator, charT, traits> impl;
typedef std::shared_ptr<impl> pimpl;
public:
typedef basic_regex<charT, traits> regex_type;
typedef match_results<BidirectionalIterator> value_type;
typedef typename std::iterator_traits<BidirectionalIterator>::difference_type
difference_type;
typedef const value_type* pointer;
typedef const value_type& reference;
typedef std::forward_iterator_tag iterator_category;
regex_iterator(){}
regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
match_flag_type m = match_default)
: pdata(new impl(&re, b, m))
{
if(!pdata->init(a))
{
pdata.reset();
}
}
regex_iterator(const regex_iterator& that)
: pdata(that.pdata) {}
regex_iterator& operator=(const regex_iterator& that)
{
pdata = that.pdata;
return *this;
}
bool operator==(const regex_iterator& that)const
{
if((pdata.get() == 0) || (that.pdata.get() == 0))
return pdata.get() == that.pdata.get();
return pdata->compare(*(that.pdata.get()));
}
bool operator!=(const regex_iterator& that)const
{ return !(*this == that); }
const value_type& operator*()const
{ return pdata->get(); }
const value_type* operator->()const
{ return &(pdata->get()); }
regex_iterator& operator++()
{
cow();
if(0 == pdata->next())
{
pdata.reset();
}
return *this;
}
regex_iterator operator++(int)
{
regex_iterator result(*this);
++(*this);
return result;
}
private:
pimpl pdata;
void cow()
{
// copy-on-write
if(pdata.get() && !pdata.unique())
{
pdata.reset(new impl(*(pdata.get())));
}
}
};
typedef regex_iterator<const char*> cregex_iterator;
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;
#endif
// make_regex_iterator:
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>
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);
}
} // namespace boost
#endif // BOOST_REGEX_V5_REGEX_ITERATOR_HPP

View File

@ -0,0 +1,92 @@
/*
*
* 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 regex_match.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Regular expression matching algorithms.
* Note this is an internal header file included
* by regex.hpp, do not include on its own.
*/
#ifndef BOOST_REGEX_MATCH_HPP
#define BOOST_REGEX_MATCH_HPP
namespace boost{
//
// proc regex_match
// 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>
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();
}
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)
{
match_results<iterator> m;
return regex_match(first, last, m, e, flags | regex_constants::match_any);
}
//
// query_match convenience interfaces:
//
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,
match_flag_type flags = match_default)
{
return regex_match(str, str + traits::length(str), m, e, flags);
}
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,
match_flag_type flags = match_default)
{
return regex_match(s.begin(), s.end(), m, e, flags);
}
template <class charT, class traits>
inline bool regex_match(const charT* str,
const basic_regex<charT, traits>& e,
match_flag_type flags = match_default)
{
match_results<const charT*> m;
return regex_match(str, str + traits::length(str), m, e, flags | regex_constants::match_any);
}
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)
{
typedef typename std::basic_string<charT, ST, SA>::const_iterator iterator;
match_results<iterator> m;
return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
}
} // namespace boost
#endif // BOOST_REGEX_MATCH_HPP

View File

@ -0,0 +1,71 @@
/*
*
* 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 regex_format.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Provides formatting output routines for search and replace
* operations. Note this is an internal header file included
* by regex.hpp, do not include on its own.
*/
#ifndef BOOST_REGEX_V5_REGEX_MERGE_HPP
#define BOOST_REGEX_V5_REGEX_MERGE_HPP
namespace boost{
template <class OutputIterator, class Iterator, class traits, class charT>
inline OutputIterator regex_merge(OutputIterator out,
Iterator first,
Iterator last,
const basic_regex<charT, traits>& e,
const charT* fmt,
match_flag_type flags = match_default)
{
return regex_replace(out, first, last, e, fmt, flags);
}
template <class OutputIterator, class Iterator, class traits, class charT>
inline OutputIterator regex_merge(OutputIterator out,
Iterator first,
Iterator last,
const basic_regex<charT, traits>& e,
const std::basic_string<charT>& fmt,
match_flag_type flags = match_default)
{
return regex_merge(out, first, last, e, fmt.c_str(), flags);
}
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,
match_flag_type flags = match_default)
{
return regex_replace(s, e, fmt, flags);
}
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,
match_flag_type flags = match_default)
{
return regex_replace(s, e, fmt, flags);
}
} // namespace boost
#endif // BOOST_REGEX_V5_REGEX_MERGE_HPP

View File

@ -0,0 +1,213 @@
/*
*
* 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 regex_raw_buffer.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Raw character buffer for regex code.
* Note this is an internal header file included
* by regex.hpp, do not include on its own.
*/
#ifndef BOOST_REGEX_RAW_BUFFER_HPP
#define BOOST_REGEX_RAW_BUFFER_HPP
#ifndef BOOST_REGEX_CONFIG_HPP
#include <boost/regex/config.hpp>
#endif
#include <algorithm>
#include <cstddef>
namespace boost{
namespace BOOST_REGEX_DETAIL_NS{
struct empty_padding{};
union padding
{
void* p;
unsigned int i;
};
template <int N>
struct padding3
{
enum{
padding_size = 8,
padding_mask = 7
};
};
template<>
struct padding3<2>
{
enum{
padding_size = 2,
padding_mask = 1
};
};
template<>
struct padding3<4>
{
enum{
padding_size = 4,
padding_mask = 3
};
};
template<>
struct padding3<8>
{
enum{
padding_size = 8,
padding_mask = 7
};
};
template<>
struct padding3<16>
{
enum{
padding_size = 16,
padding_mask = 15
};
};
enum{
padding_size = padding3<sizeof(padding)>::padding_size,
padding_mask = padding3<sizeof(padding)>::padding_mask
};
//
// class raw_storage
// basically this is a simplified vector<unsigned char>
// this is used by basic_regex for expression storage
//
class raw_storage
{
public:
typedef std::size_t size_type;
typedef unsigned char* pointer;
private:
pointer last, start, end;
public:
raw_storage();
raw_storage(size_type n);
~raw_storage()
{
::operator delete(start);
}
void resize(size_type n)
{
size_type newsize = start ? last - start : 1024;
while (newsize < n)
newsize *= 2;
size_type datasize = end - start;
// extend newsize to WORD/DWORD boundary:
newsize = (newsize + padding_mask) & ~(padding_mask);
// allocate and copy data:
pointer ptr = static_cast<pointer>(::operator new(newsize));
BOOST_REGEX_NOEH_ASSERT(ptr)
if (start)
std::memcpy(ptr, start, datasize);
// get rid of old buffer:
::operator delete(start);
// and set up pointers:
start = ptr;
end = ptr + datasize;
last = ptr + newsize;
}
void* extend(size_type n)
{
if(size_type(last - end) < n)
resize(n + (end - start));
pointer result = end;
end += n;
return result;
}
void* insert(size_type pos, size_type n)
{
BOOST_REGEX_ASSERT(pos <= size_type(end - start));
if (size_type(last - end) < n)
resize(n + (end - start));
void* result = start + pos;
std::memmove(start + pos + n, start + pos, (end - start) - pos);
end += n;
return result;
}
size_type size()
{
return size_type(end - start);
}
size_type capacity()
{
return size_type(last - start);
}
void* data()const
{
return start;
}
size_type index(void* ptr)
{
return size_type(static_cast<pointer>(ptr) - static_cast<pointer>(data()));
}
void clear()
{
end = start;
}
void align()
{
// move end up to a boundary:
end = start + (((end - start) + padding_mask) & ~padding_mask);
}
void swap(raw_storage& that)
{
std::swap(start, that.start);
std::swap(end, that.end);
std::swap(last, that.last);
}
};
inline raw_storage::raw_storage()
{
last = start = end = 0;
}
inline raw_storage::raw_storage(size_type n)
{
start = end = static_cast<pointer>(::operator new(n));
BOOST_REGEX_NOEH_ASSERT(start)
last = start + n;
}
} // namespace BOOST_REGEX_DETAIL_NS
} // namespace boost
#endif

View File

@ -0,0 +1,77 @@
/*
*
* Copyright (c) 1998-2009
* 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_format.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Provides formatting output routines for search and replace
* operations. Note this is an internal header file included
* by regex.hpp, do not include on its own.
*/
#ifndef BOOST_REGEX_V5_REGEX_REPLACE_HPP
#define BOOST_REGEX_V5_REGEX_REPLACE_HPP
namespace boost{
template <class OutputIterator, class BidirectionalIterator, class traits, class charT, class Formatter>
OutputIterator regex_replace(OutputIterator out,
BidirectionalIterator first,
BidirectionalIterator last,
const basic_regex<charT, traits>& e,
Formatter fmt,
match_flag_type flags = match_default)
{
regex_iterator<BidirectionalIterator, charT, traits> i(first, last, e, flags);
regex_iterator<BidirectionalIterator, charT, traits> j;
if(i == j)
{
if(!(flags & regex_constants::format_no_copy))
out = BOOST_REGEX_DETAIL_NS::copy(first, last, out);
}
else
{
BidirectionalIterator last_m(first);
while(i != j)
{
if(!(flags & regex_constants::format_no_copy))
out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out);
out = i->format(out, fmt, flags, e);
last_m = (*i)[0].second;
if(flags & regex_constants::format_first_only)
break;
++i;
}
if(!(flags & regex_constants::format_no_copy))
out = BOOST_REGEX_DETAIL_NS::copy(last_m, last, out);
}
return out;
}
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,
match_flag_type flags = match_default)
{
std::basic_string<charT> result;
BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result);
regex_replace(i, s.begin(), s.end(), e, fmt, flags);
return result;
}
} // namespace boost
#endif // BOOST_REGEX_V5_REGEX_REPLACE_HPP

View File

@ -0,0 +1,103 @@
/*
*
* 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 regex_search.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Provides regex_search implementation.
*/
#ifndef BOOST_REGEX_V5_REGEX_SEARCH_HPP
#define BOOST_REGEX_V5_REGEX_SEARCH_HPP
namespace boost{
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,
match_flag_type flags = match_default)
{
return regex_search(first, last, m, e, flags, first);
}
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,
match_flag_type flags,
BidiIterator base)
{
if(e.flags() & regex_constants::failbit)
return false;
BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, base);
return matcher.find();
}
//
// regex_search convenience interfaces:
//
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,
match_flag_type flags = match_default)
{
return regex_search(str, str + traits::length(str), m, e, flags);
}
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,
match_flag_type flags = match_default)
{
return regex_search(s.begin(), s.end(), m, e, flags);
}
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)
{
if(e.flags() & regex_constants::failbit)
return false;
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();
}
template <class charT, class traits>
inline bool regex_search(const charT* str,
const basic_regex<charT, traits>& e,
match_flag_type flags = match_default)
{
return regex_search(str, str + traits::length(str), e, flags);
}
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)
{
return regex_search(s.begin(), s.end(), e, flags);
}
} // namespace boost
#endif // BOOST_REGEX_V5_REGEX_SEARCH_HPP

View File

@ -0,0 +1,152 @@
/*
*
* 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 regex_split.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Implements regex_split and associated functions.
* Note this is an internal header file included
* by regex.hpp, do not include on its own.
*/
#ifndef BOOST_REGEX_SPLIT_HPP
#define BOOST_REGEX_SPLIT_HPP
namespace boost{
#ifdef BOOST_REGEX_MSVC
# pragma warning(push)
#if BOOST_REGEX_MSVC < 1910
#pragma warning(disable:4800)
#endif
#endif
namespace BOOST_REGEX_DETAIL_NS{
template <class charT>
const basic_regex<charT>& get_default_expression(charT)
{
static const charT expression_text[4] = { '\\', 's', '+', '\00', };
static const basic_regex<charT> e(expression_text);
return e;
}
template <class OutputIterator, class charT, class Traits1, class Alloc1>
class split_pred
{
typedef std::basic_string<charT, Traits1, Alloc1> string_type;
typedef typename string_type::const_iterator iterator_type;
iterator_type* p_last;
OutputIterator* p_out;
std::size_t* p_max;
std::size_t initial_max;
public:
split_pred(iterator_type* a, OutputIterator* b, std::size_t* c)
: p_last(a), p_out(b), p_max(c), initial_max(*c) {}
bool operator()(const match_results<iterator_type>& what);
};
template <class OutputIterator, class charT, class Traits1, class Alloc1>
bool split_pred<OutputIterator, charT, Traits1, Alloc1>::operator()
(const match_results<iterator_type>& what)
{
*p_last = what[0].second;
if(what.size() > 1)
{
// output sub-expressions only:
for(unsigned i = 1; i < what.size(); ++i)
{
*(*p_out) = what.str(i);
++(*p_out);
if(0 == --*p_max) return false;
}
return *p_max != 0;
}
else
{
// output $` only if it's not-null or not at the start of the input:
const sub_match<iterator_type>& sub = what[-1];
if((sub.first != sub.second) || (*p_max != initial_max))
{
*(*p_out) = sub.str();
++(*p_out);
return --*p_max;
}
}
//
// initial null, do nothing:
return true;
}
} // namespace BOOST_REGEX_DETAIL_NS
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,
match_flag_type flags,
std::size_t max_split)
{
typedef typename std::basic_string<charT, Traits1, Alloc1>::const_iterator ci_t;
//typedef typename match_results<ci_t>::allocator_type match_allocator;
ci_t last = s.begin();
std::size_t init_size = max_split;
BOOST_REGEX_DETAIL_NS::split_pred<OutputIterator, charT, Traits1, Alloc1> pred(&last, &out, &max_split);
ci_t i, j;
i = s.begin();
j = s.end();
regex_grep(pred, i, j, e, flags);
//
// if there is still input left, do a final push as long as max_split
// is not exhausted, and we're not splitting sub-expressions rather
// than whitespace:
if(max_split && (last != s.end()) && (e.mark_count() == 0))
{
*out = std::basic_string<charT, Traits1, Alloc1>((ci_t)last, (ci_t)s.end());
++out;
last = s.end();
--max_split;
}
//
// delete from the string everything that has been processed so far:
s.erase(0, last - s.begin());
//
// return the number of new records pushed:
return init_size - max_split;
}
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,
match_flag_type flags = match_default)
{
return regex_split(out, s, e, flags, UINT_MAX);
}
template <class OutputIterator, class charT, class Traits1, class Alloc1>
inline std::size_t regex_split(OutputIterator out,
std::basic_string<charT, Traits1, Alloc1>& s)
{
return regex_split(out, s, BOOST_REGEX_DETAIL_NS::get_default_expression(charT(0)), match_default, UINT_MAX);
}
#ifdef BOOST_REGEX_MSVC
# pragma warning(pop)
#endif
} // namespace boost
#endif

View File

@ -0,0 +1,255 @@
/*
*
* Copyright (c) 2003
* 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.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Provides regex_token_iterator implementation.
*/
#ifndef BOOST_REGEX_V5_REGEX_TOKEN_ITERATOR_HPP
#define BOOST_REGEX_V5_REGEX_TOKEN_ITERATOR_HPP
#include <memory>
namespace boost{
template <class BidirectionalIterator,
class charT,
class traits>
class regex_token_iterator_implementation
{
typedef basic_regex<charT, traits> regex_type;
typedef sub_match<BidirectionalIterator> value_type;
match_results<BidirectionalIterator> what; // current match
BidirectionalIterator base; // start of search area
BidirectionalIterator end; // end of search area
const regex_type re; // the expression
match_flag_type flags; // match flags
value_type result; // the current string result
int N; // the current sub-expression being enumerated
std::vector<int> subs; // the sub-expressions to enumerate
public:
regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f)
: end(last), re(*p), flags(f), N(0){ subs.push_back(sub); }
regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector<int>& v, match_flag_type f)
: end(last), re(*p), flags(f), N(0), subs(v){}
template <std::size_t CN>
regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const int (&submatches)[CN], match_flag_type f)
: end(last), re(*p), flags(f), N(0)
{
for(std::size_t i = 0; i < CN; ++i)
{
subs.push_back(submatches[i]);
}
}
regex_token_iterator_implementation(const regex_token_iterator_implementation& other) = default;
bool init(BidirectionalIterator first)
{
N = 0;
base = first;
if(regex_search(first, end, what, re, flags, base) == true)
{
N = 0;
result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]);
return true;
}
else if((subs[N] == -1) && (first != end))
{
result.first = first;
result.second = end;
result.matched = (first != end);
N = -1;
return true;
}
return false;
}
bool compare(const regex_token_iterator_implementation& that)
{
if(this == &that) return true;
return (&re.get_data() == &that.re.get_data())
&& (end == that.end)
&& (flags == that.flags)
&& (N == that.N)
&& (what[0].first == that.what[0].first)
&& (what[0].second == that.what[0].second);
}
const value_type& get()
{ return result; }
bool next()
{
if(N == -1)
return false;
if(N+1 < (int)subs.size())
{
++N;
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
return true;
}
//if(what.prefix().first != what[0].second)
// flags |= /*match_prev_avail |*/ regex_constants::match_not_bob;
BidirectionalIterator last_end(what[0].second);
if(regex_search(last_end, end, what, re, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags), base))
{
N =0;
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
return true;
}
else if((last_end != end) && (subs[0] == -1))
{
N =-1;
result.first = last_end;
result.second = end;
result.matched = (last_end != end);
return true;
}
return false;
}
private:
regex_token_iterator_implementation& operator=(const regex_token_iterator_implementation&);
};
template <class BidirectionalIterator,
class charT = typename std::iterator_traits<BidirectionalIterator>::value_type,
class traits = regex_traits<charT> >
class regex_token_iterator
{
private:
typedef regex_token_iterator_implementation<BidirectionalIterator, charT, traits> impl;
typedef std::shared_ptr<impl> pimpl;
public:
typedef basic_regex<charT, traits> regex_type;
typedef sub_match<BidirectionalIterator> value_type;
typedef typename std::iterator_traits<BidirectionalIterator>::difference_type
difference_type;
typedef const value_type* pointer;
typedef const value_type& reference;
typedef std::forward_iterator_tag iterator_category;
regex_token_iterator(){}
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
int submatch = 0, match_flag_type m = match_default)
: pdata(new impl(&re, b, submatch, m))
{
if(!pdata->init(a))
pdata.reset();
}
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
const std::vector<int>& submatches, match_flag_type m = match_default)
: pdata(new impl(&re, b, submatches, m))
{
if(!pdata->init(a))
pdata.reset();
}
template <std::size_t N>
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
const int (&submatches)[N], match_flag_type m = match_default)
: pdata(new impl(&re, b, submatches, m))
{
if(!pdata->init(a))
pdata.reset();
}
regex_token_iterator(const regex_token_iterator& that)
: pdata(that.pdata) {}
regex_token_iterator& operator=(const regex_token_iterator& that)
{
pdata = that.pdata;
return *this;
}
bool operator==(const regex_token_iterator& that)const
{
if((pdata.get() == 0) || (that.pdata.get() == 0))
return pdata.get() == that.pdata.get();
return pdata->compare(*(that.pdata.get()));
}
bool operator!=(const regex_token_iterator& that)const
{ return !(*this == that); }
const value_type& operator*()const
{ return pdata->get(); }
const value_type* operator->()const
{ return &(pdata->get()); }
regex_token_iterator& operator++()
{
cow();
if(0 == pdata->next())
{
pdata.reset();
}
return *this;
}
regex_token_iterator operator++(int)
{
regex_token_iterator result(*this);
++(*this);
return result;
}
private:
pimpl pdata;
void cow()
{
// copy-on-write
if(pdata.get() && !pdata.unique())
{
pdata.reset(new impl(*(pdata.get())));
}
}
};
typedef regex_token_iterator<const char*> cregex_token_iterator;
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;
#endif
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>
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>
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>
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>
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>
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);
}
} // namespace boost
#endif // BOOST_REGEX_V5_REGEX_TOKEN_ITERATOR_HPP

View File

@ -0,0 +1,130 @@
/*
*
* Copyright (c) 2003
* 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_traits.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares regular expression traits classes.
*/
#ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED
#define BOOST_REGEX_TRAITS_HPP_INCLUDED
#include <boost/regex/config.hpp>
#include <boost/regex/v5/regex_workaround.hpp>
#include <boost/regex/v5/syntax_type.hpp>
#include <boost/regex/v5/error_type.hpp>
#include <boost/regex/v5/regex_traits_defaults.hpp>
#include <boost/regex/v5/cpp_regex_traits.hpp>
#include <boost/regex/v5/c_regex_traits.hpp>
#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
# include <boost/regex/v5/w32_regex_traits.hpp>
#endif
#include <boost/regex_fwd.hpp>
namespace boost{
template <class charT, class implementationT >
struct regex_traits : public implementationT
{
regex_traits() : implementationT() {}
};
//
// class regex_traits_wrapper.
// this is what our implementation will actually store;
// it provides default implementations of the "optional"
// interfaces that we support, in addition to the
// required "standard" ones:
//
namespace BOOST_REGEX_DETAIL_NS{
template <class T>
struct has_boost_extensions_tag
{
template <class U>
static double checker(U*, typename U::boost_extensions_tag* = nullptr);
static char checker(...);
static T* get();
static const bool value = sizeof(checker(get())) > 1;
};
template <class BaseT>
struct default_wrapper : public BaseT
{
typedef typename BaseT::char_type char_type;
std::string error_string(::boost::regex_constants::error_type e)const
{
return ::boost::BOOST_REGEX_DETAIL_NS::get_default_error_string(e);
}
::boost::regex_constants::syntax_type syntax_type(char_type c)const
{
return (char_type(c & 0x7f) == c) ? get_default_syntax_type(static_cast<char>(c)) : ::boost::regex_constants::syntax_char;
}
::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c)const
{
return (char_type(c & 0x7f) == c) ? get_default_escape_syntax_type(static_cast<char>(c)) : ::boost::regex_constants::escape_type_identity;
}
std::intmax_t toi(const char_type*& p1, const char_type* p2, int radix)const
{
return ::boost::BOOST_REGEX_DETAIL_NS::global_toi(p1, p2, radix, *this);
}
char_type translate(char_type c, bool icase)const
{
return (icase ? this->translate_nocase(c) : this->translate(c));
}
char_type translate(char_type c)const
{
return BaseT::translate(c);
}
char_type tolower(char_type c)const
{
return ::boost::BOOST_REGEX_DETAIL_NS::global_lower(c);
}
char_type toupper(char_type c)const
{
return ::boost::BOOST_REGEX_DETAIL_NS::global_upper(c);
}
};
template <class BaseT, bool has_extensions>
struct compute_wrapper_base
{
typedef BaseT type;
};
template <class BaseT>
struct compute_wrapper_base<BaseT, false>
{
typedef default_wrapper<BaseT> type;
};
} // namespace BOOST_REGEX_DETAIL_NS
template <class BaseT>
struct regex_traits_wrapper
: public ::boost::BOOST_REGEX_DETAIL_NS::compute_wrapper_base<
BaseT,
::boost::BOOST_REGEX_DETAIL_NS::has_boost_extensions_tag<BaseT>::value
>::type
{
regex_traits_wrapper(){}
private:
regex_traits_wrapper(const regex_traits_wrapper&);
regex_traits_wrapper& operator=(const regex_traits_wrapper&);
};
} // namespace boost
#endif // include

View File

@ -0,0 +1,159 @@
/*
*
* Copyright (c) 1998-2005
* 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_workarounds.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares Misc workarounds.
*/
#ifndef BOOST_REGEX_WORKAROUND_HPP
#define BOOST_REGEX_WORKAROUND_HPP
#include <boost/regex/config.hpp>
#include <algorithm>
#include <stdexcept>
#include <cstring>
#ifndef BOOST_REGEX_STANDALONE
#include <boost/detail/workaround.hpp>
#include <boost/throw_exception.hpp>
#endif
#ifdef BOOST_REGEX_NO_BOOL
# define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>((x) ? true : false)
#else
# define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>(x)
#endif
/*****************************************************************************
*
* helper functions pointer_construct/pointer_destroy:
*
****************************************************************************/
#ifdef __cplusplus
namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
#ifdef BOOST_REGEX_MSVC
#pragma warning (push)
#pragma warning (disable : 4100)
#endif
template <class T>
inline void pointer_destroy(T* p)
{ p->~T(); (void)p; }
#ifdef BOOST_REGEX_MSVC
#pragma warning (pop)
#endif
template <class T>
inline void pointer_construct(T* p, const T& t)
{ new (p) T(t); }
}} // namespaces
#endif
/*****************************************************************************
*
* helper function copy:
*
****************************************************************************/
#if defined(BOOST_WORKAROUND)
#if BOOST_WORKAROUND(BOOST_REGEX_MSVC, >= 1400) && defined(__STDC_WANT_SECURE_LIB__) && __STDC_WANT_SECURE_LIB__
#define BOOST_REGEX_HAS_STRCPY_S
#endif
#endif
#ifdef __cplusplus
namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
#if defined(BOOST_REGEX_MSVC) && (BOOST_REGEX_MSVC < 1910)
//
// MSVC 10 will either emit warnings or else refuse to compile
// code that makes perfectly legitimate use of std::copy, when
// the OutputIterator type is a user-defined class (apparently all user
// defined iterators are "unsafe"). What's more Microsoft have removed their
// non-standard "unchecked" versions, even though they are still in the MS
// documentation!! Work around this as best we can:
//
template<class InputIterator, class OutputIterator>
inline OutputIterator copy(
InputIterator first,
InputIterator last,
OutputIterator dest
)
{
while (first != last)
*dest++ = *first++;
return dest;
}
#else
using std::copy;
#endif
#if defined(BOOST_REGEX_HAS_STRCPY_S)
// use safe versions of strcpy etc:
using ::strcpy_s;
using ::strcat_s;
#else
inline std::size_t strcpy_s(
char *strDestination,
std::size_t sizeInBytes,
const char *strSource
)
{
std::size_t lenSourceWithNull = std::strlen(strSource) + 1;
if (lenSourceWithNull > sizeInBytes)
return 1;
std::memcpy(strDestination, strSource, lenSourceWithNull);
return 0;
}
inline std::size_t strcat_s(
char *strDestination,
std::size_t sizeInBytes,
const char *strSource
)
{
std::size_t lenSourceWithNull = std::strlen(strSource) + 1;
std::size_t lenDestination = std::strlen(strDestination);
if (lenSourceWithNull + lenDestination > sizeInBytes)
return 1;
std::memcpy(strDestination + lenDestination, strSource, lenSourceWithNull);
return 0;
}
#endif
inline void overflow_error_if_not_zero(std::size_t i)
{
if(i)
{
std::overflow_error e("String buffer too small");
#ifndef BOOST_REGEX_STANDALONE
boost::throw_exception(e);
#else
throw e;
#endif
}
}
}} // namespaces
#endif // __cplusplus
#endif // include guard

View File

@ -0,0 +1,299 @@
/*
*
* 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 states.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares internal state machine structures.
*/
#ifndef BOOST_REGEX_V5_STATES_HPP
#define BOOST_REGEX_V5_STATES_HPP
namespace boost{
namespace BOOST_REGEX_DETAIL_NS{
/*** mask_type *******************************************************
Whenever we have a choice of two alternatives, we use an array of bytes
to indicate which of the two alternatives it is possible to take for any
given input character. If mask_take is set, then we can take the next
state, and if mask_skip is set then we can take the alternative.
***********************************************************************/
enum mask_type
{
mask_take = 1,
mask_skip = 2,
mask_init = 4,
mask_any = mask_skip | mask_take,
mask_all = mask_any
};
/*** helpers **********************************************************
These helpers let us use function overload resolution to detect whether
we have narrow or wide character strings:
***********************************************************************/
struct _narrow_type{};
struct _wide_type{};
template <class charT> struct is_byte;
template<> struct is_byte<char> { typedef _narrow_type width_type; };
template<> struct is_byte<unsigned char>{ typedef _narrow_type width_type; };
template<> struct is_byte<signed char> { typedef _narrow_type width_type; };
template <class charT> struct is_byte { typedef _wide_type width_type; };
/*** enum syntax_element_type ******************************************
Every record in the state machine falls into one of the following types:
***********************************************************************/
enum syntax_element_type
{
// start of a marked sub-expression, or perl-style (?...) extension
syntax_element_startmark = 0,
// end of a marked sub-expression, or perl-style (?...) extension
syntax_element_endmark = syntax_element_startmark + 1,
// any sequence of literal characters
syntax_element_literal = syntax_element_endmark + 1,
// start of line assertion: ^
syntax_element_start_line = syntax_element_literal + 1,
// end of line assertion $
syntax_element_end_line = syntax_element_start_line + 1,
// match any character: .
syntax_element_wild = syntax_element_end_line + 1,
// end of expression: we have a match when we get here
syntax_element_match = syntax_element_wild + 1,
// perl style word boundary: \b
syntax_element_word_boundary = syntax_element_match + 1,
// perl style within word boundary: \B
syntax_element_within_word = syntax_element_word_boundary + 1,
// start of word assertion: \<
syntax_element_word_start = syntax_element_within_word + 1,
// end of word assertion: \>
syntax_element_word_end = syntax_element_word_start + 1,
// start of buffer assertion: \`
syntax_element_buffer_start = syntax_element_word_end + 1,
// end of buffer assertion: \'
syntax_element_buffer_end = syntax_element_buffer_start + 1,
// backreference to previously matched sub-expression
syntax_element_backref = syntax_element_buffer_end + 1,
// either a wide character set [..] or one with multicharacter collating elements:
syntax_element_long_set = syntax_element_backref + 1,
// narrow character set: [...]
syntax_element_set = syntax_element_long_set + 1,
// jump to a new state in the machine:
syntax_element_jump = syntax_element_set + 1,
// choose between two production states:
syntax_element_alt = syntax_element_jump + 1,
// a repeat
syntax_element_rep = syntax_element_alt + 1,
// match a combining character sequence
syntax_element_combining = syntax_element_rep + 1,
// perl style soft buffer end: \z
syntax_element_soft_buffer_end = syntax_element_combining + 1,
// perl style continuation: \G
syntax_element_restart_continue = syntax_element_soft_buffer_end + 1,
// single character repeats:
syntax_element_dot_rep = syntax_element_restart_continue + 1,
syntax_element_char_rep = syntax_element_dot_rep + 1,
syntax_element_short_set_rep = syntax_element_char_rep + 1,
syntax_element_long_set_rep = syntax_element_short_set_rep + 1,
// a backstep for lookbehind repeats:
syntax_element_backstep = syntax_element_long_set_rep + 1,
// an assertion that a mark was matched:
syntax_element_assert_backref = syntax_element_backstep + 1,
syntax_element_toggle_case = syntax_element_assert_backref + 1,
// a recursive expression:
syntax_element_recurse = syntax_element_toggle_case + 1,
// Verbs:
syntax_element_fail = syntax_element_recurse + 1,
syntax_element_accept = syntax_element_fail + 1,
syntax_element_commit = syntax_element_accept + 1,
syntax_element_then = syntax_element_commit + 1
};
#ifdef BOOST_REGEX_DEBUG
// dwa 09/26/00 - This is needed to suppress warnings about an ambiguous conversion
std::ostream& operator<<(std::ostream&, syntax_element_type);
#endif
struct re_syntax_base;
/*** union offset_type ************************************************
Points to another state in the machine. During machine construction
we use integral offsets, but these are converted to pointers before
execution of the machine.
***********************************************************************/
union offset_type
{
re_syntax_base* p;
std::ptrdiff_t i;
};
/*** struct re_syntax_base ********************************************
Base class for all states in the machine.
***********************************************************************/
struct re_syntax_base
{
syntax_element_type type; // what kind of state this is
offset_type next; // next state in the machine
};
/*** struct re_brace **************************************************
A marked parenthesis.
***********************************************************************/
struct re_brace : public re_syntax_base
{
// The index to match, can be zero (don't mark the sub-expression)
// or negative (for perl style (?...) extensions):
int index;
bool icase;
};
/*** struct re_dot **************************************************
Match anything.
***********************************************************************/
enum
{
dont_care = 1,
force_not_newline = 0,
force_newline = 2,
test_not_newline = 2,
test_newline = 3
};
struct re_dot : public re_syntax_base
{
unsigned char mask;
};
/*** struct re_literal ************************************************
A string of literals, following this structure will be an
array of characters: charT[length]
***********************************************************************/
struct re_literal : public re_syntax_base
{
unsigned int length;
};
/*** struct re_case ************************************************
Indicates whether we are moving to a case insensive block or not
***********************************************************************/
struct re_case : public re_syntax_base
{
bool icase;
};
/*** struct re_set_long ***********************************************
A wide character set of characters, following this structure will be
an array of type charT:
First csingles null-terminated strings
Then 2 * cranges NULL terminated strings
Then cequivalents NULL terminated strings
***********************************************************************/
template <class mask_type>
struct re_set_long : public re_syntax_base
{
unsigned int csingles, cranges, cequivalents;
mask_type cclasses;
mask_type cnclasses;
bool isnot;
bool singleton;
};
/*** struct re_set ****************************************************
A set of narrow-characters, matches any of _map which is none-zero
***********************************************************************/
struct re_set : public re_syntax_base
{
unsigned char _map[1 << CHAR_BIT];
};
/*** struct re_jump ***************************************************
Jump to a new location in the machine (not next).
***********************************************************************/
struct re_jump : public re_syntax_base
{
offset_type alt; // location to jump to
};
/*** struct re_alt ***************************************************
Jump to a new location in the machine (possibly next).
***********************************************************************/
struct re_alt : public re_jump
{
unsigned char _map[1 << CHAR_BIT]; // which characters can take the jump
unsigned int can_be_null; // true if we match a NULL string
};
/*** struct re_repeat *************************************************
Repeat a section of the machine
***********************************************************************/
struct re_repeat : public re_alt
{
std::size_t min, max; // min and max allowable repeats
int state_id; // Unique identifier for this repeat
bool leading; // True if this repeat is at the start of the machine (lets us optimize some searches)
bool greedy; // True if this is a greedy repeat
};
/*** struct re_recurse ************************************************
Recurse to a particular subexpression.
**********************************************************************/
struct re_recurse : public re_jump
{
int state_id; // identifier of first nested repeat within the recursion.
};
/*** struct re_commit *************************************************
Used for the PRUNE, SKIP and COMMIT verbs which basically differ only in what happens
if no match is found and we start searching forward.
**********************************************************************/
enum commit_type
{
commit_prune,
commit_skip,
commit_commit
};
struct re_commit : public re_syntax_base
{
commit_type action;
};
/*** enum re_jump_size_type *******************************************
Provides compiled size of re_jump structure (allowing for trailing alignment).
We provide this so we know how manybytes to insert when constructing the machine
(The value of padding_mask is defined in regex_raw_buffer.hpp).
***********************************************************************/
enum re_jump_size_type
{
re_jump_size = (sizeof(re_jump) + padding_mask) & ~(padding_mask),
re_repeater_size = (sizeof(re_repeat) + padding_mask) & ~(padding_mask),
re_alt_size = (sizeof(re_alt) + padding_mask) & ~(padding_mask)
};
/*** proc re_is_set_member *********************************************
Forward declaration: we'll need this one later...
***********************************************************************/
template<class charT, class traits>
struct regex_data;
template <class iterator, class charT, class traits_type, class char_classT>
iterator re_is_set_member(iterator next,
iterator last,
const re_set_long<char_classT>* set_,
const regex_data<charT, traits_type>& e, bool icase);
} // namespace BOOST_REGEX_DETAIL_NS
} // namespace boost
#endif

View File

@ -0,0 +1,382 @@
/*
*
* 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 sub_match.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares template class sub_match.
*/
#ifndef BOOST_REGEX_V5_SUB_MATCH_HPP
#define BOOST_REGEX_V5_SUB_MATCH_HPP
namespace boost{
template <class BidiIterator>
struct sub_match : public std::pair<BidiIterator, BidiIterator>
{
typedef typename std::iterator_traits<BidiIterator>::value_type value_type;
typedef typename std::iterator_traits<BidiIterator>::difference_type difference_type;
typedef BidiIterator iterator_type;
typedef BidiIterator iterator;
typedef BidiIterator const_iterator;
bool matched;
sub_match() : std::pair<BidiIterator, BidiIterator>(), matched(false) {}
sub_match(BidiIterator i) : std::pair<BidiIterator, BidiIterator>(i, i), matched(false) {}
template <class T, class A>
operator std::basic_string<value_type, T, A> ()const
{
return matched ? std::basic_string<value_type, T, A>(this->first, this->second) : std::basic_string<value_type, T, A>();
}
difference_type length()const
{
difference_type n = matched ? std::distance((BidiIterator)this->first, (BidiIterator)this->second) : 0;
return n;
}
std::basic_string<value_type> str()const
{
std::basic_string<value_type> result;
if(matched)
{
std::size_t len = std::distance((BidiIterator)this->first, (BidiIterator)this->second);
result.reserve(len);
BidiIterator i = this->first;
while(i != this->second)
{
result.append(1, *i);
++i;
}
}
return result;
}
int compare(const sub_match& s)const
{
if(matched != s.matched)
return static_cast<int>(matched) - static_cast<int>(s.matched);
return str().compare(s.str());
}
int compare(const std::basic_string<value_type>& s)const
{
return str().compare(s);
}
int compare(const value_type* p)const
{
return str().compare(p);
}
bool operator==(const sub_match& that)const
{ return compare(that) == 0; }
bool operator !=(const sub_match& that)const
{ return compare(that) != 0; }
bool operator<(const sub_match& that)const
{ return compare(that) < 0; }
bool operator>(const sub_match& that)const
{ return compare(that) > 0; }
bool operator<=(const sub_match& that)const
{ return compare(that) <= 0; }
bool operator>=(const sub_match& that)const
{ return compare(that) >= 0; }
#ifdef BOOST_REGEX_MATCH_EXTRA
typedef std::vector<sub_match<BidiIterator> > capture_sequence_type;
const capture_sequence_type& captures()const
{
if(!m_captures)
m_captures.reset(new capture_sequence_type());
return *m_captures;
}
//
// Private implementation API: DO NOT USE!
//
capture_sequence_type& get_captures()const
{
if(!m_captures)
m_captures.reset(new capture_sequence_type());
return *m_captures;
}
private:
mutable std::unique_ptr<capture_sequence_type> m_captures;
public:
#endif
sub_match(const sub_match& that, bool
#ifdef BOOST_REGEX_MATCH_EXTRA
deep_copy
#endif
= true
)
: std::pair<BidiIterator, BidiIterator>(that),
matched(that.matched)
{
#ifdef BOOST_REGEX_MATCH_EXTRA
if(that.m_captures)
if(deep_copy)
m_captures.reset(new capture_sequence_type(*(that.m_captures)));
#endif
}
sub_match& operator=(const sub_match& that)
{
this->first = that.first;
this->second = that.second;
matched = that.matched;
#ifdef BOOST_REGEX_MATCH_EXTRA
if(that.m_captures)
get_captures() = *(that.m_captures);
#endif
return *this;
}
//
// Make this type a range, for both Boost.Range, and C++11:
//
BidiIterator begin()const { return this->first; }
BidiIterator end()const { return this->second; }
};
typedef sub_match<const char*> csub_match;
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;
#endif
// comparison to std::basic_string<> part 1:
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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)
{
std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result;
result.reserve(s.size() + m.length() + 1);
return result.append(s).append(m.first, m.second);
}
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)
{
std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result;
result.reserve(s.size() + m.length() + 1);
return result.append(m.first, m.second).append(s);
}
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)
{
std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> result;
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>
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)
{
std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> result;
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>
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)
{
std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> result;
result.reserve(m.length() + 2);
return result.append(1, s).append(m.first, m.second);
}
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)
{
std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> result;
result.reserve(m.length() + 2);
return result.append(m.first, m.second).append(1, s);
}
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)
{
std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> result;
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>
std::basic_ostream<charT, traits>&
operator << (std::basic_ostream<charT, traits>& os,
const sub_match<RandomAccessIterator>& s)
{
return (os << s.str());
}
} // namespace boost
#endif

View File

@ -0,0 +1,105 @@
/*
*
* Copyright (c) 2003
* 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 syntax_type.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Declares regular expression synatx type enumerator.
*/
#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP
#define BOOST_REGEX_SYNTAX_TYPE_HPP
namespace boost{
namespace regex_constants{
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;
// extensions:
static const syntax_type syntax_hash = 13;
static const syntax_type syntax_newline = 26;
// escapes:
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;
// 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
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
static const escape_syntax_type syntax_max = 60;
}
}
#endif

View File

@ -0,0 +1,177 @@
/*
*
* Copyright (c) 2003
* 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 u32regex_iterator.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Provides u32regex_iterator implementation.
*/
#ifndef BOOST_REGEX_V5_U32REGEX_ITERATOR_HPP
#define BOOST_REGEX_V5_U32REGEX_ITERATOR_HPP
namespace boost{
template <class BidirectionalIterator>
class u32regex_iterator_implementation
{
typedef u32regex regex_type;
match_results<BidirectionalIterator> what; // current match
BidirectionalIterator base; // start of sequence
BidirectionalIterator end; // end of sequence
const regex_type re; // the expression
match_flag_type flags; // flags for matching
public:
u32regex_iterator_implementation(const regex_type* p, BidirectionalIterator last, match_flag_type f)
: base(), end(last), re(*p), flags(f){}
bool init(BidirectionalIterator first)
{
base = first;
return u32regex_search(first, end, what, re, flags, base);
}
bool compare(const u32regex_iterator_implementation& that)
{
if(this == &that) return true;
return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second);
}
const match_results<BidirectionalIterator>& get()
{ return what; }
bool next()
{
//if(what.prefix().first != what[0].second)
// flags |= match_prev_avail;
BidirectionalIterator next_start = what[0].second;
match_flag_type f(flags);
if(!what.length())
f |= regex_constants::match_not_initial_null;
//if(base != next_start)
// f |= regex_constants::match_not_bob;
bool result = u32regex_search(next_start, end, what, re, f, base);
if(result)
what.set_base(base);
return result;
}
private:
u32regex_iterator_implementation& operator=(const u32regex_iterator_implementation&);
};
template <class BidirectionalIterator>
class u32regex_iterator
{
private:
typedef u32regex_iterator_implementation<BidirectionalIterator> impl;
typedef std::shared_ptr<impl> pimpl;
public:
typedef u32regex regex_type;
typedef match_results<BidirectionalIterator> value_type;
typedef typename std::iterator_traits<BidirectionalIterator>::difference_type
difference_type;
typedef const value_type* pointer;
typedef const value_type& reference;
typedef std::forward_iterator_tag iterator_category;
u32regex_iterator(){}
u32regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
match_flag_type m = match_default)
: pdata(new impl(&re, b, m))
{
if(!pdata->init(a))
{
pdata.reset();
}
}
u32regex_iterator(const u32regex_iterator& that)
: pdata(that.pdata) {}
u32regex_iterator& operator=(const u32regex_iterator& that)
{
pdata = that.pdata;
return *this;
}
bool operator==(const u32regex_iterator& that)const
{
if((pdata.get() == 0) || (that.pdata.get() == 0))
return pdata.get() == that.pdata.get();
return pdata->compare(*(that.pdata.get()));
}
bool operator!=(const u32regex_iterator& that)const
{ return !(*this == that); }
const value_type& operator*()const
{ return pdata->get(); }
const value_type* operator->()const
{ return &(pdata->get()); }
u32regex_iterator& operator++()
{
cow();
if(0 == pdata->next())
{
pdata.reset();
}
return *this;
}
u32regex_iterator operator++(int)
{
u32regex_iterator result(*this);
++(*this);
return result;
}
private:
pimpl pdata;
void cow()
{
// copy-on-write
if(pdata.get() && !pdata.unique())
{
pdata.reset(new impl(*(pdata.get())));
}
}
};
typedef u32regex_iterator<const char*> utf8regex_iterator;
typedef u32regex_iterator<const UChar*> utf16regex_iterator;
typedef u32regex_iterator<const UChar32*> utf32regex_iterator;
inline u32regex_iterator<const char*> make_u32regex_iterator(const char* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_iterator<const char*>(p, p+std::strlen(p), e, m);
}
#ifndef BOOST_NO_WREGEX
inline u32regex_iterator<const wchar_t*> make_u32regex_iterator(const wchar_t* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_iterator<const wchar_t*>(p, p+std::wcslen(p), e, m);
}
#endif
#if !defined(BOOST_REGEX_UCHAR_IS_WCHAR_T)
inline u32regex_iterator<const UChar*> make_u32regex_iterator(const UChar* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_iterator<const UChar*>(p, p+u_strlen(p), e, m);
}
#endif
template <class charT, class Traits, class Alloc>
inline u32regex_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
{
typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type;
return u32regex_iterator<iter_type>(p.begin(), p.end(), e, m);
}
inline u32regex_iterator<const UChar*> make_u32regex_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, m);
}
} // namespace boost
#endif // BOOST_REGEX_V5_REGEX_ITERATOR_HPP

View File

@ -0,0 +1,312 @@
/*
*
* Copyright (c) 2003
* 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 u32regex_token_iterator.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Provides u32regex_token_iterator implementation.
*/
#ifndef BOOST_REGEX_V5_U32REGEX_TOKEN_ITERATOR_HPP
#define BOOST_REGEX_V5_U32REGEX_TOKEN_ITERATOR_HPP
namespace boost{
#ifdef BOOST_REGEX_MSVC
# pragma warning(push)
# pragma warning(disable:4700)
#endif
template <class BidirectionalIterator>
class u32regex_token_iterator_implementation
{
typedef u32regex regex_type;
typedef sub_match<BidirectionalIterator> value_type;
match_results<BidirectionalIterator> what; // current match
BidirectionalIterator end; // end of search area
BidirectionalIterator base; // start of search area
const regex_type re; // the expression
match_flag_type flags; // match flags
value_type result; // the current string result
int N; // the current sub-expression being enumerated
std::vector<int> subs; // the sub-expressions to enumerate
public:
u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f)
: end(last), re(*p), flags(f){ subs.push_back(sub); }
u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector<int>& v, match_flag_type f)
: end(last), re(*p), flags(f), subs(v){}
template <std::size_t CN>
u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const int (&submatches)[CN], match_flag_type f)
: end(last), re(*p), flags(f)
{
for(std::size_t i = 0; i < CN; ++i)
{
subs.push_back(submatches[i]);
}
}
bool init(BidirectionalIterator first)
{
base = first;
N = 0;
if(u32regex_search(first, end, what, re, flags, base) == true)
{
N = 0;
result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]);
return true;
}
else if((subs[N] == -1) && (first != end))
{
result.first = first;
result.second = end;
result.matched = (first != end);
N = -1;
return true;
}
return false;
}
bool compare(const u32regex_token_iterator_implementation& that)
{
if(this == &that) return true;
return (&re.get_data() == &that.re.get_data())
&& (end == that.end)
&& (flags == that.flags)
&& (N == that.N)
&& (what[0].first == that.what[0].first)
&& (what[0].second == that.what[0].second);
}
const value_type& get()
{ return result; }
bool next()
{
if(N == -1)
return false;
if(N+1 < (int)subs.size())
{
++N;
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
return true;
}
//if(what.prefix().first != what[0].second)
// flags |= match_prev_avail | regex_constants::match_not_bob;
BidirectionalIterator last_end(what[0].second);
if(u32regex_search(last_end, end, what, re, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags), base))
{
N =0;
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
return true;
}
else if((last_end != end) && (subs[0] == -1))
{
N =-1;
result.first = last_end;
result.second = end;
result.matched = (last_end != end);
return true;
}
return false;
}
private:
u32regex_token_iterator_implementation& operator=(const u32regex_token_iterator_implementation&);
};
template <class BidirectionalIterator>
class u32regex_token_iterator
{
private:
typedef u32regex_token_iterator_implementation<BidirectionalIterator> impl;
typedef std::shared_ptr<impl> pimpl;
public:
typedef u32regex regex_type;
typedef sub_match<BidirectionalIterator> value_type;
typedef typename std::iterator_traits<BidirectionalIterator>::difference_type
difference_type;
typedef const value_type* pointer;
typedef const value_type& reference;
typedef std::forward_iterator_tag iterator_category;
u32regex_token_iterator(){}
u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
int submatch = 0, match_flag_type m = match_default)
: pdata(new impl(&re, b, submatch, m))
{
if(!pdata->init(a))
pdata.reset();
}
u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
const std::vector<int>& submatches, match_flag_type m = match_default)
: pdata(new impl(&re, b, submatches, m))
{
if(!pdata->init(a))
pdata.reset();
}
template <std::size_t N>
u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
const int (&submatches)[N], match_flag_type m = match_default)
: pdata(new impl(&re, b, submatches, m))
{
if(!pdata->init(a))
pdata.reset();
}
u32regex_token_iterator(const u32regex_token_iterator& that)
: pdata(that.pdata) {}
u32regex_token_iterator& operator=(const u32regex_token_iterator& that)
{
pdata = that.pdata;
return *this;
}
bool operator==(const u32regex_token_iterator& that)const
{
if((pdata.get() == 0) || (that.pdata.get() == 0))
return pdata.get() == that.pdata.get();
return pdata->compare(*(that.pdata.get()));
}
bool operator!=(const u32regex_token_iterator& that)const
{ return !(*this == that); }
const value_type& operator*()const
{ return pdata->get(); }
const value_type* operator->()const
{ return &(pdata->get()); }
u32regex_token_iterator& operator++()
{
cow();
if(0 == pdata->next())
{
pdata.reset();
}
return *this;
}
u32regex_token_iterator operator++(int)
{
u32regex_token_iterator result(*this);
++(*this);
return result;
}
private:
pimpl pdata;
void cow()
{
// copy-on-write
if(pdata.get() && !pdata.unique())
{
pdata.reset(new impl(*(pdata.get())));
}
}
};
typedef u32regex_token_iterator<const char*> utf8regex_token_iterator;
typedef u32regex_token_iterator<const UChar*> utf16regex_token_iterator;
typedef u32regex_token_iterator<const UChar32*> utf32regex_token_iterator;
// construction from an integral sub_match state_id:
inline u32regex_token_iterator<const char*> make_u32regex_token_iterator(const char* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const char*>(p, p+std::strlen(p), e, submatch, m);
}
#ifndef BOOST_NO_WREGEX
inline u32regex_token_iterator<const wchar_t*> make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const wchar_t*>(p, p+std::wcslen(p), e, submatch, m);
}
#endif
#if !defined(BOOST_REGEX_UCHAR_IS_WCHAR_T)
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const UChar* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const UChar*>(p, p+u_strlen(p), e, submatch, m);
}
#endif
template <class charT, class Traits, class Alloc>
inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default)
{
typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type;
return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, submatch, m);
}
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m);
}
// construction from a reference to an array:
template <std::size_t N>
inline u32regex_token_iterator<const char*> make_u32regex_token_iterator(const char* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const char*>(p, p+std::strlen(p), e, submatch, m);
}
#ifndef BOOST_NO_WREGEX
template <std::size_t N>
inline u32regex_token_iterator<const wchar_t*> make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const wchar_t*>(p, p+std::wcslen(p), e, submatch, m);
}
#endif
#if !defined(BOOST_REGEX_UCHAR_IS_WCHAR_T)
template <std::size_t N>
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const UChar* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const UChar*>(p, p+u_strlen(p), e, submatch, m);
}
#endif
template <class charT, class Traits, class Alloc, std::size_t N>
inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
{
typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type;
return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, submatch, m);
}
template <std::size_t N>
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m);
}
// construction from a vector of sub_match state_id's:
inline u32regex_token_iterator<const char*> make_u32regex_token_iterator(const char* p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const char*>(p, p+std::strlen(p), e, submatch, m);
}
#ifndef BOOST_NO_WREGEX
inline u32regex_token_iterator<const wchar_t*> make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const wchar_t*>(p, p+std::wcslen(p), e, submatch, m);
}
#endif
#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2)
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const UChar* p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const UChar*>(p, p+u_strlen(p), e, submatch, m);
}
#endif
template <class charT, class Traits, class Alloc>
inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
{
typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type;
return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, submatch, m);
}
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m);
}
#ifdef BOOST_REGEX_MSVC
# pragma warning(pop)
#endif
} // namespace boost
#endif // BOOST_REGEX_V5_REGEX_TOKEN_ITERATOR_HPP

Some files were not shown because too many files have changed in this diff Show More