mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 02:25:52 +00:00
Compare commits
215 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9454e0f0c | ||
|
|
26181907fc | ||
|
|
ed597e5e99 | ||
|
|
2c88c15f7f | ||
|
|
cfd3642cb1 | ||
|
|
f493590604 | ||
|
|
8c084a3de8 | ||
|
|
985aa803a4 | ||
|
|
9e319d7bd6 | ||
|
|
a122e176d7 | ||
|
|
88a6f2931e | ||
|
|
54f3a83e25 | ||
|
|
0955c0d8d3 | ||
|
|
6bb5be5216 | ||
|
|
c9cd7e4be0 | ||
|
|
ce2cecf046 | ||
|
|
6e934ee6a1 | ||
|
|
723d7d1263 | ||
|
|
298572893e | ||
|
|
405f6f7368 | ||
|
|
648ccc7c17 | ||
|
|
f5afe0587f | ||
|
|
91a227a475 | ||
|
|
4b905fe9ff | ||
|
|
0f409b7bec | ||
|
|
295c8de858 | ||
|
|
e5252f90af | ||
|
|
c2276155bf | ||
|
|
dbe49bcd87 | ||
|
|
7b936de32c | ||
|
|
9eb34f542c | ||
|
|
194304e544 | ||
|
|
c59fc332d5 | ||
|
|
b43832fe57 | ||
|
|
c24a497a23 | ||
|
|
4096fcd1bf | ||
|
|
9a0e806f78 | ||
|
|
20c9632996 | ||
|
|
65a628ca88 | ||
|
|
d82dbba096 | ||
|
|
58547f6997 | ||
|
|
e6f4eedb1e | ||
|
|
c5b963141f | ||
|
|
5df40bd746 | ||
|
|
403f15dc48 | ||
|
|
704d7451a0 | ||
|
|
fa11071443 | ||
|
|
87351c8a0c | ||
|
|
2f5fb1e68e | ||
|
|
96e1ec6d31 | ||
|
|
ac3cf05f1a | ||
|
|
6335e34395 | ||
|
|
02c2029ac1 | ||
|
|
6914aa3e27 | ||
|
|
f4fcb1cc9a | ||
|
|
b6eec21ec0 | ||
|
|
0ce3aeb189 | ||
|
|
713c8efcbe | ||
|
|
9fa5e39872 | ||
|
|
ace53fa405 | ||
|
|
3c06980107 | ||
|
|
1f26fbb5af | ||
|
|
84c6622122 | ||
|
|
63f099f2f6 | ||
|
|
373ce72984 | ||
|
|
4cf29455e4 | ||
|
|
07db5d497c | ||
|
|
f1bb0afc4e | ||
|
|
d791fe3013 | ||
|
|
c16e22a5c6 | ||
|
|
db7a720445 | ||
|
|
6c09a02099 | ||
|
|
1b3356cafd | ||
|
|
5869902f2c | ||
|
|
28898031f0 | ||
|
|
1ce0f94638 | ||
|
|
f876ad973f | ||
|
|
6014b13234 | ||
|
|
3e9c702c47 | ||
|
|
3ff919ccf1 | ||
|
|
8dc0844c79 | ||
|
|
a2764b68ca | ||
|
|
bbbae072ea | ||
|
|
b4735b5931 | ||
|
|
418638ad16 | ||
|
|
9fb09d3109 | ||
|
|
d7e08f96a5 | ||
|
|
4d49d272eb | ||
|
|
faa6890950 | ||
|
|
9c390f6da4 | ||
|
|
6842277977 | ||
|
|
ddf68d464d | ||
|
|
b2f19e8dc6 | ||
|
|
5714b42975 | ||
|
|
c4e9c49c10 | ||
|
|
9210efb051 | ||
|
|
b9f1b05625 | ||
|
|
828c2e3c71 | ||
|
|
10150a7352 | ||
|
|
baaa45f8c7 | ||
|
|
322af30d6a | ||
|
|
206efbf30d | ||
|
|
a96dee85d2 | ||
|
|
d307568cbc | ||
|
|
0ee27b143c | ||
|
|
7bfb4a9ba5 | ||
|
|
110c73fc8d | ||
|
|
424d9b8385 | ||
|
|
1b48ccc868 | ||
|
|
fac82204b6 | ||
|
|
61f114e655 | ||
|
|
24410bf1bb | ||
|
|
aa24969eee | ||
|
|
a5297d13c4 | ||
|
|
b06bdb83cb | ||
|
|
d06092212f | ||
|
|
914778eae1 | ||
|
|
e14c700c60 | ||
|
|
0848e348bb | ||
|
|
3d5ae42660 | ||
|
|
f207b6b4c9 | ||
|
|
ed2c5078ad | ||
|
|
aec792f5b8 | ||
|
|
17d64de3d5 | ||
|
|
f6bea08535 | ||
|
|
feab6c39b3 | ||
|
|
e999c76882 | ||
|
|
686cc599a2 | ||
|
|
92983556a0 | ||
|
|
837872c3f3 | ||
|
|
55222dc5d1 | ||
|
|
adce6ae851 | ||
|
|
9dc32cb791 | ||
|
|
23dc08c925 | ||
|
|
488a44b88e | ||
|
|
530bdf975e | ||
|
|
d7a6627a1f | ||
|
|
d6066183b9 | ||
|
|
3e2c3ba035 | ||
|
|
e24cba8c35 | ||
|
|
a23013abc1 | ||
|
|
27a4f44de5 | ||
|
|
4e07dbbefc | ||
|
|
dcf4ad2c21 | ||
|
|
04dd861fe3 | ||
|
|
c8ee6c6f6d | ||
|
|
a57e4263d7 | ||
|
|
3d58f0d941 | ||
|
|
a52c9232c4 | ||
|
|
7a059c7a73 | ||
|
|
506910147f | ||
|
|
cf3eb24eb0 | ||
|
|
d965b23b2a | ||
|
|
f660743065 | ||
|
|
4559bd9030 | ||
|
|
3ac98fb101 | ||
|
|
aff52db289 | ||
|
|
ea27dfe08d | ||
|
|
27620af1bf | ||
|
|
bf116308d4 | ||
|
|
3fb27d98ab | ||
|
|
7e45c17730 | ||
|
|
626533d4a7 | ||
|
|
39719f4c17 | ||
|
|
526bd88dc4 | ||
|
|
37201ecaa6 | ||
|
|
02ed879837 | ||
|
|
8b881d3a77 | ||
|
|
f25456ce25 | ||
|
|
dfb1db4ab3 | ||
|
|
4362cb660b | ||
|
|
1aa0749ba8 | ||
|
|
c7f1f6a91f | ||
|
|
888a3fec21 | ||
|
|
8514b88974 | ||
|
|
724ec46129 | ||
|
|
4f1d1d2a8a | ||
|
|
39a387b54c | ||
|
|
2b0034667d | ||
|
|
98202c56ae | ||
|
|
1e06ddf13c | ||
|
|
560071bb68 | ||
|
|
2e49ec47a3 | ||
|
|
e70d618aff | ||
|
|
3e4cf426bd | ||
|
|
3f10924594 | ||
|
|
f8182c335a | ||
|
|
1d8d6a6d68 | ||
|
|
69fccdf5c6 | ||
|
|
27e8d44a56 | ||
|
|
72bc4ebf37 | ||
|
|
353f32e6af | ||
|
|
9bbaa9a2ae | ||
|
|
096fcefae9 | ||
|
|
0f1e292e34 | ||
|
|
195957a7cc | ||
|
|
eb122f45f9 | ||
|
|
c51ac9d6da | ||
|
|
97c9d02c43 | ||
|
|
0c06939f38 | ||
|
|
5db677d74d | ||
|
|
251ce4efbc | ||
|
|
386eabb61f | ||
|
|
b35eabe161 | ||
|
|
9ad9845d69 | ||
|
|
74eb25f9b5 | ||
|
|
044f390fe0 | ||
|
|
06d6e4901e | ||
|
|
3ca9646329 | ||
|
|
4b3e629dfd | ||
|
|
568fae9878 | ||
|
|
a844026f6b | ||
|
|
b677cacb8c | ||
|
|
1d66169ef1 | ||
|
|
74653e57e6 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,6 +19,7 @@
|
||||
*.o
|
||||
build
|
||||
tags
|
||||
TAGS
|
||||
bin/rippled
|
||||
Debug/*.*
|
||||
Release/*.*
|
||||
|
||||
@@ -12,6 +12,14 @@ before_install:
|
||||
- sudo apt-get install -qq libboost1.55-all-dev
|
||||
# We want debug symbols for boost as we install gdb later
|
||||
- sudo apt-get install -qq libboost1.55-dbg
|
||||
- | # Setup the BOOST_ROOT
|
||||
export BOOST_ROOT=$HOME/boost_root
|
||||
mkdir -p $BOOST_ROOT/stage
|
||||
ln -s /usr/lib/x86_64-linux-gnu $BOOST_ROOT/stage/lib
|
||||
ln -s /usr/include/boost $BOOST_ROOT/boost
|
||||
- | # Try to patch boost
|
||||
sudo patch /usr/include/boost/bimap/detail/debug/static_error.hpp Builds/travis/static_error.boost.patch
|
||||
sudo patch /usr/include/boost/config/compiler/clang.hpp Builds/travis/clang.boost.patch
|
||||
- sudo apt-get install -qq mlocate
|
||||
- sudo updatedb
|
||||
- sudo locate libboost | grep /lib | grep -e ".a$"
|
||||
|
||||
30
Builds/Docker/Dockerfile
Normal file
30
Builds/Docker/Dockerfile
Normal file
@@ -0,0 +1,30 @@
|
||||
# rippled
|
||||
|
||||
# use the ubuntu base image
|
||||
FROM ubuntu
|
||||
MAINTAINER Roberto Catini roberto.catini@gmail.com
|
||||
|
||||
# make sure the package repository is up to date
|
||||
RUN apt-get update
|
||||
RUN apt-get -y upgrade
|
||||
|
||||
# install the dependencies
|
||||
RUN apt-get -y install git scons pkg-config protobuf-compiler libprotobuf-dev libssl-dev libboost1.55-all-dev
|
||||
|
||||
# download source code from official repository
|
||||
RUN git clone https://github.com/ripple/rippled.git src; cd src/; git checkout master
|
||||
|
||||
# compile
|
||||
RUN cd src/; scons build/rippled
|
||||
|
||||
# move to root directory and strip
|
||||
RUN cp src/build/rippled rippled; strip rippled
|
||||
|
||||
# copy default config
|
||||
RUN cp src/doc/rippled-example.cfg rippled.cfg
|
||||
|
||||
# clean source
|
||||
RUN rm -r src
|
||||
|
||||
# launch rippled when launching the container
|
||||
ENTRYPOINT ./rippled
|
||||
@@ -62,42 +62,42 @@ UI_HEADERS_DIR += ../../src/ripple_basics
|
||||
# New style
|
||||
#
|
||||
SOURCES += \
|
||||
../../src/ripple/beast/ripple_beast.cpp \
|
||||
../../src/ripple/beast/ripple_beast.unity.cpp \
|
||||
../../src/ripple/beast/ripple_beastc.c \
|
||||
../../src/ripple/common/ripple_common.cpp \
|
||||
../../src/ripple/http/ripple_http.cpp \
|
||||
../../src/ripple/json/ripple_json.cpp \
|
||||
../../src/ripple/peerfinder/ripple_peerfinder.cpp \
|
||||
../../src/ripple/radmap/ripple_radmap.cpp \
|
||||
../../src/ripple/resource/ripple_resource.cpp \
|
||||
../../src/ripple/sitefiles/ripple_sitefiles.cpp \
|
||||
../../src/ripple/sslutil/ripple_sslutil.cpp \
|
||||
../../src/ripple/testoverlay/ripple_testoverlay.cpp \
|
||||
../../src/ripple/types/ripple_types.cpp \
|
||||
../../src/ripple/validators/ripple_validators.cpp
|
||||
../../src/ripple/common/ripple_common.unity.cpp \
|
||||
../../src/ripple/http/ripple_http.unity.cpp \
|
||||
../../src/ripple/json/ripple_json.unity.cpp \
|
||||
../../src/ripple/peerfinder/ripple_peerfinder.unity.cpp \
|
||||
../../src/ripple/radmap/ripple_radmap.unity.cpp \
|
||||
../../src/ripple/resource/ripple_resource.unity.cpp \
|
||||
../../src/ripple/sitefiles/ripple_sitefiles.unity.cpp \
|
||||
../../src/ripple/sslutil/ripple_sslutil.unity.cpp \
|
||||
../../src/ripple/testoverlay/ripple_testoverlay.unity.cpp \
|
||||
../../src/ripple/types/ripple_types.unity.cpp \
|
||||
../../src/ripple/validators/ripple_validators.unity.cpp
|
||||
|
||||
# ---------
|
||||
# Old style
|
||||
#
|
||||
SOURCES += \
|
||||
../../src/ripple_app/ripple_app.cpp \
|
||||
../../src/ripple_app/ripple_app_pt1.cpp \
|
||||
../../src/ripple_app/ripple_app_pt2.cpp \
|
||||
../../src/ripple_app/ripple_app_pt3.cpp \
|
||||
../../src/ripple_app/ripple_app_pt4.cpp \
|
||||
../../src/ripple_app/ripple_app_pt5.cpp \
|
||||
../../src/ripple_app/ripple_app_pt6.cpp \
|
||||
../../src/ripple_app/ripple_app_pt7.cpp \
|
||||
../../src/ripple_app/ripple_app_pt8.cpp \
|
||||
../../src/ripple_basics/ripple_basics.cpp \
|
||||
../../src/ripple_core/ripple_core.cpp \
|
||||
../../src/ripple_data/ripple_data.cpp \
|
||||
../../src/ripple_hyperleveldb/ripple_hyperleveldb.cpp \
|
||||
../../src/ripple_leveldb/ripple_leveldb.cpp \
|
||||
../../src/ripple_net/ripple_net.cpp \
|
||||
../../src/ripple_overlay/ripple_overlay.cpp \
|
||||
../../src/ripple_rpc/ripple_rpc.cpp \
|
||||
../../src/ripple_websocket/ripple_websocket.cpp
|
||||
../../src/ripple_app/ripple_app.unity.cpp \
|
||||
../../src/ripple_app/ripple_app_pt1.unity.cpp \
|
||||
../../src/ripple_app/ripple_app_pt2.unity.cpp \
|
||||
../../src/ripple_app/ripple_app_pt3.unity.cpp \
|
||||
../../src/ripple_app/ripple_app_pt4.unity.cpp \
|
||||
../../src/ripple_app/ripple_app_pt5.unity.cpp \
|
||||
../../src/ripple_app/ripple_app_pt6.unity.cpp \
|
||||
../../src/ripple_app/ripple_app_pt7.unity.cpp \
|
||||
../../src/ripple_app/ripple_app_pt8.unity.cpp \
|
||||
../../src/ripple_basics/ripple_basics.unity.cpp \
|
||||
../../src/ripple_core/ripple_core.unity.cpp \
|
||||
../../src/ripple_data/ripple_data.unity.cpp \
|
||||
../../src/ripple_hyperleveldb/ripple_hyperleveldb.unity.cpp \
|
||||
../../src/ripple_leveldb/ripple_leveldb.unity.cpp \
|
||||
../../src/ripple_net/ripple_net.unity.cpp \
|
||||
../../src/ripple_overlay/ripple_overlay.unity.cpp \
|
||||
../../src/ripple_rpc/ripple_rpc.unity.cpp \
|
||||
../../src/ripple_websocket/ripple_websocket.unity.cpp
|
||||
|
||||
LIBS += \
|
||||
-lboost_date_time-mt\
|
||||
|
||||
4
Builds/VisualStudio2013/.gitattributes
vendored
Normal file
4
Builds/VisualStudio2013/.gitattributes
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
RippleD.vcxproj -text
|
||||
RippleD.vcxproj.filters -text
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros">
|
||||
<RepoDir>..\..</RepoDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OutDir>$(RepoDir)\build\VisualStudio2013\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(RepoDir)\build\obj\VisualStudio2013\$(Configuration).$(Platform)\</IntDir>
|
||||
<TargetName>rippled</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_VARIADIC_MAX=10;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>$(RepoDir)\src\protobuf\src;$(RepoDir)\src\protobuf\vsprojects;$(RepoDir)\src\leveldb;$(RepoDir)\src\leveldb\include;$(RepoDir)\src\snappy\snappy;$(RepoDir)\src\snappy\config;$(RepoDir)\build\proto;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<DisableSpecificWarnings>4018;4244</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SpecifySectionAttributes>
|
||||
</SpecifySectionAttributes>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<BuildMacro Include="RepoDir">
|
||||
<Value>$(RepoDir)</Value>
|
||||
</BuildMacro>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup />
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
@@ -3,9 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Express 2013 for Windows Desktop
|
||||
VisualStudioVersion = 12.0.30110.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "beast", "..\..\src\beast\Builds\VisualStudio2013\beast.vcxproj", "{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RippleD", "RippleD.vcxproj", "{B7F39ECD-473C-484D-BC34-31F8362506A5}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RippleD", "RippleD.vcxproj", "{26B7D9AC-1A80-8EF8-6703-D061F1BECB75}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -15,21 +13,12 @@ Global
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}.Debug|x64.Build.0 = Debug|x64
|
||||
{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}.Release|Win32.Build.0 = Release|Win32
|
||||
{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}.Release|x64.ActiveCfg = Release|x64
|
||||
{73C5A0F0-7629-4DE7-9194-BE7AC6C19535}.Release|x64.Build.0 = Release|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Debug|Win32.ActiveCfg = Debug|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Debug|Win32.Build.0 = Debug|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Debug|x64.Build.0 = Debug|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Release|Win32.ActiveCfg = Release|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Release|x64.ActiveCfg = Release|x64
|
||||
{B7F39ECD-473C-484D-BC34-31F8362506A5}.Release|x64.Build.0 = Release|x64
|
||||
{26B7D9AC-1A80-8EF8-6703-D061F1BECB75}.Debug|Win32.ActiveCfg = debug|x64
|
||||
{26B7D9AC-1A80-8EF8-6703-D061F1BECB75}.Debug|x64.ActiveCfg = debug|x64
|
||||
{26B7D9AC-1A80-8EF8-6703-D061F1BECB75}.Debug|x64.Build.0 = debug|x64
|
||||
{26B7D9AC-1A80-8EF8-6703-D061F1BECB75}.Release|Win32.ActiveCfg = release|x64
|
||||
{26B7D9AC-1A80-8EF8-6703-D061F1BECB75}.Release|x64.ActiveCfg = release|x64
|
||||
{26B7D9AC-1A80-8EF8-6703-D061F1BECB75}.Release|x64.Build.0 = release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<DisableSpecificWarnings>4018;4244;4267</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
@@ -1,5 +1,5 @@
|
||||
Name: rippled
|
||||
Version: 0.24.0
|
||||
Version: 0.26.2
|
||||
Release: 1%{?dist}
|
||||
Summary: Ripple peer-to-peer network daemon
|
||||
|
||||
|
||||
13
Builds/travis/clang.boost.patch
Normal file
13
Builds/travis/clang.boost.patch
Normal file
@@ -0,0 +1,13 @@
|
||||
--- /usr/include/boost/config/compiler/clang.hpp 2013-07-20 13:17:10.000000000 -0400
|
||||
+++ /usr/include/boost/config/compiler/clang.rippled.hpp 2014-03-11 16:40:51.000000000 -0400
|
||||
@@ -39,6 +39,10 @@
|
||||
// Clang supports "long long" in all compilation modes.
|
||||
#define BOOST_HAS_LONG_LONG
|
||||
|
||||
+#if defined(__SIZEOF_INT128__)
|
||||
+# define BOOST_HAS_INT128
|
||||
+#endif
|
||||
+
|
||||
//
|
||||
// Dynamic shared object (DSO) and dynamic-link library (DLL) support
|
||||
//
|
||||
10
Builds/travis/static_error.boost.patch
Normal file
10
Builds/travis/static_error.boost.patch
Normal file
@@ -0,0 +1,10 @@
|
||||
--- /usr/include/boost/bimap/detail/debug/static_error.hpp 2008-03-22 17:45:55.000000000 -0400
|
||||
+++ /usr/include/boost/bimap/detail/debug/static_error.rippled.hpp 2014-03-12 19:40:05.000000000 -0400
|
||||
@@ -25,7 +25,6 @@
|
||||
// a static error.
|
||||
/*===========================================================================*/
|
||||
#define BOOST_BIMAP_STATIC_ERROR(MESSAGE,VARIABLES) \
|
||||
- struct BOOST_PP_CAT(BIMAP_STATIC_ERROR__,MESSAGE) {}; \
|
||||
BOOST_MPL_ASSERT_MSG(false, \
|
||||
BOOST_PP_CAT(BIMAP_STATIC_ERROR__,MESSAGE), \
|
||||
VARIABLES)
|
||||
1134
SConstruct
1134
SConstruct
File diff suppressed because it is too large
Load Diff
@@ -27,12 +27,12 @@
|
||||
# Purpose
|
||||
#
|
||||
# This file documents and provides examples of all rippled server process
|
||||
# configuration options. When the rippled server instance is lanched, it looks
|
||||
# for a file with the following name:
|
||||
# configuration options. When the rippled server instance is launched, it
|
||||
# looks for a file with the following name:
|
||||
#
|
||||
# rippled.cfg
|
||||
#
|
||||
# For more information on where the rippled serer instance searches for
|
||||
# For more information on where the rippled server instance searches for
|
||||
# the file please visit the Ripple wiki. Specifically, the section explaining
|
||||
# the --conf command line option:
|
||||
#
|
||||
@@ -136,10 +136,10 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
# [max_peers]
|
||||
# [peers_max]
|
||||
#
|
||||
# The largest number of desired peer connections (incoming or outgoing).
|
||||
# Cluster and fixed peers do not count towards this total. There are
|
||||
# The largest number of desired peer connections (incoming or outgoing).
|
||||
# Cluster and fixed peers do not count towards this total. There are
|
||||
# implementation-defined lower limits imposed on this value for security
|
||||
# purposes.
|
||||
#
|
||||
@@ -242,7 +242,7 @@
|
||||
#
|
||||
# The amount of time to wait in seconds, before sending a websocket 'ping'
|
||||
# message. Ping messages are used to determine if the remote end of the
|
||||
# connection is no longer availabile.
|
||||
# connection is no longer available.
|
||||
#
|
||||
#
|
||||
#
|
||||
@@ -299,7 +299,7 @@
|
||||
#
|
||||
# This group of settings configures security and access attributes of the
|
||||
# RPC server section of the rippled process, used to service both local
|
||||
# an optional remote clients.
|
||||
# and optional remote clients.
|
||||
#
|
||||
#
|
||||
#
|
||||
@@ -314,7 +314,7 @@
|
||||
#
|
||||
# [rpc_admin_allow]
|
||||
#
|
||||
# Specify an list of IP addresses allowed to have admin access. One per line.
|
||||
# Specify a list of IP addresses allowed to have admin access. One per line.
|
||||
# If you want to test the output of non-admin commands add this section and
|
||||
# just put an ip address not under your control.
|
||||
# Defaults to 127.0.0.1.
|
||||
@@ -334,7 +334,7 @@
|
||||
#
|
||||
# [rpc_admin_password]
|
||||
#
|
||||
# As a server, require this as the admin pasword to be specified. Also,
|
||||
# As a server, require this as the admin password to be specified. Also,
|
||||
# require rpc_admin_user and rpc_admin_password to be checked for RPC admin
|
||||
# functions. The request must specify these as the admin_user and
|
||||
# admin_password in the request object.
|
||||
@@ -358,7 +358,7 @@
|
||||
#
|
||||
# [rpc_user]
|
||||
#
|
||||
# As a server, require a this user to specified and require rpc_password to
|
||||
# As a server, require this user to be specified and require rpc_password to
|
||||
# be checked for RPC access via the rpc_ip and rpc_port. The user and password
|
||||
# must be specified via HTTP's basic authentication method.
|
||||
# As a client, supply this to the server via HTTP's basic authentication
|
||||
@@ -368,7 +368,7 @@
|
||||
#
|
||||
# [rpc_password]
|
||||
#
|
||||
# As a server, require a this password to specified and require rpc_user to
|
||||
# As a server, require this password to be specified and require rpc_user to
|
||||
# be checked for RPC access via the rpc_ip and rpc_port. The user and password
|
||||
# must be specified via HTTP's basic authentication method.
|
||||
# As a client, supply this to the server via HTTP's basic authentication
|
||||
@@ -393,8 +393,9 @@
|
||||
# 0: Server certificates are not provided for RPC clients using SSL [default]
|
||||
# 1: Client RPC connections wil be provided with SSL certificates.
|
||||
#
|
||||
# Note that if rpc_secure is enabled, it will also be necessasry to configure the
|
||||
# certificate file settings located in rpc_ssl_cert, rpc_ssl_chain, and rpc_ssl_key
|
||||
# Note that if rpc_secure is enabled, it will also be necessary to configure
|
||||
# the certificate file settings located in rpc_ssl_cert, rpc_ssl_chain, and
|
||||
# rpc_ssl_key
|
||||
#
|
||||
#
|
||||
#
|
||||
@@ -402,8 +403,9 @@
|
||||
#
|
||||
# <pathname>
|
||||
#
|
||||
# A file system path leading to the SSL certificate file to use for secure RPC.
|
||||
# The file is in PEM format. The file is not needed if the chain includes it.
|
||||
# A file system path leading to the SSL certificate file to use for secure
|
||||
# RPC. The file is in PEM format. The file is not needed if the chain
|
||||
# includes it.
|
||||
#
|
||||
#
|
||||
#
|
||||
@@ -444,7 +446,7 @@
|
||||
#
|
||||
# [sms_url]?from=[sms_from]&to=[sms_to]&api_key=[sms_key]&api_secret=[sms_secret]&text=['text']
|
||||
#
|
||||
# Where [...] are the corresponding valus from the configuration file, and
|
||||
# Where [...] are the corresponding values from the configuration file, and
|
||||
# ['test'] is the value of the JSON field with name 'text'.
|
||||
#
|
||||
# [sms_url]
|
||||
@@ -538,8 +540,8 @@
|
||||
# For domains, rippled will probe for https web servers at the specified
|
||||
# domain in the following order: ripple.DOMAIN, www.DOMAIN, DOMAIN
|
||||
#
|
||||
# For public key entries, a comment may optionally be spcified after adding a
|
||||
# space to the pulic key.
|
||||
# For public key entries, a comment may optionally be specified after adding
|
||||
# a space to the public key.
|
||||
#
|
||||
# Examples:
|
||||
# ripple.com
|
||||
@@ -587,14 +589,14 @@
|
||||
#
|
||||
# [path_search_fast]
|
||||
# [path_search_max]
|
||||
# When seaching for paths, the minimum and maximum search aggressiveness.
|
||||
# When searching for paths, the minimum and maximum search aggressiveness.
|
||||
#
|
||||
# The default for 'path_search_fast' is 2. The default for 'path_search_max' is 10.
|
||||
#
|
||||
# [path_search_old]
|
||||
#
|
||||
# For clients that use the legacy path finding interfaces, the search
|
||||
# agressiveness to use. The default is 7.
|
||||
# agressivness to use. The default is 7.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#
|
||||
|
||||
[validators]
|
||||
n9KPnVLn7ewVzHvn218DcEYsnWLzKerTDwhpofhk4Ym1RUq4TeGw first
|
||||
n9LFzWuhKNvXStHAuemfRKFVECLApowncMAM5chSCL9R5ECHGN4V second
|
||||
n94rSdgTyBNGvYg8pZXGuNt59Y5bGAZGxbxyvjDaqD9ceRAgD85P third
|
||||
n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7 RL1
|
||||
n9MD5h24qrQqiyBC8aeqqCWvpiBiYQ3jxSr91uiDvmrkyHRdYLUj RL2
|
||||
n9L81uNCaPgtUJfaHh89gmdvXKAmSt5Gdsw2g1iPWaPkAHW5Nm4C RL3
|
||||
n9KiYM9CgngLvtRCQHZwgC2gjpdaZcCcbt3VboxiNFcKuwFVujzS RL4
|
||||
n9LdgEtkmGB9E2h3K4Vp7iGUaKuq23Zr32ehxiU8FWY7xoxbWTSA RL5
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"ripple-lib": "0.7.25",
|
||||
"ripple-lib": "0.7.37",
|
||||
"async": "~0.2.9",
|
||||
"extend": "~1.2.0",
|
||||
"simple-jsonrpc": "~0.0.2",
|
||||
@@ -31,4 +31,4 @@
|
||||
},
|
||||
|
||||
"readmeFilename": "README.md"
|
||||
}
|
||||
}
|
||||
|
||||
2
src/.gitignore
vendored
2
src/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
# boost subtree
|
||||
/boost
|
||||
@@ -166,16 +166,6 @@
|
||||
#define RIPPLE_DUMP_LEAKS_ON_EXIT 1
|
||||
#endif
|
||||
|
||||
/** Config: RIPPLE_TRACK_MUTEXES
|
||||
Turns on a feature that enables tracking and diagnostics for mutex
|
||||
and recursive mutex objects. This affects the type of lock used
|
||||
by RippleMutex and RippleRecursiveMutex
|
||||
@note This can slow down performance considerably.
|
||||
*/
|
||||
#ifndef RIPPLE_TRACK_MUTEXES
|
||||
#define RIPPLE_TRACK_MUTEXES 0
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// These control whether or not certain functionality gets
|
||||
@@ -200,26 +190,59 @@
|
||||
#endif
|
||||
|
||||
/** Config: BEAST_USE_BOOST_FEATURES
|
||||
This activates boost specific features and improvements. If this is
|
||||
turned on, the include paths for your build environment must be set
|
||||
correctly to find the boost headers.
|
||||
This activates boost specific features and improvements. If this is
|
||||
turned on, the include paths for your build environment must be set
|
||||
correctly to find the boost headers.
|
||||
*/
|
||||
#ifndef BEAST_USE_BOOST_FEATURES
|
||||
//#define BEAST_USE_BOOST_FEATURES 1
|
||||
#endif
|
||||
|
||||
/** Config: RIPPLE_PROPOSE_FEATURES
|
||||
This determines whether to add any features to the proposed transaction set.
|
||||
This determines whether to add any features to the proposed transaction set.
|
||||
*/
|
||||
#ifndef RIPPLE_PROPOSE_AMENDMENTS
|
||||
#define RIPPLE_PROPOSE_AMENDMENTS 0
|
||||
#endif
|
||||
|
||||
/** Config: RIPPLE_USE_OLD_CREATE_TRANSACTOR
|
||||
This determines whether ripple uses the legacy OfferCreate transactor.
|
||||
/** Config: RIPPLE_ENABLE_AUTOBRIDGING
|
||||
This determines whether ripple implements offer autobridging via XRP.
|
||||
*/
|
||||
#ifndef RIPPLE_USE_OLD_CREATE_TRANSACTOR
|
||||
#define RIPPLE_USE_OLD_CREATE_TRANSACTOR 1
|
||||
#ifndef RIPPLE_ENABLE_AUTOBRIDGING
|
||||
#define RIPPLE_ENABLE_AUTOBRIDGING 0
|
||||
#endif
|
||||
|
||||
/** Config: RIPPLE_SINGLE_IO_SERVICE_THREAD
|
||||
When set, restricts the number of threads calling io_service::run to one.
|
||||
This is useful when debugging.
|
||||
*/
|
||||
#ifndef RIPPLE_SINGLE_IO_SERVICE_THREAD
|
||||
#define RIPPLE_SINGLE_IO_SERVICE_THREAD 0
|
||||
#endif
|
||||
|
||||
/** Config: RIPPLE_STRUCTURED_OVERLAY_CLIENT
|
||||
RIPPLE_STRUCTURED_OVERLAY_SERVER
|
||||
Enables Structured Overlay support for the client or server roles.
|
||||
This feature is currently in development:
|
||||
https://ripplelabs.atlassian.net/browse/RIPD-157
|
||||
*/
|
||||
#ifndef RIPPLE_STRUCTURED_OVERLAY_CLIENT
|
||||
#define RIPPLE_STRUCTURED_OVERLAY_CLIENT 0
|
||||
#endif
|
||||
#ifndef RIPPLE_STRUCTURED_OVERLAY_SERVER
|
||||
#define RIPPLE_STRUCTURED_OVERLAY_SERVER 1
|
||||
#endif
|
||||
|
||||
/** Config: RIPPLE_ASYNC_RPC_HANDLER
|
||||
*/
|
||||
#ifndef RIPPLE_ASYNC_RPC_HANDLER
|
||||
#define RIPPLE_ASYNC_RPC_HANDLER 1
|
||||
#endif
|
||||
|
||||
/** Config: RIPPLE_ASYNC_RPC_HANDLER
|
||||
*/
|
||||
#ifndef RIPPLE_ASYNC_RPC_HANDLER
|
||||
#define RIPPLE_ASYNC_RPC_HANDLER 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# src
|
||||
|
||||
Some of these directories come from entire outside repositories
|
||||
brought in using git-subtree. This means that the source files are
|
||||
inserted directly into the rippled repository. They can be edited
|
||||
and committed just as if they were normal files.
|
||||
Some of these directories come from entire outside repositories brought in
|
||||
using git-subtree. This means that the source files are inserted directly
|
||||
into the rippled repository. They can be edited and committed just as if they
|
||||
were normal files.
|
||||
|
||||
However, if you create a commit that contains files both from a
|
||||
subtree, and from the ripple source tree please use care when designing
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros">
|
||||
<RepoDir>..\..</RepoDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PreprocessorDefinitions>BEAST_INCLUDE_BEASTCONFIG=1;_CRTDBG_MAP_ALLOC;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<BuildMacro Include="RepoDir">
|
||||
<Value>$(RepoDir)</Value>
|
||||
</BuildMacro>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,228 +0,0 @@
|
||||
Write code in a clear, self-documenting style but use comments where necessary.
|
||||
Use Test Driven Development. It encourages designing interfaces first, before implementation.
|
||||
Don't Repeat Yourself, <20>D.R.Y.<2E>. Put redundant code in a class so it can be re-used and unit tested.
|
||||
Expose as little of a class as possible. Prefer private over protected. Prefer protected over public. The smaller the interface footprint, the easier it is to write unit tests and comprehend the operation of the class. This is the Interface Segregation Principle.
|
||||
Use language constants (enum or static const) with descriptive names instead of hard-coded <20>magic numbers.<2E>
|
||||
Make classes depend on as few external classes or routines as possible. Ideally, no dependencies.
|
||||
Don't limit flexibility of parameters by forcing the caller to use specific types where general types would work.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
# Coding Standards
|
||||
|
||||
Coding standards used here are extreme strict and consistent. The style
|
||||
evolved gradually over the years, incorporating generally acknowledged
|
||||
best-practice C++ advice, experience, and personal preference.
|
||||
|
||||
## Don't Repeat Yourself!
|
||||
|
||||
The [Don't Repeat Yourself][1] principle summarises the essence of what it
|
||||
means to write good code, in all languages, at all levels.
|
||||
|
||||
## Formatting
|
||||
|
||||
The goal of source code formatting should always be to make things as easy to
|
||||
read as possible. White space is used to guide the eye so that details are not
|
||||
overlooked. Blank lines are used to separate code into "paragraphs."
|
||||
|
||||
* No tab characters please.
|
||||
* Tab stops are set to 4 spaces.
|
||||
* Braces are indented in the [Allman style][2].
|
||||
* Always place a space before and after all binary operators,
|
||||
especially assignments (`operator=`).
|
||||
* The `!` operator should always be followed by a space.
|
||||
* The `~` operator should be preceded by a space, but not followed by one.
|
||||
* The `++` and `--` operators should have no spaces between the operator and
|
||||
the operand.
|
||||
* A space never appears before a comma, and always appears after a comma.
|
||||
* Always place a space before an opening parenthesis. One exception is if
|
||||
the parentheses are empty.
|
||||
* Don't put spaces after a parenthesis. A typical member function call might
|
||||
look like this: `foobar (1, 2, 3);`
|
||||
* In general, leave a blank line before an `if` statement.
|
||||
* In general, leave a blank line after a closing brace `}`.
|
||||
* Do not place code or comments on the same line as any opening or
|
||||
closing brace.
|
||||
* Do not write `if` statements all-on-one-line. The exception to this is when
|
||||
you've got a sequence of similar `if` statements, and are aligning them all
|
||||
vertically to highlight their similarities.
|
||||
* In an `if-else` statement, if you surround one half of the statement with
|
||||
braces, you also need to put braces around the other half, to match.
|
||||
* When writing a pointer type, use this spacing: `SomeObject* myObject`.
|
||||
Technically, a more correct spacing would be `SomeObject *myObject`, but
|
||||
it makes more sense for the asterisk to be grouped with the type name,
|
||||
since being a pointer is part of the type, not the variable name. The only
|
||||
time that this can lead to any problems is when you're declaring multiple
|
||||
pointers of the same type in the same statement - which leads on to the next
|
||||
rule:
|
||||
* When declaring multiple pointers, never do so in a single statement, e.g.
|
||||
`SomeObject* p1, *p2;` - instead, always split them out onto separate lines
|
||||
and write the type name again, to make it quite clear what's going on, and
|
||||
avoid the danger of missing out any vital asterisks.
|
||||
* The previous point also applies to references, so always put the `&` next to
|
||||
the type rather than the variable, e.g. `void foo (Thing const& thing)`. And
|
||||
don't put a space on both sides of the `*` or `&` - always put a space after
|
||||
it, but never before it.
|
||||
* The word `const` should be placed to the right of the thing that it modifies,
|
||||
for consistency. For example `int const` refers to an int which is const.
|
||||
`int const*` is a pointer to an int which is const. `int *const` is a const
|
||||
pointer to an int.
|
||||
* Always place a space in between the template angle brackets and the type
|
||||
name. Template code is already hard enough to read!
|
||||
|
||||
## Naming conventions
|
||||
|
||||
* Member variables and method names are written with camel-case, and never
|
||||
begin with a capital letter.
|
||||
* Class names are also written in camel-case, but always begin with a capital
|
||||
letter.
|
||||
* For global variables... well, you shouldn't have any, so it doesn't matter.
|
||||
* Class data members begin with `m_`, static data members begin with `s_`.
|
||||
Global variables begin with `g_`. This is so the scope of the corresponding
|
||||
declaration can be easily determined.
|
||||
* Avoid underscores in your names, especially leading or trailing underscores.
|
||||
In particular, leading underscores should be avoided, as these are often used
|
||||
in standard library code, so to use them in your own code looks quite jarring.
|
||||
* If you really have to write a macro for some reason, then make it all caps,
|
||||
with underscores to separate the words. And obviously make sure that its name
|
||||
is unlikely to clash with symbols used in other libraries or 3rd party code.
|
||||
|
||||
## Types, const-correctness
|
||||
|
||||
* If a method can (and should!) be const, make it const!
|
||||
* If a method definitely doesn't throw an exception (be careful!), mark it as
|
||||
`noexcept`
|
||||
* When returning a temporary object, e.g. a String, the returned object should
|
||||
be non-const, so that if the class has a C++11 move operator, it can be used.
|
||||
* If a local variable can be const, then make it const!
|
||||
* Remember that pointers can be const as well as primitives; For example, if
|
||||
you have a `char*` whose contents are going to be altered, you may still be
|
||||
able to make the pointer itself const, e.g. `char* const foobar = getFoobar();`.
|
||||
* Do not declare all your local variables at the top of a function or method
|
||||
(i.e. in the old-fashioned C-style). Declare them at the last possible moment,
|
||||
and give them as small a scope as possible.
|
||||
* Object parameters should be passed as `const&` wherever possible. Only
|
||||
pass a parameter as a copy-by-value object if you really need to mutate
|
||||
a local copy inside the method, and if making a local copy inside the method
|
||||
would be difficult.
|
||||
* Use portable `for()` loop variable scoping (i.e. do not have multiple for
|
||||
loops in the same scope that each re-declare the same variable name, as
|
||||
this fails on older compilers)
|
||||
* When you're testing a pointer to see if it's null, never write
|
||||
`if (myPointer)`. Always avoid that implicit cast-to-bool by writing it more
|
||||
fully: `if (myPointer != nullptr)`. And likewise, never ever write
|
||||
`if (! myPointer)`, instead always write `if (myPointer == nullptr)`.
|
||||
It is more readable that way.
|
||||
* Avoid C-style casts except when converting between primitive numeric types.
|
||||
Some people would say "avoid C-style casts altogether", but `static_cast` is
|
||||
a bit unreadable when you just want to cast an `int` to a `float`. But
|
||||
whenever a pointer is involved, or a non-primitive object, always use
|
||||
`static_cast`. And when you're reinterpreting data, always use
|
||||
`reinterpret_cast`.
|
||||
* Until C++ gets a universal 64-bit primitive type (part of the C++11
|
||||
standard), it's best to stick to the `std::int64_t` and `std::uint64_t` typedefs.
|
||||
|
||||
## Object lifetime and ownership
|
||||
|
||||
* Absolutely do NOT use `delete`, `deleteAndZero`, etc. There are very very few
|
||||
situations where you can't use a `ScopedPointer` or some other automatic
|
||||
lifetime management class.
|
||||
* Do not use `new` unless there's no alternative. Whenever you type `new`, always
|
||||
treat it as a failure to find a better solution. If a local variable can be
|
||||
allocated on the stack rather than the heap, then always do so.
|
||||
* Do not ever use `new` or `malloc` to allocate a C++ array. Always use a
|
||||
`HeapBlock` instead.
|
||||
* And just to make it doubly clear: Never use `malloc` or `calloc`.
|
||||
* If a parent object needs to create and own some kind of child object, always
|
||||
use composition as your first choice. If that's not possible (e.g. if the
|
||||
child needs a pointer to the parent for its constructor), then use a
|
||||
`ScopedPointer`.
|
||||
* If possible, pass an object as a reference rather than a pointer. If possible,
|
||||
make it a `const` reference.
|
||||
* Obviously avoid static and global values. Sometimes there's no alternative,
|
||||
but if there is an alternative, then use it, no matter how much effort it
|
||||
involves.
|
||||
* If allocating a local POD structure (e.g. an operating-system structure in
|
||||
native code), and you need to initialise it with zeros, use the `= { 0 };`
|
||||
syntax as your first choice for doing this. If for some reason that's not
|
||||
appropriate, use the `zerostruct()` function, or in case that isn't suitable,
|
||||
use `zeromem()`. Don't use `memset()`.
|
||||
|
||||
## Classes
|
||||
|
||||
* Declare a class's public section first, and put its constructors and
|
||||
destructor first. Any protected items come next, and then private ones.
|
||||
* Use the most restrictive access-specifier possible for each member. Prefer
|
||||
`private` over `protected`, and `protected` over `public`. Don't expose
|
||||
things unnecessarily.
|
||||
* Preferred positioning for any inherited classes is to put them to the right
|
||||
of the class name, vertically aligned, e.g.:
|
||||
class Thing : public Foo,
|
||||
private Bar
|
||||
{
|
||||
}
|
||||
* Put a class's member variables (which should almost always be private, of course),
|
||||
after all the public and protected method declarations.
|
||||
* Any private methods can go towards the end of the class, after the member
|
||||
variables.
|
||||
* If your class does not have copy-by-value semantics, derive the class from
|
||||
`Uncopyable`.
|
||||
* If your class is likely to be leaked, then derive your class from
|
||||
`LeakChecked<>`.
|
||||
* Constructors that take a single parameter should be default be marked
|
||||
`explicit`. Obviously there are cases where you do want implicit conversion,
|
||||
but always think about it carefully before writing a non-explicit constructor.
|
||||
* Do not use `NULL`, `null`, or 0 for a null-pointer. And especially never use
|
||||
'0L', which is particulary burdensome. Use `nullptr` instead - this is the
|
||||
C++2011 standard, so get used to it. There's a fallback definition for `nullptr`
|
||||
in Beast, so it's always possible to use it even if your compiler isn't yet
|
||||
C++2011 compliant.
|
||||
* All the C++ 'guru' books and articles are full of excellent and detailed advice
|
||||
on when it's best to use inheritance vs composition. If you're not already
|
||||
familiar with the received wisdom in these matters, then do some reading!
|
||||
|
||||
## Miscellaneous
|
||||
|
||||
* Constrain the scope of identifiers to the smallest area that needs it. Consider
|
||||
using nested classes or classes inside functions, if doing so will expose less
|
||||
interface and implementation overall.
|
||||
* `goto` statements should not be used at all, even if the alternative is
|
||||
more verbose code. The only exception is when implementing an algorithm in
|
||||
a function as a state machine.
|
||||
* Don't use macros! OK, obviously there are many situations where they're the
|
||||
right tool for the job, but treat them as a last resort. Certainly don't ever
|
||||
use a macro just to hold a constant value or to perform any kind of function
|
||||
that could have been done as a real inline function. And it goes without saying
|
||||
that you should give them names which aren't going to clash with other code.
|
||||
And `#undef` them after you've used them, if possible.
|
||||
* When using the `++` or `--` operators, never use post-increment if
|
||||
pre-increment could be used instead. Although it doesn't matter for
|
||||
primitive types, it's good practice to pre-increment since this can be
|
||||
much more efficient for more complex objects. In particular, if you're
|
||||
writing a for loop, always use pre-increment,
|
||||
e.g. `for (int = 0; i < 10; ++i)`
|
||||
* Never put an "else" statement after a "return"! This is well-explained in the
|
||||
LLVM coding standards...and a couple of other very good pieces of advice from
|
||||
the LLVM standards are in there as well.
|
||||
* When getting a possibly-null pointer and using it only if it's non-null, limit
|
||||
the scope of the pointer as much as possible - e.g. Do NOT do this:
|
||||
|
||||
Foo* f = getFoo ();
|
||||
if (f != nullptr)
|
||||
f->doSomething ();
|
||||
// other code
|
||||
f->doSomething (); // oops! f may be null!
|
||||
|
||||
..instead, prefer to write it like this, which reduces the scope of the
|
||||
pointer, making it impossible to write code that accidentally uses a null
|
||||
pointer:
|
||||
|
||||
if (Foo* f = getFoo ())
|
||||
f->doSomethingElse ();
|
||||
|
||||
// f is out-of-scope here, so impossible to use it if it's null
|
||||
|
||||
(This also results in smaller, cleaner code)
|
||||
|
||||
[1]: http://en.wikipedia.org/wiki/Don%27t_repeat_yourself
|
||||
[2]: http://en.wikipedia.org/wiki/Indent_style#Allman_style
|
||||
@@ -102,7 +102,7 @@ INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS =
|
||||
RECURSIVE = YES
|
||||
EXCLUDE = modules/beast_core/beast_core.h \
|
||||
modules/beast_core/beast_core.cpp \
|
||||
modules/beast_core/beast_core.unity.cpp \
|
||||
modules/beast_basics/beast_basics.cpp \
|
||||
modules/beast_basics/native \
|
||||
modules/beast_basics/zip/zlib
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import copy
|
||||
import itertools
|
||||
import ntpath
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
|
||||
def add_beast_to_path():
|
||||
@@ -24,7 +27,7 @@ VARIANT_DIRECTORIES = {
|
||||
'modules': ('bin', 'modules'),
|
||||
}
|
||||
|
||||
BOOST_LIBRARIES = 'boost_system',
|
||||
BOOST_LIBRARIES = '' #boost_system'
|
||||
MAIN_PROGRAM_FILE = 'beast/unit_test/tests/main.cpp'
|
||||
DOTFILE = '~/.scons'
|
||||
|
||||
@@ -43,6 +46,94 @@ def main():
|
||||
for name, path in VARIANT_DIRECTORIES.items():
|
||||
env.VariantDir(os.path.join(*path), name, duplicate=0)
|
||||
env.Replace(PRINT_CMD_LINE_FUNC=Print.print_cmd_line)
|
||||
Tests.run_tests(env, MAIN_PROGRAM_FILE, '.', '.test.cpp')
|
||||
#Tests.run_tests(env, MAIN_PROGRAM_FILE, '.', '.test.cpp')
|
||||
|
||||
#main()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
def is_unity(path):
|
||||
b, e = os.path.splitext(path)
|
||||
return os.path.splitext(b)[1] == '.unity' and e in ['.c', '.cpp']
|
||||
|
||||
def files(base):
|
||||
for parent, _, files in os.walk(base):
|
||||
for path in files:
|
||||
path = os.path.join(parent, path)
|
||||
yield os.path.normpath(path)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
'''
|
||||
/MP /GS /W3 /wd"4018" /wd"4244" /wd"4267" /Gy- /Zc:wchar_t
|
||||
/I"D:\lib\OpenSSL-Win64\include" /I"D:\lib\boost_1_55_0"
|
||||
/I"..\..\src\protobuf\src" /I"..\..\src\protobuf\vsprojects"
|
||||
/I"..\..\src\leveldb" /I"..\..\src\leveldb\include" /I"..\..\build\proto"
|
||||
/Zi /Gm- /Od /Fd"..\..\build\obj\VisualStudio2013\Debug.x64\vc120.pdb"
|
||||
/fp:precise /D "_CRTDBG_MAP_ALLOC" /D "WIN32" /D "_DEBUG" /D "_CONSOLE"
|
||||
/D "_VARIADIC_MAX=10" /D "_WIN32_WINNT=0x0600" /D "_SCL_SECURE_NO_WARNINGS"
|
||||
/D "_CRT_SECURE_NO_WARNINGS" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope
|
||||
/RTC1 /GR /Gd /MTd /openmp- /Fa"..\..\build\obj\VisualStudio2013\Debug.x64\"
|
||||
/EHa /nologo /Fo"..\..\build\obj\VisualStudio2013\Debug.x64\"
|
||||
/Fp"..\..\build\obj\VisualStudio2013\Debug.x64\rippled.pch"
|
||||
'''
|
||||
|
||||
# Path to this SConstruct file
|
||||
base_dir = Dir('#').srcnode().get_abspath()
|
||||
|
||||
base_env = Environment(
|
||||
tools = ['default', 'VSProject'],
|
||||
CCCOMSTR = '',
|
||||
CMDLINE_QUIET = 1,
|
||||
CPPPATH = [
|
||||
os.environ['BOOST_ROOT'],
|
||||
os.environ['OPENSSL_ROOT']
|
||||
],
|
||||
CPPDEFINES = [
|
||||
'_WIN32_WINNT=0x6000']
|
||||
)
|
||||
|
||||
#base_env.Replace(PRINT_CMD_LINE_FUNC=Print.print_cmd_line)
|
||||
|
||||
env = base_env
|
||||
|
||||
bin_dir = os.path.join(base_dir, 'bin')
|
||||
|
||||
srcs = filter(is_unity, list(files('beast')) + list(files('modules')))
|
||||
for variant in ['Debug']: #, 'Release']:
|
||||
for platform in ['Win32']:
|
||||
#env = base_env.Clone()
|
||||
#env.Replace(PRINT_CMD_LINE_FUNC=Print.print_cmd_line)
|
||||
variant_dir = os.path.join(bin_dir, variant + '.' + platform)
|
||||
env.VariantDir(os.path.join(variant_dir, 'beast'), 'beast', duplicate=0)
|
||||
env.VariantDir(os.path.join(variant_dir, 'modules'), 'modules', duplicate=0)
|
||||
env.Append(CCFLAGS=[
|
||||
'/EHsc',
|
||||
'/bigobj',
|
||||
'/Fd${TARGET}.pdb'
|
||||
])
|
||||
if variant == 'Debug':
|
||||
env.Append(CCFLAGS=[
|
||||
'/MTd',
|
||||
'/Od',
|
||||
'/Zi'
|
||||
])
|
||||
else:
|
||||
env.Append(CCFLAGS=[
|
||||
'/MT',
|
||||
'/Ox'
|
||||
])
|
||||
variant_srcs = [os.path.join(variant_dir, os.path.relpath(f, base_dir)) for f in srcs]
|
||||
|
||||
beast = env.StaticLibrary(
|
||||
target = os.path.join(variant_dir, 'beast.lib'),
|
||||
source = variant_srcs)
|
||||
|
||||
env.VSProject (
|
||||
'out',
|
||||
buildtarget = beast,
|
||||
source = filter(is_unity, list(files('beast')) + list(files('modules'))))
|
||||
|
||||
env.Default ('out.vcxproj')
|
||||
#env.Default (os.path.join(bin_dir,'Debug.Win32', 'beast.lib'))
|
||||
|
||||
main()
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
--------------------------------------------------------------------------------
|
||||
BEAST TODO
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
- Change sqdb to use exceptions instead of errors
|
||||
|
||||
- Use SemanticVersion for beast version numbers to replace BEAST_VERSION
|
||||
|
||||
- add support for a __PRETTY_FUNCTION__ equivalent for all environments
|
||||
|
||||
- Import secp256k1 from sipa
|
||||
|
||||
- Set sqlite thread safety model to '2' in beast_sqlite
|
||||
|
||||
- Document and rename all the sqdb files and classes
|
||||
|
||||
- Specialize UnsignedInteger<> for peformance in the storage format
|
||||
|
||||
- Rename HeapBlock routines to not conflict with _CRTDBG_MAP_ALLOC macros
|
||||
|
||||
- Implement beast::Bimap?
|
||||
|
||||
- Use Bimap for storage in the DeadlineTimer::Manager, to support
|
||||
thousands of timers.
|
||||
|
||||
- Think about adding a shouldStop bool to InterruptibleThread, along
|
||||
with a shouldStop () function returning bool, and a stop() method.
|
||||
|
||||
- Tidy up CacheLine, MemoryAlignment
|
||||
|
||||
- Implement a reasonable substitute for boost's thread_local_storage
|
||||
|
||||
- Rename malloc/calloc JUCE members that conflict with the debug CRT from MSVC
|
||||
|
||||
- Reformat every Doxygen comment
|
||||
- Fix Doxygen metatags
|
||||
- update Beast Doxyfile
|
||||
|
||||
- Rename SharedData to SharedState or something?
|
||||
|
||||
- Make sure the template BeastConfig.h is included in the Doxyfile
|
||||
|
||||
- Implement robust key/value database with bulk write
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
#ifndef BEAST_ARITHMETIC_H_INCLUDED
|
||||
#define BEAST_ARITHMETIC_H_INCLUDED
|
||||
|
||||
#include "Config.h"
|
||||
#include <beast/Config.h>
|
||||
|
||||
#include "utility/noexcept.h"
|
||||
#include <beast/utility/noexcept.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
#ifndef BEAST_ATOMIC_H_INCLUDED
|
||||
#define BEAST_ATOMIC_H_INCLUDED
|
||||
|
||||
#include "Config.h"
|
||||
#include "StaticAssert.h"
|
||||
#include <beast/Config.h>
|
||||
#include <beast/StaticAssert.h>
|
||||
|
||||
#include "utility/noexcept.h"
|
||||
#include <beast/utility/noexcept.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
@@ -22,6 +22,6 @@
|
||||
|
||||
// These classes require boost in order to be used.
|
||||
|
||||
#include "boost/ErrorCode.h"
|
||||
#include <beast/boost/ErrorCode.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#ifndef BEAST_BYTEORDER_H_INCLUDED
|
||||
#define BEAST_BYTEORDER_H_INCLUDED
|
||||
|
||||
#include "Config.h"
|
||||
#include "Uncopyable.h"
|
||||
#include <beast/Config.h>
|
||||
#include <beast/Uncopyable.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
#ifndef BEAST_CHRONO_H_INCLUDED
|
||||
#define BEAST_CHRONO_H_INCLUDED
|
||||
|
||||
#include "chrono/abstract_clock.h"
|
||||
#include "chrono/basic_seconds_clock.h"
|
||||
#include "chrono/chrono_io.h"
|
||||
#include "chrono/chrono_util.h"
|
||||
#include "chrono/manual_clock.h"
|
||||
#include "chrono/ratio_io.h"
|
||||
#include <beast/chrono/abstract_clock.h>
|
||||
#include <beast/chrono/basic_seconds_clock.h>
|
||||
#include <beast/chrono/chrono_io.h>
|
||||
#include <beast/chrono/chrono_util.h>
|
||||
#include <beast/chrono/manual_clock.h>
|
||||
#include <beast/chrono/ratio_io.h>
|
||||
|
||||
#include "chrono/RelativeTime.h"
|
||||
#include <beast/chrono/RelativeTime.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,34 +30,34 @@
|
||||
#define BOOST_ASIO_HAS_STD_ARRAY 1
|
||||
|
||||
#if !defined(BEAST_COMPILER_CONFIG) && !defined(BEAST_NO_COMPILER_CONFIG) && !defined(BEAST_NO_CONFIG)
|
||||
#include "config/SelectCompilerConfig.h"
|
||||
#include <beast/config/SelectCompilerConfig.h>
|
||||
#endif
|
||||
#ifdef BEAST_COMPILER_CONFIG
|
||||
#include BEAST_COMPILER_CONFIG
|
||||
#endif
|
||||
|
||||
#if !defined(BEAST_STDLIB_CONFIG) && !defined(BEAST_NO_STDLIB_CONFIG) && !defined(BEAST_NO_CONFIG) && defined(__cplusplus)
|
||||
#include "config/SelectStdlibConfig.h"
|
||||
#include <beast/config/SelectStdlibConfig.h>
|
||||
#endif
|
||||
#ifdef BEAST_STDLIB_CONFIG
|
||||
#include BEAST_STDLIB_CONFIG
|
||||
#endif
|
||||
|
||||
#if !defined(BEAST_PLATFORM_CONFIG) && !defined(BEAST_NO_PLATFORM_CONFIG) && !defined(BEAST_NO_CONFIG)
|
||||
#include "config/SelectCompilerConfig.h"
|
||||
#include <beast/config/SelectCompilerConfig.h>
|
||||
#endif
|
||||
#ifdef BEAST_PLATFORM_CONFIG
|
||||
#include BEAST_PLATFORM_CONFIG
|
||||
#endif
|
||||
|
||||
// Legacy
|
||||
#include "Version.h"
|
||||
#include "config/PlatformConfig.h"
|
||||
#include "config/CompilerConfig.h"
|
||||
#include "config/StandardConfig.h"
|
||||
#include "config/ConfigCheck.h"
|
||||
#include <beast/Version.h>
|
||||
#include <beast/config/PlatformConfig.h>
|
||||
#include <beast/config/CompilerConfig.h>
|
||||
#include <beast/config/StandardConfig.h>
|
||||
#include <beast/config/ConfigCheck.h>
|
||||
|
||||
// Suffix
|
||||
#include "config/Suffix.h"
|
||||
#include <beast/config/Suffix.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
#ifndef BEAST_CRYPTO_H_INCLUDED
|
||||
#define BEAST_CRYPTO_H_INCLUDED
|
||||
|
||||
#include "crypto/BinaryEncoding.h"
|
||||
#include "crypto/MurmurHash.h"
|
||||
#include "crypto/Sha256.h"
|
||||
#include "crypto/UnsignedInteger.h"
|
||||
#include "crypto/UnsignedIntegerCalc.h"
|
||||
#include <beast/crypto/BinaryEncoding.h>
|
||||
#include <beast/crypto/MurmurHash.h>
|
||||
#include <beast/crypto/Sha256.h>
|
||||
#include <beast/crypto/UnsignedInteger.h>
|
||||
#include <beast/crypto/UnsignedIntegerCalc.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "Memory.h"
|
||||
#include "Uncopyable.h"
|
||||
#include <beast/Memory.h>
|
||||
#include <beast/Uncopyable.h>
|
||||
|
||||
// If the MSVC debug heap headers were included, disable
|
||||
// the macros during the juce include since they conflict.
|
||||
|
||||
@@ -20,18 +20,18 @@
|
||||
#ifndef BEAST_INSIGHT_H_INCLUDED
|
||||
#define BEAST_INSIGHT_H_INCLUDED
|
||||
|
||||
#include "insight/Counter.h"
|
||||
#include "insight/CounterImpl.h"
|
||||
#include "insight/Event.h"
|
||||
#include "insight/EventImpl.h"
|
||||
#include "insight/Gauge.h"
|
||||
#include "insight/GaugeImpl.h"
|
||||
#include "insight/Group.h"
|
||||
#include "insight/Groups.h"
|
||||
#include "insight/Hook.h"
|
||||
#include "insight/HookImpl.h"
|
||||
#include "insight/Collector.h"
|
||||
#include "insight/NullCollector.h"
|
||||
#include "insight/StatsDCollector.h"
|
||||
#include <beast/insight/Counter.h>
|
||||
#include <beast/insight/CounterImpl.h>
|
||||
#include <beast/insight/Event.h>
|
||||
#include <beast/insight/EventImpl.h>
|
||||
#include <beast/insight/Gauge.h>
|
||||
#include <beast/insight/GaugeImpl.h>
|
||||
#include <beast/insight/Group.h>
|
||||
#include <beast/insight/Groups.h>
|
||||
#include <beast/insight/Hook.h>
|
||||
#include <beast/insight/HookImpl.h>
|
||||
#include <beast/insight/Collector.h>
|
||||
#include <beast/insight/NullCollector.h>
|
||||
#include <beast/insight/StatsDCollector.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_INTRUSIVE_H_INCLUDED
|
||||
#define BEAST_INTRUSIVE_H_INCLUDED
|
||||
|
||||
#include "intrusive/List.h"
|
||||
#include "intrusive/LockFreeStack.h"
|
||||
#include <beast/intrusive/List.h>
|
||||
#include <beast/intrusive/LockFreeStack.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Config.h"
|
||||
#include "Uncopyable.h"
|
||||
#include <beast/Config.h>
|
||||
#include <beast/Uncopyable.h>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -43,7 +43,7 @@ void zerostruct (Type& structure) noexcept
|
||||
|
||||
/** Delete an object pointer, and sets the pointer to null.
|
||||
|
||||
Remember that it's not good c++ practice to use delete directly - always try to use a ScopedPointer
|
||||
Remember that it's not good c++ practice to use delete directly - always try to use a std::unique_ptr
|
||||
or other automatic lifetime-management system rather than resorting to deleting raw pointers!
|
||||
*/
|
||||
template <typename Type>
|
||||
|
||||
@@ -20,11 +20,9 @@
|
||||
#ifndef BEAST_SMARTPTR_H_INCLUDED
|
||||
#define BEAST_SMARTPTR_H_INCLUDED
|
||||
|
||||
#include "Config.h"
|
||||
#include <beast/Config.h>
|
||||
|
||||
#include "smart_ptr/ContainerDeletePolicy.h"
|
||||
#include "smart_ptr/SharedObject.h"
|
||||
#include "smart_ptr/SharedPtr.h"
|
||||
#include "smart_ptr/ScopedPointer.h"
|
||||
#include <beast/smart_ptr/SharedObject.h>
|
||||
#include <beast/smart_ptr/SharedPtr.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#ifndef BEAST_STRINGS_H_INCLUDED
|
||||
#define BEAST_STRINGS_H_INCLUDED
|
||||
|
||||
#include "strings/String.h"
|
||||
#include "strings/NewLine.h"
|
||||
#include <beast/strings/String.h>
|
||||
#include <beast/strings/NewLine.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -20,19 +20,19 @@
|
||||
#ifndef BEAST_THREADS_H_INCLUDED
|
||||
#define BEAST_THREADS_H_INCLUDED
|
||||
|
||||
#include "threads/UnlockGuard.h"
|
||||
#include "threads/TryLockGuard.h"
|
||||
#include "threads/SharedLockGuard.h"
|
||||
#include "threads/SharedMutexAdapter.h"
|
||||
#include "threads/SharedData.h"
|
||||
#include "threads/ServiceQueue.h"
|
||||
#include "threads/SpinLock.h"
|
||||
#include "threads/Stoppable.h"
|
||||
#include "threads/Thread.h"
|
||||
#include "threads/ThreadLocalValue.h"
|
||||
#include "threads/WaitableEvent.h"
|
||||
#include "threads/ScopedWrapperContext.h"
|
||||
#include <beast/threads/UnlockGuard.h>
|
||||
#include <beast/threads/TryLockGuard.h>
|
||||
#include <beast/threads/SharedLockGuard.h>
|
||||
#include <beast/threads/SharedMutexAdapter.h>
|
||||
#include <beast/threads/SharedData.h>
|
||||
#include <beast/threads/ServiceQueue.h>
|
||||
#include <beast/threads/SpinLock.h>
|
||||
#include <beast/threads/Stoppable.h>
|
||||
#include <beast/threads/Thread.h>
|
||||
#include <beast/threads/ThreadLocalValue.h>
|
||||
#include <beast/threads/WaitableEvent.h>
|
||||
#include <beast/threads/ScopedWrapperContext.h>
|
||||
|
||||
#include "threads/semaphore.h"
|
||||
#include <beast/threads/semaphore.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
//==============================================================================
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include "../../BeastConfig.h"
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include "impl/IPAddressConversion.cpp"
|
||||
#include <beast/asio/impl/IPAddressConversion.cpp>
|
||||
|
||||
#include "tests/wrap_handler.test.cpp"
|
||||
#include "tests/bind_handler.test.cpp"
|
||||
#include "tests/enable_wait_for_async.test.cpp"
|
||||
#include "tests/shared_handler.test.cpp"
|
||||
#include <beast/asio/tests/wrap_handler.test.cpp>
|
||||
#include <beast/asio/tests/bind_handler.test.cpp>
|
||||
#include <beast/asio/tests/enable_wait_for_async.test.cpp>
|
||||
#include <beast/asio/tests/shared_handler.test.cpp>
|
||||
|
||||
#include "abstract_socket.cpp" // TEMPORARY!
|
||||
#include <beast/asio/abstract_socket.cpp> // TEMPORARY!
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_ASIO_IPADDRESSCONVERSION_H_INCLUDED
|
||||
#define BEAST_ASIO_IPADDRESSCONVERSION_H_INCLUDED
|
||||
|
||||
#include "../net/IPEndpoint.h"
|
||||
#include <beast/net/IPEndpoint.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "abstract_socket.h"
|
||||
#include "bind_handler.h"
|
||||
#include <beast/asio/abstract_socket.h>
|
||||
#include <beast/asio/bind_handler.h>
|
||||
|
||||
namespace beast {
|
||||
namespace asio {
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#ifndef BEAST_ASIO_ABSTRACT_SOCKET_H_INCLUDED
|
||||
#define BEAST_ASIO_ABSTRACT_SOCKET_H_INCLUDED
|
||||
|
||||
#include "buffer_sequence.h"
|
||||
#include "shared_handler.h"
|
||||
|
||||
#include <beast/asio/buffer_sequence.h>
|
||||
#include <beast/asio/shared_handler.h>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/socket_base.hpp>
|
||||
#include <boost/asio/ssl/stream_base.hpp>
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#include <boost/asio/detail/handler_invoke_helpers.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include "../cxx14/type_traits.h" // <type_traits>
|
||||
#include "../cxx14/utility.h" // <utility>
|
||||
#include <beast/cxx14/type_traits.h> // <type_traits>
|
||||
#include <beast/cxx14/utility.h> // <utility>
|
||||
|
||||
namespace beast {
|
||||
namespace asio {
|
||||
@@ -56,6 +56,7 @@ private:
|
||||
public:
|
||||
typedef void result_type;
|
||||
|
||||
explicit
|
||||
bound_handler (DeducedHandler&& handler, Args&&... args)
|
||||
: m_handler (std::forward <DeducedHandler> (handler))
|
||||
, m_args (std::forward <Args> (args)...)
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
|
||||
#include <boost/asio/buffer.hpp>
|
||||
|
||||
#include "../utility/noexcept.h"
|
||||
#include <beast/utility/noexcept.h>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include "../cxx14/type_traits.h" // <type_traits>
|
||||
#include <beast/cxx14/type_traits.h> // <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#ifndef BEAST_ASIO_ENABLE_WAIT_FOR_ASYNC_H_INCLUDED
|
||||
#define BEAST_ASIO_ENABLE_WAIT_FOR_ASYNC_H_INCLUDED
|
||||
|
||||
#include "wrap_handler.h"
|
||||
#include <beast/asio/wrap_handler.h>
|
||||
|
||||
#include "../utility/is_call_possible.h"
|
||||
#include <beast/utility/is_call_possible.h>
|
||||
|
||||
#include <boost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <boost/asio/detail/handler_cont_helpers.hpp>
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include "../cxx14/type_traits.h" // <type_traits>
|
||||
#include <beast/cxx14/type_traits.h> // <type_traits>
|
||||
|
||||
namespace beast {
|
||||
namespace asio {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../IPAddressConversion.h"
|
||||
#include <beast/asio/IPAddressConversion.h>
|
||||
|
||||
namespace beast {
|
||||
namespace IP {
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
#ifndef BEAST_ASIO_MEMORY_BUFFER_H_INCLUDED
|
||||
#define BEAST_ASIO_MEMORY_BUFFER_H_INCLUDED
|
||||
|
||||
#include "../utility/empty_base_optimization.h"
|
||||
#include <beast/utility/empty_base_optimization.h>
|
||||
|
||||
#include <boost/asio/buffer.hpp>
|
||||
|
||||
#include "../utility/noexcept.h"
|
||||
#include <beast/utility/noexcept.h>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -20,19 +20,19 @@
|
||||
#ifndef BEAST_ASIO_SHARED_HANDLER_H_INCLUDED
|
||||
#define BEAST_ASIO_SHARED_HANDLER_H_INCLUDED
|
||||
|
||||
#include "../Config.h"
|
||||
#include <beast/Config.h>
|
||||
|
||||
#include "../utility/is_call_possible.h"
|
||||
#include <beast/utility/is_call_possible.h>
|
||||
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
#include <boost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <boost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <boost/asio/detail/handler_invoke_helpers.hpp>
|
||||
|
||||
#include "../utility/noexcept.h"
|
||||
#include <beast/utility/noexcept.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include "../cxx14/type_traits.h" // <type_traits>
|
||||
#include <beast/cxx14/type_traits.h> // <type_traits>
|
||||
|
||||
#ifndef BEAST_ASIO_NO_ALLOCATE_SHARED
|
||||
#define BEAST_ASIO_NO_ALLOCATE_SHARED 0
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
#ifndef BEAST_ASIO_SOCKET_WRAPPER_H_INCLUDED
|
||||
#define BEAST_ASIO_SOCKET_WRAPPER_H_INCLUDED
|
||||
|
||||
#include "abstract_socket.h"
|
||||
#include "bind_handler.h"
|
||||
#include <beast/asio/abstract_socket.h>
|
||||
#include <beast/asio/bind_handler.h>
|
||||
|
||||
#include "../utility/noexcept.h"
|
||||
#include <beast/utility/noexcept.h>
|
||||
|
||||
namespace beast {
|
||||
namespace asio {
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
// LIBS: boost_system
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include "../../../BeastConfig.h"
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include "../../unit_test/suite.h"
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
#include "../bind_handler.h"
|
||||
#include <beast/asio/bind_handler.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
//==============================================================================
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include "../../../BeastConfig.h"
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include "../../unit_test/suite.h"
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
#include "../bind_handler.h"
|
||||
#include "../enable_wait_for_async.h"
|
||||
#include <beast/asio/bind_handler.h>
|
||||
#include <beast/asio/enable_wait_for_async.h>
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
//==============================================================================
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include "../../../BeastConfig.h"
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include "../../unit_test/suite.h"
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
#include "../shared_handler.h"
|
||||
#include <beast/asio/shared_handler.h>
|
||||
|
||||
// Disables is_constructible tests for std::function
|
||||
// Visual Studio std::function fails the is_constructible tests
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
//==============================================================================
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include "../../../BeastConfig.h"
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include "../../unit_test/suite.h"
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
#include "../wrap_handler.h"
|
||||
#include <beast/asio/wrap_handler.h>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <boost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <boost/asio/detail/handler_invoke_helpers.hpp>
|
||||
|
||||
#include "../cxx14/type_traits.h" // <type_traits>
|
||||
#include <beast/cxx14/type_traits.h> // <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
//==============================================================================
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include "../../BeastConfig.h"
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include "ErrorCode.h"
|
||||
#include <beast/boost/ErrorCode.h>
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
//==============================================================================
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include "../../BeastConfig.h"
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include "../Config.h"
|
||||
#include <beast/Config.h>
|
||||
|
||||
#include "impl/chrono_io.cpp"
|
||||
#include "impl/RelativeTime.cpp"
|
||||
#include <beast/chrono/impl/chrono_io.cpp>
|
||||
#include <beast/chrono/impl/RelativeTime.cpp>
|
||||
|
||||
#include "tests/abstract_clock.test.cpp"
|
||||
#include "tests/basic_seconds_clock.test.cpp"
|
||||
#include <beast/chrono/tests/abstract_clock.test.cpp>
|
||||
#include <beast/chrono/tests/basic_seconds_clock.test.cpp>
|
||||
@@ -24,10 +24,10 @@
|
||||
#ifndef BEAST_CHRONO_RELATIVETIME_H_INCLUDED
|
||||
#define BEAST_CHRONO_RELATIVETIME_H_INCLUDED
|
||||
|
||||
#include "../Config.h"
|
||||
#include "../strings/String.h"
|
||||
#include <beast/Config.h>
|
||||
#include <beast/strings/String.h>
|
||||
|
||||
#include "../utility/noexcept.h"
|
||||
#include <beast/utility/noexcept.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CHRONO_ABSTRACT_CLOCK_IO_H_INCLUDED
|
||||
#define BEAST_CHRONO_ABSTRACT_CLOCK_IO_H_INCLUDED
|
||||
|
||||
#include "chrono_io.h"
|
||||
#include <beast/chrono/chrono_io.h>
|
||||
|
||||
namespace beast {
|
||||
|
||||
|
||||
@@ -20,42 +20,15 @@
|
||||
#ifndef BEAST_CHRONO_BASIC_SECONDS_CLOCK_H_INCLUDED
|
||||
#define BEAST_CHRONO_BASIC_SECONDS_CLOCK_H_INCLUDED
|
||||
|
||||
#include <beast/chrono/chrono_util.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#ifndef BEAST_BASIC_SECONDS_CLOCK_BOOST_WORKAROUND
|
||||
# ifdef _MSC_VER
|
||||
// Visual Studio 2012, 2013 have a bug in std::thread that
|
||||
// causes a hang on exit, in the library function atexit()
|
||||
# if BEAST_USE_BOOST_FEATURES
|
||||
# define BEAST_BASIC_SECONDS_CLOCK_BOOST_WORKAROUND 1
|
||||
# else
|
||||
# define BEAST_BASIC_SECONDS_CLOCK_BOOST_WORKAROUND 0
|
||||
# endif
|
||||
# else
|
||||
# define BEAST_BASIC_SECONDS_CLOCK_BOOST_WORKAROUND 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if BEAST_BASIC_SECONDS_CLOCK_BOOST_WORKAROUND
|
||||
# include <boost/version.hpp>
|
||||
# if BOOST_VERSION >= 105500
|
||||
# include <boost/thread/thread.hpp>
|
||||
# include <boost/thread/mutex.hpp>
|
||||
# include <boost/thread/condition_variable.hpp>
|
||||
# include <boost/chrono.hpp>
|
||||
# else
|
||||
# error "Boost version 1.55.0 or later is required"
|
||||
# endif
|
||||
#else
|
||||
# include <condition_variable>
|
||||
# include <mutex>
|
||||
# include <thread>
|
||||
#endif
|
||||
|
||||
#include "../chrono/chrono_util.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
namespace detail {
|
||||
@@ -72,15 +45,6 @@ public:
|
||||
class seconds_clock_thread
|
||||
{
|
||||
public:
|
||||
#if BEAST_BASIC_SECONDS_CLOCK_BOOST_WORKAROUND
|
||||
typedef boost::mutex mutex;
|
||||
typedef boost::condition_variable cond_var;
|
||||
typedef boost::lock_guard <mutex> lock_guard;
|
||||
typedef boost::unique_lock <mutex> unique_lock;
|
||||
typedef boost::chrono::steady_clock clock_type;
|
||||
typedef boost::chrono::seconds seconds;
|
||||
typedef boost::thread thread;
|
||||
#else
|
||||
typedef std::mutex mutex;
|
||||
typedef std::condition_variable cond_var;
|
||||
typedef std::lock_guard <mutex> lock_guard;
|
||||
@@ -88,7 +52,6 @@ public:
|
||||
typedef std::chrono::steady_clock clock_type;
|
||||
typedef std::chrono::seconds seconds;
|
||||
typedef std::thread thread;
|
||||
#endif
|
||||
typedef std::vector <seconds_clock_worker*> workers;
|
||||
|
||||
bool m_stop;
|
||||
@@ -106,12 +69,7 @@ public:
|
||||
|
||||
~seconds_clock_thread ()
|
||||
{
|
||||
{
|
||||
lock_guard lock (m_mutex);
|
||||
m_stop = true;
|
||||
}
|
||||
m_cond.notify_all();
|
||||
m_thread.join ();
|
||||
stop();
|
||||
}
|
||||
|
||||
void add (seconds_clock_worker& w)
|
||||
@@ -127,7 +85,20 @@ public:
|
||||
m_workers.begin (), m_workers.end(), &w));
|
||||
}
|
||||
|
||||
void run ()
|
||||
void stop()
|
||||
{
|
||||
if (m_thread.joinable())
|
||||
{
|
||||
{
|
||||
lock_guard lock (m_mutex);
|
||||
m_stop = true;
|
||||
}
|
||||
m_cond.notify_all();
|
||||
m_thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
unique_lock lock (m_mutex);;
|
||||
|
||||
@@ -157,6 +128,20 @@ public:
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Called before main exits to terminate the utility thread.
|
||||
This is a workaround for Visual Studio 2013:
|
||||
http://connect.microsoft.com/VisualStudio/feedback/details/786016/creating-a-global-c-object-that-used-thread-join-in-its-destructor-causes-a-lockup
|
||||
http://stackoverflow.com/questions/10915233/stdthreadjoin-hangs-if-called-after-main-exits-when-using-vs2012-rc
|
||||
*/
|
||||
inline
|
||||
void
|
||||
basic_seconds_clock_main_hook()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
detail::seconds_clock_thread::instance().stop();
|
||||
#endif
|
||||
}
|
||||
|
||||
/** A clock whose minimum resolution is one second.
|
||||
The purpose of this class is to optimize the performance of the now()
|
||||
member function call. It uses a dedicated thread that wakes up at least
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
#ifndef BEAST_CHRONO_CHRONO_IO_H_INCLUDED
|
||||
#define BEAST_CHRONO_CHRONO_IO_H_INCLUDED
|
||||
|
||||
#include "../Config.h"
|
||||
#include <beast/Config.h>
|
||||
|
||||
#include "../utility/noexcept.h"
|
||||
#include <beast/utility/noexcept.h>
|
||||
#include <ctime>
|
||||
#include <locale>
|
||||
|
||||
@@ -156,7 +156,7 @@ template <class charT, class Traits, class Duration>
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include "ratio_io.h"
|
||||
#include <beast/chrono/ratio_io.h>
|
||||
|
||||
//_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
namespace std {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../RelativeTime.h"
|
||||
#include <beast/chrono/RelativeTime.h>
|
||||
|
||||
// VFALCO TODO Migrate the localizable strings interfaces for this file
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
#include "../chrono_io.h"
|
||||
#include <beast/chrono/chrono_io.h>
|
||||
|
||||
//_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
namespace std {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED
|
||||
#define BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED
|
||||
|
||||
#include "abstract_clock.h"
|
||||
#include <beast/chrono/abstract_clock.h>
|
||||
|
||||
namespace beast {
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
// MODULES: ../impl/chrono_io.cpp
|
||||
|
||||
#include "../abstract_clock.h"
|
||||
#include "../abstract_clock_io.h"
|
||||
#include "../manual_clock.h"
|
||||
#include <beast/chrono/abstract_clock.h>
|
||||
#include <beast/chrono/abstract_clock_io.h>
|
||||
#include <beast/chrono/manual_clock.h>
|
||||
|
||||
#include "../../unit_test/suite.h"
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../../unit_test/suite.h"
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
#include "../basic_seconds_clock.h"
|
||||
#include <beast/chrono/basic_seconds_clock.h>
|
||||
|
||||
namespace beast {
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#define BEAST_CONFIG_COMPILERCONFIG_H_INCLUDED
|
||||
|
||||
#include <assert.h>
|
||||
#include "PlatformConfig.h"
|
||||
#include <beast/config/PlatformConfig.h>
|
||||
|
||||
// This file defines miscellaneous macros for debugging, assertions, etc.
|
||||
|
||||
|
||||
@@ -35,28 +35,28 @@
|
||||
#endif
|
||||
|
||||
#if BEAST_USE_INTRINSICS
|
||||
# include <intrin.h>
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
#if BEAST_MAC || BEAST_IOS
|
||||
# include <libkern/OSAtomic.h>
|
||||
#include <libkern/OSAtomic.h>
|
||||
#endif
|
||||
|
||||
#if BEAST_LINUX
|
||||
# include <signal.h>
|
||||
#include <signal.h>
|
||||
# if __INTEL_COMPILER
|
||||
# if __ia64__
|
||||
# include <ia64intrin.h>
|
||||
#include <ia64intrin.h>
|
||||
# else
|
||||
# include <ia32intrin.h>
|
||||
#include <ia32intrin.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if BEAST_MSVC && BEAST_DEBUG
|
||||
# include <crtdbg.h>
|
||||
# include <stdlib.h>
|
||||
# include <malloc.h>
|
||||
#include <crtdbg.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#if BEAST_MSVC
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
|
||||
// Microsoft Visual C++ compiler configuration
|
||||
|
||||
#include "../../utility/noexcept.h"
|
||||
#include <beast/utility/noexcept.h>
|
||||
|
||||
30
src/beast/beast/container/Container.unity.cpp
Normal file
30
src/beast/beast/container/Container.unity.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include <beast/container/impl/spookyv2.cpp>
|
||||
#include <beast/container/impl/siphash.cpp>
|
||||
|
||||
#include <beast/container/tests/aged_associative_container.test.cpp>
|
||||
#include <beast/container/tests/buffer_view.test.cpp>
|
||||
#include <beast/container/tests/hardened_hash.test.cpp>
|
||||
#include <beast/container/tests/hash_append.test.cpp>
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CONTAINER_AGED_CONTAINER_UTILITY_H_INCLUDED
|
||||
#define BEAST_CONTAINER_AGED_CONTAINER_UTILITY_H_INCLUDED
|
||||
|
||||
#include "aged_container.h"
|
||||
#include <beast/container/aged_container.h>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CONTAINER_AGED_MAP_H_INCLUDED
|
||||
#define BEAST_CONTAINER_AGED_MAP_H_INCLUDED
|
||||
|
||||
#include "detail/aged_ordered_container.h"
|
||||
#include <beast/container/detail/aged_ordered_container.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CONTAINER_AGED_MULTIMAP_H_INCLUDED
|
||||
#define BEAST_CONTAINER_AGED_MULTIMAP_H_INCLUDED
|
||||
|
||||
#include "detail/aged_ordered_container.h"
|
||||
#include <beast/container/detail/aged_ordered_container.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CONTAINER_AGED_MULTISET_H_INCLUDED
|
||||
#define BEAST_CONTAINER_AGED_MULTISET_H_INCLUDED
|
||||
|
||||
#include "detail/aged_ordered_container.h"
|
||||
#include <beast/container/detail/aged_ordered_container.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CONTAINER_AGED_SET_H_INCLUDED
|
||||
#define BEAST_CONTAINER_AGED_SET_H_INCLUDED
|
||||
|
||||
#include "detail/aged_ordered_container.h"
|
||||
#include <beast/container/detail/aged_ordered_container.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CONTAINER_AGED_UNORDERED_MAP_H_INCLUDED
|
||||
#define BEAST_CONTAINER_AGED_UNORDERED_MAP_H_INCLUDED
|
||||
|
||||
#include "detail/aged_unordered_container.h"
|
||||
#include <beast/container/detail/aged_unordered_container.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CONTAINER_AGED_UNORDERED_MULTIMAP_H_INCLUDED
|
||||
#define BEAST_CONTAINER_AGED_UNORDERED_MULTIMAP_H_INCLUDED
|
||||
|
||||
#include "detail/aged_unordered_container.h"
|
||||
#include <beast/container/detail/aged_unordered_container.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CONTAINER_AGED_UNORDERED_MULTISET_H_INCLUDED
|
||||
#define BEAST_CONTAINER_AGED_UNORDERED_MULTISET_H_INCLUDED
|
||||
|
||||
#include "detail/aged_unordered_container.h"
|
||||
#include <beast/container/detail/aged_unordered_container.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CONTAINER_AGED_UNORDERED_SET_H_INCLUDED
|
||||
#define BEAST_CONTAINER_AGED_UNORDERED_SET_H_INCLUDED
|
||||
|
||||
#include "detail/aged_unordered_container.h"
|
||||
#include <beast/container/detail/aged_unordered_container.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
@@ -20,16 +20,16 @@
|
||||
#ifndef BEAST_CONTAINER_BUFFER_VIEW_H_INCLUDED
|
||||
#define BEAST_CONTAINER_BUFFER_VIEW_H_INCLUDED
|
||||
|
||||
#include "../Config.h"
|
||||
#include <beast/Config.h>
|
||||
|
||||
#include <array>
|
||||
#include "../cxx14/algorithm.h" // <algorithm>
|
||||
#include <beast/cxx14/algorithm.h> // <algorithm>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../cxx14/type_traits.h" // <type_traits>
|
||||
#include <beast/cxx14/type_traits.h> // <type_traits>
|
||||
|
||||
namespace beast {
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace detail {
|
||||
template <
|
||||
bool is_const,
|
||||
class Iterator,
|
||||
class Base =
|
||||
class Base =
|
||||
std::iterator <
|
||||
typename std::iterator_traits <Iterator>::iterator_category,
|
||||
typename std::conditional <is_const,
|
||||
@@ -51,20 +51,46 @@ class aged_container_iterator
|
||||
public:
|
||||
typedef typename Iterator::value_type::stashed::time_point time_point;
|
||||
|
||||
// Could be '= default', but Visual Studio 2013 chokes on it [Aug 2014]
|
||||
aged_container_iterator ()
|
||||
{
|
||||
}
|
||||
|
||||
template <class OtherIterator, class OtherBase>
|
||||
aged_container_iterator (aged_container_iterator <
|
||||
false, OtherIterator, OtherBase> const& other)
|
||||
// copy constructor
|
||||
aged_container_iterator (
|
||||
aged_container_iterator<is_const, Iterator, Base>
|
||||
const& other) = default;
|
||||
|
||||
// Disable constructing a const_iterator from a non-const_iterator.
|
||||
// Converting between reverse and non-reverse iterators should be explicit.
|
||||
template <bool other_is_const, class OtherIterator, class OtherBase,
|
||||
class = typename std::enable_if <
|
||||
(other_is_const == false || is_const == true) &&
|
||||
std::is_same<Iterator, OtherIterator>::value == false>::type>
|
||||
explicit aged_container_iterator (aged_container_iterator <
|
||||
other_is_const, OtherIterator, OtherBase> const& other)
|
||||
: m_iter (other.m_iter)
|
||||
{
|
||||
}
|
||||
|
||||
// Disable constructing a const_iterator from a non-const_iterator.
|
||||
template <bool other_is_const, class OtherBase,
|
||||
class = typename std::enable_if <
|
||||
other_is_const == false || is_const == true>::type>
|
||||
aged_container_iterator (aged_container_iterator <
|
||||
other_is_const, Iterator, OtherBase> const& other)
|
||||
: m_iter (other.m_iter)
|
||||
{
|
||||
}
|
||||
|
||||
// Disable assigning a const_iterator to a non-const iterator
|
||||
template <bool other_is_const, class OtherIterator, class OtherBase>
|
||||
aged_container_iterator& operator= (aged_container_iterator <
|
||||
other_is_const, OtherIterator, OtherBase> const& other)
|
||||
auto
|
||||
operator= (aged_container_iterator <
|
||||
other_is_const, OtherIterator, OtherBase> const& other) ->
|
||||
typename std::enable_if <
|
||||
other_is_const == false || is_const == true,
|
||||
aged_container_iterator&>::type
|
||||
{
|
||||
m_iter = other.m_iter;
|
||||
return *this;
|
||||
|
||||
@@ -20,28 +20,40 @@
|
||||
#ifndef BEAST_CONTAINER_AGED_ORDERED_CONTAINER_H_INCLUDED
|
||||
#define BEAST_CONTAINER_AGED_ORDERED_CONTAINER_H_INCLUDED
|
||||
|
||||
#include "aged_container_iterator.h"
|
||||
#include "aged_associative_container.h"
|
||||
#include <beast/container/detail/aged_container_iterator.h>
|
||||
#include <beast/container/detail/aged_associative_container.h>
|
||||
|
||||
#include "../aged_container.h"
|
||||
#include <beast/container/aged_container.h>
|
||||
|
||||
#include "../../chrono/abstract_clock.h"
|
||||
#include "../../utility/empty_base_optimization.h"
|
||||
#include <beast/chrono/abstract_clock.h>
|
||||
#include <beast/utility/empty_base_optimization.h>
|
||||
|
||||
#include <boost/intrusive/list.hpp>
|
||||
#include <boost/intrusive/set.hpp>
|
||||
|
||||
#include "../../cxx14/algorithm.h" // <algorithm>
|
||||
#include <beast/cxx14/algorithm.h> // <algorithm>
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include "../../cxx14/type_traits.h" // <type_traits>
|
||||
#include <beast/cxx14/type_traits.h> // <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
// Traits templates used to discern reverse_iterators, which are disallowed
|
||||
// for mutating operations.
|
||||
template <class It>
|
||||
struct is_boost_reverse_iterator
|
||||
: std::false_type
|
||||
{};
|
||||
|
||||
template <class It>
|
||||
struct is_boost_reverse_iterator<boost::intrusive::detail::reverse_iterator<It>>
|
||||
: std::true_type
|
||||
{};
|
||||
|
||||
/** Associative container where each element is also indexed by time.
|
||||
|
||||
This container mirrors the interface of the standard library ordered
|
||||
@@ -203,7 +215,7 @@ private:
|
||||
{
|
||||
return this->member() (k, extract (e.value));
|
||||
}
|
||||
|
||||
|
||||
template <class K>
|
||||
bool operator() (element const& e, K const& k) const
|
||||
{
|
||||
@@ -215,7 +227,7 @@ private:
|
||||
{
|
||||
return this->member() (k, extract (e.value));
|
||||
}
|
||||
|
||||
|
||||
bool operator() (element const& e, Key const& k) const
|
||||
{
|
||||
return this->member() (extract (e.value), k);
|
||||
@@ -384,13 +396,14 @@ private:
|
||||
return p;
|
||||
}
|
||||
|
||||
void delete_element (element* p)
|
||||
void delete_element (element const* p)
|
||||
{
|
||||
ElementAllocatorTraits::destroy (m_config.alloc(), p);
|
||||
ElementAllocatorTraits::deallocate (m_config.alloc(), p, 1);
|
||||
ElementAllocatorTraits::deallocate (
|
||||
m_config.alloc(), const_cast<element*>(p), 1);
|
||||
}
|
||||
|
||||
void unlink_and_delete_element (element* p)
|
||||
void unlink_and_delete_element (element const* p)
|
||||
{
|
||||
chronological.list.erase (
|
||||
chronological.list.iterator_to (*p));
|
||||
@@ -412,11 +425,13 @@ public:
|
||||
typedef typename std::allocator_traits <
|
||||
Allocator>::const_pointer const_pointer;
|
||||
|
||||
typedef detail::aged_container_iterator <false,
|
||||
// A set (that is, !IsMap) iterator is aways const because the elements
|
||||
// of a set are immutable.
|
||||
typedef detail::aged_container_iterator <!IsMap,
|
||||
typename cont_type::iterator> iterator;
|
||||
typedef detail::aged_container_iterator <true,
|
||||
typename cont_type::iterator> const_iterator;
|
||||
typedef detail::aged_container_iterator <false,
|
||||
typedef detail::aged_container_iterator <!IsMap,
|
||||
typename cont_type::reverse_iterator> reverse_iterator;
|
||||
typedef detail::aged_container_iterator <true,
|
||||
typename cont_type::reverse_iterator> const_reverse_iterator;
|
||||
@@ -433,11 +448,13 @@ public:
|
||||
class chronological_t
|
||||
{
|
||||
public:
|
||||
typedef detail::aged_container_iterator <false,
|
||||
// A set (that is, !IsMap) iterator is aways const because the elements
|
||||
// of a set are immutable.
|
||||
typedef detail::aged_container_iterator <!IsMap,
|
||||
typename list_type::iterator> iterator;
|
||||
typedef detail::aged_container_iterator <true,
|
||||
typename list_type::iterator> const_iterator;
|
||||
typedef detail::aged_container_iterator <false,
|
||||
typedef detail::aged_container_iterator <!IsMap,
|
||||
typename list_type::reverse_iterator> reverse_iterator;
|
||||
typedef detail::aged_container_iterator <true,
|
||||
typename list_type::reverse_iterator> const_reverse_iterator;
|
||||
@@ -823,7 +840,7 @@ public:
|
||||
template <bool maybe_multi = IsMulti>
|
||||
typename std::enable_if <maybe_multi,
|
||||
iterator>::type
|
||||
insert (const_iterator const& /*hint*/, value_type const& value)
|
||||
insert (const_iterator /*hint*/, value_type const& value)
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
return insert (value);
|
||||
@@ -840,7 +857,7 @@ public:
|
||||
template <bool maybe_multi = IsMulti>
|
||||
typename std::enable_if <maybe_multi,
|
||||
iterator>::type
|
||||
insert (const_iterator const& /*hint*/, value_type&& value)
|
||||
insert (const_iterator /*hint*/, value_type&& value)
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
return insert (std::move (value));
|
||||
@@ -882,7 +899,7 @@ public:
|
||||
|
||||
template <class InputIt>
|
||||
void
|
||||
insert (InputIt first, InputIt const& last)
|
||||
insert (InputIt first, InputIt last)
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
insert (cend(), *first);
|
||||
@@ -911,7 +928,7 @@ public:
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace_hint (const_iterator const& hint, Args&&... args) ->
|
||||
emplace_hint (const_iterator hint, Args&&... args) ->
|
||||
typename std::enable_if <! maybe_multi,
|
||||
std::pair <iterator, bool>>::type;
|
||||
|
||||
@@ -919,24 +936,26 @@ public:
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
typename std::enable_if <maybe_multi,
|
||||
iterator>::type
|
||||
emplace_hint (const_iterator const& /*hint*/, Args&&... args)
|
||||
emplace_hint (const_iterator /*hint*/, Args&&... args)
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
return emplace <maybe_multi> (
|
||||
std::forward <Args> (args)...);
|
||||
}
|
||||
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
// enable_if prevents erase (reverse_iterator pos) from compiling
|
||||
template <bool is_const, class Iterator, class Base,
|
||||
class = std::enable_if_t<!is_boost_reverse_iterator<Iterator>::value>>
|
||||
detail::aged_container_iterator <false, Iterator, Base>
|
||||
erase (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& pos);
|
||||
erase (detail::aged_container_iterator <is_const, Iterator, Base> pos);
|
||||
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
// enable_if prevents erase (reverse_iterator first, reverse_iterator last)
|
||||
// from compiling
|
||||
template <bool is_const, class Iterator, class Base,
|
||||
class = std::enable_if_t<!is_boost_reverse_iterator<Iterator>::value>>
|
||||
detail::aged_container_iterator <false, Iterator, Base>
|
||||
erase (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> first,
|
||||
detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& last);
|
||||
erase (detail::aged_container_iterator <is_const, Iterator, Base> first,
|
||||
detail::aged_container_iterator <is_const, Iterator, Base> last);
|
||||
|
||||
template <class K>
|
||||
auto
|
||||
@@ -948,10 +967,11 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
// enable_if prevents touch (reverse_iterator pos) from compiling
|
||||
template <bool is_const, class Iterator, class Base,
|
||||
class = std::enable_if_t<!is_boost_reverse_iterator<Iterator>::value>>
|
||||
void
|
||||
touch (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& pos)
|
||||
touch (detail::aged_container_iterator <is_const, Iterator, Base> pos)
|
||||
{
|
||||
touch (pos, clock().now());
|
||||
}
|
||||
@@ -1047,7 +1067,7 @@ public:
|
||||
const_iterator
|
||||
upper_bound (K const& k) const
|
||||
{
|
||||
return const_iterator (m_cont.upper_bound (k,
|
||||
return const_iterator (m_cont.upper_bound (k,
|
||||
std::cref (m_config.key_compare())));
|
||||
}
|
||||
|
||||
@@ -1176,10 +1196,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
// enable_if prevents erase (reverse_iterator pos, now) from compiling
|
||||
template <bool is_const, class Iterator, class Base,
|
||||
class = std::enable_if_t<!is_boost_reverse_iterator<Iterator>::value>>
|
||||
void
|
||||
touch (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& pos,
|
||||
is_const, Iterator, Base> pos,
|
||||
typename clock_type::time_point const& now);
|
||||
|
||||
template <bool maybe_propagate = std::allocator_traits <
|
||||
@@ -1693,7 +1715,7 @@ template <bool IsMulti, bool IsMap, class Key, class T,
|
||||
template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_ordered_container <IsMulti, IsMap, Key, T, Duration, Compare, Allocator>::
|
||||
emplace_hint (const_iterator const& hint, Args&&... args) ->
|
||||
emplace_hint (const_iterator hint, Args&&... args) ->
|
||||
typename std::enable_if <! maybe_multi,
|
||||
std::pair <iterator, bool>>::type
|
||||
{
|
||||
@@ -1716,36 +1738,27 @@ emplace_hint (const_iterator const& hint, Args&&... args) ->
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T,
|
||||
class Duration, class Compare, class Allocator>
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
auto
|
||||
template <bool is_const, class Iterator, class Base, class>
|
||||
detail::aged_container_iterator <false, Iterator, Base>
|
||||
aged_ordered_container <IsMulti, IsMap, Key, T, Duration, Compare, Allocator>::
|
||||
erase (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& pos) ->
|
||||
detail::aged_container_iterator <false, Iterator, Base>
|
||||
erase (detail::aged_container_iterator <is_const, Iterator, Base> pos)
|
||||
{
|
||||
auto iter (pos.iterator());
|
||||
auto p (&*iter++);
|
||||
unlink_and_delete_element (p);
|
||||
unlink_and_delete_element(&*((pos++).iterator()));
|
||||
return detail::aged_container_iterator <
|
||||
false, Iterator, Base> (iter);
|
||||
false, Iterator, Base> (pos.iterator());
|
||||
}
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T,
|
||||
class Duration, class Compare, class Allocator>
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
auto
|
||||
template <bool is_const, class Iterator, class Base, class>
|
||||
detail::aged_container_iterator <false, Iterator, Base>
|
||||
aged_ordered_container <IsMulti, IsMap, Key, T, Duration, Compare, Allocator>::
|
||||
erase (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> first,
|
||||
detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& last) ->
|
||||
detail::aged_container_iterator <false, Iterator, Base>
|
||||
erase (detail::aged_container_iterator <is_const, Iterator, Base> first,
|
||||
detail::aged_container_iterator <is_const, Iterator, Base> last)
|
||||
{
|
||||
for (; first != last;)
|
||||
{
|
||||
auto p (&*first++);
|
||||
unlink_and_delete_element (p);
|
||||
}
|
||||
unlink_and_delete_element(&*((first++).iterator()));
|
||||
|
||||
return detail::aged_container_iterator <
|
||||
false, Iterator, Base> (first.iterator());
|
||||
}
|
||||
@@ -1839,11 +1852,11 @@ operator== (
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T,
|
||||
class Duration, class Compare, class Allocator>
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
template <bool is_const, class Iterator, class Base, class>
|
||||
void
|
||||
aged_ordered_container <IsMulti, IsMap, Key, T, Duration, Compare, Allocator>::
|
||||
touch (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& pos,
|
||||
is_const, Iterator, Base> pos,
|
||||
typename clock_type::time_point const& now)
|
||||
{
|
||||
auto& e (*pos.iterator());
|
||||
|
||||
@@ -20,23 +20,23 @@
|
||||
#ifndef BEAST_CONTAINER_AGED_UNORDERED_CONTAINER_H_INCLUDED
|
||||
#define BEAST_CONTAINER_AGED_UNORDERED_CONTAINER_H_INCLUDED
|
||||
|
||||
#include "aged_container_iterator.h"
|
||||
#include "aged_associative_container.h"
|
||||
#include <beast/container/detail/aged_container_iterator.h>
|
||||
#include <beast/container/detail/aged_associative_container.h>
|
||||
|
||||
#include "../aged_container.h"
|
||||
#include <beast/container/aged_container.h>
|
||||
|
||||
#include "../../chrono/abstract_clock.h"
|
||||
#include "../../utility/empty_base_optimization.h"
|
||||
#include <beast/chrono/abstract_clock.h>
|
||||
#include <beast/utility/empty_base_optimization.h>
|
||||
|
||||
#include <boost/intrusive/list.hpp>
|
||||
#include <boost/intrusive/unordered_set.hpp>
|
||||
|
||||
#include "../../cxx14/algorithm.h" // <algorithm>
|
||||
#include <beast/cxx14/algorithm.h> // <algorithm>
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include "../../cxx14/type_traits.h" // <type_traits>
|
||||
#include <beast/cxx14/type_traits.h> // <type_traits>
|
||||
#include <utility>
|
||||
|
||||
/*
|
||||
@@ -186,7 +186,7 @@ private:
|
||||
{
|
||||
return this->member() (extract (e.value));
|
||||
}
|
||||
|
||||
|
||||
Hash& hash_function()
|
||||
{
|
||||
return this->member();
|
||||
@@ -222,7 +222,7 @@ private:
|
||||
{
|
||||
return this->member() (k, extract (e.value));
|
||||
}
|
||||
|
||||
|
||||
template <class K>
|
||||
bool operator() (element const& e, K const& k) const
|
||||
{
|
||||
@@ -234,7 +234,7 @@ private:
|
||||
{
|
||||
return this->member() (k, extract (e.value));
|
||||
}
|
||||
|
||||
|
||||
bool operator() (element const& e, Key const& k) const
|
||||
{
|
||||
return this->member() (extract (e.value), k);
|
||||
@@ -584,13 +584,14 @@ private:
|
||||
return p;
|
||||
}
|
||||
|
||||
void delete_element (element* p)
|
||||
void delete_element (element const* p)
|
||||
{
|
||||
ElementAllocatorTraits::destroy (m_config.alloc(), p);
|
||||
ElementAllocatorTraits::deallocate (m_config.alloc(), p, 1);
|
||||
ElementAllocatorTraits::deallocate (
|
||||
m_config.alloc(), const_cast<element*>(p), 1);
|
||||
}
|
||||
|
||||
void unlink_and_delete_element (element* p)
|
||||
void unlink_and_delete_element (element const* p)
|
||||
{
|
||||
chronological.list.erase (
|
||||
chronological.list.iterator_to (*p));
|
||||
@@ -609,12 +610,14 @@ public:
|
||||
typedef typename std::allocator_traits <
|
||||
Allocator>::const_pointer const_pointer;
|
||||
|
||||
typedef detail::aged_container_iterator <false,
|
||||
// A set (that is, !IsMap) iterator is aways const because the elements
|
||||
// of a set are immutable.
|
||||
typedef detail::aged_container_iterator <!IsMap,
|
||||
typename cont_type::iterator> iterator;
|
||||
typedef detail::aged_container_iterator <true,
|
||||
typename cont_type::iterator> const_iterator;
|
||||
|
||||
typedef detail::aged_container_iterator <false,
|
||||
typedef detail::aged_container_iterator <!IsMap,
|
||||
typename cont_type::local_iterator> local_iterator;
|
||||
typedef detail::aged_container_iterator <true,
|
||||
typename cont_type::local_iterator> const_local_iterator;
|
||||
@@ -631,11 +634,13 @@ public:
|
||||
class chronological_t
|
||||
{
|
||||
public:
|
||||
typedef detail::aged_container_iterator <false,
|
||||
// A set (that is, !IsMap) iterator is aways const because the elements
|
||||
// of a set are immutable.
|
||||
typedef detail::aged_container_iterator <!IsMap,
|
||||
typename list_type::iterator> iterator;
|
||||
typedef detail::aged_container_iterator <true,
|
||||
typename list_type::iterator> const_iterator;
|
||||
typedef detail::aged_container_iterator <false,
|
||||
typedef detail::aged_container_iterator <!IsMap,
|
||||
typename list_type::reverse_iterator> reverse_iterator;
|
||||
typedef detail::aged_container_iterator <true,
|
||||
typename list_type::reverse_iterator> const_reverse_iterator;
|
||||
@@ -1021,7 +1026,7 @@ public:
|
||||
template <bool maybe_multi = IsMulti>
|
||||
typename std::enable_if <maybe_multi,
|
||||
iterator>::type
|
||||
insert (const_iterator const& /*hint*/, value_type const& value)
|
||||
insert (const_iterator /*hint*/, value_type const& value)
|
||||
{
|
||||
// VFALCO TODO The hint could be used to let
|
||||
// the client order equal ranges
|
||||
@@ -1043,7 +1048,7 @@ public:
|
||||
template <bool maybe_multi = IsMulti>
|
||||
typename std::enable_if <maybe_multi,
|
||||
iterator>::type
|
||||
insert (const_iterator const& /*hint*/, value_type&& value)
|
||||
insert (const_iterator /*hint*/, value_type&& value)
|
||||
{
|
||||
// VFALCO TODO The hint could be used to let
|
||||
// the client order equal ranges
|
||||
@@ -1083,7 +1088,7 @@ public:
|
||||
}
|
||||
|
||||
template <class InputIt>
|
||||
void insert (InputIt first, InputIt const& last)
|
||||
void insert (InputIt first, InputIt last)
|
||||
{
|
||||
insert (first, last,
|
||||
typename std::iterator_traits <
|
||||
@@ -1113,7 +1118,7 @@ public:
|
||||
// set, map
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace_hint (const_iterator const& /*hint*/, Args&&... args) ->
|
||||
emplace_hint (const_iterator /*hint*/, Args&&... args) ->
|
||||
typename std::enable_if <! maybe_multi,
|
||||
std::pair <iterator, bool>>::type;
|
||||
|
||||
@@ -1121,7 +1126,7 @@ public:
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
typename std::enable_if <maybe_multi,
|
||||
iterator>::type
|
||||
emplace_hint (const_iterator const& /*hint*/, Args&&... args)
|
||||
emplace_hint (const_iterator /*hint*/, Args&&... args)
|
||||
{
|
||||
// VFALCO TODO The hint could be used for multi, to let
|
||||
// the client order equal ranges
|
||||
@@ -1132,14 +1137,14 @@ public:
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
detail::aged_container_iterator <false, Iterator, Base>
|
||||
erase (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& pos);
|
||||
is_const, Iterator, Base> pos);
|
||||
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
detail::aged_container_iterator <false, Iterator, Base>
|
||||
erase (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> first,
|
||||
detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& last);
|
||||
is_const, Iterator, Base> last);
|
||||
|
||||
template <class K>
|
||||
auto
|
||||
@@ -1152,7 +1157,7 @@ public:
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
void
|
||||
touch (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& pos)
|
||||
is_const, Iterator, Base> pos)
|
||||
{
|
||||
touch (pos, clock().now());
|
||||
}
|
||||
@@ -1349,24 +1354,11 @@ public:
|
||||
class OtherAllocator,
|
||||
bool maybe_multi = IsMulti
|
||||
>
|
||||
typename std::enable_if <! maybe_multi,
|
||||
bool>::type
|
||||
typename std::enable_if <! maybe_multi, bool>::type
|
||||
operator== (
|
||||
aged_unordered_container <false, OtherIsMap,
|
||||
OtherKey, OtherT, OtherDuration, OtherHash, KeyEqual,
|
||||
OtherAllocator> const& other) const
|
||||
{
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
for (auto iter (cbegin()), last (cend()), olast (other.cend());
|
||||
iter != last; ++iter)
|
||||
{
|
||||
auto oiter (other.find (extract (*iter)));
|
||||
if (oiter == olast)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
OtherAllocator> const& other) const;
|
||||
|
||||
template <
|
||||
bool OtherIsMap,
|
||||
@@ -1377,35 +1369,11 @@ public:
|
||||
class OtherAllocator,
|
||||
bool maybe_multi = IsMulti
|
||||
>
|
||||
typename std::enable_if <maybe_multi,
|
||||
bool>::type
|
||||
typename std::enable_if <maybe_multi, bool>::type
|
||||
operator== (
|
||||
aged_unordered_container <true, OtherIsMap,
|
||||
OtherKey, OtherT, OtherDuration, OtherHash, KeyEqual,
|
||||
OtherAllocator> const& other) const
|
||||
{
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
typedef std::pair <const_iterator, const_iterator> EqRng;
|
||||
for (auto iter (cbegin()), last (cend()); iter != last;)
|
||||
{
|
||||
auto const& k (extract (*iter));
|
||||
auto const eq (equal_range (k));
|
||||
auto const oeq (other.equal_range (k));
|
||||
#if BEAST_NO_CXX14_IS_PERMUTATION
|
||||
if (std::distance (eq.first, eq.second) !=
|
||||
std::distance (oeq.first, oeq.second) ||
|
||||
! std::is_permutation (eq.first, eq.second, oeq.first))
|
||||
return false;
|
||||
#else
|
||||
if (! std::is_permutation (eq.first,
|
||||
eq.second, oeq.first, oeq.second))
|
||||
return false;
|
||||
#endif
|
||||
iter = eq.second;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
OtherAllocator> const& other) const;
|
||||
|
||||
template <
|
||||
bool OtherIsMulti,
|
||||
@@ -1456,7 +1424,7 @@ private:
|
||||
|
||||
template <class InputIt>
|
||||
void
|
||||
insert_unchecked (InputIt first, InputIt const& last)
|
||||
insert_unchecked (InputIt first, InputIt last)
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
insert_unchecked (*first);
|
||||
@@ -1464,7 +1432,7 @@ private:
|
||||
|
||||
template <class InputIt>
|
||||
void
|
||||
insert (InputIt first, InputIt const& last,
|
||||
insert (InputIt first, InputIt last,
|
||||
std::input_iterator_tag)
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
@@ -1473,7 +1441,7 @@ private:
|
||||
|
||||
template <class InputIt>
|
||||
void
|
||||
insert (InputIt first, InputIt const& last,
|
||||
insert (InputIt first, InputIt last,
|
||||
std::random_access_iterator_tag)
|
||||
{
|
||||
auto const n (std::distance (first, last));
|
||||
@@ -1484,7 +1452,7 @@ private:
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
void
|
||||
touch (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& pos,
|
||||
is_const, Iterator, Base> pos,
|
||||
typename clock_type::time_point const& now)
|
||||
{
|
||||
auto& e (*pos.iterator());
|
||||
@@ -2268,7 +2236,7 @@ template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_unordered_container <IsMulti, IsMap, Key, T, Duration,
|
||||
Hash, KeyEqual, Allocator>::
|
||||
emplace_hint (const_iterator const& /*hint*/, Args&&... args) ->
|
||||
emplace_hint (const_iterator /*hint*/, Args&&... args) ->
|
||||
typename std::enable_if <! maybe_multi,
|
||||
std::pair <iterator, bool>>::type
|
||||
{
|
||||
@@ -2298,13 +2266,11 @@ detail::aged_container_iterator <false, Iterator, Base>
|
||||
aged_unordered_container <IsMulti, IsMap, Key, T, Duration,
|
||||
Hash, KeyEqual, Allocator>::
|
||||
erase (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& pos)
|
||||
is_const, Iterator, Base> pos)
|
||||
{
|
||||
auto iter (pos.iterator());
|
||||
auto p (&*iter++);
|
||||
unlink_and_delete_element (p);
|
||||
unlink_and_delete_element(&*((pos++).iterator()));
|
||||
return detail::aged_container_iterator <
|
||||
false, Iterator, Base> (iter);
|
||||
false, Iterator, Base> (pos.iterator());
|
||||
}
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T,
|
||||
@@ -2316,14 +2282,11 @@ aged_unordered_container <IsMulti, IsMap, Key, T, Duration,
|
||||
erase (detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> first,
|
||||
detail::aged_container_iterator <
|
||||
is_const, Iterator, Base> const& last)
|
||||
is_const, Iterator, Base> last)
|
||||
{
|
||||
size_type n (0);
|
||||
for (; first != last; ++n)
|
||||
{
|
||||
auto p (&*first++);
|
||||
unlink_and_delete_element (p);
|
||||
}
|
||||
for (; first != last;)
|
||||
unlink_and_delete_element(&*((first++).iterator()));
|
||||
|
||||
return detail::aged_container_iterator <
|
||||
false, Iterator, Base> (first.iterator());
|
||||
}
|
||||
@@ -2387,6 +2350,79 @@ touch (K const& k) ->
|
||||
return n;
|
||||
}
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T,
|
||||
class Duration, class Hash, class KeyEqual, class Allocator>
|
||||
template <
|
||||
bool OtherIsMap,
|
||||
class OtherKey,
|
||||
class OtherT,
|
||||
class OtherDuration,
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool maybe_multi
|
||||
>
|
||||
typename std::enable_if <! maybe_multi, bool>::type
|
||||
aged_unordered_container <
|
||||
IsMulti, IsMap, Key, T, Duration, Hash, KeyEqual, Allocator>::
|
||||
operator== (
|
||||
aged_unordered_container <false, OtherIsMap,
|
||||
OtherKey, OtherT, OtherDuration, OtherHash, KeyEqual,
|
||||
OtherAllocator> const& other) const
|
||||
{
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
for (auto iter (cbegin()), last (cend()), olast (other.cend());
|
||||
iter != last; ++iter)
|
||||
{
|
||||
auto oiter (other.find (extract (*iter)));
|
||||
if (oiter == olast)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T,
|
||||
class Duration, class Hash, class KeyEqual, class Allocator>
|
||||
template <
|
||||
bool OtherIsMap,
|
||||
class OtherKey,
|
||||
class OtherT,
|
||||
class OtherDuration,
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool maybe_multi
|
||||
>
|
||||
typename std::enable_if <maybe_multi, bool>::type
|
||||
aged_unordered_container <
|
||||
IsMulti, IsMap, Key, T, Duration, Hash, KeyEqual, Allocator>::
|
||||
operator== (
|
||||
aged_unordered_container <true, OtherIsMap,
|
||||
OtherKey, OtherT, OtherDuration, OtherHash, KeyEqual,
|
||||
OtherAllocator> const& other) const
|
||||
{
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
typedef std::pair <const_iterator, const_iterator> EqRng;
|
||||
for (auto iter (cbegin()), last (cend()); iter != last;)
|
||||
{
|
||||
auto const& k (extract (*iter));
|
||||
auto const eq (equal_range (k));
|
||||
auto const oeq (other.equal_range (k));
|
||||
#if BEAST_NO_CXX14_IS_PERMUTATION
|
||||
if (std::distance (eq.first, eq.second) !=
|
||||
std::distance (oeq.first, oeq.second) ||
|
||||
! std::is_permutation (eq.first, eq.second, oeq.first))
|
||||
return false;
|
||||
#else
|
||||
if (! std::is_permutation (eq.first,
|
||||
eq.second, oeq.first, oeq.second))
|
||||
return false;
|
||||
#endif
|
||||
iter = eq.second;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// map, set
|
||||
|
||||
@@ -20,17 +20,18 @@
|
||||
#ifndef BEAST_CONTAINER_HARDENED_HASH_H_INCLUDED
|
||||
#define BEAST_CONTAINER_HARDENED_HASH_H_INCLUDED
|
||||
|
||||
#include "hash_append.h"
|
||||
#include <beast/container/hash_append.h>
|
||||
#include <beast/cxx14/utility.h> // <utility>
|
||||
#include <beast/cxx14/type_traits.h> // <type_traits>
|
||||
#include <beast/utility/noexcept.h>
|
||||
#include <beast/utility/static_initializer.h>
|
||||
|
||||
#include "../utility/noexcept.h"
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <random>
|
||||
#include "../cxx14/type_traits.h" // <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include "../cxx14/utility.h" // <utility>
|
||||
|
||||
// When set to 1, makes the seed per-process instead
|
||||
// of per default-constructed instance of hardened_hash
|
||||
@@ -44,78 +45,86 @@
|
||||
#endif
|
||||
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
template <class Result>
|
||||
class hardened_hash_base
|
||||
using seed_pair = std::pair<std::uint64_t, std::uint64_t>;
|
||||
|
||||
template <bool = true>
|
||||
seed_pair
|
||||
get_seed_pair() noexcept
|
||||
{
|
||||
public:
|
||||
typedef Result result_type;
|
||||
struct state_t
|
||||
{
|
||||
std::mutex mutex;
|
||||
std::random_device rng;
|
||||
std::mt19937_64 gen {rng()};
|
||||
std::uniform_int_distribution <std::uint64_t> dist;
|
||||
|
||||
private:
|
||||
state_t() : gen(rng()) {}
|
||||
// state_t(state_t const&) = delete;
|
||||
// state_t& operator=(state_t const&) = delete;
|
||||
};
|
||||
static static_initializer <state_t> state;
|
||||
std::lock_guard <std::mutex> lock (state->mutex);
|
||||
return {state->dist(state->gen), state->dist(state->gen)};
|
||||
}
|
||||
|
||||
template <class HashAlgorithm, bool ProcessSeeded>
|
||||
class basic_hardened_hash;
|
||||
|
||||
/**
|
||||
* Seed functor once per process
|
||||
*/
|
||||
template <class HashAlgorithm>
|
||||
class basic_hardened_hash<HashAlgorithm, true>
|
||||
{
|
||||
static
|
||||
seed_pair const&
|
||||
init_seed_pair()
|
||||
{
|
||||
static static_initializer <seed_pair, basic_hardened_hash> const
|
||||
p(get_seed_pair<>());
|
||||
return *p;
|
||||
}
|
||||
|
||||
public:
|
||||
using result_type = typename HashAlgorithm::result_type;
|
||||
|
||||
template <class T>
|
||||
result_type
|
||||
next_seed() noexcept
|
||||
operator()(T const& t) const noexcept
|
||||
{
|
||||
static std::mutex mutex;
|
||||
static std::random_device rng;
|
||||
static std::mt19937_64 gen (rng());
|
||||
std::lock_guard <std::mutex> lock (mutex);
|
||||
std::uniform_int_distribution <result_type> dist;
|
||||
result_type value;
|
||||
for(;;)
|
||||
{
|
||||
value = dist (gen);
|
||||
// VFALCO Do we care if 0 is picked?
|
||||
if (value != 0)
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
std::uint64_t seed0;
|
||||
std::uint64_t seed1;
|
||||
std::tie(seed0, seed1) = init_seed_pair();
|
||||
HashAlgorithm h(seed0, seed1);
|
||||
hash_append(h, t);
|
||||
return static_cast<result_type>(h);
|
||||
}
|
||||
|
||||
#if BEAST_NO_HARDENED_HASH_INSTANCE_SEED
|
||||
protected:
|
||||
hardened_hash_base() noexcept = default;
|
||||
|
||||
hardened_hash_base(result_type) noexcept
|
||||
{
|
||||
}
|
||||
|
||||
result_type
|
||||
seed() const noexcept
|
||||
{
|
||||
static result_type const value (next_seed());
|
||||
return value;
|
||||
}
|
||||
|
||||
#else
|
||||
protected:
|
||||
hardened_hash_base() noexcept
|
||||
: m_seed (next_seed())
|
||||
{
|
||||
}
|
||||
|
||||
hardened_hash_base(result_type seed) noexcept
|
||||
: m_seed (seed)
|
||||
{
|
||||
}
|
||||
|
||||
result_type
|
||||
seed() const noexcept
|
||||
{
|
||||
return m_seed;
|
||||
}
|
||||
|
||||
private:
|
||||
// VFALCO Should seed be per process or per hash function?
|
||||
result_type m_seed;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
* Seed functor once per construction
|
||||
*/
|
||||
template <class HashAlgorithm>
|
||||
class basic_hardened_hash<HashAlgorithm, false>
|
||||
{
|
||||
seed_pair m_seeds;
|
||||
public:
|
||||
using result_type = typename HashAlgorithm::result_type;
|
||||
|
||||
} // detail
|
||||
basic_hardened_hash()
|
||||
: m_seeds(get_seed_pair<>())
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
result_type
|
||||
operator()(T const& t) const noexcept
|
||||
{
|
||||
HashAlgorithm h(m_seeds.first, m_seeds.second);
|
||||
hash_append(h, t);
|
||||
return static_cast<result_type>(h);
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -140,31 +149,18 @@ private:
|
||||
}
|
||||
|
||||
@endcode
|
||||
|
||||
Do not use any version of Murmur or CityHash for the Hasher
|
||||
template parameter (the hashing algorithm). For details
|
||||
see https://131002.net/siphash/#at
|
||||
*/
|
||||
template <class T, class Hasher = detail::spooky_wrapper>
|
||||
class hardened_hash
|
||||
: public detail::hardened_hash_base <std::size_t>
|
||||
{
|
||||
typedef detail::hardened_hash_base <std::size_t> base;
|
||||
public:
|
||||
typedef T argument_type;
|
||||
using detail::hardened_hash_base <std::size_t>::result_type;
|
||||
|
||||
public:
|
||||
hardened_hash() = default;
|
||||
explicit hardened_hash(result_type seed)
|
||||
: base (seed)
|
||||
{
|
||||
}
|
||||
|
||||
result_type
|
||||
operator() (argument_type const& key) const noexcept
|
||||
{
|
||||
Hasher h {base::seed()};
|
||||
hash_append (h, key);
|
||||
return static_cast<result_type> (h);
|
||||
}
|
||||
};
|
||||
#if BEAST_NO_HARDENED_HASH_INSTANCE_SEED
|
||||
template <class HashAlgorithm = siphash>
|
||||
using hardened_hash = basic_hardened_hash<HashAlgorithm, true>;
|
||||
#else
|
||||
template <class HashAlgorithm = siphash>
|
||||
using hardened_hash = basic_hardened_hash<HashAlgorithm, false>;
|
||||
#endif
|
||||
|
||||
} // beast
|
||||
|
||||
|
||||
@@ -21,23 +21,23 @@
|
||||
#ifndef BEAST_CONTAINER_HASH_APPEND_H_INCLUDED
|
||||
#define BEAST_CONTAINER_HASH_APPEND_H_INCLUDED
|
||||
|
||||
#include "../utility/meta.h"
|
||||
#include <beast/utility/meta.h>
|
||||
|
||||
#include "impl/spookyv2.h"
|
||||
#include <beast/container/impl/spookyv2.h>
|
||||
|
||||
#if BEAST_USE_BOOST_FEATURES
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#endif
|
||||
|
||||
#include "../utility/noexcept.h"
|
||||
#include <beast/utility/noexcept.h>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include "../cxx14/type_traits.h" // <type_traits>
|
||||
#include "../cxx14/utility.h" // <utility>
|
||||
#include <beast/cxx14/type_traits.h> // <type_traits>
|
||||
#include <beast/cxx14/utility.h> // <utility>
|
||||
#include <vector>
|
||||
|
||||
// Set to 1 to disable variadic hash_append for tuple. When set, overloads
|
||||
@@ -656,16 +656,38 @@ hash_append (Hasher& h, T0 const& t0, T1 const& t1, T const& ...t) noexcept
|
||||
hash_append (h, t1, t...);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
// See http://www.isthe.com/chongo/tech/comp/fnv/
|
||||
class fnv1a
|
||||
{
|
||||
std::uint64_t state_ = 14695981039346656037ULL;
|
||||
public:
|
||||
|
||||
class spooky_wrapper
|
||||
using result_type = std::size_t;
|
||||
|
||||
void
|
||||
append (void const* key, std::size_t len) noexcept
|
||||
{
|
||||
unsigned char const* p = static_cast<unsigned char const*>(key);
|
||||
unsigned char const* const e = p + len;
|
||||
for (; p < e; ++p)
|
||||
state_ = (state_ ^ *p) * 1099511628211ULL;
|
||||
}
|
||||
|
||||
explicit
|
||||
operator std::size_t() noexcept
|
||||
{
|
||||
return static_cast<std::size_t>(state_);
|
||||
}
|
||||
};
|
||||
|
||||
// See http://burtleburtle.net/bob/hash/spooky.html
|
||||
class spooky
|
||||
{
|
||||
SpookyHash state_;
|
||||
public:
|
||||
using result_type = std::size_t;
|
||||
|
||||
spooky_wrapper (std::size_t seed1 = 1, std::size_t seed2 = 2) noexcept
|
||||
spooky (std::size_t seed1 = 1, std::size_t seed2 = 2) noexcept
|
||||
{
|
||||
state_.Init (seed1, seed2);
|
||||
}
|
||||
@@ -685,9 +707,30 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // detail
|
||||
// See https://131002.net/siphash/
|
||||
class siphash
|
||||
{
|
||||
std::uint64_t v0_ = 0x736f6d6570736575ULL;
|
||||
std::uint64_t v1_ = 0x646f72616e646f6dULL;
|
||||
std::uint64_t v2_ = 0x6c7967656e657261ULL;
|
||||
std::uint64_t v3_ = 0x7465646279746573ULL;
|
||||
unsigned char buf_[8];
|
||||
unsigned bufsize_ = 0;
|
||||
unsigned total_length_ = 0;
|
||||
public:
|
||||
using result_type = std::size_t;
|
||||
|
||||
template <class Hasher = detail::spooky_wrapper>
|
||||
siphash() = default;
|
||||
explicit siphash(std::uint64_t k0, std::uint64_t k1 = 0) noexcept;
|
||||
|
||||
void
|
||||
append (void const* key, std::size_t len) noexcept;
|
||||
|
||||
explicit
|
||||
operator std::size_t() noexcept;
|
||||
};
|
||||
|
||||
template <class Hasher = spooky>
|
||||
struct uhash
|
||||
{
|
||||
using result_type = typename Hasher::result_type;
|
||||
@@ -702,15 +745,6 @@ struct uhash
|
||||
}
|
||||
};
|
||||
|
||||
struct call_hash_value
|
||||
{
|
||||
template <class T>
|
||||
std::size_t
|
||||
operator()(T const& t) const noexcept
|
||||
{
|
||||
return hash_value(t);
|
||||
}
|
||||
};
|
||||
|
||||
} // beast
|
||||
|
||||
|
||||
166
src/beast/beast/container/impl/siphash.cpp
Normal file
166
src/beast/beast/container/impl/siphash.cpp
Normal file
@@ -0,0 +1,166 @@
|
||||
//------------------------------- siphash.h ------------------------------------
|
||||
//
|
||||
// This software is in the public domain. The only restriction on its use is
|
||||
// that no one can remove it from the public domain by claiming ownership of it,
|
||||
// including the original authors.
|
||||
//
|
||||
// There is no warranty of correctness on the software contained herein. Use
|
||||
// at your own risk.
|
||||
//
|
||||
// Derived from:
|
||||
//
|
||||
// SipHash reference C implementation
|
||||
//
|
||||
// Written in 2012 by Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
|
||||
// Daniel J. Bernstein <djb@cr.yp.to>
|
||||
//
|
||||
// To the extent possible under law, the author(s) have dedicated all copyright
|
||||
// and related and neighboring rights to this software to the public domain
|
||||
// worldwide. This software is distributed without any warranty.
|
||||
//
|
||||
// You should have received a copy of the CC0 Public Domain Dedication along
|
||||
// with this software. If not, see
|
||||
// <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <beast/container/hash_append.h>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
// namespace acme is used to demonstrate example code. It is not proposed.
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
typedef std::uint64_t u64;
|
||||
typedef std::uint32_t u32;
|
||||
typedef std::uint8_t u8;
|
||||
|
||||
inline
|
||||
u64
|
||||
rotl(u64 x, u64 b)
|
||||
{
|
||||
return (x << b) | (x >> (64 - b));
|
||||
}
|
||||
|
||||
inline
|
||||
u64
|
||||
u8to64_le(const u8* p)
|
||||
{
|
||||
#if BEAST_LITTLE_ENDIAN
|
||||
return *static_cast<u64 const*>(static_cast<void const*>(p));
|
||||
#else
|
||||
return static_cast<u64>(p[7]) << 56 | static_cast<u64>(p[6]) << 48 |
|
||||
static_cast<u64>(p[5]) << 40 | static_cast<u64>(p[4]) << 32 |
|
||||
static_cast<u64>(p[3]) << 24 | static_cast<u64>(p[2]) << 16 |
|
||||
static_cast<u64>(p[1]) << 8 | static_cast<u64>(p[0]);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
sipround(u64& v0, u64& v1, u64& v2, u64& v3)
|
||||
{
|
||||
v0 += v1;
|
||||
v1 = rotl(v1, 13);
|
||||
v1 ^= v0;
|
||||
v0 = rotl(v0, 32);
|
||||
v2 += v3;
|
||||
v3 = rotl(v3, 16);
|
||||
v3 ^= v2;
|
||||
v0 += v3;
|
||||
v3 = rotl(v3, 21);
|
||||
v3 ^= v0;
|
||||
v2 += v1;
|
||||
v1 = rotl(v1, 17);
|
||||
v1 ^= v2;
|
||||
v2 = rotl(v2, 32);
|
||||
}
|
||||
|
||||
} // unnamed
|
||||
|
||||
siphash::siphash(std::uint64_t k0, std::uint64_t k1) noexcept
|
||||
{
|
||||
v3_ ^= k1;
|
||||
v2_ ^= k0;
|
||||
v1_ ^= k1;
|
||||
v0_ ^= k0;
|
||||
}
|
||||
|
||||
void
|
||||
siphash::append (void const* key, std::size_t inlen) noexcept
|
||||
{
|
||||
u8 const* in = static_cast<const u8*>(key);
|
||||
total_length_ += inlen;
|
||||
if (bufsize_ + inlen < 8)
|
||||
{
|
||||
std::copy(in, in+inlen, buf_ + bufsize_);
|
||||
bufsize_ += inlen;
|
||||
return;
|
||||
}
|
||||
if (bufsize_ > 0)
|
||||
{
|
||||
auto t = 8 - bufsize_;
|
||||
std::copy(in, in+t, buf_ + bufsize_);
|
||||
u64 m = u8to64_le( buf_ );
|
||||
v3_ ^= m;
|
||||
sipround(v0_, v1_, v2_, v3_);
|
||||
sipround(v0_, v1_, v2_, v3_);
|
||||
v0_ ^= m;
|
||||
in += t;
|
||||
inlen -= t;
|
||||
}
|
||||
bufsize_ = inlen & 7;
|
||||
u8 const* const end = in + (inlen - bufsize_);
|
||||
for ( ; in != end; in += 8 )
|
||||
{
|
||||
u64 m = u8to64_le( in );
|
||||
v3_ ^= m;
|
||||
sipround(v0_, v1_, v2_, v3_);
|
||||
sipround(v0_, v1_, v2_, v3_);
|
||||
v0_ ^= m;
|
||||
}
|
||||
std::copy(end, end + bufsize_, buf_);
|
||||
}
|
||||
|
||||
siphash::operator std::size_t() noexcept
|
||||
{
|
||||
std::size_t b = static_cast<u64>(total_length_) << 56;
|
||||
switch(bufsize_)
|
||||
{
|
||||
case 7:
|
||||
b |= static_cast<u64>(buf_[6]) << 48;
|
||||
case 6:
|
||||
b |= static_cast<u64>(buf_[5]) << 40;
|
||||
case 5:
|
||||
b |= static_cast<u64>(buf_[4]) << 32;
|
||||
case 4:
|
||||
b |= static_cast<u64>(buf_[3]) << 24;
|
||||
case 3:
|
||||
b |= static_cast<u64>(buf_[2]) << 16;
|
||||
case 2:
|
||||
b |= static_cast<u64>(buf_[1]) << 8;
|
||||
case 1:
|
||||
b |= static_cast<u64>(buf_[0]);
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
v3_ ^= b;
|
||||
sipround(v0_, v1_, v2_, v3_);
|
||||
sipround(v0_, v1_, v2_, v3_);
|
||||
v0_ ^= b;
|
||||
v2_ ^= 0xff;
|
||||
sipround(v0_, v1_, v2_, v3_);
|
||||
sipround(v0_, v1_, v2_, v3_);
|
||||
sipround(v0_, v1_, v2_, v3_);
|
||||
sipround(v0_, v1_, v2_, v3_);
|
||||
b = v0_ ^ v1_ ^ v2_ ^ v3_;
|
||||
return b;
|
||||
}
|
||||
|
||||
} // beast
|
||||
@@ -10,7 +10,7 @@
|
||||
// August 5 2012: SpookyV2: d = should be d += in short hash, and remove extra mix from long hash
|
||||
|
||||
#include <memory.h>
|
||||
#include "spookyv2.h"
|
||||
#include <beast/container/impl/spookyv2.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
typedef unsigned __int16 uint16;
|
||||
typedef unsigned __int8 uint8;
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#include <stdint.h>
|
||||
# define INLINE inline
|
||||
typedef uint64_t uint64;
|
||||
typedef uint32_t uint32;
|
||||
|
||||
@@ -17,17 +17,17 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../../chrono/manual_clock.h"
|
||||
#include "../../unit_test/suite.h"
|
||||
#include <beast/chrono/manual_clock.h>
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
#include "../aged_set.h"
|
||||
#include "../aged_map.h"
|
||||
#include "../aged_multiset.h"
|
||||
#include "../aged_multimap.h"
|
||||
#include "../aged_unordered_set.h"
|
||||
#include "../aged_unordered_map.h"
|
||||
#include "../aged_unordered_multiset.h"
|
||||
#include "../aged_unordered_multimap.h"
|
||||
#include <beast/container/aged_set.h>
|
||||
#include <beast/container/aged_map.h>
|
||||
#include <beast/container/aged_multiset.h>
|
||||
#include <beast/container/aged_multimap.h>
|
||||
#include <beast/container/aged_unordered_set.h>
|
||||
#include <beast/container/aged_unordered_map.h>
|
||||
#include <beast/container/aged_unordered_multiset.h>
|
||||
#include <beast/container/aged_unordered_multimap.h>
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
return static_cast <T*> (
|
||||
::operator new (n * sizeof(T)));
|
||||
}
|
||||
|
||||
|
||||
void deallocate (T* p, std::size_t)
|
||||
{
|
||||
::operator delete (p);
|
||||
@@ -482,6 +482,23 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
template <bool IsUnordered, bool IsMulti, bool IsMap>
|
||||
void
|
||||
testIterator ();
|
||||
|
||||
// Unordered containers don't have reverse iterators
|
||||
template <bool IsUnordered, bool IsMulti, bool IsMap>
|
||||
typename std::enable_if <! IsUnordered>::type
|
||||
testReverseIterator();
|
||||
|
||||
template <bool IsUnordered, bool IsMulti, bool IsMap>
|
||||
typename std::enable_if <IsUnordered>::type
|
||||
testReverseIterator()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
template <class Container, class Values>
|
||||
void checkInsertCopy (Container& c, Values const& v);
|
||||
|
||||
@@ -524,6 +541,31 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
// Helpers for erase tests
|
||||
template <class Container, class Values>
|
||||
void reverseFillAgedContainer(Container& c, Values const& v);
|
||||
|
||||
template <class Iter>
|
||||
Iter nextToEndIter (Iter const beginIter, Iter const endItr);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
template <class Container, class Iter>
|
||||
bool doElementErase (Container& c, Iter const beginItr, Iter const endItr);
|
||||
|
||||
template <bool IsUnordered, bool IsMulti, bool IsMap>
|
||||
void testElementErase();
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
template <class Container, class BeginEndSrc>
|
||||
void doRangeErase (Container& c, BeginEndSrc const& beginEndSrc);
|
||||
|
||||
template <bool IsUnordered, bool IsMulti, bool IsMap>
|
||||
void testRangeErase();
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
// ordered
|
||||
template <bool IsUnordered, bool IsMulti, bool IsMap>
|
||||
typename std::enable_if <! IsUnordered>::type
|
||||
@@ -1083,6 +1125,163 @@ testCopyMove ()
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Iterator construction and assignment
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <bool IsUnordered, bool IsMulti, bool IsMap>
|
||||
void
|
||||
aged_associative_container_test_base::
|
||||
testIterator()
|
||||
{
|
||||
typedef TestTraits <IsUnordered, IsMulti, IsMap> Traits;
|
||||
typedef typename Traits::Value Value;
|
||||
typedef typename Traits::Alloc Alloc;
|
||||
typename Traits::Clock clock;
|
||||
auto const v (Traits::values());
|
||||
|
||||
//testcase (Traits::name() + " iterators");
|
||||
testcase ("iterator");
|
||||
|
||||
typename Traits::template Cont <> c {clock};
|
||||
|
||||
using iterator = decltype (c.begin());
|
||||
using const_iterator = decltype (c.cbegin());
|
||||
|
||||
// Should be able to construct or assign an iterator from an iterator.
|
||||
iterator nnIt_0 {c.begin()};
|
||||
iterator nnIt_1 {nnIt_0};
|
||||
expect (nnIt_0 == nnIt_1, "iterator constructor failed");
|
||||
iterator nnIt_2;
|
||||
nnIt_2 = nnIt_1;
|
||||
expect (nnIt_1 == nnIt_2, "iterator assignment failed");
|
||||
|
||||
// Should be able to construct or assign a const_iterator from a
|
||||
// const_iterator.
|
||||
const_iterator ccIt_0 {c.cbegin()};
|
||||
const_iterator ccIt_1 {ccIt_0};
|
||||
expect (ccIt_0 == ccIt_1, "const_iterator constructor failed");
|
||||
const_iterator ccIt_2;
|
||||
ccIt_2 = ccIt_1;
|
||||
expect (ccIt_1 == ccIt_2, "const_iterator assignment failed");
|
||||
|
||||
// Comparison between iterator and const_iterator is okay
|
||||
expect (nnIt_0 == ccIt_0,
|
||||
"Comparing an iterator to a const_iterator failed");
|
||||
expect (ccIt_1 == nnIt_1,
|
||||
"Comparing a const_iterator to an iterator failed");
|
||||
|
||||
// Should be able to construct a const_iterator from an iterator.
|
||||
const_iterator ncIt_3 {c.begin()};
|
||||
const_iterator ncIt_4 {nnIt_0};
|
||||
expect (ncIt_3 == ncIt_4,
|
||||
"const_iterator construction from iterator failed");
|
||||
const_iterator ncIt_5;
|
||||
ncIt_5 = nnIt_2;
|
||||
expect (ncIt_5 == ncIt_4,
|
||||
"const_iterator assignment from iterator failed");
|
||||
|
||||
// None of these should compile because they construct or assign to a
|
||||
// non-const iterator with a const_iterator.
|
||||
|
||||
// iterator cnIt_0 {c.cbegin()};
|
||||
|
||||
// iterator cnIt_1 {ccIt_0};
|
||||
|
||||
// iterator cnIt_2;
|
||||
// cnIt_2 = ccIt_2;
|
||||
}
|
||||
|
||||
template <bool IsUnordered, bool IsMulti, bool IsMap>
|
||||
typename std::enable_if <! IsUnordered>::type
|
||||
aged_associative_container_test_base::
|
||||
testReverseIterator()
|
||||
{
|
||||
typedef TestTraits <IsUnordered, IsMulti, IsMap> Traits;
|
||||
typedef typename Traits::Value Value;
|
||||
typedef typename Traits::Alloc Alloc;
|
||||
typename Traits::Clock clock;
|
||||
auto const v (Traits::values());
|
||||
|
||||
//testcase (Traits::name() + " reverse_iterators");
|
||||
testcase ("reverse_iterator");
|
||||
|
||||
typename Traits::template Cont <> c {clock};
|
||||
|
||||
using iterator = decltype (c.begin());
|
||||
using const_iterator = decltype (c.cbegin());
|
||||
using reverse_iterator = decltype (c.rbegin());
|
||||
using const_reverse_iterator = decltype (c.crbegin());
|
||||
|
||||
// Naming decoder ring
|
||||
// constructed from ------+ +----- constructed type
|
||||
// /\/\ -- character pairs
|
||||
// xAyBit
|
||||
// r (reverse) or f (forward)--^-^
|
||||
// ^-^------ C (const) or N (non-const)
|
||||
|
||||
// Should be able to construct or assign a reverse_iterator from a
|
||||
// reverse_iterator.
|
||||
reverse_iterator rNrNit_0 {c.rbegin()};
|
||||
reverse_iterator rNrNit_1 {rNrNit_0};
|
||||
expect (rNrNit_0 == rNrNit_1, "reverse_iterator constructor failed");
|
||||
reverse_iterator xXrNit_2;
|
||||
xXrNit_2 = rNrNit_1;
|
||||
expect (rNrNit_1 == xXrNit_2, "reverse_iterator assignment failed");
|
||||
|
||||
// Should be able to construct or assign a const_reverse_iterator from a
|
||||
// const_reverse_iterator
|
||||
const_reverse_iterator rCrCit_0 {c.crbegin()};
|
||||
const_reverse_iterator rCrCit_1 {rCrCit_0};
|
||||
expect (rCrCit_0 == rCrCit_1, "reverse_iterator constructor failed");
|
||||
const_reverse_iterator xXrCit_2;
|
||||
xXrCit_2 = rCrCit_1;
|
||||
expect (rCrCit_1 == xXrCit_2, "reverse_iterator assignment failed");
|
||||
|
||||
// Comparison between reverse_iterator and const_reverse_iterator is okay
|
||||
expect (rNrNit_0 == rCrCit_0,
|
||||
"Comparing an iterator to a const_iterator failed");
|
||||
expect (rCrCit_1 == rNrNit_1,
|
||||
"Comparing a const_iterator to an iterator failed");
|
||||
|
||||
// Should be able to construct or assign a const_reverse_iterator from a
|
||||
// reverse_iterator
|
||||
const_reverse_iterator rNrCit_0 {c.rbegin()};
|
||||
const_reverse_iterator rNrCit_1 {rNrNit_0};
|
||||
expect (rNrCit_0 == rNrCit_1,
|
||||
"const_reverse_iterator construction from reverse_iterator failed");
|
||||
xXrCit_2 = rNrNit_1;
|
||||
expect (rNrCit_1 == xXrCit_2,
|
||||
"const_reverse_iterator assignment from reverse_iterator failed");
|
||||
|
||||
// The standard allows these conversions:
|
||||
// o reverse_iterator is explicitly constructible from iterator.
|
||||
// o const_reverse_iterator is explicitly constructible from const_iterator.
|
||||
// Should be able to construct or assign reverse_iterators from
|
||||
// non-reverse iterators.
|
||||
reverse_iterator fNrNit_0 {c.begin()};
|
||||
const_reverse_iterator fNrCit_0 {c.begin()};
|
||||
expect (fNrNit_0 == fNrCit_0,
|
||||
"reverse_iterator construction from iterator failed");
|
||||
const_reverse_iterator fCrCit_0 {c.cbegin()};
|
||||
expect (fNrCit_0 == fCrCit_0,
|
||||
"const_reverse_iterator construction from const_iterator failed");
|
||||
|
||||
// None of these should compile because they construct a non-reverse
|
||||
// iterator from a reverse_iterator.
|
||||
// iterator rNfNit_0 {c.rbegin()};
|
||||
// const_iterator rNfCit_0 {c.rbegin()};
|
||||
// const_iterator rCfCit_0 {c.crbegin()};
|
||||
|
||||
// You should not be able to assign an iterator to a reverse_iterator or
|
||||
// vise-versa. So the following lines should not compile.
|
||||
iterator xXfNit_0;
|
||||
// xXfNit_0 = xXrNit_2;
|
||||
// xXrNit_2 = xXfNit_0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Modifiers
|
||||
@@ -1232,9 +1431,12 @@ testChronological ()
|
||||
c.chronological.cbegin(), c.chronological.cend(),
|
||||
v.begin(), v.end(), equal_value <Traits> ()));
|
||||
|
||||
for (auto iter (v.rbegin()); iter != v.rend(); ++iter)
|
||||
// Test touch() with a non-const iterator.
|
||||
for (auto iter (v.crbegin()); iter != v.crend(); ++iter)
|
||||
{
|
||||
auto found (c.find (Traits::extract (*iter)));
|
||||
using iterator = typename decltype (c)::iterator;
|
||||
iterator found (c.find (Traits::extract (*iter)));
|
||||
|
||||
expect (found != c.cend());
|
||||
if (found == c.cend())
|
||||
return;
|
||||
@@ -1243,7 +1445,30 @@ testChronological ()
|
||||
|
||||
expect (std::equal (
|
||||
c.chronological.cbegin(), c.chronological.cend(),
|
||||
v.rbegin(), v.rend(), equal_value <Traits> ()));
|
||||
v.crbegin(), v.crend(), equal_value <Traits> ()));
|
||||
|
||||
// Test touch() with a const_iterator
|
||||
for (auto iter (v.cbegin()); iter != v.cend(); ++iter)
|
||||
{
|
||||
using const_iterator = typename decltype (c)::const_iterator;
|
||||
const_iterator found (c.find (Traits::extract (*iter)));
|
||||
|
||||
expect (found != c.cend());
|
||||
if (found == c.cend())
|
||||
return;
|
||||
c.touch (found);
|
||||
}
|
||||
|
||||
expect (std::equal (
|
||||
c.chronological.cbegin(), c.chronological.cend(),
|
||||
v.cbegin(), v.cend(), equal_value <Traits> ()));
|
||||
|
||||
{
|
||||
// Because touch (reverse_iterator pos) is not allowed, the following
|
||||
// lines should not compile for any aged_container type.
|
||||
// c.touch (c.rbegin());
|
||||
// c.touch (c.crbegin());
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -1282,6 +1507,270 @@ testArrayCreate()
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Helpers for erase tests
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <class Container, class Values>
|
||||
void
|
||||
aged_associative_container_test_base::
|
||||
reverseFillAgedContainer (Container& c, Values const& values)
|
||||
{
|
||||
// Just in case the passed in container was not empty.
|
||||
c.clear();
|
||||
|
||||
// c.clock() returns an abstract_clock, so dynamic_cast to manual_clock.
|
||||
typedef TestTraitsBase::Clock Clock;
|
||||
Clock& clk (dynamic_cast <Clock&> (c.clock ()));
|
||||
clk.set (0);
|
||||
|
||||
Values rev (values);
|
||||
std::sort (rev.begin (), rev.end ());
|
||||
std::reverse (rev.begin (), rev.end ());
|
||||
for (auto& v : rev)
|
||||
{
|
||||
// Add values in reverse order so they are reversed chronologically.
|
||||
++clk;
|
||||
c.insert (v);
|
||||
}
|
||||
}
|
||||
|
||||
// Get one iterator before endIter. We have to use operator++ because you
|
||||
// cannot use operator-- with unordered container iterators.
|
||||
template <class Iter>
|
||||
Iter
|
||||
aged_associative_container_test_base::
|
||||
nextToEndIter (Iter beginIter, Iter const endIter)
|
||||
{
|
||||
if (beginIter == endIter)
|
||||
{
|
||||
fail ("Internal test failure. Cannot advance beginIter");
|
||||
return beginIter;
|
||||
}
|
||||
|
||||
//
|
||||
Iter nextToEnd = beginIter;
|
||||
do
|
||||
{
|
||||
nextToEnd = beginIter++;
|
||||
} while (beginIter != endIter);
|
||||
return nextToEnd;
|
||||
}
|
||||
|
||||
// Implementation for the element erase tests
|
||||
//
|
||||
// This test accepts:
|
||||
// o the container from which we will erase elements
|
||||
// o iterators into that container defining the range of the erase
|
||||
//
|
||||
// This implementation does not declare a pass, since it wants to allow
|
||||
// the caller to examine the size of the container and the returned iterator
|
||||
//
|
||||
// Note that this test works on the aged_associative containers because an
|
||||
// erase only invalidates references and iterators to the erased element
|
||||
// (see 23.2.4/13). Therefore the passed-in end iterator stays valid through
|
||||
// the whole test.
|
||||
template <class Container, class Iter>
|
||||
bool aged_associative_container_test_base::
|
||||
doElementErase (Container& c, Iter const beginItr, Iter const endItr)
|
||||
{
|
||||
auto it (beginItr);
|
||||
size_t count = c.size();
|
||||
while (it != endItr)
|
||||
{
|
||||
auto expectIt = it;
|
||||
++expectIt;
|
||||
it = c.erase (it);
|
||||
|
||||
if (it != expectIt)
|
||||
{
|
||||
fail ("Unexpected returned iterator from element erase");
|
||||
return false;
|
||||
}
|
||||
|
||||
--count;
|
||||
if (count != c.size())
|
||||
{
|
||||
fail ("Failed to erase element");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (c.empty ())
|
||||
{
|
||||
if (it != endItr)
|
||||
{
|
||||
fail ("Erase of last element didn't produce end");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Erase of individual elements
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <bool IsUnordered, bool IsMulti, bool IsMap>
|
||||
void
|
||||
aged_associative_container_test_base::
|
||||
testElementErase ()
|
||||
{
|
||||
typedef TestTraits <IsUnordered, IsMulti, IsMap> Traits;
|
||||
|
||||
//testcase (Traits::name() + " element erase"
|
||||
testcase ("element erase");
|
||||
|
||||
// Make and fill the container
|
||||
typename Traits::Clock ck;
|
||||
typename Traits::template Cont <> c {ck};
|
||||
reverseFillAgedContainer (c, Traits::values());
|
||||
|
||||
{
|
||||
// Test standard iterators
|
||||
auto tempContainer (c);
|
||||
if (! doElementErase (tempContainer,
|
||||
tempContainer.cbegin(), tempContainer.cend()))
|
||||
return; // Test failed
|
||||
|
||||
expect (tempContainer.empty(), "Failed to erase all elements");
|
||||
pass();
|
||||
}
|
||||
{
|
||||
// Test chronological iterators
|
||||
auto tempContainer (c);
|
||||
auto& chron (tempContainer.chronological);
|
||||
if (! doElementErase (tempContainer, chron.begin(), chron.end()))
|
||||
return; // Test failed
|
||||
|
||||
expect (tempContainer.empty(),
|
||||
"Failed to chronologically erase all elements");
|
||||
pass();
|
||||
}
|
||||
{
|
||||
// Test standard iterator partial erase
|
||||
auto tempContainer (c);
|
||||
expect (tempContainer.size() > 2,
|
||||
"Internal failure. Container too small.");
|
||||
if (! doElementErase (tempContainer, ++tempContainer.begin(),
|
||||
nextToEndIter (tempContainer.begin(), tempContainer.end())))
|
||||
return; // Test failed
|
||||
|
||||
expect (tempContainer.size() == 2,
|
||||
"Failed to erase expected number of elements");
|
||||
pass();
|
||||
}
|
||||
{
|
||||
// Test chronological iterator partial erase
|
||||
auto tempContainer (c);
|
||||
expect (tempContainer.size() > 2,
|
||||
"Internal failure. Container too small.");
|
||||
auto& chron (tempContainer.chronological);
|
||||
if (! doElementErase (tempContainer, ++chron.begin(),
|
||||
nextToEndIter (chron.begin(), chron.end())))
|
||||
return; // Test failed
|
||||
|
||||
expect (tempContainer.size() == 2,
|
||||
"Failed to chronologically erase expected number of elements");
|
||||
pass();
|
||||
}
|
||||
{
|
||||
auto tempContainer (c);
|
||||
expect (tempContainer.size() > 4,
|
||||
"Internal failure. Container too small.");
|
||||
// erase(reverse_iterator) is not allowed. None of the following
|
||||
// should compile for any aged_container type.
|
||||
// c.erase (c.rbegin());
|
||||
// c.erase (c.crbegin());
|
||||
// c.erase(c.rbegin(), ++c.rbegin());
|
||||
// c.erase(c.crbegin(), ++c.crbegin());
|
||||
}
|
||||
}
|
||||
|
||||
// Implementation for the range erase tests
|
||||
//
|
||||
// This test accepts:
|
||||
//
|
||||
// o A container with more than 2 elements and
|
||||
// o An object to ask for begin() and end() iterators in the passed container
|
||||
//
|
||||
// This peculiar interface allows either the container itself to be passed as
|
||||
// the second argument or the container's "chronological" element. Both
|
||||
// sources of iterators need to be tested on the container.
|
||||
//
|
||||
// The test locates iterators such that a range-based delete leaves the first
|
||||
// and last elements in the container. It then validates that the container
|
||||
// ended up with the expected contents.
|
||||
//
|
||||
template <class Container, class BeginEndSrc>
|
||||
void
|
||||
aged_associative_container_test_base::
|
||||
doRangeErase (Container& c, BeginEndSrc const& beginEndSrc)
|
||||
{
|
||||
expect (c.size () > 2,
|
||||
"Internal test failure. Container must have more than 2 elements");
|
||||
auto itBeginPlusOne (beginEndSrc.begin ());
|
||||
auto const valueFront = *itBeginPlusOne;
|
||||
++itBeginPlusOne;
|
||||
|
||||
// Get one iterator before end()
|
||||
auto itBack (nextToEndIter (itBeginPlusOne, beginEndSrc.end ()));
|
||||
auto const valueBack = *itBack;
|
||||
|
||||
// Erase all elements but first and last
|
||||
auto const retIter = c.erase (itBeginPlusOne, itBack);
|
||||
|
||||
expect (c.size() == 2,
|
||||
"Unexpected size for range-erased container");
|
||||
|
||||
expect (valueFront == *(beginEndSrc.begin()),
|
||||
"Unexpected first element in range-erased container");
|
||||
|
||||
expect (valueBack == *(++beginEndSrc.begin()),
|
||||
"Unexpected last element in range-erased container");
|
||||
|
||||
expect (retIter == (++beginEndSrc.begin()),
|
||||
"Unexpected return iterator from erase");
|
||||
|
||||
pass ();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Erase range of elements
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <bool IsUnordered, bool IsMulti, bool IsMap>
|
||||
void
|
||||
aged_associative_container_test_base::
|
||||
testRangeErase ()
|
||||
{
|
||||
typedef TestTraits <IsUnordered, IsMulti, IsMap> Traits;
|
||||
|
||||
//testcase (Traits::name() + " element erase"
|
||||
testcase ("range erase");
|
||||
|
||||
// Make and fill the container
|
||||
typename Traits::Clock ck;
|
||||
typename Traits::template Cont <> c {ck};
|
||||
reverseFillAgedContainer (c, Traits::values());
|
||||
|
||||
// Not bothering to test range erase with reverse iterators.
|
||||
{
|
||||
auto tempContainer (c);
|
||||
doRangeErase (tempContainer, tempContainer);
|
||||
}
|
||||
{
|
||||
auto tempContainer (c);
|
||||
doRangeErase (tempContainer, tempContainer.chronological);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Container-wide comparison
|
||||
@@ -1378,9 +1867,13 @@ testMaybeUnorderedMultiMap ()
|
||||
testConstructRange <IsUnordered, IsMulti, IsMap> ();
|
||||
testConstructInitList <IsUnordered, IsMulti, IsMap> ();
|
||||
testCopyMove <IsUnordered, IsMulti, IsMap> ();
|
||||
testIterator <IsUnordered, IsMulti, IsMap> ();
|
||||
testReverseIterator <IsUnordered, IsMulti, IsMap> ();
|
||||
testModifiers <IsUnordered, IsMulti, IsMap> ();
|
||||
testChronological <IsUnordered, IsMulti, IsMap> ();
|
||||
testArrayCreate <IsUnordered, IsMulti, IsMap> ();
|
||||
testElementErase <IsUnordered, IsMulti, IsMap> ();
|
||||
testRangeErase <IsUnordered, IsMulti, IsMap> ();
|
||||
testCompare <IsUnordered, IsMulti, IsMap> ();
|
||||
testObservers <IsUnordered, IsMulti, IsMap> ();
|
||||
}
|
||||
@@ -1514,4 +2007,4 @@ BEAST_DEFINE_TESTSUITE(aged_unordered_map,container,beast);
|
||||
BEAST_DEFINE_TESTSUITE(aged_unordered_multiset,container,beast);
|
||||
BEAST_DEFINE_TESTSUITE(aged_unordered_multimap,container,beast);
|
||||
|
||||
}
|
||||
} // namespace beast
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../../unit_test/suite.h"
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
#include "../buffer_view.h"
|
||||
#include <beast/container/buffer_view.h>
|
||||
|
||||
#include "../../cxx14/algorithm.h" // <algorithm>
|
||||
#include <beast/cxx14/algorithm.h> // <algorithm>
|
||||
|
||||
namespace beast {
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
// MODULES: ../../crypto/impl/Sha256.cpp ../../container/impl/spookyv2.cpp
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include "../../../BeastConfig.h"
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include "../hardened_hash.h"
|
||||
#include "../../unit_test/suite.h"
|
||||
#include <beast/container/hardened_hash.h>
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
#include "../../crypto/Sha256.h"
|
||||
#include <beast/crypto/Sha256.h>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#include <array>
|
||||
@@ -90,19 +90,19 @@ namespace detail {
|
||||
|
||||
template <class T>
|
||||
using test_hardened_unordered_set =
|
||||
std::unordered_set <T, hardened_hash <T>>;
|
||||
std::unordered_set <T, hardened_hash <>>;
|
||||
|
||||
template <class T>
|
||||
using test_hardened_unordered_map =
|
||||
std::unordered_map <T, int, hardened_hash <T>>;
|
||||
std::unordered_map <T, int, hardened_hash <>>;
|
||||
|
||||
template <class T>
|
||||
using test_hardened_unordered_multiset =
|
||||
std::unordered_multiset <T, hardened_hash <T>>;
|
||||
std::unordered_multiset <T, hardened_hash <>>;
|
||||
|
||||
template <class T>
|
||||
using test_hardened_unordered_multimap =
|
||||
std::unordered_multimap <T, int, hardened_hash <T>>;
|
||||
std::unordered_multimap <T, int, hardened_hash <>>;
|
||||
|
||||
} // beast
|
||||
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
check ()
|
||||
{
|
||||
T t{};
|
||||
hardened_hash <T>() (t);
|
||||
hardened_hash <>() (t);
|
||||
pass();
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
log <<
|
||||
"sizeof(std::size_t) == " << sizeof(std::size_t);
|
||||
|
||||
hardened_hash <sha256_t> h;
|
||||
hardened_hash <> h;
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
sha256_t v (sha256_t::from_number (i));
|
||||
|
||||
@@ -20,17 +20,17 @@
|
||||
// MODULES: ../impl/spookyv2.cpp
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include "../../../BeastConfig.h"
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include "hash_metrics.h"
|
||||
#include <beast/container/tests/hash_metrics.h>
|
||||
|
||||
#include "../hash_append.h"
|
||||
#include "../impl/spookyv2.h"
|
||||
#include <beast/container/hash_append.h>
|
||||
#include <beast/container/impl/spookyv2.h>
|
||||
|
||||
#include "../../chrono/chrono_io.h"
|
||||
#include "../../unit_test/suite.h"
|
||||
#include "../../utility/type_name.h"
|
||||
#include <beast/chrono/chrono_io.h>
|
||||
#include <beast/unit_test/suite.h>
|
||||
#include <beast/utility/type_name.h>
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -157,7 +157,7 @@ window (T* blob, int start, int count )
|
||||
|
||||
/** Calculated a windowed metric using bins.
|
||||
TODO Need reference (SMHasher?)
|
||||
*/
|
||||
*/
|
||||
template <class FwdIter>
|
||||
double
|
||||
windowed_score (FwdIter first, FwdIter last)
|
||||
@@ -169,8 +169,6 @@ windowed_score (FwdIter first, FwdIter last)
|
||||
while (static_cast<double>(size) / (1 << maxwidth) < 5.0)
|
||||
maxwidth--;
|
||||
double worst = 0;
|
||||
int worstStart = -1;
|
||||
int worstWidth = -1;
|
||||
std::vector <int> bins (1 << maxwidth);
|
||||
int const hashbits = sizeof(std::size_t) * CHAR_BIT;
|
||||
for (int start = 0; start < hashbits; ++start)
|
||||
@@ -185,12 +183,7 @@ windowed_score (FwdIter first, FwdIter last)
|
||||
{
|
||||
double score (detail::score (
|
||||
bins.data(), bins.size(), size));
|
||||
if (score > worst)
|
||||
{
|
||||
worst = score;
|
||||
worstStart = start;
|
||||
worstWidth = width;
|
||||
}
|
||||
worst = std::max(score, worst);
|
||||
if (--width < 8)
|
||||
break;
|
||||
for (std::size_t i = 0, j = bins.size() / 2; j < bins.size(); ++i, ++j)
|
||||
|
||||
@@ -18,12 +18,13 @@
|
||||
//==============================================================================
|
||||
|
||||
#if BEAST_INCLUDE_BEASTCONFIG
|
||||
#include "../../BeastConfig.h"
|
||||
#include <BeastConfig.h>
|
||||
#endif
|
||||
|
||||
#include "impl/spookyv2.cpp"
|
||||
#include <beast/crypto/impl/MurmurHash.cpp>
|
||||
#include <beast/crypto/impl/Sha256.cpp>
|
||||
#include <beast/crypto/impl/UnsignedInteger.cpp>
|
||||
|
||||
#include "tests/aged_associative_container.test.cpp"
|
||||
#include "tests/buffer_view.test.cpp"
|
||||
#include "tests/hardened_hash.test.cpp"
|
||||
#include "tests/hash_append.test.cpp"
|
||||
#include <beast/crypto/tests/BinaryEncoding.cpp>
|
||||
|
||||
#include <beast/crypto/tests/UnsignedInteger.test.cpp>
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BEAST_CRYPTO_SHA256_H_INCLUDED
|
||||
#define BEAST_CRYPTO_SHA256_H_INCLUDED
|
||||
|
||||
#include "../Config.h"
|
||||
#include <beast/Config.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user