2
0
mirror of https://github.com/boostorg/url.git synced 2026-01-19 04:42:15 +00:00

Port beast uri

This commit is contained in:
Vinnie Falco
2019-11-27 08:07:15 -08:00
parent 84a36f7800
commit ab84af954f
47 changed files with 4738 additions and 1 deletions

153
.appveyor.yml Normal file
View File

@@ -0,0 +1,153 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright (C) 2017 - 2019 James E. King III
# 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)
#
# Generic Appveyor build script for boostorg repositories
# See: https://github.com/boostorg/boost-ci/
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want.
# 2. If you have more than include/, src/, test/, example/, examples/,
# benchmark/ or tools/ directories, set the environment variable DEPINST.
# For example if your build uses code in "bench/" and "fog/" directories:
# - DEPINST: --include bench --include fog
# 3. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the script will do everything else for you.
#
version: 1.0.{build}-{branch}
#clone_depth: 1
branches:
only:
- master
- develop
- /bugfix\/.*/
- /feature\/.*/
- /fix\/.*/
- /pr\/.*/
matrix:
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
allow_failures:
- MAYFAIL: true
environment:
global:
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# to use the default for a given environment, comment it out; recommend you build debug and release however:
# on Windows it is important to exercise all the possibilities, especially shared vs static, however most
# libraries that care about this exercise it in their Jamfiles...
# B2_ADDRESS_MODEL: address-model=64,32
# B2_LINK: link=shared,static
# B2_THREADING: threading=multi,single
B2_VARIANT: variant=release
matrix:
- FLAVOR: mingw32
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARCH: i686
B2_ADDRESS_MODEL: address-model=32
B2_CXXSTD: 11
SCRIPT: ci\appveyor\mingw.bat
B2_VARIANT: variant=debug
- FLAVOR: cygwin (64-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin64\bin;
B2_ADDRESS_MODEL: address-model=64
B2_CXXSTD: 11,17
# https://github.com/boostorg/test/issues/144
B2_DEFINES: define=_POSIX_C_SOURCE=200112L define=__USE_ISOC99
B2_THREADING: threadapi=pthread
B2_TOOLSET: gcc
- FLAVOR: Visual Studio 2019
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
B2_ADDRESS_MODEL: address-model=64
B2_CXXFLAGS: cxxflags=-permissive-
B2_CXXSTD: latest # 2a
B2_TOOLSET: msvc-14.2
- FLAVOR: Visual Studio 2015 C++14 (Default)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_ADDRESS_MODEL: address-model=64,32
B2_TOOLSET: msvc-14.0
B2_VARIANT: variant=debug
- FLAVOR: Visual Studio 2017 C++2a Strict
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64
B2_CXXFLAGS: cxxflags=-permissive-
B2_CXXSTD: latest # 2a
B2_TOOLSET: msvc-14.1
- FLAVOR: Visual Studio 2017 C++17
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64
B2_CXXSTD: 17
B2_TOOLSET: msvc-14.1
B2_VARIANT: variant=debug
- FLAVOR: Visual Studio 2017 C++17 Standalone
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64
B2_CXXSTD: 17
B2_DEFINES: define=BOOST_JSON_STANDALONE
B2_TOOLSET: msvc-14.1
B2_VARIANT: variant=debug
STANDALONE: 1
- FLAVOR: Visual Studio 2017 C++14 (Default)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64,32
B2_TOOLSET: msvc-14.1
- FLAVOR: clang-cl
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64
B2_CXXSTD: 11
B2_TOOLSET: clang-win
- FLAVOR: cygwin (32-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: address-model=32
B2_CXXSTD: 11
# https://github.com/boostorg/test/issues/144
B2_DEFINES: define=_POSIX_C_SOURCE=200112L
B2_THREADING: threadapi=pthread
B2_TOOLSET: gcc
B2_VARIANT: variant=debug
- FLAVOR: mingw64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARCH: x86_64
B2_ADDRESS_MODEL: address-model=64
B2_CXXSTD: 11,17
B2_DEFINES: define=__USE_ISOC99
SCRIPT: ci\appveyor\mingw.bat
install:
- git submodule update --init --recursive
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
- git clone https://github.com/boostorg/boost-ci.git C:\boost-ci
- xcopy /s /e /q /i C:\boost-ci\ci .\ci
- ci\appveyor\install.bat
build: off
test_script:
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
- PATH=%ADDPATH%%PATH%
# The definition of B2_TOOLCXX omits B2_CXXSTD= if it was not defined above
- IF NOT DEFINED B2_CXXSTD (SET B2_TOOLCXX=toolset=%B2_TOOLSET%) ELSE (SET B2_TOOLCXX=toolset=%B2_TOOLSET% cxxstd=%B2_CXXSTD%)
# Echo the complete build command to the build log
- IF NOT DEFINED SCRIPT (ECHO b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
# Now go build...
- IF DEFINED SCRIPT (call libs\%SELF%\%SCRIPT%) ELSE (b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)

311
.azure-pipelines.yml Normal file
View File

@@ -0,0 +1,311 @@
# Copyright 2015-2019 Rene Rivera.
# Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
# 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)
#
# Generic Azure Pipelines build script for boostorg repositories
# See: https://github.com/boostorg/boost-ci/
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want.
# 2. If you have more than include/, src/, test/, example/, examples/,
# benchmark/ or tools/ directories, set the environment variable DEPINST.
# For example if your build uses code in "bench/" and "fog/" directories:
# - DEPINST: --include bench --include fog
# 3. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the script will do everything else for you.
trigger:
branches:
include:
- develop
- master
- bugfix/*
- feature/*
- fix/*
- pr/*
pr:
branches:
include:
- develop
variables:
- name: B2_VARIANT
value: variant=release,debug
stages:
- stage: Test
jobs:
- job: 'Linux'
pool:
vmImage: 'ubuntu-16.04'
strategy:
matrix:
GCC 8:
B2_TOOLSET: gcc
B2_CXXSTD: 14,17,2a
CXX: g++-8
PACKAGES: g++-8
GCC 7:
B2_TOOLSET: gcc
B2_CXXSTD: 11,14,17
CXX: g++-7
PACKAGES: g++-7
GCC 6:
B2_TOOLSET: gcc
B2_CXXSTD: 11,14
CXX: g++-6
PACKAGES: g++-6
GCC 5:
B2_TOOLSET: gcc
B2_CXXSTD: 11
CXX: g++-5
PACKAGES: g++-5
GCC 4.9:
B2_TOOLSET: gcc
B2_CXXSTD: 11
CXX: g++-4.9
PACKAGES: g++-4.9
GCC 4.8:
B2_TOOLSET: gcc
B2_CXXSTD: 11
CXX: g++-4.8
PACKAGES: g++-4.8
Clang 8:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
CXX: clang++-8
PACKAGES: clang-8
LLVM_REPO: llvm-toolchain-xenial-8
Clang 7:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
CXX: clang++-7
PACKAGES: clang-7
LLVM_REPO: llvm-toolchain-xenial-7
Clang 6:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
CXX: clang++-6.0
PACKAGES: clang-6.0
LLVM_REPO: llvm-toolchain-xenial-6.0
Clang 5:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17
PACKAGES: clang-5.0
CXX: clang++-5.0
LLVM_REPO: llvm-toolchain-xenial-5.0
Clang 4:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17
CXX: clang++-4.0
PACKAGES: clang-4.0
LLVM_REPO: llvm-toolchain-xenial-4.0
Clang 3.9:
B2_TOOLSET: clang
B2_CXXSTD: 11,14
CXX: clang++-3.9
PACKAGES: clang-3.9
Clang 3.8:
B2_TOOLSET: clang
CXX: clang++-3.8
B2_CXXSTD: 11,14
PACKAGES: clang-3.8
Clang 3.7:
B2_TOOLSET: clang
B2_CXXSTD: 11
CXX: clang++-3.7
PACKAGES: clang-3.7
Clang 3.6:
B2_TOOLSET: clang
B2_CXXSTD: 11
CXX: clang++-3.6
PACKAGES: clang-3.6
Clang 3.5:
B2_TOOLSET: clang
B2_CXXSTD: 11
CXX: clang++-3.5
PACKAGES: clang-3.5
steps:
- checkout: self
submodules: true
- bash: |
set -e
uname -a
sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
if test -n "${LLVM_REPO}" ; then
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo -E apt-add-repository "deb http://apt.llvm.org/xenial/ ${LLVM_REPO} main"
fi
sudo -E apt-get update
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install ${PACKAGES}
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
rm -rf boost-ci
source ci/azure-pipelines/install.sh
# AzP requires to run special task in order to export
# SELF and BOOST_ROOT as job-scoped variable from a script.
# NOTE: Disable set -x is necessary, see the troubleshooting guide
# on "Variables having ' (single quote) appended":
# https://docs.microsoft.com/en-us/azure/devops/pipelines/troubleshooting
set +x
echo "##vso[task.setvariable variable=SELF]"$SELF
echo "##vso[task.setvariable variable=BOOST_ROOT]"$BOOST_ROOT
set -x
displayName: 'Install'
- bash: |
set -e
echo "SELF=$SELF"
echo "BOOST_ROOT=$BOOST_ROOT"
cd $BOOST_ROOT/libs/$SELF
ci/azure-pipelines/build.sh --debug-configuration
displayName: 'Build'
- job: 'Windows'
strategy:
matrix:
VS 2019 C++2a Strict:
B2_TOOLSET: msvc-14.2
B2_CXXSTD: latest # 2a
B2_CXXFLAGS: cxxflags=-permissive-
B2_ADDRESS_MODEL: address-model=64
VM_IMAGE: 'windows-2019'
VS 2017 C++2a Strict:
B2_TOOLSET: msvc-14.1
B2_CXXSTD: latest # 2a
B2_CXXFLAGS: cxxflags=-permissive-
B2_ADDRESS_MODEL: address-model=64
VM_IMAGE: 'vs2017-win2016'
VS 2017 C++17:
B2_TOOLSET: msvc-14.1
B2_CXXSTD: 17
B2_ADDRESS_MODEL: address-model=64,32
VM_IMAGE: 'vs2017-win2016'
VS 2017 C++14:
B2_TOOLSET: msvc-14.1
#B2_CXXSTD: 14 # default
B2_ADDRESS_MODEL: address-model=64,32
VM_IMAGE: 'vs2017-win2016'
VS 2015 C++14:
B2_TOOLSET: msvc-14.0
#B2_CXXSTD: 14 # default
B2_ADDRESS_MODEL: address-model=64,32
VM_IMAGE: 'vs2015-win2012r2'
pool:
vmImage: $(VM_IMAGE)
steps:
- checkout: self
submodules: true
- script: |
set SELF=%BUILD_REPOSITORY_NAME:-=_%
for /f "tokens=2 delims=/" %%a in ("%SELF%") do set SELF=%%a
set BOOST_ROOT=%BUILD_SOURCESDIRECTORY%\boost-root
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci
xcopy /s /e /q /i boost-ci\ci .\ci
cmd /k ci\azure-pipelines\install.bat
echo ##vso[task.setvariable variable=SELF]%SELF%
echo ##vso[task.setvariable variable=BOOST_ROOT]%BOOST_ROOT%
displayName: 'Install'
- script: |
PATH=%ADDPATH%%PATH%
REM The definition of B2_TOOLCXX omits B2_CXXSTD= if it was not defined above
IF NOT DEFINED B2_CXXSTD (SET B2_TOOLCXX=toolset=%B2_TOOLSET%) ELSE (SET B2_TOOLCXX=toolset=%B2_TOOLSET% cxxstd=%B2_CXXSTD%)
cd %BOOST_ROOT%
ECHO b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3
b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3
displayName: 'Build'
- job: 'macOS'
pool:
vmImage: 'macOS-10.13'
strategy:
matrix:
Xcode 10.1:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
XCODE_APP: /Applications/Xcode_10.1.app
Xcode 10.0:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
XCODE_APP: /Applications/Xcode_10.app
Xcode 9.4.1:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17
XCODE_APP: /Applications/Xcode_9.4.1.app
Xcode 9.4:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17
XCODE_APP: /Applications/Xcode_9.4.app
Xcode 9.3.1:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17
XCODE_APP: /Applications/Xcode_9.3.1.app
Xcode 9.3:
B2_TOOLSET: clang
B2_CXXSTD: 11,14
XCODE_APP: /Applications/Xcode_9.3.app
Xcode 9.2:
B2_TOOLSET: clang
B2_CXXSTD: 11,14
XCODE_APP: /Applications/Xcode_9.2.app
Xcode 9.1:
B2_TOOLSET: clang
B2_CXXSTD: 11
XCODE_APP: /Applications/Xcode_9.1.app
Xcode 9.0.1:
B2_TOOLSET: clang
B2_CXXSTD: 11
XCODE_APP: /Applications/Xcode_9.0.1.app
Xcode 9.0:
B2_TOOLSET: clang
B2_CXXSTD: 11
XCODE_APP: /Applications/Xcode_9.app
Xcode 8.3.3:
B2_TOOLSET: clang
B2_CXXSTD: 11
XCODE_APP: /Applications/Xcode_8.3.3.app
steps:
- checkout: self
submodules: true
- bash: |
set -e
uname -a
sudo xcode-select -switch ${XCODE_APP}
which clang++
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
rm -rf boost-ci
source ci/azure-pipelines/install.sh
# AzP requires to run special task in order to export
# SELF and BOOST_ROOT as job-scoped variable from a script.
# NOTE: Disable set -x is necessary, see the troubleshooting guide
# on "Variables having ' (single quote) appended":
# https://docs.microsoft.com/en-us/azure/devops/pipelines/troubleshooting
set +x
echo "##vso[task.setvariable variable=SELF]"$SELF
echo "##vso[task.setvariable variable=BOOST_ROOT]"$BOOST_ROOT
set -x
displayName: Install
- bash: |
set -e
echo "SELF=$SELF"
echo "BOOST_ROOT=$BOOST_ROOT"
cd $BOOST_ROOT/libs/$SELF
ci/azure-pipelines/build.sh --debug-configuration
displayName: 'Build'

8
.gitignore vendored Normal file
View File

@@ -0,0 +1,8 @@
bin
bin64
*.*#
temp
# Because of CMake and VS2017
Win32
x64

260
.travis.yml Normal file
View File

@@ -0,0 +1,260 @@
# Copyright 2016 Peter Dimov
# Copyright 2017 - 2019 James E. King III
# 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)
#
# Generic Travis CI build script for boostorg repositories
# See: https://github.com/boostorg/boost-ci
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want in the 'jobs'.
# 2. If you have more than include/, src/, test/, example/, examples/, or
# tools/ directories, modify your Travis CI project and add the environment
# variable DEPINST. For example if your build uses code in "bench/" and
# "fog/" directories, then set DEPINST to the following:
# --include bench --include fog
# 3. If you want to enable Coverity Scan, you need to provide the environment
# variables COVERITY_SCAN_TOKEN and COVERITY_SCAN_NOTIFICATION_EMAIL in
# your github settings.
# 4. If you want to enable a big-endian build, you need to uncomment the
# big-endian build job.
# 5. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the scripts will do everything else for you.
dist: xenial
language: cpp
env:
global:
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# - B2_ADDRESS_MODEL=address-model=64,32
# - B2_LINK=link=shared,static
# - B2_THREADING=threading=multi,single
- B2_VARIANT=variant=release
install:
- git clone https://github.com/boostorg/boost-ci.git boost-ci
- cp -pr boost-ci/ci boost-ci/.codecov.yml .
- source ci/travis/install.sh
addons:
apt:
packages:
- binutils-gold
- gdb
- libc6-dbg
- qemu-user-static
services:
- docker
branches:
only:
- master
- develop
- /bugfix\/.*/
- /feature\/.*/
- /fix\/.*/
- /pr\/.*/
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/build.sh
#
# Default toolsets in Ubuntu
#
# trusty xenial bionic
# 14.04 16.04 18.04
# ------ ------ ------
# clang 3.4 3.8 6.0
# gcc 4.8.2 5.3.1 7.3.0
#
anchors:
clang-38: &clang-38 { apt: { packages: [ "clang-3.8",
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-3.8",
"ubuntu-toolchain-r-test" ] } }
clang-4: &clang-4 { apt: { packages: [ "clang-4.0",
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-4.0",
"ubuntu-toolchain-r-test" ] } }
clang-5: &clang-5 { apt: { packages: [ "clang-5.0",
"libstdc++-7-dev" ], sources: [ "llvm-toolchain-xenial-5.0",
"ubuntu-toolchain-r-test" ] } }
clang-6: &clang-6 { apt: { packages: [ "clang-6.0",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-6.0",
"ubuntu-toolchain-r-test" ] } }
clang-7: &clang-7 { apt: { packages: [ "clang-7",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-7",
"ubuntu-toolchain-r-test" ] } }
clang-8: &clang-8 { apt: { packages: [ "clang-8",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-8",
"ubuntu-toolchain-r-test" ] } }
gcc-48: &gcc-48 { apt: { packages: [ "g++-4.8" ] } }
gcc-49: &gcc-49 { apt: { packages: [ "g++-4.9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-5: &gcc-5 { apt: { packages: [ "g++-5" ] } }
gcc-6: &gcc-6 { apt: { packages: [ "g++-6" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-7: &gcc-7 { apt: { packages: [ "g++-7" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-8: &gcc-8 { apt: { packages: [ "g++-8" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-9: &gcc-9 { apt: { packages: [ "g++-9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
jobs:
allow_failures:
- env:
- COPY="all the environment settings from your job"
include:
# coverage
- os: linux
env:
- COMMENT=codecov.io
- B2_CXXSTD=11
#- B2_CXXFLAGS="inlining=off"
- B2_TOOLSET=gcc-8
- B2_DEFINES="define=BOOST_DISABLE_ASSERTS define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
script:
- cd $BOOST_ROOT/libs/$SELF
- tools/codecov.sh
- { os: "linux", env: [ "B2_TOOLSET=clang-8", "B2_CXXSTD=17,2a" ], addons: *clang-8 }
- os: linux
env:
- COMMENT=valgrind
- B2_TOOLSET=clang-6.0
- B2_CXXSTD=11,14
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
- B2_VARIANT=variant=debug
- B2_TESTFLAGS=testing.launcher=valgrind
- VALGRIND_OPTS=--error-exitcode=1
addons: *clang-6
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/valgrind.sh
- os: linux
env:
- COMMENT=asan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=11,14
- B2_CXXFLAGS="address-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
- os: linux
env:
- COMMENT=tsan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=11,14
- B2_CXXFLAGS="thread-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
- os: linux
env:
- COMMENT=ubsan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=11,14
- B2_CXXFLAGS="undefined-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1 define=BOOST_JSON_HEADER_ONLY"
- B2_LINKFLAGS="linkflags=-fuse-ld=gold"
- UBSAN_OPTIONS=print_stacktrace=1
addons: *gcc-8
# standalone
- os: "linux"
env:
- COMMENT=standalone
- STANDALONE=1
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-7
- B2_CXXSTD=17
- B2_DEFINES="define=BOOST_JSON_STANDALONE=1"
addons: *gcc-7
- os: "linux"
env:
- COMMENT=standalone
- STANDALONE=1
- B2_VARIANT=variant=debug
- B2_TOOLSET=clang-7
- B2_CXXSTD=17
- B2_DEFINES="define=BOOST_JSON_STANDALONE=1"
addons: *clang-7
# libstdc++
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=gcc-4.8", "B2_CXXSTD=11" ], addons: *gcc-48 }
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=gcc-4.9", "B2_CXXSTD=11" ], addons: *gcc-49 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-5", "B2_CXXSTD=11" ], addons: *gcc-5 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-6", "B2_CXXSTD=11,14" ], addons: *gcc-6 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-7", "B2_CXXSTD=14,17" ], addons: *gcc-7 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-8", "B2_CXXSTD=17,2a" ], addons: *gcc-8 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-9", "B2_CXXSTD=17,2a" ], addons: *gcc-9 }
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=clang-3.8", "B2_CXXSTD=11" ], addons: *clang-38 }
- { os: "linux", env: [ "B2_TOOLSET=clang-4.0", "B2_CXXSTD=11,14" ], addons: *clang-4 }
- { os: "linux", env: [ "B2_TOOLSET=clang-5.0", "B2_CXXSTD=11,14" ], addons: *clang-5 }
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=14,17" ], addons: *clang-6 }
- { os: "linux", env: [ "B2_TOOLSET=clang-7", "B2_CXXSTD=17,2a" ], addons: *clang-7 }
# - { os: "linux", env: [ "B2_TOOLSET=clang-8", "B2_CXXSTD=17,2a" ], addons: *clang-8 }
# libc++
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=11,14",
"B2_CXXFLAGS=-stdlib=libc++" ], addons: *clang-6 }
- { os: "osx" , env: [ "B2_TOOLSET=clang", "B2_CXXSTD=11,17" ] }
# to enable Intel ICC define INTEL_ICC_SERIAL_NUMBER and the following (under development):
# - { os: "linux", env: [ "B2_TOOLSET=intel-linux", "B2_CXXSTD=11,14,17" ], addons: *gcc-7,
# script: cd $BOOST_ROOT/libs/$SELF && ci/travis/intelicc.sh }
# uncomment to enable a big-endian build job, just note that it is 5-10 times slower
# than a regular build and travis has a 50 minute time limit per job
# - os: linux
# env:
# - COMMENT=big-endian
# - B2_CXXSTD=03
# - B2_TOOLSET=gcc
# - B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
# - BDDE_OS=red
# - BDDE_ARCH=ppc64
# script:
# - cd $BOOST_ROOT/libs/$SELF
# - ci/travis/bdde.sh
# - os: linux
# env:
# - COMMENT=cppcheck
# script:
# - cd $BOOST_ROOT/libs/$SELF
# - ci/travis/cppcheck.sh
#################### Jobs to run on pushes to master, develop ###################
# Coverity Scan
- os: linux
if: (env(COVERITY_SCAN_NOTIFICATION_EMAIL) IS present) AND (branch IN (develop, master)) AND (type IN (cron, push))
env:
- COMMENT="Coverity Scan"
- B2_TOOLSET=clang
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/coverity.sh
notifications:
email:
false

152
CMakeLists.txt Normal file
View File

@@ -0,0 +1,152 @@
#
# Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
#
# 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)
#
# Official repository: https://github.com/vinniefalco/uri
#
cmake_minimum_required (VERSION 3.5.1)
if (POLICY CMP0074)
cmake_policy (SET CMP0074 NEW)
endif()
#-------------------------------------------------------------------------------
function (DoGroupSources curdir rootdir folder)
file (GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
foreach (child ${children})
if (IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
DoGroupSources (${curdir}/${child} ${rootdir} ${folder})
elseif (${child} STREQUAL "CMakeLists.txt")
source_group("" FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
else()
string (REGEX REPLACE ^${rootdir} ${folder} groupname ${curdir})
string (REPLACE "/" "\\" groupname ${groupname})
source_group (${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
endif()
endforeach()
endfunction()
function (GroupSources curdir folder)
DoGroupSources (${curdir} ${curdir} ${folder})
endfunction()
#-------------------------------------------------------------------------------
#
# URI
#
#-------------------------------------------------------------------------------
project (URI VERSION 1)
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
if (MSVC)
set (CMAKE_VERBOSE_MAKEFILE FALSE)
add_definitions (
-D_WIN32_WINNT=0x0601
-D_CRT_SECURE_NO_WARNINGS
)
add_compile_options(
/permissive- # strict C++
/W4 # enable all warnings
/MP # Multi-processor compilation
)
add_link_options(
/INCREMENTAL:NO
)
set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_STATIC_RUNTIME ON)
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob2 /Oi /Ot /GL /MT")
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi /Ot /MT")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
# for RelWithDebInfo builds, disable incremental linking
# since CMake sets it ON by default for that build type and it
# causes warnings
#
string (REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" replacement_flags
${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacement_flags})
else()
set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package (Threads)
set( CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic -Wno-unused-parameter")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wrange-loop-analysis")
endif ()
endif()
# Must come before Boost includes, otherwise the
# IDE sees the wrong file due to boost/ symlinks.
include_directories (include)
#-------------------------------------------------------------------------------
#
# Boost
#
#-------------------------------------------------------------------------------
get_filename_component (BOOST_ROOT ../../ ABSOLUTE)
# VFALCO I want static but "b2 stage" builds a minimal set which excludes static
add_definitions (-DBOOST_ALL_STATIC_LINK=1)
include_directories (${BOOST_ROOT})
link_directories(${BOOST_ROOT}/stage/lib)
#-------------------------------------------------------------------------------
if ("${VARIANT}" STREQUAL "coverage")
if (MSVC)
else()
set (CMAKE_BUILD_TYPE DEBUG)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 --coverage")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()
elseif ("${VARIANT}" STREQUAL "ubasan")
if (MSVC)
else()
set (CMAKE_BUILD_TYPE RELWITHDEBINFO)
set (CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/tools/blacklist.supp")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined -fno-sanitize-recover=address,undefined")
endif()
elseif ("${VARIANT}" STREQUAL "debug")
set (CMAKE_BUILD_TYPE DEBUG)
elseif ("${VARIANT}" STREQUAL "release")
set (CMAKE_BUILD_TYPE RELEASE)
endif()
#-------------------------------------------------------------------------------
#
# Tests and examples
#
file (GLOB_RECURSE PROJECT_FILES
${PROJECT_SOURCE_DIR}/include/boost/uri/*.hpp
${PROJECT_SOURCE_DIR}/include/boost/uri/*.ipp
)
add_subdirectory (example)
add_subdirectory (test)

12
Jamfile Normal file
View File

@@ -0,0 +1,12 @@
#
# Copyright (c) 2013-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
#
# 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)
#
# Official repository: https://github.com/vinniefalco/json
#
path-constant LIB_DIR : . ;
build-project test ;

23
LICENSE_1_0.txt Normal file
View File

@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@@ -1,2 +1,24 @@
# uri
Boost.URI
<img width="880" height = "80" alt = "Boost.URI Title"
src="https://raw.githubusercontent.com/vinniefalco/uri/master/doc/images/repo-logo.png">
Branch | Travis | Appveyor | Azure Pipelines | codecov.io | Docs | Matrix |
:-------------: | ------ | -------- | --------------- | ---------- | ---- | ------ |
[`master`](https://github.com/vinniefalco/uri/tree/master) | [![Build Status](https://travis-ci.org/vinniefalco/uri.svg?branch=master)](https://travis-ci.org/vinniefalco/uri) | [![Build status](https://ci.appveyor.com/api/projects/status/github/vinniefalco/uri?branch=master&svg=true)](https://ci.appveyor.com/project/vinniefalco/uri/branch/master) | [![Build Status](https://img.shields.io/azure-devops/build/vinniefalco/2571d415-8cc8-4120-a762-c03a8eda0659/1/master)](https://vinniefalco.visualstudio.com/uri/_build/latest?definitionId=1&branchName=master) | [![codecov](https://codecov.io/gh/vinniefalco/uri/branch/master/graph/badge.svg)](https://codecov.io/gh/vinniefalco/uri/branch/master) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://vinniefalco.github.com/doc/uri/index.html) | [![Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/uri.html)
[`develop`](https://github.com/vinniefalco/uri/tree/develop) | [![Build Status](https://travis-ci.org/vinniefalco/uri.svg?branch=develop)](https://travis-ci.org/vinniefalco/uri) | [![Build status](https://ci.appveyor.com/api/projects/status/github/vinniefalco/uri?branch=develop&svg=true)](https://ci.appveyor.com/project/vinniefalco/uri/branch/develop) | [![Build Status](https://img.shields.io/azure-devops/build/vinniefalco/2571d415-8cc8-4120-a762-c03a8eda0659/1/develop)](https://vinniefalco.visualstudio.com/uri/_build/latest?definitionId=1&branchName=develop) | [![codecov](https://codecov.io/gh/vinniefalco/uri/branch/develop/graph/badge.svg)](https://codecov.io/gh/vinniefalco/uri/branch/develop) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://vinniefalco.github.com/doc/uri/index.html) | [![Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/uri.html)
# Boost.URI
## This is currently **NOT** an official Boost library.
## Introduction
## Motivation
## Design Goals
## License
Distributed under the Boost Software License, Version 1.0.
(See accompanying file [LICENSE_1_0.txt](LICENSE_1_0.txt) or copy at
https://www.boost.org/LICENSE_1_0.txt)

31
build/Jamfile Normal file
View File

@@ -0,0 +1,31 @@
#
# Copyright (c) 2019 Vinnie Falco (vinnie dot falco at gmail dot com)
#
# 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)
#
# Official repository: https://github.com/boostorg/json
#
project boost/uri
: requirements
<link>shared:<define>BOOST_URI_DYN_LINK=1
<link>static:<define>BOOST_URI_STATIC_LINK=1
<define>BOOST_JSON_SOURCE
: usage-requirements
<link>shared:<define>BOOST_URI_DYN_LINK=1
<link>static:<define>BOOST_URI_STATIC_LINK=1
: source-location ../src
;
alias uri_sources
: src.cpp
;
explicit uri_sources ;
lib boost_uri
: uri_sources
;
boost-install boost_uri ;

4
doc/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
html
temp
out.txt
qbk/reference.qbk

343
doc/Jamfile Normal file
View File

@@ -0,0 +1,343 @@
#
# Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
#
# 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)
#
# Official repository: https://github.com/vinniefalco/uri
#
project uri/doc ;
import os ;
import path ;
import boostbook ;
import quickbook ;
import xsltproc ;
import doxygen ;
import modules ;
import saxonhe ;
local broot = [ os.environ BOOST_ROOT ] ;
path-constant out : . ;
#-------------------------------------------------------------------------------
#
# Build the list of header files that Doxygen will scan. We need
# this list to inform the build system of the dependencies so the
# docs can be rebuild if any of the header files change.
#
local sources = [ path.glob-tree ../include/boost/uri : *.hpp *.ipp : detail impl ] ;
# Get the configured paths to doxygen and xsltproc
.doxygen = [ doxygen.name ] ;
.doxygen ?= doxygen ;
.xsltproc = [ xsltproc.name ] ;
.xsltproc ?= xsltproc ;
#-------------------------------------------------------------------------------
#
# Invoke Doxygen to process the header files and produce the XML
# containing the description of the C++ declarations and extracted
# Javadoc comments.
#
make index.xml
:
./source.dox
:
@make_doxygen_xml
:
<dependency>$(sources)
;
rule make_doxygen_xml ( targets * : sources * : properties * )
{
}
if [ os.name ] = NT
{
actions make_doxygen_xml
{
SET LIB_DIR=$(LIB_DIR)
SET XML_OUTPUT=$(1:D)
"$(.doxygen)" $(2)
}
}
else
{
actions make_doxygen_xml
{
export LIB_DIR=$(LIB_DIR)
export XML_OUTPUT=$(1:D)
"$(.doxygen)" $(2)
}
}
#-------------------------------------------------------------------------------
#
# Copy all the XSLT modules to the target directory.
#
# FIXME: Change this so we can just specify a directory,
# rather than every file individually.
#
# Also, somehow force dependencies in a general way
# such that the XSLT has to be executed again
# if any of the modules change. For example,
# if base-extract-xml-pages.xml changes, then
# an invocation of extract-xml-pages.xsl (which
# imports the former) must be run again.
#
make extract-xml-pages.xsl : docca/include/docca/extract-xml-pages.xsl : @copy_script ;
make base-extract-xml-pages.xsl : docca/include/docca/base-extract-xml-pages.xsl : @copy_script ;
make common.xsl : docca/include/docca/common.xsl : @copy_script ;
make stage1.xsl : docca/include/docca/stage1.xsl : @copy_script ;
make base-stage1.xsl : docca/include/docca/base-stage1.xsl : @copy_script ;
make stage2.xsl : docca/include/docca/stage2.xsl : @copy_script ;
make assemble-quickbook.xsl : docca/include/docca/assemble-quickbook.xsl : @copy_script ;
make emphasized-types.xsl : docca/include/docca/emphasized-types.xsl : @copy_script ;
make config.xsl
:
docca/include/docca/config.xsl
xsl/config.xsl
xsl/class_detail.xsl
xsl/includes.xsl
:
@make_config
;
actions make_config
{
cp $(2[1]) $(1)
sed -i -e "/<!-- CONFIG_TEMPLATE -->/{r $(2[2])" -e "d}" $(1)
sed -i -e "/<!-- INCLUDES_FOOT_TEMPLATE -->/{r $(2[4])" -e "d}" $(1)
}
# Make a copy of the given file.
#
actions copy_script
{
cp $(2[1]) $(1)
}
# This is to initially create the directory as a side effect; I'm sure there's a better way...
make xml-pages/directory/placeholder : index.xml : @null_action ;
#-------------------------------------------------------------------------------
#
# Run index.xml through the first transformation stage
# (assembling and splitting the XML into page-specific files).
#
make xml-pages.xml
:
index.xml
extract-xml-pages.xsl
# Make bjam aware of additional dependencies
base-extract-xml-pages.xsl
config.xsl
common.xsl
:
saxonhe.saxonhe
;
# This is just to make the directory eligible as a source
make xml-pages : index.xml : @null_action ;
# Not ready for prime time until I figure out how to get the xslt-visualizer code in place
#make stage1/code-trace-enabled/stage1.xsl
# :
# stage1.xsl
# xslt-visualizer/xsl/trace-enable.xsl
# :
# saxonhe.saxonhe
# ;
# This is to initially create the directory as a side effect; I'm sure there's a better way...
make stage1/results/directory/placeholder : xml-pages.xml : @null_action ;
make stage2/results/directory/placeholder : xml-pages.xml : @null_action ;
# TODO: figure out why this (and the following stage) get built every time
make stage1/results
:
xml-pages
stage1.xsl
# additional dependencies
xml-pages.xml
base-stage1.xsl
config.xsl
common.xsl
:
saxonhe.saxonhe
;
make stage2/results
:
stage1/results
stage2.xsl
:
saxonhe.saxonhe
;
make reference.qbk
:
xml-pages.xml
assemble-quickbook.xsl
# TODO: make this input to the XSLT somehow
# rather than relying on it being hard-coded
# in the XSLT (which it is!)
stage2/results
:
saxonhe.saxonhe
;
actions make_dir
{
mkdir $(1)
}
make combine.xslt : index.xml : @null_action ;
actions touch_file
{
touch $(1) ;
}
actions null_action
{
touch -c $(1) ;
}
make reference.xml
:
combine.xslt
index.xml
:
@call-xsltproc
;
actions call-xsltproc
{
"$(.xsltproc)" $(2) > $(1)
}
#-------------------------------------------------------------------------------
#
# Produce the reference.qbk file by running
# the reference xml through the transform.
#
#make reference.qbk
# :
# reference.xml
# transform.xsl
# :
# saxonhe.saxonhe
# ;
# We have to make a copy of reference.qbk and put it
# in a place where the static .qbk files can find it
#
install qbk : reference.qbk ;
#-------------------------------------------------------------------------------
#
# Produce the Boost.Book XML from the QuickBook
#
# stylesheets and callouts are for
# out-of-tree docs on vinniefalco.github.io
install stylesheets
:
$(broot)/doc/src/boostbook.css
:
<location>$(out)/html
;
explicit stylesheets ;
install callouts
:
[ glob $(broot)/doc/src/images/callouts/*.png ]
:
<location>$(out)/html/images/callouts
;
explicit callout ;
install treeimages
:
[ glob $(broot)/doc/src/images/*.png ]
images/doc-logo.png
:
<location>$(out)/html/images
;
explicit treeimages ;
install images
:
[ glob images/*.png ]
:
<location>html/uri/images
;
explicit images ;
xml uri_doc
:
qbk/main.qbk
:
<dependency>qbk
# <include>$(broot)/tools/boostbook/dtd
;
explicit uri_doc ;
#-------------------------------------------------------------------------------
#
# HTML documentation for $(BOOST_ROOT)/doc/html
#
#-------------------------------------------------------------------------------
boostbook uri
:
uri_doc
:
<xsl:param>boost.image.src=images/doc-logo.png
<xsl:param>boost.image.alt="Boost.URI Logo"
<xsl:param>boost.image.w=880
<xsl:param>boost.image.h=80
<xsl:param>boost.graphics.root=images/
<xsl:param>html.stylesheet=boostbook.css
<xsl:param>nav.layout=none
<xsl:param>chapter.autolabel=0
<xsl:param>chunk.first.sections=1 # Chunk the first top-level section?
<xsl:param>chunk.section.depth=8 # Depth to which sections should be chunked
<xsl:param>generate.toc="chapter nop section nop"
:
<dependency>stylesheets
<dependency>treeimages
<dependency>images
;
#-------------------------------------------------------------------------------
#
# These are used to inform the build system of the
# means to build the integrated and stand-alone docs.
#
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : uri ;
explicit boostrelease ;

BIN
doc/images/doc-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

BIN
doc/images/repo-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

15
doc/qbk/index.xml Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "../../../../tools/boostbook/dtd/boostbook.dtd">
<!--
Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
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)
Official repository: https://github.com/vinniefalco/uri
-->
<section id="json.index">
<title>Index</title>
<index/>
</section>

78
doc/qbk/main.qbk Normal file
View File

@@ -0,0 +1,78 @@
[/
Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
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)
Official repository: https://github.com/vinniefalco/uri
]
[library Boost.URI
[id uri]
[quickbook 1.6]
[copyright 2019 Vinnie Falco]
[purpose URI Library]
[license
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])
]
[authors [Falco, Vinnie]]
[category template]
[category generic]
]
[template mdash[] '''&mdash; ''']
[template indexterm1[term1] '''<indexterm><primary>'''[term1]'''</primary></indexterm>''']
[template indexterm2[term1 term2] '''<indexterm><primary>'''[term1]'''</primary><secondary>'''[term2]'''</secondary></indexterm>''']
[template include_file[path][^<'''<ulink url="https://github.com/vinniefalco/json/blob/master/include/'''[path]'''">'''[path]'''</ulink>'''>]]
[template issue[n] '''<ulink url="https://github.com/vinniefalco/json/issues/'''[n]'''">#'''[n]'''</ulink>''']
[/ Named Requirements ]
[def __Allocator__ [@https://en.cppreference.com/w/cpp/named_req/Allocator ['Allocator]]]
[def __CopyAssignable__ [@https://en.cppreference.com/w/cpp/named_req/CopyAssignable ['CopyAssignable]]]
[def __CopyConstructible__ [@https://en.cppreference.com/w/cpp/named_req/CopyConstructible ['CopyConstructible]]]
[def __DefaultConstructible__ [@https://en.cppreference.com/w/cpp/named_req/DefaultConstructible ['DefaultConstructible]]]
[def __Hash__ [@https://en.cppreference.com/w/cpp/named_req/Hash ['Hash]]]
[def __InputIterator__ [@https://en.cppreference.com/w/cpp/named_req/InputIterator ['InputIterator]]]
[def __MoveAssignable__ [@https://en.cppreference.com/w/cpp/named_req/MoveAssignable ['MoveAssignable]]]
[def __MoveConstructible__ [@https://en.cppreference.com/w/cpp/named_req/MoveConstructible ['MoveConstructible]]]
[def __Swappable__ [@https://en.cppreference.com/w/cpp/named_req/Swappable ['Swappable]]]
[def __Copyable__ [@https://en.cppreference.com/w/cpp/concepts/copyable ['Copyable]]]
[def __SemiRegular__ [@https://en.cppreference.com/w/cpp/concepts/semiregular ['SemiRegular]]]
[/ Dingbats ]
[def __good__ [role green \u2714]]
[def __bad__ [role red \u2718]]
[/-----------------------------------------------------------------------------]
[import ../../test/snippets.cpp]
[/-----------------------------------------------------------------------------]
[variablelist
[[
[link uri.overview Overview]
][
A review of the requirements and features included in Boost.URI,
rationale and design information, answers to frequently
asked questions, and credits.
]]
[[
[link uri.ref Reference]
][
Detailed function and type reference.
]]
]
[section:ref Reference]
[xinclude quickref.xml]
[include reference.qbk]
[endsect]
[xinclude index.xml]

50
doc/qbk/quickref.xml Normal file
View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "../../../../tools/boostbook/dtd/boostbook.dtd">
<!--
Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
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)
Official repository: https://github.com/vinniefalco/uri
-->
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="a"/><colspec colname="b"/><colspec colname="c"/><colspec colname="d"/><colspec colname="e"/>
<thead><row>
<entry valign="center" namest="a" nameend="e"><bridgehead renderas="sect2">JSON</bridgehead></entry>
</row></thead>
<tbody><row>
<entry valign="top">
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Functions</bridgehead>
<simplelist type="vert" columns="1">
</simplelist>
<bridgehead renderas="sect3">Type Traits</bridgehead>
<simplelist type="vert" columns="1">
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Operators</bridgehead>
<simplelist type="vert" columns="1">
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Constants</bridgehead>
<simplelist type="vert" columns="1">
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">Aliases</bridgehead>
<simplelist type="vert" columns="1">
</simplelist>
</entry>
</row></tbody>
</tgroup>
</informaltable>

254
doc/source.dox Normal file
View File

@@ -0,0 +1,254 @@
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = \
$(LIB_DIR)/include/boost/uri
ALIASES += esafe="@par Exception Safety"
INPUT_ENCODING = UTF-8
FILE_PATTERNS =
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
FILTER_SOURCE_PATTERNS =
USE_MDFILE_AS_MAINPAGE =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
SEARCH_INCLUDES = YES
INCLUDE_PATH = ../
INCLUDE_FILE_PATTERNS =
PREDEFINED = \
GENERATING_DOCUMENTATION \
BOOST_URI_DECL \
BOOST_URI_PUBLIC \
BOOST_URI_FORCEINLINE \
"BOOST_URI_NODISCARD=[[nodiscard]]" \
"BOOST_URI_INLINE_VARIABLE(v, t)=constexpr t v;"
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "URI"
PROJECT_NUMBER =
PROJECT_BRIEF = URI Library
PROJECT_LOGO =
OUTPUT_DIRECTORY =
CREATE_SUBDIRS = NO
#####ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF =
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = YES
FULL_PATH_NAMES = YES
#STRIP_FROM_PATH = $(LIB_DIR)/include # Requires doxygen 1.8.7+
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 4
TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
EXTENSION_MAPPING =
MARKDOWN_SUPPORT = YES
AUTOLINK_SUPPORT = YES
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = YES
#####GROUP_NESTED_COMPOUNDS = NO
SUBGROUPING = YES
INLINE_GROUPED_CLASSES = NO
INLINE_SIMPLE_STRUCTS = NO
TYPEDEF_HIDES_STRUCT = NO
LOOKUP_CACHE_SIZE = 0
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_PACKAGE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
EXTRACT_LOCAL_METHODS = NO
EXTRACT_ANON_NSPACES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
#####HIDE_COMPOUND_REFERENCE= NO
SHOW_INCLUDE_FILES = NO
SHOW_GROUPED_MEMB_INC = NO
FORCE_LOCAL_INCLUDES = NO
INLINE_INFO = NO
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
SORT_MEMBERS_CTORS_1ST = YES
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = NO
STRICT_PROTO_MATCHING = NO
GENERATE_TODOLIST = NO
GENERATE_TESTLIST = NO
GENERATE_BUGLIST = NO
GENERATE_DEPRECATEDLIST= NO
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = NO
SHOW_FILES = NO
SHOW_NAMESPACES = NO
FILE_VERSION_FILTER =
LAYOUT_FILE =
CITE_BIB_FILES =
#---------------------------------------------------------------------------
# Configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
#####WARN_AS_ERROR = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
REFERENCES_LINK_SOURCE = YES
SOURCE_TOOLTIPS = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
CLANG_ASSISTED_PARSING = NO
CLANG_OPTIONS =
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = NO
HTML_OUTPUT = dhtm
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_EXTRA_STYLESHEET =
HTML_EXTRA_FILES =
HTML_COLORSTYLE_HUE = 220
HTML_COLORSTYLE_SAT = 100
HTML_COLORSTYLE_GAMMA = 80
HTML_TIMESTAMP = NO
HTML_DYNAMIC_SECTIONS = NO
HTML_INDEX_NUM_ENTRIES = 100
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
DOCSET_PUBLISHER_NAME = Publisher
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
CHM_INDEX_ENCODING =
BINARY_TOC = NO
TOC_EXPAND = NO
GENERATE_QHP = NO
QCH_FILE =
QHP_NAMESPACE = org.doxygen.Project
QHP_VIRTUAL_FOLDER = doc
QHP_CUST_FILTER_NAME =
QHP_CUST_FILTER_ATTRS =
QHP_SECT_FILTER_ATTRS =
QHG_LOCATION =
GENERATE_ECLIPSEHELP = NO
ECLIPSE_DOC_ID = org.doxygen.Project
DISABLE_INDEX = NO
GENERATE_TREEVIEW = NO
ENUM_VALUES_PER_LINE = 4
TREEVIEW_WIDTH = 250
EXT_LINKS_IN_WINDOW = NO
FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
USE_MATHJAX = NO
MATHJAX_FORMAT = HTML-CSS
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
MATHJAX_EXTENSIONS =
MATHJAX_CODEFILE =
SEARCHENGINE = YES
SERVER_BASED_SEARCH = NO
EXTERNAL_SEARCH = NO
SEARCHENGINE_URL =
SEARCHDATA_FILE = searchdata.xml
EXTERNAL_SEARCH_ID =
EXTRA_SEARCH_MAPPINGS =
GENERATE_LATEX = NO
GENERATE_RTF = NO
GENERATE_MAN = NO
GENERATE_DOCBOOK = NO
GENERATE_AUTOGEN_DEF = NO
GENERATE_PERLMOD = NO
CLASS_DIAGRAMS = NO
HAVE_DOT = NO
#---------------------------------------------------------------------------
# Configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = YES
XML_OUTPUT = $(XML_OUTPUT)
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# Configuration options related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES
PERL_PATH = /usr/bin/perl

6
doc/xsl/class_detail.xsl Normal file
View File

@@ -0,0 +1,6 @@
<!-- CLASS_DETAIL_TEMPLATE BEGIN -->
<xsl:when test="$normal-tparam = 'Allocator'"><xsl:text>__Allocator__</xsl:text></xsl:when>
<xsl:when test="$normal-tparam = 'InputIterator'"><xsl:text>__InputIterator__</xsl:text></xsl:when>
<xsl:when test="$normal-tparam = 'ConstBufferSequence'"><xsl:text>__ConstBufferSequence__</xsl:text></xsl:when>
<xsl:when test="$normal-tparam = 'MutableBufferSequence'"><xsl:text>__MutableBufferSequence__</xsl:text></xsl:when>
<!-- CLASS_DETAIL_TEMPLATE END -->

6
doc/xsl/config.xsl Normal file
View File

@@ -0,0 +1,6 @@
<!-- Variables (Edit for your project) -->
<xsl:variable name="doc-ref" select="'json.ref'"/>
<xsl:variable name="doc-ns" select="'boost::json'"/>
<xsl:variable name="debug" select="0"/>
<xsl:variable name="private" select="0"/>
<!-- End Variables -->

15
doc/xsl/includes.xsl Normal file
View File

@@ -0,0 +1,15 @@
<!-- INCLUDES_FOOT_TEMPLATE BEGIN -->
<xsl:template mode="includes-template-footer" match="location">
<xsl:variable name="convenience-header" as="xs:string?">
<xsl:apply-templates mode="convenience-header" select="@file"/>
</xsl:variable>
<xsl:if test="$convenience-header">
<xsl:text>{$nl}</xsl:text>
<xsl:text>Convenience header [include_file boost/{$convenience-header}]</xsl:text>
<xsl:text>{$nl}</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template mode="convenience-header" match="@file[contains(., 'boost/json')]">json.hpp</xsl:template>
<xsl:template mode="convenience-header" match="@file"/>
<!-- INCLUDES_FOOT_TEMPLATE END -->

8
example/CMakeLists.txt Normal file
View File

@@ -0,0 +1,8 @@
#
# Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
#
# 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)
#
# Official repository: https://github.com/vinniefalco/uri
#

15
include/boost/uri.hpp Normal file
View File

@@ -0,0 +1,15 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/json
//
#ifndef BOOST_JSON_HPP
#define BOOST_JSON_HPP
#include <boost/uri/config.hpp>
#endif

View File

@@ -0,0 +1,373 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_BUFFER_HPP
#define BOOST_URI_BUFFER_HPP
#include <boost/beast/uri/view.hpp>
#include <cstdlib>
#include <iterator>
namespace boost {
namespace beast {
namespace uri {
class buffer : public view
{
protected:
char* data_ = nullptr;
std::size_t capacity_ = 0;
buffer() = default;
buffer(char* data, std::size_t capacity)
: data_(data)
, capacity_(capacity)
{
BOOST_ASSERT(data != nullptr);
BOOST_ASSERT(capacity > 0);
this->p_.data = data_;
data_[0] = '\0';
}
void
reset(char* data, std::size_t capacity)
{
BOOST_ASSERT(data != nullptr);
BOOST_ASSERT(capacity > static_cast<
std::size_t>(this->p_.size));
data_ = data;
capacity_ = capacity;
this->p_.data = data;
data_[this->p_.size] = '\0'; // null terminate
}
virtual
void
grow(std::size_t at_least) = 0;
public:
class const_iterator;
buffer(buffer const&) = delete;
buffer& operator=(buffer const&) = delete;
virtual ~buffer() = default;
/** Returns the maximum number of characters which may be stored.
This does not include the null which terminates all
sequences.
*/
virtual
std::size_t
max_size() const = 0;
/** Returns the total number of characters which may be stored without reallocating.
This does not include the null which terminates all
sequences.
*/
std::size_t
capacity() const
{
return capacity_;
}
/// Return an const_iterator to the beginning of the sequence
const_iterator
begin() noexcept;
/** Return an const_iterator to one past the end of the sequence
This does not include the null which terminates all
sequences.
*/
const_iterator
end() noexcept;
parts&
parts() noexcept
{
return this->p_;
}
void
clear()
{
this->p_ = {};
if(capacity_ > 0)
{
this->p_.data = data_;
data_[0] = '\0';
}
}
parts::piece
piece_from(const_iterator const& it) const;
void
append(char c)
{
if(this->p_.size + 1U >= capacity_)
grow(1);
data_[this->p_.size++] = c;
data_[this->p_.size] = '\0';
}
void
append(char const* s, unsigned short len)
{
if(static_cast<std::size_t>(
this->p_.size + len) >= capacity_)
grow(len);
std::memcpy(&data_[this->p_.size], s, len);
this->p_.size += len;
data_[this->p_.size] = '\0';
}
char*
prepare(unsigned short len)
{
if(static_cast<std::size_t>(
this->p_.size + len) >= capacity_)
grow(len);
auto s = &data_[this->p_.size];
this->p_.size += len;
data_[this->p_.size] = '\0';
return s;
}
};
//------------------------------------------------------------------------------
class buffer::const_iterator
{
friend class buffer;
buffer* b_ = nullptr;
unsigned short offset_ = 0;
const_iterator(buffer& b, unsigned short offset)
: b_(&b)
, offset_(offset)
{
}
public:
using value_type = char;
using pointer = char const*;
using reference = char const&;
using difference_type = std::ptrdiff_t;
using iterator_category =
std::random_access_iterator_tag;
const_iterator() = default;
const_iterator(const_iterator const&) = default;
const_iterator& operator=(const_iterator const&) = default;
value_type
operator*()
{
BOOST_ASSERT(b_);
return *(b_->data_ + offset_);
}
const_iterator&
operator++()
{
BOOST_ASSERT(*this < b_->end());
offset_++;
return *this;
}
const_iterator
operator++(int)
{
auto tmp = *this;
++(*this);
return tmp;
}
const_iterator&
operator--()
{
BOOST_ASSERT(*this > b_->begin());
offset_--;
return *this;
}
const_iterator
operator--(int)
{
auto tmp = *this;
++(*this);
return tmp;
}
friend
bool
operator==(
const_iterator const& lhs,
const_iterator const& rhs)
{
BOOST_ASSERT(lhs.b_ == rhs.b_);
return lhs.offset_ == rhs.offset_;
}
friend
bool
operator!=(
const_iterator const& lhs,
const_iterator const& rhs)
{
BOOST_ASSERT(lhs.b_ == rhs.b_);
return lhs.offset_ != rhs.offset_;
}
friend
bool
operator<(
const_iterator const& lhs,
const_iterator const& rhs)
{
BOOST_ASSERT(lhs.b_ == rhs.b_);
return lhs.offset_ < rhs.offset_;
}
friend
bool
operator<=(
const_iterator const& lhs,
const_iterator const& rhs)
{
BOOST_ASSERT(lhs.b_ == rhs.b_);
return lhs.offset_ <= rhs.offset_;
}
friend
bool
operator>(
const_iterator const& lhs,
const_iterator const& rhs)
{
BOOST_ASSERT(lhs.b_ == rhs.b_);
return lhs.offset_ > rhs.offset_;
}
friend
bool
operator>=(
const_iterator const& lhs,
const_iterator const& rhs)
{
BOOST_ASSERT(lhs.b_ == rhs.b_);
return lhs.offset_ >= rhs.offset_;
}
};
//------------------------------------------------------------------------------
inline
auto
buffer::
begin() noexcept ->
const_iterator
{
return {*this, 0};
}
inline
auto
buffer::
end() noexcept ->
const_iterator
{
return {*this, p_.size};
}
inline
parts::piece
buffer::
piece_from(const_iterator const& it) const
{
BOOST_ASSERT(it.b_ == this);
parts::piece result;
result.offset = it.offset_;
result.size = static_cast<unsigned short>(
this->p_.size - result.offset);
return result;
}
//------------------------------------------------------------------------------
template<std::size_t N>
class static_buffer : public buffer
{
char buf_[N + 1]; // room for null
void
grow(std::size_t) override
{
BOOST_THROW_EXCEPTION(std::length_error{
"static_buffer overflow"});
}
public:
static_buffer()
: buffer(buf_, N)
{
}
std::size_t
max_size() const override
{
return N;
}
};
} // uri
} // beast
} // boost
#include <memory>
#include <type_traits>
namespace boost {
namespace beast {
namespace uri {
template<class Allocator>
class dynamic_buffer : public buffer
{
static_assert(std::is_same<char,
typename std::allocator_traits<
Allocator>::value_type>::value,
"Allocator requirements not met");
void
grow(std::size_t at_least) override
{
boost::ignore_unused(at_least);
BOOST_THROW_EXCEPTION(std::length_error{
"static_buffer overflow"});
}
public:
std::size_t
max_size() const override
{
return 0xffffffff;
}
};
} // uri
} // beast
} // boost
#endif

View File

@@ -0,0 +1,57 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_CONFIG_HPP
#define BOOST_URI_CONFIG_HPP
#include <boost/uri/detail/config.hpp>
namespace boost {
namespace uri {
#ifndef BOOST_URI_STANDALONE
/// The type of string view used by the library.
using string_view = boost::string_view;
/// The type of error code used by the library.
using error_code = boost::system::error_code;
/// The type of system error thrown by the library.
using system_error = boost::system::system_error;
/// The type of error category used by the library.
using error_category = boost::system::error_category;
/// The type of error condition used by the library.
using error_condition = boost::system::error_condition;
#ifdef GENERATING_DOCUMENTATION
/// Returns the generic error category used by the library.
error_category const&
generic_category();
#else
using boost::system::generic_category;
#endif
#else
using error_code = std::error_code;
using error_category = std::error_category;
using error_condition = std::error_condition;
using string_view = std::string_view;
using system_error = std::system_error;
using std::generic_category;
#endif
} // uri
} // boost
#endif

View File

@@ -0,0 +1,242 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_DETAIL_CONFIG_HPP
#define BOOST_URI_DETAIL_CONFIG_HPP
#include <boost/config.hpp>
#ifndef BOOST_URI_STANDALONE
# include <boost/assert.hpp>
# include <boost/system/error_code.hpp>
# include <boost/system/system_error.hpp>
# include <boost/utility/string_view.hpp>
#else
# include <cassert>
# include <string_view>
# include <system_error>
#endif
#include <stdint.h>
// detect 32/64 bit
#if UINTPTR_MAX == UINT64_MAX
# define BOOST_URI_ARCH 64
#elif UINTPTR_MAX == UINT32_MAX
# define BOOST_URI_ARCH 32
#else
# error Unknown or unsupported architecture, please open an issue
#endif
// VFALCO Copied from <boost/config.hpp>
// This is a derivative work.
#ifdef __has_cpp_attribute
// clang-6 accepts [[nodiscard]] with -std=c++14, but warns about it -pedantic
# if __has_cpp_attribute(nodiscard) && !(defined(__clang__) && (__cplusplus < 201703L))
# define BOOST_URI_NODISCARD [[nodiscard]]
# else
# define BOOST_URI_NODISCARD
# endif
#else
# define BOOST_URI_NODISCARD
#endif
#ifndef BOOST_URI_FORCEINLINE
# ifdef _MSC_VER
# define BOOST_URI_FORCEINLINE __forceinline
# else
# define BOOST_URI_FORCEINLINE inline
# endif
#endif
#ifndef BOOST_NO_EXCEPTIONS
# define BOOST_URI_THROW(x) throw(x)
#else
# define BOOST_URI_THROW(x) do{}while(0)
#endif
#ifndef BOOST_URI_STANDALONE
# define BOOST_URI_ASSERT BOOST_ASSERT
#else
# define BOOST_URI_ASSERT assert
#endif
#define BOOST_URI_STATIC_ASSERT( ... ) static_assert(__VA_ARGS__, #__VA_ARGS__)
#ifndef BOOST_URI_NO_SSE2
# if (defined(_M_IX86) && _M_IX86_FP == 2) || \
defined(_M_X64) || defined(__SSE2__)
# define BOOST_URI_USE_SSE2
# endif
#endif
#ifndef BOOST_URI_STANDALONE
# if defined(GENERATING_DOCUMENTATION)
# define BOOST_URI_DECL
# elif defined(BOOST_URI_HEADER_ONLY)
# define BOOST_URI_DECL inline
# else
# if (defined(BOOST_URI_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_URI_STATIC_LINK)
# if defined(BOOST_URI_SOURCE)
# define BOOST_URI_DECL BOOST_SYMBOL_EXPORT
# define BOOST_URI_BUILD_DLL
# else
# define BOOST_URI_DECL BOOST_SYMBOL_IMPORT
# endif
# endif // shared lib
# ifndef BOOST_URI_DECL
# define BOOST_URI_DECL
# endif
# if !defined(BOOST_URI_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_URI_NO_LIB)
# define BOOST_LIB_NAME boost_uri
# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URI_DYN_LINK)
# define BOOST_DYN_LINK
# endif
//# include <boost/config/auto_link.hpp>
# endif // auto-linking disabled
# endif
#else
# ifdef BOOST_URI_HEADER_ONLY
# define BOOST_URI_DECL inline
# else
# define BOOST_URI_DECL
# endif
#endif
// These macros are private, for tests, do not change
// them or else previously built libraries won't match.
#ifndef BOOST_URI_MAX_OBJECT_SIZE
# define BOOST_URI_NO_MAX_OBJECT_SIZE
# define BOOST_URI_MAX_OBJECT_SIZE 0x7ffffffe
#endif
#ifndef BOOST_URI_MAX_ARRAY_SIZE
# define BOOST_URI_NO_MAX_ARRAY_SIZE
# define BOOST_URI_MAX_ARRAY_SIZE 0x7ffffffe
#endif
#ifndef BOOST_URI_MAX_STRING_SIZE
# define BOOST_URI_NO_MAX_STRING_SIZE
# define BOOST_URI_MAX_STRING_SIZE 0x7ffffffe
#endif
#ifndef BOOST_URI_MAX_STACK_SIZE
# define BOOST_URI_NO_MAX_STACK_SIZE
# define BOOST_URI_MAX_STACK_SIZE ((::size_t)(-1))
#endif
#ifndef BOOST_URI_PARSER_BUFFER_SIZE
# define BOOST_URI_NO_PARSER_BUFFER_SIZE
# define BOOST_URI_PARSER_BUFFER_SIZE 2048
#endif
namespace boost {
namespace uri {
namespace detail {
template<class...>
struct make_void
{
using type =void;
};
template<class... Ts>
using void_t = typename
make_void<Ts...>::type;
template<class T>
struct remove_const
{
using type = T;
};
template<class T>
struct remove_const<T const>
{
using type = T;
};
template<class T>
struct remove_reference
{
using type = T;
};
template<class T>
struct remove_reference<T&>
{
using type = T;
};
template<class T>
constexpr
typename remove_reference<T>::type&&
move(T&& t) noexcept
{
return static_cast<typename
remove_reference<T>::type&&>(t);
}
template<class T, class U>
inline
T
exchange(T& t, U u) noexcept
{
T v = move(t);
t = move(u);
return v;
}
template<class T>
using is_string_viewish = typename std::enable_if<
std::is_convertible<
T const&, string_view>::value &&
! std::is_convertible<
T const&, char const*>::value
>::type;
/* This is a derivative work, original copyright:
Copyright Eric Niebler 2013-present
Use, modification and distribution is 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)
Project home: https://github.com/ericniebler/range-v3
*/
template<typename T>
struct static_const
{
static constexpr T value {};
};
template<typename T>
constexpr T static_const<T>::value;
#define BOOST_URI_INLINE_VARIABLE(name, type) \
namespace \
{ \
constexpr auto& name = \
::boost::uri::detail::static_const<type>::value; \
}
struct primary_template
{
};
template<class T>
using is_specialized =
std::integral_constant<bool,
! std::is_base_of<primary_template, T>::value>;
template<class T>
using remove_cr =
typename remove_const<
typename remove_reference<T>::type>::type;
} // detail
} // uri
} // boost
#endif

View File

@@ -0,0 +1,23 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_DETAIL_RFC3986_HPP
#define BOOST_URI_DETAIL_RFC3986_HPP
namespace boost {
namespace beast {
namespace uri {
namespace detail {
} // detail
} // uri
} // beast
} // boost
#endif

View File

@@ -0,0 +1,25 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_DETAIL_TYPES_HPP
#define BOOST_URI_DETAIL_TYPES_HPP
#include <boost/beast/core/string.hpp>
#include <boost/beast/uri/scheme.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace beast {
namespace uri {
} // uri
} // beast
} // boost
#endif

View File

@@ -0,0 +1,45 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_ERROR_HPP
#define BOOST_URI_ERROR_HPP
#include <boost/uri/config.hpp>
namespace boost {
namespace uri {
/** Error codes returned by URI operations
*/
enum class error
{
/// An input did not match a structural element (soft error)
mismatch = 1,
/// A syntax error occurred
syntax,
/// The parser encountered an invalid input
invalid
};
enum class condition
{
parse_error = 1
};
} // uri
} // boost
#include <boost/uri/impl/error.hpp>
#ifdef BOOST_URI_HEADER_ONLY
#include <boost/uri/impl/error.ipp>
#endif
#endif

View File

@@ -0,0 +1,63 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_IMPL_ERROR_HPP
#define BOOST_URI_IMPL_ERROR_HPP
#include <type_traits>
#ifndef BOOST_URI_STANDALONE
namespace boost {
namespace system {
template<>
struct is_error_code_enum<::boost::uri::error>
{
static bool const value = true;
};
template<>
struct is_error_condition_enum<::boost::uri::condition>
{
static bool const value = true;
};
} // system
} // boost
#else
namespace std {
template<>
struct is_error_code_enum<::boost::uri::error>
{
static bool const value = true;
};
template<>
struct is_error_condition_enum<::boost::uri::condition>
{
static bool const value = true;
};
} // std
#endif
namespace boost {
namespace uri {
BOOST_URI_DECL
error_code
make_error_code(error e);
BOOST_URI_DECL
error_condition
make_error_condition(condition c);
} // uri
} // boost
#endif

View File

@@ -0,0 +1,93 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_IMPL_ERROR_IPP
#define BOOST_URI_IMPL_ERROR_IPP
#include <boost/uri/error.hpp>
namespace boost {
namespace uri {
error_code
make_error_code(error e)
{
struct codes : error_category
{
const char*
name() const noexcept override
{
return "boost.uri";
}
std::string
message(int ev) const override
{
switch(static_cast<error>(ev))
{
default:
case error::mismatch: return "mismatch";
case error::syntax: return "syntax";
case error::invalid: return "invalid";
}
}
error_condition
default_error_condition(
int ev) const noexcept override
{
switch(static_cast<error>(ev))
{
default:
return {ev, *this};
case error::mismatch:
case error::syntax:
case error::invalid:
return condition::parse_error;
}
}
};
static codes const cat{};
return error_code{static_cast<
std::underlying_type<error>::type>(e), cat};
}
error_condition
make_error_condition(condition c)
{
struct codes : error_category
{
const char*
name() const noexcept override
{
return "boost.uri";
}
std::string
message(int cv) const override
{
switch(static_cast<condition>(cv))
{
default:
case condition::parse_error:
return "parsing error";
}
}
};
static codes const cat{};
return error_condition{static_cast<
std::underlying_type<condition>::type>(c), cat};
}
} // uri
} // boost
#endif

View File

@@ -0,0 +1,607 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_IMPL_PARSE_IPP
#define BOOST_URI_IMPL_PARSE_IPP
#include <boost/beast/uri/error.hpp>
#include <boost/beast/uri/input.hpp>
#include <stdexcept>
namespace boost {
namespace beast {
namespace uri {
namespace detail {
/* References:
Uniform Resource Identifier (URI): Generic Syntax
https://tools.ietf.org/html/rfc3986
Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content
https://tools.ietf.org/html/rfc7231
Internationalized Resource Identifiers (IRIs)
https://tools.ietf.org/html/rfc3987
URL Living Standard
https://url.spec.whatwg.org
java.net Class URI
https://docs.oracle.com/javase/7/docs/api/java/net/URI.html
Generic URI
[scheme:]scheme-specific-part[#fragment]
Hierarchical URI
[scheme:][//authority][path][?query][#fragment]
bool is_hierarchical() const
bool is_opaque() const
*/
template<class>
struct parser_impl
{
bool
is_alpha(char c)
{
unsigned constexpr a = 'a';
return ((static_cast<unsigned>(c) | 32) - a) < 26U;
}
bool
is_digit(char c)
{
unsigned constexpr zero = '0';
return (static_cast<unsigned>(c) - zero) < 10;
}
/*
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
*/
bool
is_unreserved(char c)
{
return
(c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') ||
c == '-' || c == '.' ||
c == '_' || c == '~'
;
}
/*
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
*/
bool
is_sub_delim(char c)
{
return
c == '!' || c == '$' || c == '&' || c == '\'' ||
c == '(' || c == ')' || c == '*' || c == '+' ||
c == ',' || c == ';' || c == '='
;
}
int
hex_val(char c)
{
if(c >= '0' && c <= '9')
return c - '0';
if(c >= 'A' && c <= 'F')
return c - 'A' + 10;
if(c >= 'a' && c <= 'f')
return c - 'a' + 10;
return -1;
}
char
hex_digit(int v)
{
if(v < 10)
return static_cast<char>(
'0' + v);
return static_cast<char>(
'A' + v - 10);
}
char
to_lower(char c)
{
if((static_cast<unsigned>(c) - 65U) < 26)
return c + ('a' - 'A');
return c;
}
//--------------------------------------------------------------------------
/*
pct-encoded = "%" HEXDIG HEXDIG
Caller is responsible for consuming the '%'
*/
void
parse_pct_encoded(
char& c,
input& in,
error_code& ec)
{
if(in.remain() < 2)
{
// short input
ec = error::syntax;
return;
}
auto d1 = hex_val(in[0]);
if(d1 == -1)
{
// invalid hex digit
ec = error::syntax;
return;
}
auto d2 = hex_val(in[1]);
if(d2 == -1)
{
// invalid hex digit
ec = uri::error::invalid;
return;
}
c = static_cast<char>(
16 * d1 + d2);
in += 2;
}
// append a percent encoded char to the
// current string. the hex digits are normalized
void
append_pct_encoded(buffer& out, char c)
{
auto it = out.prepare(3);
*it++ = '%';
*it++ = hex_digit(
static_cast<unsigned char>(c) / 16);
*it++ = hex_digit(
static_cast<unsigned char>(c) % 16);
}
//--------------------------------------------------------------------------
/*
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
*/
void
parse_pchar(
buffer& out,
input& in,
error_code& ec)
{
/*
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
*/
auto const is_pchar =
[&](char c)
{
return
is_alpha(c) ||
is_digit(c) ||
c == '-' || c == '.' || c == '_' || c == '~' ||
c == '!' || c == '$' || c == '&' || c == '\'' ||
c == '(' || c == ')' || c == '*' || c == '+' ||
c == ',' || c == ';' || c == '=' ||
c == ':' || c == '@'
;
};
if(is_pchar(*in))
{
out.append(*in++);
return;
}
if(*in != '%')
{
ec = error::mismatch;
return;
}
in++;
char c;
parse_pct_encoded(c, in, ec);
if(ec)
return;
if(is_unreserved(c))
{
out.append(c);
return;
}
/* VFALCO Small problem here
https://tools.ietf.org/html/rfc3986#section-2.2
URI producing applications should percent-encode data octets that
correspond to characters in the reserved set unless these characters
are specifically allowed by the URI scheme to represent data in that
component.
How do we know if the URI scheme considers `c` a delimiter?
Maybe we need to use CRTP or something as a customization point.
*/
append_pct_encoded(out, c);
}
/*
qchar = unreserved / pct-encoded / sub-delims / ":" / "@" / '/' / "?"
*/
void
parse_qchar(
buffer& out,
input& in,
error_code& ec)
{
/*
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
*/
auto const is_qchar =
[&](char c)
{
return
is_alpha(c) ||
is_digit(c) ||
c == '-' || c == '.' || c == '_' || c == '~' ||
c == '!' || c == '$' || c == '&' || c == '\'' ||
c == '(' || c == ')' || c == '*' || c == '+' ||
c == ',' || c == ';' || c == '=' ||
c == ':' || c == '@' || c == '/' || c == '?'
;
};
if(is_qchar(*in))
{
out.append(*in++);
return;
}
if(*in != '%')
{
ec = error::mismatch;
return;
}
in++;
char c;
parse_pct_encoded(c, in, ec);
if(ec)
return;
if(is_unreserved(c))
{
out.append(c);
return;
}
/* VFALCO Small problem here
https://tools.ietf.org/html/rfc3986#section-2.2
URI producing applications should percent-encode data octets that
correspond to characters in the reserved set unless these characters
are specifically allowed by the URI scheme to represent data in that
component.
How do we know if the URI scheme considers `c` a delimiter?
Maybe we need to use CRTP or something as a customization point.
*/
append_pct_encoded(out, c);
}
//--------------------------------------------------------------------------
/*
segment = *pchar
*/
void
parse_segment(
buffer& out,
input& in,
error_code& ec)
{
for(;;)
{
if(in.empty())
break;
parse_pchar(out, in, ec);
if(ec)
{
if(ec != error::mismatch)
return;
ec.clear();
break;
}
}
}
//--------------------------------------------------------------------------
/*
https://tools.ietf.org/html/rfc3986#section-3.2
The authority component is preceded by a double slash ("//") and is
terminated by the next slash ("/"), question mark ("?"), or number
sign ("#") character, or by the end of the URI.
*/
void
parse_authority(
buffer& out,
input& in,
error_code& ec)
{
boost::ignore_unused(ec);
auto start = out.end();
while(! in.empty())
{
if( *in == '/' ||
*in == '?' ||
*in == '#')
break;
out.append(*in++);
}
out.parts().authority = out.piece_from(start);
}
/*
path-abempty = *( "/" segment )
segment = *pchar
*/
void
parse_path_abempty(
buffer& out,
input& in,
error_code& ec)
{
if(in.empty())
{
auto start = out.end();
// normalize: path is not empty
out.append('/');
out.parts().path = out.piece_from(start);
return;
}
auto start = out.end();
while(! in.empty() && *in == '/')
{
in++;
out.append('/');
parse_segment(out, in, ec);
if(ec)
return;
}
out.parts().path = out.piece_from(start);
}
//--------------------------------------------------------------------------
/*
scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) ":"
*/
void
parse_scheme(
buffer& out,
input& in,
error_code& ec)
{
if(in.empty())
{
// bad scheme
ec = error::syntax;
return;
}
if(! is_alpha(*in))
{
// bad scheme
ec = error::syntax;
return;
}
auto start = out.end();
for(;;)
{
out.append(to_lower(*in++));
if(in.empty())
{
// bad scheme
ec = error::syntax;
return;
}
if( ! is_alpha(*in) &&
! is_digit(*in) &&
*in != '+' &&
*in != '-' &&
*in != '.')
break;
}
out.parts().scheme = out.piece_from(start);
out.parts().scheme_value = string_to_scheme(out.scheme());
}
/*
hier-part = "//" authority path-abempty
/ path-absolute
/ path-rootless
/ path-empty
*/
void
parse_hier_part(
buffer& out,
input& in,
error_code& ec)
{
if( in.remain() >= 2 &&
in[0] == '/' &&
in[1] == '/')
{
in += 2;
auto s = out.prepare(2);
s[0] = '/';
s[1] = '/';
parse_authority(out, in, ec);
if(ec)
return;
parse_path_abempty(out, in, ec);
if(ec)
return;
}
}
/*
query = *qchar
qchar = pchar / "/" / "?"
*/
void
parse_query(
buffer& out,
input& in,
error_code& ec)
{
auto start = out.end();
for(;;)
{
if(in.empty())
break;
parse_qchar(out, in, ec);
if(ec)
{
if(ec != error::mismatch)
return;
ec.clear();
break;
}
}
if(out.end() != start)
out.parts().query = out.piece_from(start);
}
//--------------------------------------------------------------------------
/*
absolute-URI = scheme ":" hier-part [ "?" query ]
https://tools.ietf.org/html/rfc3986#section-4.3
To allow for transition to absoluteURIs in all requests in future
versions of HTTP, all HTTP/1.1 servers MUST accept the absoluteURI
form in requests, even though HTTP/1.1 clients will only generate
them in requests to proxies.
*/
void
parse_absolute_form(
buffer& out,
input& in,
error_code& ec)
{
// scheme
parse_scheme(out, in, ec);
if(ec)
return;
// ":"
if(in.empty())
{
ec = error::syntax;
return;
}
if(*in++ != ':')
{
ec = error::syntax;
return;
}
out.append(':');
// hier-part
parse_hier_part(out, in, ec);
if(ec)
return;
// "?"
if(in.empty())
return;
if(*in != '?')
{
ec = error::syntax;
return;
}
in++;
out.append('?');
// query
parse_query(out, in, ec);
if(ec)
return;
if(! in.empty())
{
// spurious characters
ec = error::syntax;
return;
}
}
};
using parser = parser_impl<void>;
} // detail
//------------------------------------------------------------------------------
/*
absolute-URI = scheme ":" hier-part [ "?" query ]
https://tools.ietf.org/html/rfc3986#section-4.3
To allow for transition to absoluteURIs in all requests in future
versions of HTTP, all HTTP/1.1 servers MUST accept the absoluteURI
form in requests, even though HTTP/1.1 clients will only generate
them in requests to proxies.
*/
inline
void
parse_absolute_form(
buffer& out,
string_view s,
error_code& ec)
{
input in{s};
out.clear();
ec.assign(0, ec.category());
try
{
detail::parser p;
p.parse_absolute_form(out, in, ec);
}
catch(std::length_error const&)
{
//ec = error::overflow
}
}
} // uri
} // beast
} // boost
#endif

View File

@@ -0,0 +1,167 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_IMPL_SCHEME_IPP
#define BOOST_URI_IMPL_SCHEME_IPP
#include <boost/beast/uri/detail/rfc3986.hpp>
namespace boost {
namespace beast {
namespace uri {
namespace detail {
template<class = void>
known_scheme
string_to_scheme(string_view s)
{
switch(s.size())
{
case 2: // ws
if( tolower(s[0]) == 'w' &&
tolower(s[1]) == 's')
return known_scheme::ws;
break;
case 3:
switch(tolower(s[0]))
{
case 'w': // wss
if( tolower(s[1]) == 's' &&
tolower(s[2]) == 's')
return known_scheme::wss;
break;
case 'f': // ftp
if( tolower(s[1]) == 't' &&
tolower(s[2]) == 'p')
return known_scheme::ftp;
break;
default:
break;
}
break;
case 4:
switch(tolower(s[0]))
{
case 'f': // file
if( tolower(s[1]) == 'i' &&
tolower(s[2]) == 'l' &&
tolower(s[3]) == 'e')
return known_scheme::file;
break;
case 'h': // http
if( tolower(s[1]) == 't' &&
tolower(s[2]) == 't' &&
tolower(s[3]) == 'p')
return known_scheme::http;
break;
default:
break;
}
break;
case 5: // https
if( tolower(s[0]) == 'h' &&
tolower(s[1]) == 't' &&
tolower(s[2]) == 't' &&
tolower(s[3]) == 'p' &&
tolower(s[4]) == 's')
return known_scheme::https;
break;
case 6:
if( tolower(s[0]) == 'g' &&
tolower(s[1]) == 'o' &&
tolower(s[2]) == 'p' &&
tolower(s[3]) == 'h' &&
tolower(s[4]) == 'e' &&
tolower(s[5]) == 'r')
return known_scheme::gopher;
break;
default:
break;
}
return known_scheme::unknown;
}
template<class = void>
string_view
to_string(known_scheme s)
{
switch(s)
{
case known_scheme::ftp: return "ftp";
case known_scheme::file: return "file";
case known_scheme::gopher: return "gopher";
case known_scheme::http: return "http";
case known_scheme::https: return "https";
case known_scheme::ws: return "ws";
case known_scheme::wss: return "wss";
default:
break;
}
return "<unknown>";
}
template<class = void>
bool
is_special(known_scheme s)
{
switch(s)
{
case known_scheme::ftp:
case known_scheme::file:
case known_scheme::gopher:
case known_scheme::http:
case known_scheme::https:
case known_scheme::ws:
case known_scheme::wss:
return true;
default:
break;
}
return false;
}
} // detail
inline
known_scheme
string_to_scheme(string_view s)
{
return detail::string_to_scheme(s);
}
inline
string_view
to_string(known_scheme s)
{
return detail::to_string(s);
}
inline
bool
is_special(known_scheme s)
{
return detail::is_special(s);
}
} // uri
} // beast
} // boost
#endif

View File

@@ -0,0 +1,167 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_IMPL_SCHEME_IPP
#define BOOST_URI_IMPL_SCHEME_IPP
#include <boost/beast/uri/detail/rfc3986.hpp>
namespace boost {
namespace beast {
namespace uri {
namespace detail {
template<class = void>
known_scheme
string_to_scheme(string_view s)
{
switch(s.size())
{
case 2: // ws
if( tolower(s[0]) == 'w' &&
tolower(s[1]) == 's')
return known_scheme::ws;
break;
case 3:
switch(tolower(s[0]))
{
case 'w': // wss
if( tolower(s[1]) == 's' &&
tolower(s[2]) == 's')
return known_scheme::wss;
break;
case 'f': // ftp
if( tolower(s[1]) == 't' &&
tolower(s[2]) == 'p')
return known_scheme::ftp;
break;
default:
break;
}
break;
case 4:
switch(tolower(s[0]))
{
case 'f': // file
if( tolower(s[1]) == 'i' &&
tolower(s[2]) == 'l' &&
tolower(s[3]) == 'e')
return known_scheme::file;
break;
case 'h': // http
if( tolower(s[1]) == 't' &&
tolower(s[2]) == 't' &&
tolower(s[3]) == 'p')
return known_scheme::http;
break;
default:
break;
}
break;
case 5: // https
if( tolower(s[0]) == 'h' &&
tolower(s[1]) == 't' &&
tolower(s[2]) == 't' &&
tolower(s[3]) == 'p' &&
tolower(s[4]) == 's')
return known_scheme::https;
break;
case 6:
if( tolower(s[0]) == 'g' &&
tolower(s[1]) == 'o' &&
tolower(s[2]) == 'p' &&
tolower(s[3]) == 'h' &&
tolower(s[4]) == 'e' &&
tolower(s[5]) == 'r')
return known_scheme::gopher;
break;
default:
break;
}
return known_scheme::unknown;
}
template<class = void>
string_view
to_string(known_scheme s)
{
switch(s)
{
case known_scheme::ftp: return "ftp";
case known_scheme::file: return "file";
case known_scheme::gopher: return "gopher";
case known_scheme::http: return "http";
case known_scheme::https: return "https";
case known_scheme::ws: return "ws";
case known_scheme::wss: return "wss";
default:
break;
}
return "<unknown>";
}
template<class = void>
bool
is_special(known_scheme s)
{
switch(s)
{
case known_scheme::ftp:
case known_scheme::file:
case known_scheme::gopher:
case known_scheme::http:
case known_scheme::https:
case known_scheme::ws:
case known_scheme::wss:
return true;
default:
break;
}
return false;
}
} // detail
inline
known_scheme
string_to_scheme(string_view s)
{
return detail::string_to_scheme(s);
}
inline
string_view
to_string(known_scheme s)
{
return detail::to_string(s);
}
inline
bool
is_special(known_scheme s)
{
return detail::is_special(s);
}
} // uri
} // beast
} // boost
#endif

176
include/boost/uri/input.hpp Normal file
View File

@@ -0,0 +1,176 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_INPUT_HPP
#define BOOST_URI_INPUT_HPP
#include <boost/beast/core/string.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace beast {
namespace uri {
/** Represents an input character sequence.
*/
class input
{
char const* it_ = nullptr;
char const* end_ = nullptr;
public:
/** Allows input sequence modifications to be rolled back
*/
class guard;
/// Constructor
input() = default;
/// Constructor
input(input const&) = default;
/// Assignment
input& operator=(input const&) = default;
/// Constructor
explicit
input(string_view s) noexcept
: it_(s.data())
, end_(s.data() + s.size())
{
}
/// Returns an iterator to the end of the input sequence
char const*
end() const noexcept
{
return end_;
}
/// Returns `true` if no characters are remaining
bool
empty() const noexcept
{
return it_ >= end_;
}
/// Return the number of characters remaining
std::size_t
remain() const noexcept
{
return static_cast<std::size_t>(end_ - it_);
}
/// Return an iterator to the current character
char const*
get() const noexcept
{
return it_;
}
/// Return the current character
char const&
operator*() const noexcept
{
BOOST_ASSERT(it_ < end_);
return *it_;
}
/// Return the character at a particular offset
char const&
operator[](int offset) const noexcept
{
BOOST_ASSERT(it_ + offset < end_);
return it_[offset];
}
/// Advance the current character
input&
operator++() noexcept
{
BOOST_ASSERT(it_ < end_);
++it_;
return *this;
}
/// Advance the current character
input
operator++(int) noexcept
{
auto temp = *this;
++(*this);
return temp;
}
input&
operator+=(int n) noexcept
{
it_ += n;
return *this;
}
};
//------------------------------------------------------------------------------
class input::guard
{
char const*& it_;
char const* saved_;
bool revert_ = true;
public:
guard() = delete;
guard(guard const&) = delete;
guard& operator=(guard const&) = delete;
/// Constructor
explicit
guard(input& in)
: it_(in.it_)
, saved_(in.it_)
{
}
/// Constructor
guard(guard&& other)
: it_(other.it_)
, saved_(other.saved_)
, revert_(other.revert_)
{
other.revert_ = false;
}
/// Destructor
~guard()
{
if(revert_)
it_ = saved_;
}
/// Returns an iterator to the beginning of the guarded sequence
char const*
begin() const noexcept
{
return saved_;
}
/// Commit to the current input iterator position
void
commit()
{
BOOST_ASSERT(revert_);
revert_ = false;
}
};
} // uri
} // beast
} // boost
#endif

View File

@@ -0,0 +1,178 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_MAKE_SHARED_HPP
#define BOOST_URI_MAKE_SHARED_HPP
#include <boost/beast/uri/view.hpp>
#include <boost/beast/core/detail/allocator.hpp>
#include <boost/beast/core/detail/empty_base_optimization.hpp>
#include <boost/assert.hpp>
#include <boost/type_traits/type_with_alignment.hpp>
#include <memory>
#include <type_traits>
namespace boost {
namespace beast {
namespace uri {
namespace detail {
template<class T, class Allocator>
class extra_alloc
: private beast::detail::empty_base_optimization<Allocator>
{
template<class U, class OtherAlloc>
friend class extra_alloc;
std::size_t extra_;
public:
using is_always_equal = std::false_type;
using value_type = typename
beast::detail::allocator_traits<typename beast::detail::allocator_traits<
Allocator>::template rebind_alloc<T>>::value_type;
using pointer = typename
beast::detail::allocator_traits<typename beast::detail::allocator_traits<
Allocator>::template rebind_alloc<T>>::pointer;
using const_pointer = typename
beast::detail::allocator_traits<typename beast::detail::allocator_traits<
Allocator>::template rebind_alloc<T>>::const_pointer;
using size_type = typename
beast::detail::allocator_traits<typename beast::detail::allocator_traits<
Allocator>::template rebind_alloc<T>>::size_type;
using difference_type = typename
beast::detail::allocator_traits<typename beast::detail::allocator_traits<
Allocator>::template rebind_alloc<T>>::difference_type;
template<class U>
struct rebind
{
using other = extra_alloc<U, Allocator>;
};
extra_alloc(
std::size_t extra,
Allocator const& alloc)
: beast::detail::empty_base_optimization<Allocator>(alloc)
, extra_(extra)
{
}
template<class U>
extra_alloc(extra_alloc<U, Allocator> const& other) noexcept
: beast::detail::empty_base_optimization<Allocator>(other.member())
, extra_(other.extra_)
{
}
pointer
allocate(size_type n)
{
BOOST_ASSERT(n == 1);
using U = typename boost::type_with_alignment<
alignof(value_type)>::type;
auto constexpr S = sizeof(U);
using A = typename beast::detail::allocator_traits<
Allocator>::template rebind_alloc<U>;
A a{this->member()};
return reinterpret_cast<pointer>(
std::allocator_traits<A>::allocate(a,
(n * sizeof(value_type) + extra_ + S - 1) / S));
}
void
deallocate(pointer p, size_type n)
{
BOOST_ASSERT(n == 1);
using U = typename boost::type_with_alignment<
alignof(value_type)>::type;
auto constexpr S = sizeof(U);
using A = typename beast::detail::allocator_traits<
Allocator>::template rebind_alloc<U>;
A a{this->member()};
std::allocator_traits<A>::deallocate(a,
reinterpret_cast<U*>(p),
(n * sizeof(value_type) + extra_ + S - 1) / S);
}
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000
template<class U, class... Args>
void
construct(U* ptr, Args&&... args)
{
::new((void*)ptr) U(std::forward<Args>(args)...);
}
template<class U>
void
destroy(U* ptr)
{
ptr->~U();
}
#endif
template<class U>
friend
bool
operator==(
extra_alloc const& lhs,
extra_alloc<U, Allocator> const& rhs)
{
return
lhs.member() == rhs.member() &&
lhs.extra_ == rhs.extra_;
}
template<class U>
friend
bool
operator!=(
extra_alloc const& lhs,
extra_alloc<U, Allocator> const& rhs)
{
return ! (lhs == rhs);
}
};
struct shared_view_impl : view
{
shared_view_impl(view const& v)
: view(v.cparts(),
reinterpret_cast<
char const*>(this + 1))
{
}
};
} // detail
template<
class Allocator = std::allocator<char>>
std::shared_ptr<view>
make_shared(
view const& v,
Allocator const& alloc = Allocator{})
{
using T = detail::shared_view_impl;
auto p = std::allocate_shared<T>(
detail::extra_alloc<T, Allocator>(
v.str().size(), alloc), v);
std::memcpy(
reinterpret_cast<char*>(p.get() + 1),
v.str().data(),
v.str().size());
return p;
}
} // uri
} // beast
} // boost
#endif

106
include/boost/uri/parse.hpp Normal file
View File

@@ -0,0 +1,106 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_PARSE_HPP
#define BOOST_URI_PARSE_HPP
#include <boost/beast/core/error.hpp>
#include <boost/beast/core/string.hpp>
#include <boost/beast/uri/buffer.hpp>
namespace boost {
namespace beast {
namespace uri {
/*
5.3 Request Target
https://tools.ietf.org/html/rfc7230#section-5.3
request-target = origin-form
/ absolute-form
/ authority-form
/ asterisk-form
origin-form = absolute-path [ "?" query ]
absolute-form = absolute-URI
authority-form = authority
asterisk-form = "*"
*/
/* Parse a URI in origin form.
The origin form is used in direct requests to an
origin server, except for CONNECT or OPTIONS *.
@par Example
The request-target is this example HTTP request
uses origin form:
@code
GET /index.html HTTP/1.1\r\n
@endcode
@par BNF
@code
origin-form = absolute-path [ "?" query ]
@endcode
*/
void
parse_origin_form(error_code& ec);
/** Parse a URI string in absolute form.
Absolute form is used in HTTP requests to a proxy,
except for CONNECT or OPTIONS *
absolute-URI = scheme ":" hier-part [ "?" query ]
https://tools.ietf.org/html/rfc3986#section-4.3
To allow for transition to absoluteURIs in all requests in future
versions of HTTP, all HTTP/1.1 servers MUST accept the absoluteURI
form in requests, even though HTTP/1.1 clients will only generate
them in requests to proxies.
*/
void
parse_absolute_form(
buffer& out,
string_view s,
error_code& ec);
/* Used in CONNECT requests
The authority-form of request-target is only used for CONNECT requests
https://tools.ietf.org/html/rfc7230#section-5.3.3
Although CONNECT must exclude userinfo and '@' we parse it anyway and
let the caller decide what to do with it.
authority-form = authority
*/
void
parse_authority_form(error_code& ec);
/* Used for server-wide OPTIONS requests
*/
void
parse_asterisk_form(error_code& ec);
} // uri
} // beast
} // boost
#include <boost/beast/uri/impl/parse.ipp>
#endif

View File

@@ -0,0 +1,88 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_PARTS_HPP
#define BOOST_URI_PARTS_HPP
#include <boost/beast/uri/scheme.hpp>
#include <boost/beast/core/string.hpp>
#include <boost/assert.hpp>
#include <limits>
namespace boost {
namespace beast {
namespace uri {
/** Represents parts of a URI in linear, normalized form.
*/
struct parts
{
struct piece
{
unsigned short offset = 0;
unsigned short size = 0;
piece() = default;
piece(
char const* base,
char const* first, char const* last)
: offset(static_cast<unsigned short>(first - base))
, size(static_cast<unsigned short>(last - first))
{
BOOST_ASSERT(first - base < (
std::numeric_limits<unsigned short>::max)());
BOOST_ASSERT(last - first < (
std::numeric_limits<unsigned short>::max)());
}
bool
empty() const
{
return size == 0;
}
explicit
operator bool() const
{
return ! empty();
}
string_view
operator()(char const* base) const
{
return {base + offset, size};
}
};
char const* data;
unsigned short size = 0;
known_scheme scheme_value = known_scheme::unknown;
piece scheme;
piece authority;
piece userinfo;
piece username;
piece password;
piece host;
piece port;
piece path;
piece query;
piece fragment;
parts()
: data("")
{
}
};
} // uri
} // beast
} // boost
#endif

View File

@@ -0,0 +1,63 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_SCHEME_HPP
#define BOOST_URI_SCHEME_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/string.hpp>
namespace boost {
namespace beast {
namespace uri {
/** Identifies a known URI scheme
*/
enum class known_scheme : unsigned char
{
unknown = 0,
ftp,
file,
gopher,
http,
https,
ws,
wss
};
/** Return the scheme for a non-normalized string, if known
*/
known_scheme
string_to_scheme(string_view s);
/** Return the normalized string for a known scheme
*/
string_view
to_string(known_scheme s);
/** Return `true` if the known scheme is a special scheme
The list of special schemes is as follows:
ftp, file, gopher, http, https, ws, wss.
@param s The known-scheme constant to check
@return `true` if the scheme is special
*/
bool
is_special(known_scheme s);
} // uri
} // beast
} // boost
#include <boost/beast/uri/impl/scheme.ipp>
#endif

26
include/boost/uri/src.hpp Normal file
View File

@@ -0,0 +1,26 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_SRC_HPP
#define BOOST_URI_SRC_HPP
/*
This file is meant to be included once,
in a translation unit of the program.
*/
#include <boost/uri/config.hpp>
#if defined(BOOST_URI_HEADER_ONLY)
# error Do not compile library source with the header only macro defined
#endif
#endif

115
include/boost/uri/uri.hpp Normal file
View File

@@ -0,0 +1,115 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_URI_HPP
#define BOOST_URI_URI_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/string.hpp>
namespace boost {
namespace beast {
namespace uri {
#if 0
namespace detail {
template<class Buffer>
class parser;
} // detail
template<class Buffer>
class basic_uri
{
template<class Buffer>
friend class detail::parser;
detail::parts p_;
Buffer b_;
explicit
basic_uri(detail::parts const& p)
: p_(p)
{
}
public:
basic_uri() = default;
basic_uri(basic_uri&&) = default;
basic_uri(basic_uri const&) = default;
basic_uri& operator=(basic_uri&&) = default;
basic_uri& operator=(basic_uri const&) = default;
template<class... Args>
explicit
basic_uri(Args&&... args)
: b_(std::forward<Args>(args)...)
{
}
//
// Observers
//
known_scheme
scheme_value() const
{
return p_.scheme_value;
}
string_view
scheme() const
{
return p_.scheme(b_.data());
}
//
// Modifiers
//
void
clear()
{
p_ = parse{};
b_.clear();
}
};
//------------------------------------------------------------------------------
template<unsigned short N>
class static_buffer
{
char buf_[N];
public:
char*
data()
{
return buf_;
}
char const*
data() const
{
return buf_;
}
std::size_t
size() const
{
return N;
}
};
#endif
} // uri
} // beast
} // boost
#endif

132
include/boost/uri/view.hpp Normal file
View File

@@ -0,0 +1,132 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_VIEW_HPP
#define BOOST_URI_VIEW_HPP
#include <boost/beast/uri/parts.hpp>
#include <iosfwd>
namespace boost {
namespace beast {
namespace uri {
struct view
{
view() = default;
view(view const&) = default;
view& operator=(view const&) = default;
view(parts const& p, char const* data) noexcept
: p_(p)
{
p_.data = data;
}
string_view
str() const noexcept
{
return {p_.data, p_.size};
}
char const*
c_str() const noexcept
{
return p_.data;
}
known_scheme
scheme_value() const noexcept
{
return p_.scheme_value;
}
string_view
scheme() const noexcept
{
return p_.scheme(p_.data);
}
string_view
authority() const noexcept
{
return p_.authority(p_.data);
}
string_view
userinfo() const noexcept
{
return p_.userinfo(p_.data);
}
string_view
username() const noexcept
{
return p_.username(p_.data);
}
string_view
password() const noexcept
{
return p_.password(p_.data);
}
string_view
host() const noexcept
{
return p_.host(p_.data);
}
string_view
port() const noexcept
{
return p_.port(p_.data);
}
string_view
path() const noexcept
{
return p_.path(p_.data);
}
string_view
query() const noexcept
{
return p_.query(p_.data);
}
string_view
fragment() const noexcept
{
return p_.fragment(p_.data);
}
parts const&
cparts() const noexcept
{
return p_;
}
protected:
parts p_;
};
inline
std::ostream&
operator<<(std::ostream& os, view const& v)
{
os << v.str();
return os;
}
} // uri
} // beast
} // boost
#endif

12
src/src.cpp Normal file
View File

@@ -0,0 +1,12 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
#ifndef BOOST_URI_HEADER_ONLY
#include <boost/uri/src.hpp>
#endif

27
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,27 @@
#
# Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
#
# 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)
#
# Official repository: https://github.com/vinniefalco/uri
#
source_group (uri FILES ${PROJECT_SOURCE_DIR}/include/boost/uri.hpp)
source_group (TREE ${PROJECT_SOURCE_DIR}/include/boost/uri PREFIX uri FILES ${PROJECT_FILES})
GroupSources(test "/")
add_definitions(-DBOOST_URI_HEADER_ONLY=1)
add_executable (uri-tests
${BEAST_FILES}
${PROJECT_FILES}
${PROJECT_SOURCE_DIR}/include/boost/uri.hpp
${PROJECT_SOURCE_DIR}/src/src.cpp
Jamfile
main.cpp
error.cpp
)
add_test(uri-tests uri-tests)

52
test/Jamfile Normal file
View File

@@ -0,0 +1,52 @@
#
# Copyright (c) 2013-2019 Vinnie Falco (vinnie.falco@gmail.com)
#
# 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)
#
# Official repository: https://github.com/vinniefalco/uri
#
import testing ;
import ../../config/checks/config : requires ;
import os ;
STANDALONE = [ os.environ STANDALONE ] ;
if $(STANDALONE)
{
LIB =
<define>BOOST_JSON_STANDALONE=1
<source>../src/src.cpp
;
}
else
{
LIB = <library>/boost/uri//boost_uri ;
}
local SOURCES =
error.cpp
;
local LIMIT_SOURCES =
;
local RUN_TESTS ;
for local f in $(SOURCES)
{
RUN_TESTS += [
run $(f) main.cpp : : :
$(LIB)
] ;
}
for local f in $(LIMIT_SOURCES)
{
RUN_TESTS += [
run $(f) main.cpp : : :
<source>../src/src.cpp
] ;
}
alias run-tests : $(RUN_TESTS) ;

59
test/error.cpp Normal file
View File

@@ -0,0 +1,59 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/uri
//
// Test that header file is self-contained.
#include <boost/uri/error.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <memory>
namespace boost {
namespace uri {
class error_test : public beast::unit_test::suite
{
public:
void check(error e)
{
auto const ec = make_error_code(e);
BEAST_EXPECT(ec.category().name() != nullptr);
BEAST_EXPECT(! ec.message().empty());
BEAST_EXPECT(ec.category().default_error_condition(
static_cast<int>(e)).category() == ec.category());
}
void check(condition c, error e)
{
{
auto const ec = make_error_code(e);
BEAST_EXPECT(ec.category().name() != nullptr);
BEAST_EXPECT(! ec.message().empty());
BEAST_EXPECT(ec == c);
}
{
auto ec = make_error_condition(c);
BEAST_EXPECT(ec.category().name() != nullptr);
BEAST_EXPECT(! ec.message().empty());
BEAST_EXPECT(ec == c);
}
}
void
run() override
{
check(condition::parse_error, error::mismatch);
check(condition::parse_error, error::syntax);
check(condition::parse_error, error::invalid);
}
};
BEAST_DEFINE_TESTSUITE(boost,uri,error);
} // uri
} // boost

10
test/main.cpp Normal file
View File

@@ -0,0 +1,10 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// 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)
//
// Official repository: https://github.com/vinniefalco/json
//
#include <boost/beast/_experimental/unit_test/main.ipp>

65
tools/codecov.sh Normal file
View File

@@ -0,0 +1,65 @@
#! /bin/bash
#
# Copyright 2017 - 2019 James E. King III
# 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)
#
# Bash script to run in travis to perform codecov.io integration
#
# assumes cwd is the top level directory of the boost project
# assumes an environment variable $SELF is the boost project name
set -ex
. ci/travis/enforce.sh
if [ -z "$GCOV" ]; then
if [ "${B2_TOOLSET%%-*}" == "gcc" ]; then
ver="${B2_TOOLSET#*-}"
GCOV=gcov-${ver}
else
GCOV=gcov-7 # default
fi
fi
# lcov after 1.14 needs this
# sudo apt install --no-install-recommends -y libperlio-gzip-perl libjson-perl
# install the latest lcov we know works
# some older .travis.yml files install the tip which may be unstable
rm -rf /tmp/lcov
pushd /tmp
git clone -b v1.14 https://github.com/linux-test-project/lcov.git
export PATH=/tmp/lcov/bin:$PATH
which lcov
lcov --version
popd
B2_VARIANT=variant=debug
ci/travis/build.sh cxxflags=--coverage linkflags=--coverage
#cxxflags=-fprofile-arcs cxxflags=-ftest-coverage linkflags=-fprofile-arcs linkflags=-ftest-coverage
# switch back to the original source code directory
cd $TRAVIS_BUILD_DIR
# coverage files are in ../../b2 from this location
lcov --gcov-tool=$GCOV --rc lcov_branch_coverage=0 --base-directory "$BOOST_ROOT/libs/$SELF" --directory "$BOOST_ROOT" --capture --output-file all.info
# all.info contains all the coverage info for all projects - limit to ours
# first we extract the interesting headers for our project then we use that list to extract the right things
for f in `for f in include/boost/*; do echo $f; done | cut -f2- -d/`; do echo "*/$f*"; done > /tmp/interesting
echo headers that matter:
cat /tmp/interesting
xargs -L 999999 -a /tmp/interesting lcov --gcov-tool=$GCOV --rc lcov_branch_coverage=1 --extract all.info {} "*/libs/$SELF/src/*" --output-file coverage.info
# dump a summary on the console - helps us identify problems in pathing
lcov --gcov-tool=$GCOV --rc lcov_branch_coverage=1 --list coverage.info
#
# upload to codecov.io
#
curl -s https://codecov.io/bash > .codecov
chmod +x .codecov
./.codecov -f coverage.info -X gcov -x "$GCOV"