beast cleanup and tidying:

* Replace custom types with C++11 <cstdint> types
* Fix sqlite integer intos and uses
* Fix String implicit integer constructors
* Escape the enclosing namespace in sqdb
* Replace contract checks with assert
* Make many header files compile independently
* Remove the dependence on beast_core.h in many places
* Remove unused or obsolete classes and functions
* Remove unused or obsolete macros
* Remove unused network functions and files
* Remove unused or obsolete classes:
  - ChildProcess
  - HighResolutionTimer
  - InterProcessLock
  - Throw
  - TrackedMutex
  - UntrackedMutex
  - XmlDocument
  - XmlElement
This commit is contained in:
Vinnie Falco
2014-03-22 09:43:11 -07:00
parent 5eb0aa2765
commit 3fbff6e620
203 changed files with 1427 additions and 7889 deletions

View File

@@ -47,12 +47,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</None> </None>
<None Include="..\..\modules\beast_core\native\mac_Network.mm">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</None>
<None Include="..\..\modules\beast_core\native\mac_Strings.mm"> <None Include="..\..\modules\beast_core\native\mac_Strings.mm">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -142,7 +136,6 @@
<ClInclude Include="..\..\beast\crypto\Sha256.h" /> <ClInclude Include="..\..\beast\crypto\Sha256.h" />
<ClInclude Include="..\..\beast\crypto\UnsignedInteger.h" /> <ClInclude Include="..\..\beast\crypto\UnsignedInteger.h" />
<ClInclude Include="..\..\beast\crypto\UnsignedIntegerCalc.h" /> <ClInclude Include="..\..\beast\crypto\UnsignedIntegerCalc.h" />
<ClInclude Include="..\..\beast\CStdInt.h" />
<ClInclude Include="..\..\beast\cxx14\algorithm.h" /> <ClInclude Include="..\..\beast\cxx14\algorithm.h" />
<ClInclude Include="..\..\beast\cxx14\config.h" /> <ClInclude Include="..\..\beast\cxx14\config.h" />
<ClInclude Include="..\..\beast\cxx14\functional.h" /> <ClInclude Include="..\..\beast\cxx14\functional.h" />
@@ -299,7 +292,6 @@
<ClInclude Include="..\..\modules\beast_core\containers\ArrayAllocationBase.h" /> <ClInclude Include="..\..\modules\beast_core\containers\ArrayAllocationBase.h" />
<ClInclude Include="..\..\modules\beast_core\containers\ElementComparator.h" /> <ClInclude Include="..\..\modules\beast_core\containers\ElementComparator.h" />
<ClInclude Include="..\..\modules\beast_core\containers\LinkedListPointer.h" /> <ClInclude Include="..\..\modules\beast_core\containers\LinkedListPointer.h" />
<ClInclude Include="..\..\modules\beast_core\containers\OwnedArray.h" />
<ClInclude Include="..\..\modules\beast_core\containers\ScopedValueSetter.h" /> <ClInclude Include="..\..\modules\beast_core\containers\ScopedValueSetter.h" />
<ClInclude Include="..\..\modules\beast_core\diagnostic\FatalError.h" /> <ClInclude Include="..\..\modules\beast_core\diagnostic\FatalError.h" />
<ClInclude Include="..\..\modules\beast_core\diagnostic\SemanticVersion.h" /> <ClInclude Include="..\..\modules\beast_core\diagnostic\SemanticVersion.h" />
@@ -340,26 +332,16 @@
<ClInclude Include="..\..\modules\beast_core\text\LexicalCast.h" /> <ClInclude Include="..\..\modules\beast_core\text\LexicalCast.h" />
<ClInclude Include="..\..\modules\beast_core\text\StringArray.h" /> <ClInclude Include="..\..\modules\beast_core\text\StringArray.h" />
<ClInclude Include="..\..\modules\beast_core\text\StringPairArray.h" /> <ClInclude Include="..\..\modules\beast_core\text\StringPairArray.h" />
<ClInclude Include="..\..\modules\beast_core\threads\ChildProcess.h" />
<ClInclude Include="..\..\modules\beast_core\threads\CriticalSection.h" /> <ClInclude Include="..\..\modules\beast_core\threads\CriticalSection.h" />
<ClInclude Include="..\..\modules\beast_core\threads\DynamicLibrary.h" /> <ClInclude Include="..\..\modules\beast_core\threads\DynamicLibrary.h" />
<ClInclude Include="..\..\modules\beast_core\threads\HighResolutionTimer.h" />
<ClInclude Include="..\..\modules\beast_core\threads\InterProcessLock.h" />
<ClInclude Include="..\..\modules\beast_core\threads\Process.h" /> <ClInclude Include="..\..\modules\beast_core\threads\Process.h" />
<ClInclude Include="..\..\modules\beast_core\threads\ScopedLock.h" /> <ClInclude Include="..\..\modules\beast_core\threads\ScopedLock.h" />
<ClInclude Include="..\..\modules\beast_core\thread\DeadlineTimer.h" /> <ClInclude Include="..\..\modules\beast_core\thread\DeadlineTimer.h" />
<ClInclude Include="..\..\modules\beast_core\thread\Workers.h" /> <ClInclude Include="..\..\modules\beast_core\thread\Workers.h" />
<ClInclude Include="..\..\modules\beast_core\thread\detail\ScopedLock.h" /> <ClInclude Include="..\..\modules\beast_core\thread\detail\ScopedLock.h" />
<ClInclude Include="..\..\modules\beast_core\thread\detail\TrackedMutex.h" />
<ClInclude Include="..\..\modules\beast_core\thread\impl\TrackedMutex.h" />
<ClInclude Include="..\..\modules\beast_core\thread\impl\TrackedMutexType.h" />
<ClInclude Include="..\..\modules\beast_core\thread\impl\UntrackedMutexType.h" />
<ClInclude Include="..\..\modules\beast_core\thread\MutexTraits.h" /> <ClInclude Include="..\..\modules\beast_core\thread\MutexTraits.h" />
<ClInclude Include="..\..\modules\beast_core\thread\TrackedMutex.h" />
<ClInclude Include="..\..\modules\beast_core\time\AtExitHook.h" /> <ClInclude Include="..\..\modules\beast_core\time\AtExitHook.h" />
<ClInclude Include="..\..\modules\beast_core\time\Time.h" /> <ClInclude Include="..\..\modules\beast_core\time\Time.h" />
<ClInclude Include="..\..\modules\beast_core\xml\XmlDocument.h" />
<ClInclude Include="..\..\modules\beast_core\xml\XmlElement.h" />
<ClInclude Include="..\..\modules\beast_sqdb\api\backend.h" /> <ClInclude Include="..\..\modules\beast_sqdb\api\backend.h" />
<ClInclude Include="..\..\modules\beast_sqdb\api\blob.h" /> <ClInclude Include="..\..\modules\beast_sqdb\api\blob.h" />
<ClInclude Include="..\..\modules\beast_sqdb\api\into.h" /> <ClInclude Include="..\..\modules\beast_sqdb\api\into.h" />
@@ -988,12 +970,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\bsd_Network.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\bsd_SystemStats.cpp"> <ClCompile Include="..\..\modules\beast_core\native\bsd_SystemStats.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1012,12 +988,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\linux_Network.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\linux_SystemStats.cpp"> <ClCompile Include="..\..\modules\beast_core\native\linux_SystemStats.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1036,12 +1006,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\win32_Network.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\win32_Registry.cpp"> <ClCompile Include="..\..\modules\beast_core\native\win32_Registry.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1114,18 +1078,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\threads\ChildProcess.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\threads\HighResolutionTimer.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\thread\DeadlineTimer.cpp"> <ClCompile Include="..\..\modules\beast_core\thread\DeadlineTimer.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -1138,12 +1090,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\thread\impl\TrackedMutex.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\time\AtExitHook.cpp"> <ClCompile Include="..\..\modules\beast_core\time\AtExitHook.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -1156,18 +1102,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\xml\XmlDocument.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\xml\XmlElement.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_sqdb\beast_sqdb.cpp" /> <ClCompile Include="..\..\modules\beast_sqdb\beast_sqdb.cpp" />
<ClCompile Include="..\..\modules\beast_sqdb\source\blob.cpp"> <ClCompile Include="..\..\modules\beast_sqdb\source\blob.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>

View File

@@ -4,9 +4,6 @@
<None Include="..\..\modules\beast_core\native\mac_Files.mm"> <None Include="..\..\modules\beast_core\native\mac_Files.mm">
<Filter>beast_core\native</Filter> <Filter>beast_core\native</Filter>
</None> </None>
<None Include="..\..\modules\beast_core\native\mac_Network.mm">
<Filter>beast_core\native</Filter>
</None>
<None Include="..\..\modules\beast_core\native\mac_Strings.mm"> <None Include="..\..\modules\beast_core\native\mac_Strings.mm">
<Filter>beast_core\native</Filter> <Filter>beast_core\native</Filter>
</None> </None>
@@ -111,9 +108,6 @@
<Filter Include="beast_core\time"> <Filter Include="beast_core\time">
<UniqueIdentifier>{d3ea4af5-ae48-4144-a2ef-a212342d72ee}</UniqueIdentifier> <UniqueIdentifier>{d3ea4af5-ae48-4144-a2ef-a212342d72ee}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="beast_core\xml">
<UniqueIdentifier>{a1a38659-7779-41d6-8a3c-068433c4deaf}</UniqueIdentifier>
</Filter>
<Filter Include="beast_core\diagnostic"> <Filter Include="beast_core\diagnostic">
<UniqueIdentifier>{69e28551-92ea-420b-a465-75ed248e3b59}</UniqueIdentifier> <UniqueIdentifier>{69e28551-92ea-420b-a465-75ed248e3b59}</UniqueIdentifier>
</Filter> </Filter>
@@ -159,9 +153,6 @@
<Filter Include="beast_core\thread\detail"> <Filter Include="beast_core\thread\detail">
<UniqueIdentifier>{1b2e8962-c087-4453-8107-7077c2de5846}</UniqueIdentifier> <UniqueIdentifier>{1b2e8962-c087-4453-8107-7077c2de5846}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="beast_core\thread\impl">
<UniqueIdentifier>{91538dcf-b219-4c80-9861-bb4949089775}</UniqueIdentifier>
</Filter>
<Filter Include="beast_asio\protocol"> <Filter Include="beast_asio\protocol">
<UniqueIdentifier>{c0724499-ab69-40c3-90e2-65242dbd2eaa}</UniqueIdentifier> <UniqueIdentifier>{c0724499-ab69-40c3-90e2-65242dbd2eaa}</UniqueIdentifier>
</Filter> </Filter>
@@ -326,9 +317,6 @@
<ClInclude Include="..\..\modules\beast_core\containers\LinkedListPointer.h"> <ClInclude Include="..\..\modules\beast_core\containers\LinkedListPointer.h">
<Filter>beast_core\containers</Filter> <Filter>beast_core\containers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\modules\beast_core\containers\OwnedArray.h">
<Filter>beast_core\containers</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\containers\ScopedValueSetter.h"> <ClInclude Include="..\..\modules\beast_core\containers\ScopedValueSetter.h">
<Filter>beast_core\containers</Filter> <Filter>beast_core\containers</Filter>
</ClInclude> </ClInclude>
@@ -401,21 +389,12 @@
<ClInclude Include="..\..\modules\beast_core\text\StringPairArray.h"> <ClInclude Include="..\..\modules\beast_core\text\StringPairArray.h">
<Filter>beast_core\text</Filter> <Filter>beast_core\text</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\modules\beast_core\threads\ChildProcess.h">
<Filter>beast_core\threads</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\threads\CriticalSection.h"> <ClInclude Include="..\..\modules\beast_core\threads\CriticalSection.h">
<Filter>beast_core\threads</Filter> <Filter>beast_core\threads</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\modules\beast_core\threads\DynamicLibrary.h"> <ClInclude Include="..\..\modules\beast_core\threads\DynamicLibrary.h">
<Filter>beast_core\threads</Filter> <Filter>beast_core\threads</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\modules\beast_core\threads\HighResolutionTimer.h">
<Filter>beast_core\threads</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\threads\InterProcessLock.h">
<Filter>beast_core\threads</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\threads\Process.h"> <ClInclude Include="..\..\modules\beast_core\threads\Process.h">
<Filter>beast_core\threads</Filter> <Filter>beast_core\threads</Filter>
</ClInclude> </ClInclude>
@@ -425,12 +404,6 @@
<ClInclude Include="..\..\modules\beast_core\time\Time.h"> <ClInclude Include="..\..\modules\beast_core\time\Time.h">
<Filter>beast_core\time</Filter> <Filter>beast_core\time</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\modules\beast_core\xml\XmlDocument.h">
<Filter>beast_core\xml</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\xml\XmlElement.h">
<Filter>beast_core\xml</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\diagnostic\Throw.h"> <ClInclude Include="..\..\modules\beast_core\diagnostic\Throw.h">
<Filter>beast_core\diagnostic</Filter> <Filter>beast_core\diagnostic</Filter>
</ClInclude> </ClInclude>
@@ -521,24 +494,9 @@
<ClInclude Include="..\..\modules\beast_core\thread\MutexTraits.h"> <ClInclude Include="..\..\modules\beast_core\thread\MutexTraits.h">
<Filter>beast_core\thread</Filter> <Filter>beast_core\thread</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\modules\beast_core\thread\TrackedMutex.h">
<Filter>beast_core\thread</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\thread\detail\TrackedMutex.h">
<Filter>beast_core\thread\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\thread\detail\ScopedLock.h"> <ClInclude Include="..\..\modules\beast_core\thread\detail\ScopedLock.h">
<Filter>beast_core\thread\detail</Filter> <Filter>beast_core\thread\detail</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\modules\beast_core\thread\impl\TrackedMutex.h">
<Filter>beast_core\thread\impl</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\thread\impl\TrackedMutexType.h">
<Filter>beast_core\thread\impl</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\thread\impl\UntrackedMutexType.h">
<Filter>beast_core\thread\impl</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\thread\DeadlineTimer.h"> <ClInclude Include="..\..\modules\beast_core\thread\DeadlineTimer.h">
<Filter>beast_core\thread</Filter> <Filter>beast_core\thread</Filter>
</ClInclude> </ClInclude>
@@ -677,9 +635,6 @@
<ClInclude Include="..\..\beast\Config.h"> <ClInclude Include="..\..\beast\Config.h">
<Filter>beast</Filter> <Filter>beast</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\beast\CStdInt.h">
<Filter>beast</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\utility\Journal.h"> <ClInclude Include="..\..\beast\utility\Journal.h">
<Filter>beast\utility</Filter> <Filter>beast\utility</Filter>
</ClInclude> </ClInclude>
@@ -1265,9 +1220,6 @@
<ClCompile Include="..\..\modules\beast_core\native\linux_Files.cpp"> <ClCompile Include="..\..\modules\beast_core\native\linux_Files.cpp">
<Filter>beast_core\native</Filter> <Filter>beast_core\native</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\linux_Network.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\linux_SystemStats.cpp"> <ClCompile Include="..\..\modules\beast_core\native\linux_SystemStats.cpp">
<Filter>beast_core\native</Filter> <Filter>beast_core\native</Filter>
</ClCompile> </ClCompile>
@@ -1277,9 +1229,6 @@
<ClCompile Include="..\..\modules\beast_core\native\win32_Files.cpp"> <ClCompile Include="..\..\modules\beast_core\native\win32_Files.cpp">
<Filter>beast_core\native</Filter> <Filter>beast_core\native</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\win32_Network.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\win32_Registry.cpp"> <ClCompile Include="..\..\modules\beast_core\native\win32_Registry.cpp">
<Filter>beast_core\native</Filter> <Filter>beast_core\native</Filter>
</ClCompile> </ClCompile>
@@ -1307,30 +1256,15 @@
<ClCompile Include="..\..\modules\beast_core\text\StringPairArray.cpp"> <ClCompile Include="..\..\modules\beast_core\text\StringPairArray.cpp">
<Filter>beast_core\text</Filter> <Filter>beast_core\text</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\threads\ChildProcess.cpp">
<Filter>beast_core\threads</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\threads\HighResolutionTimer.cpp">
<Filter>beast_core\threads</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\time\Time.cpp"> <ClCompile Include="..\..\modules\beast_core\time\Time.cpp">
<Filter>beast_core\time</Filter> <Filter>beast_core\time</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\xml\XmlDocument.cpp">
<Filter>beast_core\xml</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\xml\XmlElement.cpp">
<Filter>beast_core\xml</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\bsd_SystemStats.cpp"> <ClCompile Include="..\..\modules\beast_core\native\bsd_SystemStats.cpp">
<Filter>beast_core\native</Filter> <Filter>beast_core\native</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\bsd_Files.cpp"> <ClCompile Include="..\..\modules\beast_core\native\bsd_Files.cpp">
<Filter>beast_core\native</Filter> <Filter>beast_core\native</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\bsd_Network.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\bsd_Threads.cpp"> <ClCompile Include="..\..\modules\beast_core\native\bsd_Threads.cpp">
<Filter>beast_core\native</Filter> <Filter>beast_core\native</Filter>
</ClCompile> </ClCompile>
@@ -1391,9 +1325,6 @@
<ClCompile Include="..\..\modules\beast_core\diagnostic\SemanticVersion.cpp"> <ClCompile Include="..\..\modules\beast_core\diagnostic\SemanticVersion.cpp">
<Filter>beast_core\diagnostic</Filter> <Filter>beast_core\diagnostic</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\beast_core\thread\impl\TrackedMutex.cpp">
<Filter>beast_core\thread\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\thread\DeadlineTimer.cpp"> <ClCompile Include="..\..\modules\beast_core\thread\DeadlineTimer.cpp">
<Filter>beast_core\thread</Filter> <Filter>beast_core\thread</Filter>
</ClCompile> </ClCompile>

View File

@@ -120,7 +120,7 @@ overlooked. Blank lines are used to separate code into "paragraphs."
`static_cast`. And when you're reinterpreting data, always use `static_cast`. And when you're reinterpreting data, always use
`reinterpret_cast`. `reinterpret_cast`.
* Until C++ gets a universal 64-bit primitive type (part of the C++11 * Until C++ gets a universal 64-bit primitive type (part of the C++11
standard), it's best to stick to the `int64` and `uint64` typedefs. standard), it's best to stick to the `std::int64_t` and `std::uint64_t` typedefs.
## Object lifetime and ownership ## Object lifetime and ownership

View File

@@ -2,12 +2,12 @@
BEAST TODO BEAST TODO
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
- Change sqdb to use exceptions instead of errors
- Use SemanticVersion for beast version numbers to replace BEAST_VERSION - Use SemanticVersion for beast version numbers to replace BEAST_VERSION
- add support for a __PRETTY_FUNCTION__ equivalent for all environments - add support for a __PRETTY_FUNCTION__ equivalent for all environments
- add expectThrow() to UnitTest, where it expects an exception
- Import secp256k1 from sipa - Import secp256k1 from sipa
- Set sqlite thread safety model to '2' in beast_sqlite - Set sqlite thread safety model to '2' in beast_sqlite
@@ -18,8 +18,6 @@ BEAST TODO
- Rename HeapBlock routines to not conflict with _CRTDBG_MAP_ALLOC macros - Rename HeapBlock routines to not conflict with _CRTDBG_MAP_ALLOC macros
- Design a WeakPtr / SharedPtr / SharedObject intrusive system
- Implement beast::Bimap? - Implement beast::Bimap?
- Use Bimap for storage in the DeadlineTimer::Manager, to support - Use Bimap for storage in the DeadlineTimer::Manager, to support
@@ -28,39 +26,18 @@ BEAST TODO
- Think about adding a shouldStop bool to InterruptibleThread, along - Think about adding a shouldStop bool to InterruptibleThread, along
with a shouldStop () function returning bool, and a stop() method. with a shouldStop () function returning bool, and a stop() method.
- Make OwnedArray add routines return a pointer instead of reference
- Tidy up CacheLine, MemoryAlignment - Tidy up CacheLine, MemoryAlignment
- Remove anything having to do with DLL builds like
BEAST_DLL, BEAST_DLL_BUILD, BEAST_DISABLE_DLL_ALLOCATORS
- Fix FifoFreeStoreWithTLS reference counting bug
- Implement a reasonable substitute for boost's thread_local_storage - Implement a reasonable substitute for boost's thread_local_storage
- Think about doing away with BEAST_CALLTYPE and BEAST_API
- Rename malloc/calloc JUCE members that conflict with the debug CRT from MSVC - Rename malloc/calloc JUCE members that conflict with the debug CRT from MSVC
- Reformat every Doxygen comment - Reformat every Doxygen comment
- Fix Doxygen metatags - Fix Doxygen metatags
- update Beast Doxyfile - update Beast Doxyfile
- Rename include guards to boost style, e.g. BEAST_THROW_H_INCLUDED
- Clean up CacheLine, StaticObject
- Clean up ConcurrentObject
- Rename SharedData to SharedState or something? - Rename SharedData to SharedState or something?
- Put BEAST_PUBLIC_FUNCTION in front of all loose functions
- restructure the repo sources to look like this:
/Source/beast/beast_core/beast_core.h
etc...
- Make sure the template BeastConfig.h is included in the Doxyfile - Make sure the template BeastConfig.h is included in the Doxyfile
- Implement robust key/value database with bulk write - Implement robust key/value database with bulk write

View File

@@ -25,11 +25,11 @@
#define BEAST_ARITHMETIC_H_INCLUDED #define BEAST_ARITHMETIC_H_INCLUDED
#include "Config.h" #include "Config.h"
#include "CStdInt.h"
#include "utility/noexcept.h" #include "utility/noexcept.h"
#include <cmath> #include <cmath>
#include <cstdint>
#include <algorithm> #include <algorithm>
namespace beast { namespace beast {
@@ -197,12 +197,6 @@ inline bool isPositiveAndNotGreaterThan (const int valueToTest, const int upperL
} }
//============================================================================== //==============================================================================
/** Handy function to swap two values. */
template <typename Type>
inline void swapVariables (Type& variable1, Type& variable2)
{
std::swap (variable1, variable2);
}
/** Handy function for getting the number of elements in a simple const C array. /** Handy function for getting the number of elements in a simple const C array.
E.g. E.g.
@@ -220,54 +214,12 @@ int numElementsInArray (Type (&array)[N])
return N; return N;
} }
//==============================================================================
// Some useful maths functions that aren't always present with all compilers and build settings.
/** Using beast_hypot is easier than dealing with the different types of hypot function
that are provided by the various platforms and compilers. */
template <typename Type>
inline Type beast_hypot (Type a, Type b) noexcept
{
#if BEAST_MSVC
return static_cast <Type> (_hypot (a, b));
#else
return static_cast <Type> (hypot (a, b));
#endif
}
/** 64-bit abs function. */ /** 64-bit abs function. */
inline int64 abs64 (const int64 n) noexcept inline std::int64_t abs64 (const std::int64_t n) noexcept
{ {
return (n >= 0) ? n : -n; return (n >= 0) ? n : -n;
} }
//==============================================================================
/** A predefined value for Pi, at double-precision.
@see float_Pi
*/
const double double_Pi = 3.1415926535897932384626433832795;
/** A predefined value for Pi, at single-precision.
@see double_Pi
*/
const float float_Pi = 3.14159265358979323846f;
//==============================================================================
/** The isfinite() method seems to vary between platforms, so this is a
platform-independent function for it.
*/
template <typename FloatingPointType>
inline bool beast_isfinite (FloatingPointType value)
{
#if BEAST_WINDOWS
return _finite (value);
#elif BEAST_ANDROID
return isfinite (value);
#else
return std::isfinite (value);
#endif
}
//============================================================================== //==============================================================================
#if BEAST_MSVC #if BEAST_MSVC
@@ -311,149 +263,6 @@ inline int roundToInt (const FloatType value) noexcept
#pragma optimize ("", on) // resets optimisations to the project defaults #pragma optimize ("", on) // resets optimisations to the project defaults
#endif #endif
/** Fast floating-point-to-integer conversion.
This is a slightly slower and slightly more accurate version of roundDoubleToInt(). It works
fine for values above zero, but negative numbers are rounded the wrong way.
*/
inline int roundToIntAccurate (const double value) noexcept
{
#ifdef __INTEL_COMPILER
#pragma float_control (pop)
#endif
return roundToInt (value + 1.5e-8);
}
/** Fast floating-point-to-integer conversion.
This is faster than using the normal c++ cast to convert a double to an int, and
it will round the value to the nearest integer, rather than rounding it down
like the normal cast does.
Note that this routine gets its speed at the expense of some accuracy, and when
rounding values whose floating point component is exactly 0.5, odd numbers and
even numbers will be rounded up or down differently. For a more accurate conversion,
see roundDoubleToIntAccurate().
*/
inline int roundDoubleToInt (const double value) noexcept
{
return roundToInt (value);
}
/** Fast floating-point-to-integer conversion.
This is faster than using the normal c++ cast to convert a float to an int, and
it will round the value to the nearest integer, rather than rounding it down
like the normal cast does.
Note that this routine gets its speed at the expense of some accuracy, and when
rounding values whose floating point component is exactly 0.5, odd numbers and
even numbers will be rounded up or down differently.
*/
inline int roundFloatToInt (const float value) noexcept
{
return roundToInt (value);
}
//==============================================================================
/** Returns true if the specified integer is a power-of-two.
*/
template <typename IntegerType>
bool isPowerOfTwo (IntegerType value)
{
return (value & (value - 1)) == 0;
}
/** Returns the smallest power-of-two which is equal to or greater than the given integer.
*/
inline int nextPowerOfTwo (int n) noexcept
{
--n;
n |= (n >> 1);
n |= (n >> 2);
n |= (n >> 4);
n |= (n >> 8);
n |= (n >> 16);
return n + 1;
}
/** Performs a modulo operation, but can cope with the dividend being negative.
The divisor must be greater than zero.
*/
template <typename IntegerType>
IntegerType negativeAwareModulo (IntegerType dividend, const IntegerType divisor) noexcept
{
bassert (divisor > 0);
dividend %= divisor;
return (dividend < 0) ? (dividend + divisor) : dividend;
}
//==============================================================================
#if (BEAST_INTEL && BEAST_32BIT) || defined (DOXYGEN)
/** This macro can be applied to a float variable to check whether it contains a denormalised
value, and to normalise it if necessary.
On CPUs that aren't vulnerable to denormalisation problems, this will have no effect.
*/
#define BEAST_UNDENORMALISE(x) x += 1.0f; x -= 1.0f;
#else
#define BEAST_UNDENORMALISE(x)
#endif
//==============================================================================
/** This namespace contains a few template classes for helping work out class type variations.
*/
namespace TypeHelpers
{
#if BEAST_VC8_OR_EARLIER
#define PARAMETER_TYPE(type) const type&
#else
/** The ParameterType struct is used to find the best type to use when passing some kind
of object as a parameter.
Of course, this is only likely to be useful in certain esoteric template situations.
Because "typename TypeHelpers::ParameterType<SomeClass>::type" is a bit of a mouthful, there's
a PARAMETER_TYPE(SomeClass) macro that you can use to get the same effect.
E.g. "myFunction (PARAMETER_TYPE (int), PARAMETER_TYPE (MyObject))"
would evaluate to "myfunction (int, const MyObject&)", keeping any primitive types as
pass-by-value, but passing objects as a const reference, to avoid copying.
*/
template <typename Type> struct ParameterType { typedef const Type& type; };
#if ! DOXYGEN
template <typename Type> struct ParameterType <Type&> { typedef Type& type; };
template <typename Type> struct ParameterType <Type*> { typedef Type* type; };
template <> struct ParameterType <char> { typedef char type; };
template <> struct ParameterType <unsigned char> { typedef unsigned char type; };
template <> struct ParameterType <short> { typedef short type; };
template <> struct ParameterType <unsigned short> { typedef unsigned short type; };
template <> struct ParameterType <int> { typedef int type; };
template <> struct ParameterType <unsigned int> { typedef unsigned int type; };
template <> struct ParameterType <long> { typedef long type; };
template <> struct ParameterType <unsigned long> { typedef unsigned long type; };
template <> struct ParameterType <int64> { typedef int64 type; };
template <> struct ParameterType <uint64> { typedef uint64 type; };
template <> struct ParameterType <bool> { typedef bool type; };
template <> struct ParameterType <float> { typedef float type; };
template <> struct ParameterType <double> { typedef double type; };
#endif
/** A helpful macro to simplify the use of the ParameterType template.
@see ParameterType
*/
#define PARAMETER_TYPE(a) typename TypeHelpers::ParameterType<a>::type
#endif
/** These templates are designed to take a type, and if it's a double, they return a double
type; for anything else, they return a float type.
*/
template <typename Type> struct SmallestFloatType { typedef float type; };
template <> struct SmallestFloatType <double> { typedef double type; };
}
} }
#endif #endif

View File

@@ -25,11 +25,12 @@
#define BEAST_ATOMIC_H_INCLUDED #define BEAST_ATOMIC_H_INCLUDED
#include "Config.h" #include "Config.h"
#include "CStdInt.h"
#include "StaticAssert.h" #include "StaticAssert.h"
#include "utility/noexcept.h" #include "utility/noexcept.h"
#include <cstdint>
namespace beast { namespace beast {
//============================================================================== //==============================================================================
@@ -158,10 +159,10 @@ private:
template <typename Dest, typename Source> template <typename Dest, typename Source>
static inline Dest castTo (Source value) noexcept { union { Dest d; Source s; } u; u.s = value; return u.d; } static inline Dest castTo (Source value) noexcept { union { Dest d; Source s; } u; u.s = value; return u.d; }
static inline Type castFrom32Bit (int32 value) noexcept { return castTo <Type, int32> (value); } static inline Type castFrom32Bit (std::int32_t value) noexcept { return castTo <Type, std::int32_t> (value); }
static inline Type castFrom64Bit (int64 value) noexcept { return castTo <Type, int64> (value); } static inline Type castFrom64Bit (std::int64_t value) noexcept { return castTo <Type, std::int64_t> (value); }
static inline int32 castTo32Bit (Type value) noexcept { return castTo <int32, Type> (value); } static inline std::int32_t castTo32Bit (Type value) noexcept { return castTo <std::int32_t, Type> (value); }
static inline int64 castTo64Bit (Type value) noexcept { return castTo <int64, Type> (value); } static inline std::int64_t castTo64Bit (Type value) noexcept { return castTo <std::int64_t, Type> (value); }
Type operator++ (int); // better to just use pre-increment with atomics.. Type operator++ (int); // better to just use pre-increment with atomics..
@@ -174,14 +175,14 @@ private:
return sizeof (ValueType) == 1 ? (ValueType) -(signed char) n return sizeof (ValueType) == 1 ? (ValueType) -(signed char) n
: (sizeof (ValueType) == 2 ? (ValueType) -(short) n : (sizeof (ValueType) == 2 ? (ValueType) -(short) n
: (sizeof (ValueType) == 4 ? (ValueType) -(int) n : (sizeof (ValueType) == 4 ? (ValueType) -(int) n
: ((ValueType) -(int64) n))); : ((ValueType) -(std::int64_t) n)));
} }
/** This templated negate function will negate pointers as well as integers */ /** This templated negate function will negate pointers as well as integers */
template <typename PointerType> template <typename PointerType>
inline PointerType* negateValue (PointerType* n) noexcept inline PointerType* negateValue (PointerType* n) noexcept
{ {
return reinterpret_cast <PointerType*> (-reinterpret_cast <pointer_sized_int> (n)); return reinterpret_cast <PointerType*> (-reinterpret_cast <std::intptr_t> (n));
} }
}; };
@@ -274,14 +275,14 @@ template <typename Type>
inline Type Atomic<Type>::get() const noexcept inline Type Atomic<Type>::get() const noexcept
{ {
#if BEAST_ATOMICS_MAC #if BEAST_ATOMICS_MAC
return sizeof (Type) == 4 ? castFrom32Bit ((int32) OSAtomicAdd32Barrier ((int32_t) 0, (BEAST_MAC_ATOMICS_VOLATILE int32_t*) &value)) return sizeof (Type) == 4 ? castFrom32Bit ((std::int32_t) OSAtomicAdd32Barrier ((int32_t) 0, (BEAST_MAC_ATOMICS_VOLATILE int32_t*) &value))
: castFrom64Bit ((int64) OSAtomicAdd64Barrier ((int64_t) 0, (BEAST_MAC_ATOMICS_VOLATILE int64_t*) &value)); : castFrom64Bit ((std::int64_t) OSAtomicAdd64Barrier ((int64_t) 0, (BEAST_MAC_ATOMICS_VOLATILE int64_t*) &value));
#elif BEAST_ATOMICS_WINDOWS #elif BEAST_ATOMICS_WINDOWS
return sizeof (Type) == 4 ? castFrom32Bit ((int32) beast_InterlockedExchangeAdd ((volatile long*) &value, (long) 0)) return sizeof (Type) == 4 ? castFrom32Bit ((std::int32_t) beast_InterlockedExchangeAdd ((volatile long*) &value, (long) 0))
: castFrom64Bit ((int64) beast_InterlockedExchangeAdd64 ((volatile __int64*) &value, (__int64) 0)); : castFrom64Bit ((std::int64_t) beast_InterlockedExchangeAdd64 ((volatile __int64*) &value, (__int64) 0));
#elif BEAST_ATOMICS_GCC #elif BEAST_ATOMICS_GCC
return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_add_and_fetch ((volatile int32*) &value, 0)) return sizeof (Type) == 4 ? castFrom32Bit ((std::int32_t) __sync_add_and_fetch ((volatile std::int32_t*) &value, 0))
: castFrom64Bit ((int64) __sync_add_and_fetch ((volatile int64*) &value, 0)); : castFrom64Bit ((std::int64_t) __sync_add_and_fetch ((volatile std::int64_t*) &value, 0));
#endif #endif
} }
@@ -293,8 +294,8 @@ inline Type Atomic<Type>::exchange (const Type newValue) noexcept
while (! compareAndSetBool (newValue, currentVal)) { currentVal = value; } while (! compareAndSetBool (newValue, currentVal)) { currentVal = value; }
return currentVal; return currentVal;
#elif BEAST_ATOMICS_WINDOWS #elif BEAST_ATOMICS_WINDOWS
return sizeof (Type) == 4 ? castFrom32Bit ((int32) beast_InterlockedExchange ((volatile long*) &value, (long) castTo32Bit (newValue))) return sizeof (Type) == 4 ? castFrom32Bit ((std::int32_t) beast_InterlockedExchange ((volatile long*) &value, (long) castTo32Bit (newValue)))
: castFrom64Bit ((int64) beast_InterlockedExchange64 ((volatile __int64*) &value, (__int64) castTo64Bit (newValue))); : castFrom64Bit ((std::int64_t) beast_InterlockedExchange64 ((volatile __int64*) &value, (__int64) castTo64Bit (newValue)));
#endif #endif
} }
@@ -379,8 +380,8 @@ inline bool Atomic<Type>::compareAndSetBool (const Type newValue, const Type val
#elif BEAST_ATOMICS_WINDOWS #elif BEAST_ATOMICS_WINDOWS
return compareAndSetValue (newValue, valueToCompare) == valueToCompare; return compareAndSetValue (newValue, valueToCompare) == valueToCompare;
#elif BEAST_ATOMICS_GCC #elif BEAST_ATOMICS_GCC
return sizeof (Type) == 4 ? __sync_bool_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue)) return sizeof (Type) == 4 ? __sync_bool_compare_and_swap ((volatile std::int32_t*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue))
: __sync_bool_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue)); : __sync_bool_compare_and_swap ((volatile std::int64_t*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue));
#endif #endif
} }
@@ -399,11 +400,11 @@ inline Type Atomic<Type>::compareAndSetValue (const Type newValue, const Type va
} }
#elif BEAST_ATOMICS_WINDOWS #elif BEAST_ATOMICS_WINDOWS
return sizeof (Type) == 4 ? castFrom32Bit ((int32) beast_InterlockedCompareExchange ((volatile long*) &value, (long) castTo32Bit (newValue), (long) castTo32Bit (valueToCompare))) return sizeof (Type) == 4 ? castFrom32Bit ((std::int32_t) beast_InterlockedCompareExchange ((volatile long*) &value, (long) castTo32Bit (newValue), (long) castTo32Bit (valueToCompare)))
: castFrom64Bit ((int64) beast_InterlockedCompareExchange64 ((volatile __int64*) &value, (__int64) castTo64Bit (newValue), (__int64) castTo64Bit (valueToCompare))); : castFrom64Bit ((std::int64_t) beast_InterlockedCompareExchange64 ((volatile __int64*) &value, (__int64) castTo64Bit (newValue), (__int64) castTo64Bit (valueToCompare)));
#elif BEAST_ATOMICS_GCC #elif BEAST_ATOMICS_GCC
return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_val_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue))) return sizeof (Type) == 4 ? castFrom32Bit ((std::int32_t) __sync_val_compare_and_swap ((volatile std::int32_t*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue)))
: castFrom64Bit ((int64) __sync_val_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue))); : castFrom64Bit ((std::int64_t) __sync_val_compare_and_swap ((volatile std::int64_t*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue)));
#endif #endif
} }

View File

@@ -25,9 +25,10 @@
#define BEAST_BYTEORDER_H_INCLUDED #define BEAST_BYTEORDER_H_INCLUDED
#include "Config.h" #include "Config.h"
#include "CStdInt.h"
#include "Uncopyable.h" #include "Uncopyable.h"
#include <cstdint>
namespace beast { namespace beast {
//============================================================================== //==============================================================================
@@ -39,51 +40,51 @@ class ByteOrder : public Uncopyable
public: public:
//============================================================================== //==============================================================================
/** Swaps the upper and lower bytes of a 16-bit integer. */ /** Swaps the upper and lower bytes of a 16-bit integer. */
static uint16 swap (uint16 value); static std::uint16_t swap (std::uint16_t value);
/** Reverses the order of the 4 bytes in a 32-bit integer. */ /** Reverses the order of the 4 bytes in a 32-bit integer. */
static uint32 swap (uint32 value); static std::uint32_t swap (std::uint32_t value);
/** Reverses the order of the 8 bytes in a 64-bit integer. */ /** Reverses the order of the 8 bytes in a 64-bit integer. */
static uint64 swap (uint64 value); static std::uint64_t swap (std::uint64_t value);
//============================================================================== //==============================================================================
/** Swaps the byte order of a 16-bit int if the CPU is big-endian */ /** Swaps the byte order of a 16-bit int if the CPU is big-endian */
static uint16 swapIfBigEndian (uint16 value); static std::uint16_t swapIfBigEndian (std::uint16_t value);
/** Swaps the byte order of a 32-bit int if the CPU is big-endian */ /** Swaps the byte order of a 32-bit int if the CPU is big-endian */
static uint32 swapIfBigEndian (uint32 value); static std::uint32_t swapIfBigEndian (std::uint32_t value);
/** Swaps the byte order of a 64-bit int if the CPU is big-endian */ /** Swaps the byte order of a 64-bit int if the CPU is big-endian */
static uint64 swapIfBigEndian (uint64 value); static std::uint64_t swapIfBigEndian (std::uint64_t value);
/** Swaps the byte order of a 16-bit int if the CPU is little-endian */ /** Swaps the byte order of a 16-bit int if the CPU is little-endian */
static uint16 swapIfLittleEndian (uint16 value); static std::uint16_t swapIfLittleEndian (std::uint16_t value);
/** Swaps the byte order of a 32-bit int if the CPU is little-endian */ /** Swaps the byte order of a 32-bit int if the CPU is little-endian */
static uint32 swapIfLittleEndian (uint32 value); static std::uint32_t swapIfLittleEndian (std::uint32_t value);
/** Swaps the byte order of a 64-bit int if the CPU is little-endian */ /** Swaps the byte order of a 64-bit int if the CPU is little-endian */
static uint64 swapIfLittleEndian (uint64 value); static std::uint64_t swapIfLittleEndian (std::uint64_t value);
//============================================================================== //==============================================================================
/** Turns 2 bytes into a little-endian integer. */ /** Turns 2 bytes into a little-endian integer. */
static uint16 littleEndianShort (const void* bytes); static std::uint16_t littleEndianShort (const void* bytes);
/** Turns 4 bytes into a little-endian integer. */ /** Turns 4 bytes into a little-endian integer. */
static uint32 littleEndianInt (const void* bytes); static std::uint32_t littleEndianInt (const void* bytes);
/** Turns 4 bytes into a little-endian integer. */ /** Turns 4 bytes into a little-endian integer. */
static uint64 littleEndianInt64 (const void* bytes); static std::uint64_t littleEndianInt64 (const void* bytes);
/** Turns 2 bytes into a big-endian integer. */ /** Turns 2 bytes into a big-endian integer. */
static uint16 bigEndianShort (const void* bytes); static std::uint16_t bigEndianShort (const void* bytes);
/** Turns 4 bytes into a big-endian integer. */ /** Turns 4 bytes into a big-endian integer. */
static uint32 bigEndianInt (const void* bytes); static std::uint32_t bigEndianInt (const void* bytes);
/** Turns 4 bytes into a big-endian integer. */ /** Turns 4 bytes into a big-endian integer. */
static uint64 bigEndianInt64 (const void* bytes); static std::uint64_t bigEndianInt64 (const void* bytes);
//============================================================================== //==============================================================================
/** Converts 3 little-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */ /** Converts 3 little-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */
@@ -111,16 +112,16 @@ private:
#pragma intrinsic (_byteswap_ulong) #pragma intrinsic (_byteswap_ulong)
#endif #endif
inline uint16 ByteOrder::swap (uint16 n) inline std::uint16_t ByteOrder::swap (std::uint16_t n)
{ {
#if BEAST_USE_INTRINSICSxxx // agh - the MS compiler has an internal error when you try to use this intrinsic! #if BEAST_USE_INTRINSICSxxx // agh - the MS compiler has an internal error when you try to use this intrinsic!
return static_cast <uint16> (_byteswap_ushort (n)); return static_cast <std::uint16_t> (_byteswap_ushort (n));
#else #else
return static_cast <uint16> ((n << 8) | (n >> 8)); return static_cast <std::uint16_t> ((n << 8) | (n >> 8));
#endif #endif
} }
inline uint32 ByteOrder::swap (uint32 n) inline std::uint32_t ByteOrder::swap (std::uint32_t n)
{ {
#if BEAST_MAC || BEAST_IOS #if BEAST_MAC || BEAST_IOS
return OSSwapInt32 (n); return OSSwapInt32 (n);
@@ -143,48 +144,48 @@ inline uint32 ByteOrder::swap (uint32 n)
#endif #endif
} }
inline uint64 ByteOrder::swap (uint64 value) inline std::uint64_t ByteOrder::swap (std::uint64_t value)
{ {
#if BEAST_MAC || BEAST_IOS #if BEAST_MAC || BEAST_IOS
return OSSwapInt64 (value); return OSSwapInt64 (value);
#elif BEAST_USE_INTRINSICS #elif BEAST_USE_INTRINSICS
return _byteswap_uint64 (value); return _byteswap_uint64 (value);
#else #else
return (((int64) swap ((uint32) value)) << 32) | swap ((uint32) (value >> 32)); return (((std::int64_t) swap ((std::uint32_t) value)) << 32) | swap ((std::uint32_t) (value >> 32));
#endif #endif
} }
#if BEAST_LITTLE_ENDIAN #if BEAST_LITTLE_ENDIAN
inline uint16 ByteOrder::swapIfBigEndian (const uint16 v) { return v; } inline std::uint16_t ByteOrder::swapIfBigEndian (const std::uint16_t v) { return v; }
inline uint32 ByteOrder::swapIfBigEndian (const uint32 v) { return v; } inline std::uint32_t ByteOrder::swapIfBigEndian (const std::uint32_t v) { return v; }
inline uint64 ByteOrder::swapIfBigEndian (const uint64 v) { return v; } inline std::uint64_t ByteOrder::swapIfBigEndian (const std::uint64_t v) { return v; }
inline uint16 ByteOrder::swapIfLittleEndian (const uint16 v) { return swap (v); } inline std::uint16_t ByteOrder::swapIfLittleEndian (const std::uint16_t v) { return swap (v); }
inline uint32 ByteOrder::swapIfLittleEndian (const uint32 v) { return swap (v); } inline std::uint32_t ByteOrder::swapIfLittleEndian (const std::uint32_t v) { return swap (v); }
inline uint64 ByteOrder::swapIfLittleEndian (const uint64 v) { return swap (v); } inline std::uint64_t ByteOrder::swapIfLittleEndian (const std::uint64_t v) { return swap (v); }
inline uint16 ByteOrder::littleEndianShort (const void* const bytes) { return *static_cast <const uint16*> (bytes); } inline std::uint16_t ByteOrder::littleEndianShort (const void* const bytes) { return *static_cast <const std::uint16_t*> (bytes); }
inline uint32 ByteOrder::littleEndianInt (const void* const bytes) { return *static_cast <const uint32*> (bytes); } inline std::uint32_t ByteOrder::littleEndianInt (const void* const bytes) { return *static_cast <const std::uint32_t*> (bytes); }
inline uint64 ByteOrder::littleEndianInt64 (const void* const bytes) { return *static_cast <const uint64*> (bytes); } inline std::uint64_t ByteOrder::littleEndianInt64 (const void* const bytes) { return *static_cast <const std::uint64_t*> (bytes); }
inline uint16 ByteOrder::bigEndianShort (const void* const bytes) { return swap (*static_cast <const uint16*> (bytes)); } inline std::uint16_t ByteOrder::bigEndianShort (const void* const bytes) { return swap (*static_cast <const std::uint16_t*> (bytes)); }
inline uint32 ByteOrder::bigEndianInt (const void* const bytes) { return swap (*static_cast <const uint32*> (bytes)); } inline std::uint32_t ByteOrder::bigEndianInt (const void* const bytes) { return swap (*static_cast <const std::uint32_t*> (bytes)); }
inline uint64 ByteOrder::bigEndianInt64 (const void* const bytes) { return swap (*static_cast <const uint64*> (bytes)); } inline std::uint64_t ByteOrder::bigEndianInt64 (const void* const bytes) { return swap (*static_cast <const std::uint64_t*> (bytes)); }
inline bool ByteOrder::isBigEndian() { return false; } inline bool ByteOrder::isBigEndian() { return false; }
#else #else
inline uint16 ByteOrder::swapIfBigEndian (const uint16 v) { return swap (v); } inline std::uint16_t ByteOrder::swapIfBigEndian (const std::uint16_t v) { return swap (v); }
inline uint32 ByteOrder::swapIfBigEndian (const uint32 v) { return swap (v); } inline std::uint32_t ByteOrder::swapIfBigEndian (const std::uint32_t v) { return swap (v); }
inline uint64 ByteOrder::swapIfBigEndian (const uint64 v) { return swap (v); } inline std::uint64_t ByteOrder::swapIfBigEndian (const std::uint64_t v) { return swap (v); }
inline uint16 ByteOrder::swapIfLittleEndian (const uint16 v) { return v; } inline std::uint16_t ByteOrder::swapIfLittleEndian (const std::uint16_t v) { return v; }
inline uint32 ByteOrder::swapIfLittleEndian (const uint32 v) { return v; } inline std::uint32_t ByteOrder::swapIfLittleEndian (const std::uint32_t v) { return v; }
inline uint64 ByteOrder::swapIfLittleEndian (const uint64 v) { return v; } inline std::uint64_t ByteOrder::swapIfLittleEndian (const std::uint64_t v) { return v; }
inline uint32 ByteOrder::littleEndianInt (const void* const bytes) { return swap (*static_cast <const uint32*> (bytes)); } inline std::uint32_t ByteOrder::littleEndianInt (const void* const bytes) { return swap (*static_cast <const std::uint32_t*> (bytes)); }
inline uint16 ByteOrder::littleEndianShort (const void* const bytes) { return swap (*static_cast <const uint16*> (bytes)); } inline std::uint16_t ByteOrder::littleEndianShort (const void* const bytes) { return swap (*static_cast <const std::uint16_t*> (bytes)); }
inline uint16 ByteOrder::bigEndianShort (const void* const bytes) { return *static_cast <const uint16*> (bytes); } inline std::uint16_t ByteOrder::bigEndianShort (const void* const bytes) { return *static_cast <const std::uint16_t*> (bytes); }
inline uint32 ByteOrder::bigEndianInt (const void* const bytes) { return *static_cast <const uint32*> (bytes); } inline std::uint32_t ByteOrder::bigEndianInt (const void* const bytes) { return *static_cast <const std::uint32_t*> (bytes); }
inline uint64 ByteOrder::bigEndianInt64 (const void* const bytes) { return *static_cast <const uint64*> (bytes); } inline std::uint64_t ByteOrder::bigEndianInt64 (const void* const bytes) { return *static_cast <const std::uint64_t*> (bytes); }
inline bool ByteOrder::isBigEndian() { return true; } inline bool ByteOrder::isBigEndian() { return true; }
#endif #endif
inline int ByteOrder::littleEndian24Bit (const char* const bytes) { return (((int) bytes[2]) << 16) | (((int) (uint8) bytes[1]) << 8) | ((int) (uint8) bytes[0]); } inline int ByteOrder::littleEndian24Bit (const char* const bytes) { return (((int) bytes[2]) << 16) | (((int) (std::uint8_t) bytes[1]) << 8) | ((int) (std::uint8_t) bytes[0]); }
inline int ByteOrder::bigEndian24Bit (const char* const bytes) { return (((int) bytes[0]) << 16) | (((int) (uint8) bytes[1]) << 8) | ((int) (uint8) bytes[2]); } inline int ByteOrder::bigEndian24Bit (const char* const bytes) { return (((int) bytes[0]) << 16) | (((int) (std::uint8_t) bytes[1]) << 8) | ((int) (std::uint8_t) bytes[2]); }
inline void ByteOrder::littleEndian24BitToChars (const int value, char* const destBytes) { destBytes[0] = (char)(value & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)((value >> 16) & 0xff); } inline void ByteOrder::littleEndian24BitToChars (const int value, char* const destBytes) { destBytes[0] = (char)(value & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)((value >> 16) & 0xff); }
inline void ByteOrder::bigEndian24BitToChars (const int value, char* const destBytes) { destBytes[0] = (char)((value >> 16) & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)(value & 0xff); } inline void ByteOrder::bigEndian24BitToChars (const int value, char* const destBytes) { destBytes[0] = (char)((value >> 16) & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)(value & 0xff); }
@@ -211,29 +212,29 @@ struct SwapBytes
// Specializations for signed integers // Specializations for signed integers
template <> template <>
struct SwapBytes <int16> struct SwapBytes <std::int16_t>
{ {
inline int16 operator() (int16 value) const noexcept inline std::int16_t operator() (std::int16_t value) const noexcept
{ {
return static_cast <int16> (ByteOrder::swap (static_cast <uint16> (value))); return static_cast <std::int16_t> (ByteOrder::swap (static_cast <std::uint16_t> (value)));
} }
}; };
template <> template <>
struct SwapBytes <int32> struct SwapBytes <std::int32_t>
{ {
inline int32 operator() (int32 value) const noexcept inline std::int32_t operator() (std::int32_t value) const noexcept
{ {
return static_cast <int32> (ByteOrder::swap (static_cast <uint32> (value))); return static_cast <std::int32_t> (ByteOrder::swap (static_cast <std::uint32_t> (value)));
} }
}; };
template <> template <>
struct SwapBytes <int64> struct SwapBytes <std::int64_t>
{ {
inline int64 operator() (int64 value) const noexcept inline std::int64_t operator() (std::int64_t value) const noexcept
{ {
return static_cast <int64> (ByteOrder::swap (static_cast <uint64> (value))); return static_cast <std::int64_t> (ByteOrder::swap (static_cast <std::uint64_t> (value)));
} }
}; };

View File

@@ -1,88 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Portions of this file are from JUCE.
Copyright (c) 2013 - Raw Material Software Ltd.
Please visit http://www.juce.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.
*/
//==============================================================================
#ifndef BEAST_CSTDINT_H_INCLUDED
#define BEAST_CSTDINT_H_INCLUDED
#include "Config.h"
namespace beast {
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
#if BEAST_MSVC
typedef __int64 int64;
typedef unsigned __int64 uint64;
/** A platform-independent macro for writing 64-bit literals, needed because
different compilers have different syntaxes for this.
E.g. writing literal64bit (0x1000000000) will translate to 0x1000000000LL for
GCC, or 0x1000000000 for MSVC.
*/
#define literal64bit(longLiteral) ((__int64) longLiteral)
#else
/** A platform-independent 64-bit integer type. */
typedef long long int64;
/** A platform-independent 64-bit unsigned integer type. */
typedef unsigned long long uint64;
/** A platform-independent macro for writing 64-bit literals, needed because
different compilers have different syntaxes for this.
E.g. writing literal64bit (0x1000000000) will translate to 0x1000000000LL for
GCC, or 0x1000000000 for MSVC.
*/
#define literal64bit(longLiteral) (longLiteral##LL)
#endif
#if BEAST_64BIT
/** A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
typedef int64 pointer_sized_int;
/** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
typedef uint64 pointer_sized_uint;
#elif BEAST_MSVC
/** A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
typedef _W64 int pointer_sized_int;
/** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
typedef _W64 unsigned int pointer_sized_uint;
#else
/** A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
typedef int pointer_sized_int;
/** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
typedef unsigned int pointer_sized_uint;
#endif
#if BEAST_MSVC
typedef pointer_sized_int ssize_t;
#endif
}
#endif

View File

@@ -119,7 +119,7 @@ namespace HeapBlockHelper
then a failed allocation will just leave the heapblock with a null pointer (assuming then a failed allocation will just leave the heapblock with a null pointer (assuming
that the system's malloc() function doesn't throw). that the system's malloc() function doesn't throw).
@see Array, OwnedArray, MemoryBlock @see Array, MemoryBlock
*/ */
template <class ElementType, bool throwOnFailure = false> template <class ElementType, bool throwOnFailure = false>
class HeapBlock : public Uncopyable class HeapBlock : public Uncopyable
@@ -339,10 +339,6 @@ private:
{ {
HeapBlockHelper::ThrowOnFail<throwOnFailure>::check (data); HeapBlockHelper::ThrowOnFail<throwOnFailure>::check (data);
} }
#if ! (defined (BEAST_DLL) || defined (BEAST_DLL_BUILD))
BEAST_PREVENT_HEAP_ALLOCATION // Creating a 'new HeapBlock' would be missing the point!
#endif
}; };
} }

View File

@@ -78,7 +78,7 @@ Type* createCopyIfNotNull (const Type* pointer)
/** A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII. /** A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII.
You should use the BEAST_AUTORELEASEPOOL macro to create a local auto-release pool on the stack. You should use the BEAST_AUTORELEASEPOOL macro to create a local auto-release pool on the stack.
*/ */
class BEAST_API ScopedAutoReleasePool : public Uncopyable class ScopedAutoReleasePool : public Uncopyable
{ {
public: public:
ScopedAutoReleasePool(); ScopedAutoReleasePool();

View File

@@ -33,7 +33,7 @@ Endpoint from_asio (boost::asio::ip::address const& address)
} }
// VFALCO TODO IPv6 support // VFALCO TODO IPv6 support
bassertfalse; assert(false);
return Endpoint(); return Endpoint();
} }
@@ -52,7 +52,7 @@ boost::asio::ip::address to_asio_address (Endpoint const& endpoint)
} }
// VFALCO TODO IPv6 support // VFALCO TODO IPv6 support
bassertfalse; assert(false);
return boost::asio::ip::address ( return boost::asio::ip::address (
boost::asio::ip::address_v6 ()); boost::asio::ip::address_v6 ());
} }

View File

@@ -41,7 +41,7 @@ namespace beast {
If you need an absolute time, (i.e. a date + time), see the Time class. If you need an absolute time, (i.e. a date + time), see the Time class.
*/ */
class BEAST_API RelativeTime class RelativeTime
{ {
public: public:
//============================================================================== //==============================================================================
@@ -88,7 +88,7 @@ public:
/** Creates a new RelativeTime object representing a number of milliseconds. /** Creates a new RelativeTime object representing a number of milliseconds.
@see seconds, minutes, hours, days, weeks @see seconds, minutes, hours, days, weeks
*/ */
static RelativeTime milliseconds (int64 milliseconds) noexcept; static RelativeTime milliseconds (std::int64_t milliseconds) noexcept;
/** Creates a new RelativeTime object representing a number of seconds. /** Creates a new RelativeTime object representing a number of seconds.
@see milliseconds, minutes, hours, days, weeks @see milliseconds, minutes, hours, days, weeks
@@ -119,7 +119,7 @@ public:
/** Returns the number of milliseconds this time represents. /** Returns the number of milliseconds this time represents.
@see milliseconds, inSeconds, inMinutes, inHours, inDays, inWeeks @see milliseconds, inSeconds, inMinutes, inHours, inDays, inWeeks
*/ */
int64 inMilliseconds() const noexcept; std::int64_t inMilliseconds() const noexcept;
/** Returns the number of seconds this time represents. /** Returns the number of seconds this time represents.
@see inMilliseconds, inMinutes, inHours, inDays, inWeeks @see inMilliseconds, inMinutes, inHours, inDays, inWeeks

View File

@@ -54,7 +54,7 @@ RelativeTime RelativeTime::milliseconds (const int milliseconds) noexcept
return RelativeTime (milliseconds * 0.001); return RelativeTime (milliseconds * 0.001);
} }
RelativeTime RelativeTime::milliseconds (const int64 milliseconds) noexcept RelativeTime RelativeTime::milliseconds (const std::int64_t milliseconds) noexcept
{ {
return RelativeTime (milliseconds * 0.001); return RelativeTime (milliseconds * 0.001);
} }
@@ -86,9 +86,9 @@ RelativeTime RelativeTime::weeks (const RelativeTime::value_type numberOfWeeks)
//============================================================================== //==============================================================================
int64 RelativeTime::inMilliseconds() const noexcept std::int64_t RelativeTime::inMilliseconds() const noexcept
{ {
return (int64) (numSeconds * 1000.0); return (std::int64_t) (numSeconds * 1000.0);
} }
RelativeTime::value_type RelativeTime::inMinutes() const noexcept RelativeTime::value_type RelativeTime::inMinutes() const noexcept
@@ -301,7 +301,7 @@ static double monotonicCurrentTimeInSeconds()
{ {
numerator = timebase.numer; numerator = timebase.numer;
// VFALCO NOTE I don't understand this code // VFALCO NOTE I don't understand this code
//denominator = timebase.denom * (uint64) 1000000 * 1000.0; //denominator = timebase.denom * (std::uint64_t) 1000000 * 1000.0;
denominator = timebase.denom * 1000000000.0; denominator = timebase.denom * 1000000000.0;
} }

View File

@@ -42,10 +42,8 @@
/** This macro defines the C calling convention used as the standard for Beast calls. /** This macro defines the C calling convention used as the standard for Beast calls.
*/ */
#if BEAST_MSVC #if BEAST_MSVC
# define BEAST_CALLTYPE __stdcall
# define BEAST_CDECL __cdecl # define BEAST_CDECL __cdecl
#else #else
# define BEAST_CALLTYPE
# define BEAST_CDECL # define BEAST_CDECL
#endif #endif
@@ -148,16 +146,6 @@ extern void beast_reportFatalError (char const* message, char const* fileName, i
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** This macro can be added to class definitions to disable the use of new/delete to
allocate the object on the heap, forcing it to only be used as a stack or member variable.
*/
#define BEAST_PREVENT_HEAP_ALLOCATION \
private: \
static void* operator new (size_t); \
static void operator delete (void*);
//------------------------------------------------------------------------------
#if ! DOXYGEN #if ! DOXYGEN
#define BEAST_JOIN_MACRO_HELPER(a, b) a ## b #define BEAST_JOIN_MACRO_HELPER(a, b) a ## b
#define BEAST_STRINGIFY_MACRO_HELPER(a) #a #define BEAST_STRINGIFY_MACRO_HELPER(a) #a
@@ -175,19 +163,6 @@ extern void beast_reportFatalError (char const* message, char const* fileName, i
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if BEAST_DEBUG || DOXYGEN
/** A platform-independent way of forcing an inline function.
Use the syntax: @code
forcedinline void myfunction (int x)
@endcode
*/
# define forcedinline inline
#elif BEAST_MSVC
# define forcedinline __forceinline
#else
# define forcedinline inline __attribute__((always_inline))
#endif
#if BEAST_MSVC || DOXYGEN #if BEAST_MSVC || DOXYGEN
/** This can be placed before a stack or member variable declaration to tell /** This can be placed before a stack or member variable declaration to tell
the compiler to align it to the specified number of bytes. the compiler to align it to the specified number of bytes.

View File

@@ -24,13 +24,10 @@
#if defined (fatal_error) || \ #if defined (fatal_error) || \
defined (fatal_condition) || \ defined (fatal_condition) || \
defined (fatal_assert) || \
defined (meets_condition) || \ defined (meets_condition) || \
defined (meets_precondition) || \ defined (meets_precondition) || \
defined (meets_postcondition) || \ defined (meets_postcondition) || \
defined (meets_invariant) || \ defined (meets_invariant) || \
defined (check_precondition) || \
defined (check_postcondition) || \
defined (check_invariant) defined (check_invariant)
#error "Programming by contract macros cannot be overriden!" #error "Programming by contract macros cannot be overriden!"
#endif #endif
@@ -52,13 +49,6 @@
(((!!(condition)) || (beast_reportFatalError ( \ (((!!(condition)) || (beast_reportFatalError ( \
category " '" BEAST_STRINGIFY(condition) "' failed.", __FILE__, __LINE__), 0))) category " '" BEAST_STRINGIFY(condition) "' failed.", __FILE__, __LINE__), 0)))
/** Replacement for assert which generates a fatal error if the condition is false.
The condition is always evaluated regardless of compilation settings.
Meets this declaration syntax:
@code inline void fatal_assert (bool condition); @endcode
*/
#define fatal_assert(condition) fatal_condition(condition,"Assertion")
/** Reports a fatal error message type if the condition is false /** Reports a fatal error message type if the condition is false
The condition is always evaluated regardless of settings. The condition is always evaluated regardless of settings.
Meets this declaration syntax: Meets this declaration syntax:
@@ -87,12 +77,8 @@
*/ */
/** @{ */ /** @{ */
#if ! BEAST_DISABLE_CONTRACT_CHECKS #if ! BEAST_DISABLE_CONTRACT_CHECKS
# define check_precondition(condition) meets_precondition(condition)
# define check_postcondition(condition) meets_postcondition(condition)
# define check_invariant(condition) meets_invariant(condition) # define check_invariant(condition) meets_invariant(condition)
#else #else
# define check_precondition(condition) ((void)0)
# define check_postcondition(condition) ((void)0)
# define check_invariant(condition) ((void)0) # define check_invariant(condition) ((void)0)
#endif #endif
/** @} */ /** @} */

View File

@@ -74,40 +74,4 @@
#undef max #undef max
#undef min #undef min
//------------------------------------------------------------------------------
// DLL building settings on Windows
//
// VFALCO TODO Deprecate this
//
#if BEAST_MSVC
#ifdef BEAST_DLL_BUILD
#define BEAST_API __declspec (dllexport)
#pragma warning (disable: 4251)
#elif defined (BEAST_DLL)
#define BEAST_API __declspec (dllimport)
#pragma warning (disable: 4251)
#endif
#ifdef __INTEL_COMPILER
#pragma warning (disable: 1125) // (virtual override warning)
#endif
#elif defined (BEAST_DLL) || defined (BEAST_DLL_BUILD)
#define BEAST_API __attribute__ ((visibility("default")))
#endif
//------------------------------------------------------------------------------
#ifndef BEAST_API
#define BEAST_API /**< This macro is added to all beast public class declarations. */
#endif
#if BEAST_MSVC && BEAST_DLL_BUILD
#define BEAST_PUBLIC_IN_DLL_BUILD(decl) public: decl; private:
#else
#define BEAST_PUBLIC_IN_DLL_BUILD(decl) decl;
#endif
/** This macro is added to all beast public function declarations. */
#define BEAST_PUBLIC_FUNCTION BEAST_API BEAST_CALLTYPE
#endif #endif

View File

@@ -20,22 +20,23 @@
#ifndef BEAST_CRYPTO_MURMURHASH_H_INCLUDED #ifndef BEAST_CRYPTO_MURMURHASH_H_INCLUDED
#define BEAST_CRYPTO_MURMURHASH_H_INCLUDED #define BEAST_CRYPTO_MURMURHASH_H_INCLUDED
#include "../CStdInt.h" #include <cstdint>
#include <stdexcept>
// Original source code links in .cpp file // Original source code links in .cpp file
namespace beast { namespace beast {
namespace Murmur { namespace Murmur {
extern void MurmurHash3_x86_32 (const void* key, int len, uint32 seed, void* out); extern void MurmurHash3_x86_32 (const void* key, int len, std::uint32_t seed, void* out);
extern void MurmurHash3_x86_128 (const void* key, int len, uint32 seed, void* out); extern void MurmurHash3_x86_128 (const void* key, int len, std::uint32_t seed, void* out);
extern void MurmurHash3_x64_128 (const void* key, int len, uint32 seed, void* out); extern void MurmurHash3_x64_128 (const void* key, int len, std::uint32_t seed, void* out);
// Uses Beast to choose an appropriate routine // Uses Beast to choose an appropriate routine
// This handy template deduces which size hash is desired // This handy template deduces which size hash is desired
template <typename HashType> template <typename HashType>
inline void Hash (const void* key, int len, uint32 seed, HashType* out) inline void Hash (const void* key, int len, std::uint32_t seed, HashType* out)
{ {
switch (8 * sizeof (HashType)) switch (8 * sizeof (HashType))
{ {
@@ -72,7 +73,7 @@ inline void Hash (const void* key, int len, uint32 seed, HashType* out)
#endif #endif
default: default:
Throw (std::runtime_error ("invalid key size in MurmurHash")); throw std::runtime_error ("invalid key size in MurmurHash");
break; break;
}; };
} }

View File

@@ -21,9 +21,9 @@
#define BEAST_CRYPTO_SHA256_H_INCLUDED #define BEAST_CRYPTO_SHA256_H_INCLUDED
#include "../Config.h" #include "../Config.h"
#include "../CStdInt.h"
#include <array> #include <array>
#include <cstdint>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -37,14 +37,14 @@ enum
}; };
/** A container suitable for holding the resulting hash. */ /** A container suitable for holding the resulting hash. */
typedef std::array <uint8, digestLength> digest_type; typedef std::array <std::uint8_t, digestLength> digest_type;
namespace detail { namespace detail {
struct Context struct Context
{ {
beast::uint32 state[8]; std::uint32_t state[8];
beast::uint64 bitcount; std::uint64_t bitcount;
beast::uint8 buffer[Sha256::blockLength]; std::uint8_t buffer[Sha256::blockLength];
}; };
} }
@@ -59,12 +59,12 @@ public:
/** @{ */ /** @{ */
void update (void const* buffer, std::size_t bytes); void update (void const* buffer, std::size_t bytes);
void update (int8 const* begin, int8 const* end) void update (std::int8_t const* begin, std::int8_t const* end)
{ {
update (begin, end - begin); update (begin, end - begin);
} }
void update (uint8 const* begin, uint8 const* end) void update (std::uint8_t const* begin, std::uint8_t const* end)
{ {
update (begin, end - begin); update (begin, end - begin);
} }
@@ -115,10 +115,10 @@ digest_type const& empty_digest();
void* hash (void const* buffer, std::size_t bytes, void* digest); void* hash (void const* buffer, std::size_t bytes, void* digest);
digest_type& hash ( void const* buffer, std::size_t bytes, digest_type& digest); digest_type& hash ( void const* buffer, std::size_t bytes, digest_type& digest);
digest_type hash (void const* buffer, std::size_t bytes); digest_type hash (void const* buffer, std::size_t bytes);
void* hash (int8 const* begin, int8 const* end, void* digest); void* hash (std::int8_t const* begin, std::int8_t const* end, void* digest);
void* hash (uint8 const* begin, uint8 const* end, void* digest); void* hash (std::uint8_t const* begin, std::uint8_t const* end, void* digest);
digest_type hash (int8 const* begin, int8 const* end); digest_type hash (std::int8_t const* begin, std::int8_t const* end);
digest_type hash (uint8 const* begin, uint8 const* end); digest_type hash (std::uint8_t const* begin, std::uint8_t const* end);
template <typename T> template <typename T>
void* hash (T const& t, void* digest) void* hash (T const& t, void* digest)

View File

@@ -23,8 +23,12 @@
#include "UnsignedIntegerCalc.h" #include "UnsignedIntegerCalc.h"
#include "MurmurHash.h" #include "MurmurHash.h"
#include "../../modules/beast_core/beast_core.h" // FIX ASAP #include "../ByteOrder.h"
#include "../utility/hardened_hash.h"
#include "../utility/noexcept.h"
#include <algorithm>
#include <cassert>
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
@@ -56,35 +60,20 @@ public:
typedef value_type* iterator; typedef value_type* iterator;
typedef value_type const* const_iterator; typedef value_type const* const_iterator;
void
hash_combine (std::size_t& seed) const noexcept
{
std::size_t result;
Murmur::Hash (get(), size, seed, &result);
seed = result;
}
/** Hardened hash function for use with hash based containers. /** Hardened hash function for use with hash based containers.
The seed is used to make the hash unpredictable. This prevents The seed is used to make the hash unpredictable. This prevents
attackers from exploiting crafted inputs to produce degenerate attackers from exploiting crafted inputs to produce degenerate
containers. containers.
*/ */
class hasher typedef hardened_hash <UnsignedInteger> hasher;
{
public:
/** Construct a hash function
If a seed is specified it will be used, else a random seed
will be generated from the system
@param seedToUse An optional seed to use.
*/
explicit hasher (std::size_t seedToUse = Random::getSystemRandom ().nextInt ())
: m_seed (seedToUse)
{
}
/** Generates a simple hash from an UnsignedInteger. */
std::size_t operator() (UnsignedInteger const& key) const
{
std::size_t hash;
Murmur::Hash (key.cbegin (), key.size, m_seed, &hash);
return hash;
}
private:
std::size_t m_seed;
};
/** Determins if two UnsignedInteger objects are equal. */ /** Determins if two UnsignedInteger objects are equal. */
class equal class equal
@@ -126,7 +115,7 @@ public:
UnsignedInteger (InputIt first, InputIt last) UnsignedInteger (InputIt first, InputIt last)
{ {
m_values [0] = 0; // clear any pad bytes m_values [0] = 0; // clear any pad bytes
check_precondition (std::distance (first, last) == size); assert (std::distance (first, last) == size);
std::copy (first, last, begin()); std::copy (first, last, begin());
} }
/** @} */ /** @} */
@@ -150,7 +139,8 @@ public:
UnsignedInteger <Bytes> result; UnsignedInteger <Bytes> result;
value = toNetworkByteOrder <UnsignedIntegralType> (value); value = toNetworkByteOrder <UnsignedIntegralType> (value);
result.clear (); result.clear ();
std::memcpy (result.end () - sizeof (value), &value, bmin (Bytes, sizeof (value))); std::memcpy (result.end () - sizeof (value), &value,
std::min (Bytes, sizeof (value)));
return result; return result;
} }

View File

@@ -20,8 +20,11 @@
#ifndef BEAST_CRYPTO_UNSIGNEDINTEGERCALC_H_INCLUDED #ifndef BEAST_CRYPTO_UNSIGNEDINTEGERCALC_H_INCLUDED
#define BEAST_CRYPTO_UNSIGNEDINTEGERCALC_H_INCLUDED #define BEAST_CRYPTO_UNSIGNEDINTEGERCALC_H_INCLUDED
#include "../ByteOrder.h"
#include <cassert> #include <cassert>
#include <cstdint> #include <cstdint>
#include <cstring>
namespace beast { namespace beast {
@@ -111,7 +114,7 @@ public:
if (swizzle) if (swizzle)
{ {
// Zero fill the possibly uninitialized pad bytes // Zero fill the possibly uninitialized pad bytes
memset (buffer, 0, std::memset (buffer, 0,
((sizeof(UInt)-(bytes&(sizeof(UInt)-1)))&(sizeof(UInt)-1))); ((sizeof(UInt)-(bytes&(sizeof(UInt)-1)))&(sizeof(UInt)-1)));
// Swap and swizzle // Swap and swizzle
UInt* lo (values); UInt* lo (values);

View File

@@ -42,12 +42,12 @@ namespace Murmur {
#else #else
static inline uint32_t rotl32 ( uint32_t x, int8_t r ) static inline std::uint32_t rotl32 ( std::uint32_t x, int8_t r )
{ {
return (x << r) | (x >> (32 - r)); return (x << r) | (x >> (32 - r));
} }
static inline uint64_t rotl64 ( uint64_t x, int8_t r ) static inline std::uint64_t rotl64 ( std::uint64_t x, int8_t r )
{ {
return (x << r) | (x >> (64 - r)); return (x << r) | (x >> (64 - r));
} }
@@ -63,12 +63,12 @@ static inline uint64_t rotl64 ( uint64_t x, int8_t r )
// Block read - if your platform needs to do endian-swapping or can only // Block read - if your platform needs to do endian-swapping or can only
// handle aligned reads, do the conversion here // handle aligned reads, do the conversion here
static forcedinline uint32_t getblock ( const uint32_t* p, int i ) static inline std::uint32_t getblock ( const std::uint32_t* p, int i )
{ {
return p[i]; return p[i];
} }
static forcedinline uint64_t getblock ( const uint64_t* p, int i ) static inline std::uint64_t getblock ( const std::uint64_t* p, int i )
{ {
return p[i]; return p[i];
} }
@@ -76,7 +76,7 @@ static forcedinline uint64_t getblock ( const uint64_t* p, int i )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Finalization mix - force all bits of a hash block to avalanche // Finalization mix - force all bits of a hash block to avalanche
static forcedinline uint32_t fmix ( uint32_t h ) static inline std::uint32_t fmix ( std::uint32_t h )
{ {
h ^= h >> 16; h ^= h >> 16;
h *= 0x85ebca6b; h *= 0x85ebca6b;
@@ -89,7 +89,7 @@ static forcedinline uint32_t fmix ( uint32_t h )
//---------- //----------
static forcedinline uint64_t fmix ( uint64_t k ) static inline std::uint64_t fmix ( std::uint64_t k )
{ {
k ^= k >> 33; k ^= k >> 33;
k *= BIG_CONSTANT (0xff51afd7ed558ccd); k *= BIG_CONSTANT (0xff51afd7ed558ccd);
@@ -103,24 +103,24 @@ static forcedinline uint64_t fmix ( uint64_t k )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void MurmurHash3_x86_32 ( const void* key, int len, void MurmurHash3_x86_32 ( const void* key, int len,
uint32_t seed, void* out ) std::uint32_t seed, void* out )
{ {
const uint8_t* data = (const uint8_t*)key; const uint8_t* data = (const uint8_t*)key;
const int nblocks = len / 4; const int nblocks = len / 4;
uint32_t h1 = seed; std::uint32_t h1 = seed;
uint32_t c1 = 0xcc9e2d51; std::uint32_t c1 = 0xcc9e2d51;
uint32_t c2 = 0x1b873593; std::uint32_t c2 = 0x1b873593;
//---------- //----------
// body // body
const uint32_t* blocks = (const uint32_t*) (data + nblocks * 4); const std::uint32_t* blocks = (const std::uint32_t*) (data + nblocks * 4);
for (int i = -nblocks; i; i++) for (int i = -nblocks; i; i++)
{ {
uint32_t k1 = getblock (blocks, i); std::uint32_t k1 = getblock (blocks, i);
k1 *= c1; k1 *= c1;
k1 = ROTL32 (k1, 15); k1 = ROTL32 (k1, 15);
@@ -136,7 +136,7 @@ void MurmurHash3_x86_32 ( const void* key, int len,
const uint8_t* tail = (const uint8_t*) (data + nblocks * 4); const uint8_t* tail = (const uint8_t*) (data + nblocks * 4);
uint32_t k1 = 0; std::uint32_t k1 = 0;
switch (len & 3) switch (len & 3)
{ {
@@ -161,38 +161,38 @@ void MurmurHash3_x86_32 ( const void* key, int len,
h1 = fmix (h1); h1 = fmix (h1);
* (uint32_t*)out = h1; * (std::uint32_t*)out = h1;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void MurmurHash3_x86_128 ( const void* key, const int len, void MurmurHash3_x86_128 ( const void* key, const int len,
uint32_t seed, void* out ) std::uint32_t seed, void* out )
{ {
const uint8_t* data = (const uint8_t*)key; const uint8_t* data = (const uint8_t*)key;
const int nblocks = len / 16; const int nblocks = len / 16;
uint32_t h1 = seed; std::uint32_t h1 = seed;
uint32_t h2 = seed; std::uint32_t h2 = seed;
uint32_t h3 = seed; std::uint32_t h3 = seed;
uint32_t h4 = seed; std::uint32_t h4 = seed;
uint32_t c1 = 0x239b961b; std::uint32_t c1 = 0x239b961b;
uint32_t c2 = 0xab0e9789; std::uint32_t c2 = 0xab0e9789;
uint32_t c3 = 0x38b34ae5; std::uint32_t c3 = 0x38b34ae5;
uint32_t c4 = 0xa1e38b93; std::uint32_t c4 = 0xa1e38b93;
//---------- //----------
// body // body
const uint32_t* blocks = (const uint32_t*) (data + nblocks * 16); const std::uint32_t* blocks = (const std::uint32_t*) (data + nblocks * 16);
for (int i = -nblocks; i; i++) for (int i = -nblocks; i; i++)
{ {
uint32_t k1 = getblock (blocks, i * 4 + 0); std::uint32_t k1 = getblock (blocks, i * 4 + 0);
uint32_t k2 = getblock (blocks, i * 4 + 1); std::uint32_t k2 = getblock (blocks, i * 4 + 1);
uint32_t k3 = getblock (blocks, i * 4 + 2); std::uint32_t k3 = getblock (blocks, i * 4 + 2);
uint32_t k4 = getblock (blocks, i * 4 + 3); std::uint32_t k4 = getblock (blocks, i * 4 + 3);
k1 *= c1; k1 *= c1;
k1 = ROTL32 (k1, 15); k1 = ROTL32 (k1, 15);
@@ -236,10 +236,10 @@ void MurmurHash3_x86_128 ( const void* key, const int len,
const uint8_t* tail = (const uint8_t*) (data + nblocks * 16); const uint8_t* tail = (const uint8_t*) (data + nblocks * 16);
uint32_t k1 = 0; std::uint32_t k1 = 0;
uint32_t k2 = 0; std::uint32_t k2 = 0;
uint32_t k3 = 0; std::uint32_t k3 = 0;
uint32_t k4 = 0; std::uint32_t k4 = 0;
switch (len & 15) switch (len & 15)
{ {
@@ -348,38 +348,38 @@ void MurmurHash3_x86_128 ( const void* key, const int len,
h4 += h1; h4 += h1;
((uint32_t*)out)[0] = h1; ((std::uint32_t*)out)[0] = h1;
((uint32_t*)out)[1] = h2; ((std::uint32_t*)out)[1] = h2;
((uint32_t*)out)[2] = h3; ((std::uint32_t*)out)[2] = h3;
((uint32_t*)out)[3] = h4; ((std::uint32_t*)out)[3] = h4;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void MurmurHash3_x64_128 ( const void* key, const int len, void MurmurHash3_x64_128 ( const void* key, const int len,
const uint32_t seed, void* out ) const std::uint32_t seed, void* out )
{ {
const uint8_t* data = (const uint8_t*)key; const uint8_t* data = (const uint8_t*)key;
const int nblocks = len / 16; const int nblocks = len / 16;
uint64_t h1 = seed; std::uint64_t h1 = seed;
uint64_t h2 = seed; std::uint64_t h2 = seed;
uint64_t c1 = BIG_CONSTANT (0x87c37b91114253d5); std::uint64_t c1 = BIG_CONSTANT (0x87c37b91114253d5);
uint64_t c2 = BIG_CONSTANT (0x4cf5ad432745937f); std::uint64_t c2 = BIG_CONSTANT (0x4cf5ad432745937f);
//---------- //----------
// body // body
const uint64_t* blocks = (const uint64_t*) (data); const std::uint64_t* blocks = (const std::uint64_t*) (data);
for (int i = 0; i < nblocks; i++) for (int i = 0; i < nblocks; i++)
{ {
uint64_t k1 = getblock (blocks, i * 2 + 0); std::uint64_t k1 = getblock (blocks, i * 2 + 0);
uint64_t k2 = getblock (blocks, i * 2 + 1); std::uint64_t k2 = getblock (blocks, i * 2 + 1);
k1 *= c1; k1 *= c1;
k1 = ROTL64 (k1, 31); k1 = ROTL64 (k1, 31);
@@ -405,59 +405,59 @@ void MurmurHash3_x64_128 ( const void* key, const int len,
const uint8_t* tail = (const uint8_t*) (data + nblocks * 16); const uint8_t* tail = (const uint8_t*) (data + nblocks * 16);
uint64_t k1 = 0; std::uint64_t k1 = 0;
uint64_t k2 = 0; std::uint64_t k2 = 0;
switch (len & 15) switch (len & 15)
{ {
case 15: case 15:
k2 ^= uint64_t (tail[14]) << 48; k2 ^= std::uint64_t (tail[14]) << 48;
case 14: case 14:
k2 ^= uint64_t (tail[13]) << 40; k2 ^= std::uint64_t (tail[13]) << 40;
case 13: case 13:
k2 ^= uint64_t (tail[12]) << 32; k2 ^= std::uint64_t (tail[12]) << 32;
case 12: case 12:
k2 ^= uint64_t (tail[11]) << 24; k2 ^= std::uint64_t (tail[11]) << 24;
case 11: case 11:
k2 ^= uint64_t (tail[10]) << 16; k2 ^= std::uint64_t (tail[10]) << 16;
case 10: case 10:
k2 ^= uint64_t (tail[ 9]) << 8; k2 ^= std::uint64_t (tail[ 9]) << 8;
case 9: case 9:
k2 ^= uint64_t (tail[ 8]) << 0; k2 ^= std::uint64_t (tail[ 8]) << 0;
k2 *= c2; k2 *= c2;
k2 = ROTL64 (k2, 33); k2 = ROTL64 (k2, 33);
k2 *= c1; k2 *= c1;
h2 ^= k2; h2 ^= k2;
case 8: case 8:
k1 ^= uint64_t (tail[ 7]) << 56; k1 ^= std::uint64_t (tail[ 7]) << 56;
case 7: case 7:
k1 ^= uint64_t (tail[ 6]) << 48; k1 ^= std::uint64_t (tail[ 6]) << 48;
case 6: case 6:
k1 ^= uint64_t (tail[ 5]) << 40; k1 ^= std::uint64_t (tail[ 5]) << 40;
case 5: case 5:
k1 ^= uint64_t (tail[ 4]) << 32; k1 ^= std::uint64_t (tail[ 4]) << 32;
case 4: case 4:
k1 ^= uint64_t (tail[ 3]) << 24; k1 ^= std::uint64_t (tail[ 3]) << 24;
case 3: case 3:
k1 ^= uint64_t (tail[ 2]) << 16; k1 ^= std::uint64_t (tail[ 2]) << 16;
case 2: case 2:
k1 ^= uint64_t (tail[ 1]) << 8; k1 ^= std::uint64_t (tail[ 1]) << 8;
case 1: case 1:
k1 ^= uint64_t (tail[ 0]) << 0; k1 ^= std::uint64_t (tail[ 0]) << 0;
k1 *= c1; k1 *= c1;
k1 = ROTL64 (k1, 31); k1 = ROTL64 (k1, 31);
k1 *= c2; k1 *= c2;
@@ -483,9 +483,9 @@ void MurmurHash3_x64_128 ( const void* key, const int len,
h2 += h1; h2 += h1;
((uint64_t*)out)[0] = h1; ((std::uint64_t*)out)[0] = h1;
((uint64_t*)out)[1] = h2; ((std::uint64_t*)out)[1] = h2;
} }
} }

View File

@@ -49,12 +49,12 @@ Context::Context ()
void Context::update (void const* buffer, std::size_t bytes) void Context::update (void const* buffer, std::size_t bytes)
{ {
detail::SHA256_Update (&m_context, static_cast <uint8 const*> (buffer), bytes); detail::SHA256_Update (&m_context, static_cast <std::uint8_t const*> (buffer), bytes);
} }
void* Context::finish (void* hash) void* Context::finish (void* hash)
{ {
detail::SHA256_Final (static_cast <uint8*> (hash), &m_context); detail::SHA256_Final (static_cast <std::uint8_t*> (hash), &m_context);
return hash; return hash;
} }
@@ -66,7 +66,7 @@ digest_type const& empty_digest()
{ {
Holder () Holder ()
{ {
uint8 zero (0); std::uint8_t zero (0);
hash (zero, digest); hash (zero, digest);
} }
@@ -99,24 +99,24 @@ digest_type hash (void const* buffer, std::size_t bytes)
return digest; return digest;
} }
void* hash (int8 const* begin, int8 const* end, void* digest) void* hash (std::int8_t const* begin, std::int8_t const* end, void* digest)
{ {
return hash (begin, end - begin, digest); return hash (begin, end - begin, digest);
} }
void* hash (uint8 const* begin, uint8 const* end, void* digest) void* hash (std::uint8_t const* begin, std::uint8_t const* end, void* digest)
{ {
return hash (begin, end - begin, digest); return hash (begin, end - begin, digest);
} }
digest_type hash (int8 const* begin, int8 const* end) digest_type hash (std::int8_t const* begin, std::int8_t const* end)
{ {
digest_type digest; digest_type digest;
hash (begin, end - begin, digest); hash (begin, end - begin, digest);
return digest; return digest;
} }
digest_type hash (uint8 const* begin, uint8 const* end) digest_type hash (std::uint8_t const* begin, std::uint8_t const* end)
{ {
digest_type digest; digest_type digest;
hash (begin, end - begin, digest); hash (begin, end - begin, digest);

View File

@@ -103,9 +103,9 @@
* types and pointing out recent ANSI C support for uintXX_t in inttypes.h. * types and pointing out recent ANSI C support for uintXX_t in inttypes.h.
*/ */
typedef uint8 sha2_byte; /* Exactly 1 byte */ typedef std::uint8_t sha2_byte; /* Exactly 1 byte */
typedef uint32 sha2_word32; /* Exactly 4 bytes */ typedef std::uint32_t sha2_word32; /* Exactly 4 bytes */
typedef uint64 sha2_word64; /* Exactly 8 bytes */ typedef std::uint64_t sha2_word64; /* Exactly 8 bytes */
/*** SHA-256/384/512 Various Length Definitions ***********************/ /*** SHA-256/384/512 Various Length Definitions ***********************/
/* NOTE: Most of these are in sha2.h */ /* NOTE: Most of these are in sha2.h */

View File

@@ -58,9 +58,9 @@
/*** SHA-256/384/512 Context Structures *******************************/ /*** SHA-256/384/512 Context Structures *******************************/
typedef struct _SHA512_CTX { typedef struct _SHA512_CTX {
uint64 state[8]; std::uint64_t state[8];
uint64 bitcount[2]; std::uint64_t bitcount[2];
uint8 buffer[SHA512_BLOCK_LENGTH]; std::uint8_t buffer[SHA512_BLOCK_LENGTH];
} SHA512_CTX; } SHA512_CTX;
typedef SHA512_CTX SHA384_CTX; typedef SHA512_CTX SHA384_CTX;
@@ -70,22 +70,22 @@ typedef SHA512_CTX SHA384_CTX;
#ifndef NOPROTO #ifndef NOPROTO
void SHA256_Init(Sha256::detail::Context *); void SHA256_Init(Sha256::detail::Context *);
void SHA256_Update(Sha256::detail::Context*, const uint8*, size_t); void SHA256_Update(Sha256::detail::Context*, const std::uint8_t*, size_t);
void SHA256_Final(uint8[Sha256::digestLength], Sha256::detail::Context*); void SHA256_Final(std::uint8_t[Sha256::digestLength], Sha256::detail::Context*);
char* SHA256_End(Sha256::detail::Context*, char[SHA256_DIGEST_STRING_LENGTH]); char* SHA256_End(Sha256::detail::Context*, char[SHA256_DIGEST_STRING_LENGTH]);
char* SHA256_Data(const uint8*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); char* SHA256_Data(const std::uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
void SHA384_Init(SHA384_CTX*); void SHA384_Init(SHA384_CTX*);
void SHA384_Update(SHA384_CTX*, const uint8*, size_t); void SHA384_Update(SHA384_CTX*, const std::uint8_t*, size_t);
void SHA384_Final(uint8[SHA384_DIGEST_LENGTH], SHA384_CTX*); void SHA384_Final(std::uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
char* SHA384_Data(const uint8*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); char* SHA384_Data(const std::uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
void SHA512_Init(SHA512_CTX*); void SHA512_Init(SHA512_CTX*);
void SHA512_Update(SHA512_CTX*, const uint8*, size_t); void SHA512_Update(SHA512_CTX*, const std::uint8_t*, size_t);
void SHA512_Final(uint8[SHA512_DIGEST_LENGTH], SHA512_CTX*); void SHA512_Final(std::uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
char* SHA512_Data(const uint8*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); char* SHA512_Data(const std::uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
#else /* NOPROTO */ #else /* NOPROTO */

View File

@@ -21,6 +21,7 @@
#include "../UnsignedInteger.h" #include "../UnsignedInteger.h"
#include "../../unit_test/suite.h" #include "../../unit_test/suite.h"
#include "../../../modules/beast_core/maths/Random.h"
#include <cstddef> #include <cstddef>
#include <string> #include <string>
@@ -134,12 +135,12 @@ public:
static std::string encode (UnsignedInteger <Bytes> const& v) static std::string encode (UnsignedInteger <Bytes> const& v)
{ {
std::string s; std::string s;
uint8 const* src (v.cbegin()-1); std::uint8_t const* src (v.cbegin()-1);
char const* const tab (alphabet().c_str()); char const* const tab (alphabet().c_str());
s.reserve (Bytes * 2); s.reserve (Bytes * 2);
for (std::size_t bytes (v.size);bytes--;) for (std::size_t bytes (v.size);bytes--;)
{ {
uint8 const v (*++src); std::uint8_t const v (*++src);
s.push_back (tab [v>>4]); s.push_back (tab [v>>4]);
s.push_back (tab [v&0x0f]); s.push_back (tab [v&0x0f]);
} }
@@ -153,7 +154,7 @@ public:
// can't have an odd size // can't have an odd size
if (s.size() & 1) if (s.size() & 1)
return false; return false;
uint8* dest (rv.begin()-1); std::uint8_t* dest (rv.begin()-1);
int const* const tab (&inverse_alphabet().front()); int const* const tab (&inverse_alphabet().front());
for (std::string::const_iterator iter (s.begin()); iter != s.end();) for (std::string::const_iterator iter (s.begin()); iter != s.end();)
{ {
@@ -163,7 +164,7 @@ public:
int const n2 (tab [*iter++]); int const n2 (tab [*iter++]);
if (n2 == -1) if (n2 == -1)
return false; return false;
*++dest = ((uint8)((n1<<4)|n2)); *++dest = ((std::uint8_t)((n1<<4)|n2));
} }
return true; return true;
} }

View File

@@ -39,7 +39,7 @@ public:
URL ( URL (
String schema_, String schema_,
String host_, String host_,
uint16 port_, std::uint16_t port_,
String port_string_, String port_string_,
String path_, String path_,
String query_ = "", String query_ = "",
@@ -68,7 +68,7 @@ public:
/** Returns the port number as an integer. /** Returns the port number as an integer.
If no port was specified, the value will be zero. If no port was specified, the value will be zero.
*/ */
uint16 port () const; std::uint16_t port () const;
/** Returns the port number as a string. /** Returns the port number as a string.
If no port was specified, the string will be empty. If no port was specified, the string will be empty.
@@ -100,7 +100,7 @@ public:
private: private:
String m_scheme; String m_scheme;
String m_host; String m_host;
uint16 m_port; std::uint16_t m_port;
String m_port_string; String m_port_string;
String m_path; String m_path;
String m_query; String m_query;

View File

@@ -28,7 +28,7 @@ URL::URL ()
URL::URL ( URL::URL (
String scheme_, String scheme_,
String host_, String host_,
uint16 port_, std::uint16_t port_,
String port_string_, String port_string_,
String path_, String path_,
String query_, String query_,
@@ -92,7 +92,7 @@ String URL::port_string () const
return m_port_string; return m_port_string;
} }
uint16 URL::port () const std::uint16_t URL::port () const
{ {
return m_port; return m_port;
} }

View File

@@ -20,14 +20,14 @@
#ifndef BEAST_NET_IPADDRESS_H_INCLUDED #ifndef BEAST_NET_IPADDRESS_H_INCLUDED
#define BEAST_NET_IPADDRESS_H_INCLUDED #define BEAST_NET_IPADDRESS_H_INCLUDED
#include <string>
#include <ios>
#include <sstream>
#include "../CStdInt.h"
#include "IPAddressV4.h" #include "IPAddressV4.h"
#include "IPAddressV6.h" #include "IPAddressV6.h"
#include <cstdint>
#include <ios>
#include <string>
#include <sstream>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace beast { namespace beast {

View File

@@ -20,12 +20,11 @@
#ifndef BEAST_NET_IPADDRESSV4_H_INCLUDED #ifndef BEAST_NET_IPADDRESSV4_H_INCLUDED
#define BEAST_NET_IPADDRESSV4_H_INCLUDED #define BEAST_NET_IPADDRESSV4_H_INCLUDED
#include <string> #include <cstdint>
#include <ios> #include <ios>
#include <string>
#include <utility> #include <utility>
#include "../CStdInt.h"
namespace beast { namespace beast {
namespace IP { namespace IP {
@@ -38,12 +37,12 @@ struct AddressV4
/** Construct from a 32-bit unsigned. /** Construct from a 32-bit unsigned.
@note Octets are formed in order from the MSB to the LSB. @note Octets are formed in order from the MSB to the LSB.
*/ */
explicit AddressV4 (uint32 value_); explicit AddressV4 (std::uint32_t value_);
/** Construct from four individual octets.. /** Construct from four individual octets..
@note The resulting address is a.b.c.d @note The resulting address is a.b.c.d
*/ */
AddressV4 (uint8 a, uint8 b, uint8 c, uint8 d); AddressV4 (std::uint8_t a, std::uint8_t b, std::uint8_t c, std::uint8_t d);
/** Create an address from an IPv4 address string in dotted decimal form. /** Create an address from an IPv4 address string in dotted decimal form.
@return A pair with the address, and bool set to `true` on success. @return A pair with the address, and bool set to `true` on success.
@@ -108,7 +107,7 @@ struct AddressV4
{ {
public: public:
typedef typename std::conditional < typedef typename std::conditional <
IsConst, uint32 const*, uint32*>::type Pointer; IsConst, std::uint32_t const*, std::uint32_t*>::type Pointer;
Proxy (int shift, Pointer value) Proxy (int shift, Pointer value)
: m_shift (shift) : m_shift (shift)
@@ -116,7 +115,7 @@ struct AddressV4
{ {
} }
operator uint8() const operator std::uint8_t() const
{ {
return ((*m_value)>>m_shift) & 0xff; return ((*m_value)>>m_shift) & 0xff;
} }
@@ -141,7 +140,7 @@ struct AddressV4
/** @{ */ /** @{ */
/** The value as a 32 bit unsigned. */ /** The value as a 32 bit unsigned. */
uint32 value; std::uint32_t value;
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@@ -20,12 +20,12 @@
#ifndef BEAST_NET_IPADDRESSV6_H_INCLUDED #ifndef BEAST_NET_IPADDRESSV6_H_INCLUDED
#define BEAST_NET_IPADDRESSV6_H_INCLUDED #define BEAST_NET_IPADDRESSV6_H_INCLUDED
#include <string> #include <cassert>
#include <cstdint>
#include <ios> #include <ios>
#include <string>
#include <utility> #include <utility>
#include "../CStdInt.h"
namespace beast { namespace beast {
namespace IP { namespace IP {
@@ -37,9 +37,9 @@ struct AddressV6
/** Arithmetic comparison. */ /** Arithmetic comparison. */
/** @{ */ /** @{ */
friend bool operator== (AddressV6 const&, AddressV6 const&) friend bool operator== (AddressV6 const&, AddressV6 const&)
{ bassertfalse; return false; } { assert(false); return false; }
friend bool operator< (AddressV6 const&, AddressV6 const&) friend bool operator< (AddressV6 const&, AddressV6 const&)
{ bassertfalse; return false; } { assert(false); return false; }
friend bool operator!= (AddressV6 const& lhs, AddressV6 const& rhs) friend bool operator!= (AddressV6 const& lhs, AddressV6 const& rhs)
{ return ! (lhs == rhs); } { return ! (lhs == rhs); }
@@ -73,7 +73,7 @@ bool is_public (AddressV6 const& addr);
/** boost::hash support. */ /** boost::hash support. */
inline std::size_t hash_value (AddressV6 const&) inline std::size_t hash_value (AddressV6 const&)
{ bassertfalse; return 0; } { assert(false); return 0; }
/** Returns the address represented as a string. */ /** Returns the address represented as a string. */
std::string to_string (AddressV6 const& addr); std::string to_string (AddressV6 const& addr);

View File

@@ -20,16 +20,16 @@
#ifndef BEAST_NET_IPENDPOINT_H_INCLUDED #ifndef BEAST_NET_IPENDPOINT_H_INCLUDED
#define BEAST_NET_IPENDPOINT_H_INCLUDED #define BEAST_NET_IPENDPOINT_H_INCLUDED
#include <string>
#include <ios>
#include "../CStdInt.h"
#include "IPAddress.h" #include "IPAddress.h"
#include <cstdint>
#include <ios>
#include <string>
namespace beast { namespace beast {
namespace IP { namespace IP {
typedef uint16 Port; typedef std::uint16_t Port;
/** A version-independent IP address and port combination. */ /** A version-independent IP address and port combination. */
class Endpoint class Endpoint

View File

@@ -61,16 +61,16 @@ struct integer_holder
/** Parse 8-bit unsigned integer. */ /** Parse 8-bit unsigned integer. */
template <typename InputStream> template <typename InputStream>
InputStream& operator>> (InputStream& is, integer_holder <uint8> const& i) InputStream& operator>> (InputStream& is, integer_holder <std::uint8_t> const& i)
{ {
uint16 v; std::uint16_t v;
is >> v; is >> v;
if (! (v>=0 && v<=255)) if (! (v>=0 && v<=255))
{ {
is.setstate (std::ios_base::failbit); is.setstate (std::ios_base::failbit);
return is; return is;
} }
i = uint8(v); i = std::uint8_t(v);
return is; return is;
} }

View File

@@ -34,12 +34,12 @@ AddressV4::AddressV4 ()
{ {
} }
AddressV4::AddressV4 (uint32 value_) AddressV4::AddressV4 (std::uint32_t value_)
: value (value_) : value (value_)
{ {
} }
AddressV4::AddressV4 (uint8 a, uint8 b, uint8 c, uint8 d) AddressV4::AddressV4 (std::uint8_t a, std::uint8_t b, std::uint8_t c, std::uint8_t d)
: value ((a<<24)|(b<<16)|(c<<8)|d) : value ((a<<24)|(b<<16)|(c<<8)|d)
{ {
} }
@@ -166,7 +166,7 @@ std::string to_string (AddressV4 const& addr)
std::istream& operator>> (std::istream& is, AddressV4& addr) std::istream& operator>> (std::istream& is, AddressV4& addr)
{ {
uint8 octet [4]; std::uint8_t octet [4];
is >> IP::detail::integer (octet [0]); is >> IP::detail::integer (octet [0]);
for (int i = 1; i < 4; ++i) for (int i = 1; i < 4; ++i)
{ {

View File

@@ -36,7 +36,7 @@ namespace IP {
class IPEndpoint_test : public unit_test::suite class IPEndpoint_test : public unit_test::suite
{ {
public: public:
void shouldParseV4 (std::string const& s, uint32 value) void shouldParseV4 (std::string const& s, std::uint32_t value)
{ {
std::pair <AddressV4, bool> const result ( std::pair <AddressV4, bool> const result (
AddressV4::from_string (s)); AddressV4::from_string (s));

View File

@@ -63,7 +63,7 @@ namespace beast {
@see SharedPtr, SharedObjectArray, SingleThreadedSharedObject @see SharedPtr, SharedObjectArray, SingleThreadedSharedObject
*/ */
class BEAST_API SharedObject : public Uncopyable class SharedObject : public Uncopyable
{ {
public: public:
//============================================================================== //==============================================================================

View File

@@ -87,7 +87,7 @@ public:
inline bool isEmpty() const noexcept { return *data == 0; } inline bool isEmpty() const noexcept { return *data == 0; }
/** Returns the unicode character that this pointer is pointing to. */ /** Returns the unicode character that this pointer is pointing to. */
inline beast_wchar operator*() const noexcept { return (beast_wchar) (uint8) *data; } inline beast_wchar operator*() const noexcept { return (beast_wchar) (std::uint8_t) *data; }
/** Moves this pointer along to the next character in the string. */ /** Moves this pointer along to the next character in the string. */
inline CharPointer_ASCII operator++() noexcept inline CharPointer_ASCII operator++() noexcept
@@ -105,7 +105,7 @@ public:
/** Returns the character that this pointer is currently pointing to, and then /** Returns the character that this pointer is currently pointing to, and then
advances the pointer to point to the next character. */ advances the pointer to point to the next character. */
inline beast_wchar getAndAdvance() noexcept { return (beast_wchar) (uint8) *data++; } inline beast_wchar getAndAdvance() noexcept { return (beast_wchar) (std::uint8_t) *data++; }
/** Moves this pointer along to the next character in the string. */ /** Moves this pointer along to the next character in the string. */
CharPointer_ASCII operator++ (int) noexcept CharPointer_ASCII operator++ (int) noexcept
@@ -332,27 +332,27 @@ public:
/** Returns true if the first character of this string is a letter or digit. */ /** Returns true if the first character of this string is a letter or digit. */
bool isLetterOrDigit() const { return CharacterFunctions::isLetterOrDigit (*data) != 0; } bool isLetterOrDigit() const { return CharacterFunctions::isLetterOrDigit (*data) != 0; }
/** Returns true if the first character of this string is upper-case. */ /** Returns true if the first character of this string is upper-case. */
bool isUpperCase() const { return CharacterFunctions::isUpperCase ((beast_wchar) (uint8) *data) != 0; } bool isUpperCase() const { return CharacterFunctions::isUpperCase ((beast_wchar) (std::uint8_t) *data) != 0; }
/** Returns true if the first character of this string is lower-case. */ /** Returns true if the first character of this string is lower-case. */
bool isLowerCase() const { return CharacterFunctions::isLowerCase ((beast_wchar) (uint8) *data) != 0; } bool isLowerCase() const { return CharacterFunctions::isLowerCase ((beast_wchar) (std::uint8_t) *data) != 0; }
/** Returns an upper-case version of the first character of this string. */ /** Returns an upper-case version of the first character of this string. */
beast_wchar toUpperCase() const noexcept { return CharacterFunctions::toUpperCase ((beast_wchar) (uint8) *data); } beast_wchar toUpperCase() const noexcept { return CharacterFunctions::toUpperCase ((beast_wchar) (std::uint8_t) *data); }
/** Returns a lower-case version of the first character of this string. */ /** Returns a lower-case version of the first character of this string. */
beast_wchar toLowerCase() const noexcept { return CharacterFunctions::toLowerCase ((beast_wchar) (uint8) *data); } beast_wchar toLowerCase() const noexcept { return CharacterFunctions::toLowerCase ((beast_wchar) (std::uint8_t) *data); }
/** Parses this string as a 32-bit integer. */ /** Parses this string as a 32-bit integer. */
int getIntValue32() const noexcept { return atoi (data); } int getIntValue32() const noexcept { return atoi (data); }
/** Parses this string as a 64-bit integer. */ /** Parses this string as a 64-bit integer. */
int64 getIntValue64() const noexcept std::int64_t getIntValue64() const noexcept
{ {
#if BEAST_LINUX || BEAST_ANDROID #if BEAST_LINUX || BEAST_ANDROID
return atoll (data); return atoll (data);
#elif BEAST_WINDOWS #elif BEAST_WINDOWS
return _atoi64 (data); return _atoi64 (data);
#else #else
return CharacterFunctions::getIntValue <int64, CharPointer_ASCII> (*this); return CharacterFunctions::getIntValue <std::int64_t, CharPointer_ASCII> (*this);
#endif #endif
} }

View File

@@ -26,10 +26,11 @@
#include "../Config.h" #include "../Config.h"
#include "../Atomic.h" #include "../Atomic.h"
#include "../CStdInt.h"
#include "CharacterFunctions.h" #include "CharacterFunctions.h"
#include <cstdint>
namespace beast { namespace beast {
//============================================================================== //==============================================================================
@@ -44,7 +45,7 @@ public:
#if BEAST_NATIVE_WCHAR_IS_UTF16 #if BEAST_NATIVE_WCHAR_IS_UTF16
typedef wchar_t CharType; typedef wchar_t CharType;
#else #else
typedef int16 CharType; typedef std::int16_t CharType;
#endif #endif
inline explicit CharPointer_UTF16 (const CharType* const rawPointer) noexcept inline explicit CharPointer_UTF16 (const CharType* const rawPointer) noexcept
@@ -89,10 +90,10 @@ public:
/** Returns the unicode character that this pointer is pointing to. */ /** Returns the unicode character that this pointer is pointing to. */
beast_wchar operator*() const noexcept beast_wchar operator*() const noexcept
{ {
uint32 n = (uint32) (uint16) *data; std::uint32_t n = (std::uint32_t) (std::uint16_t) *data;
if (n >= 0xd800 && n <= 0xdfff && ((uint32) (uint16) data[1]) >= 0xdc00) if (n >= 0xd800 && n <= 0xdfff && ((std::uint32_t) (std::uint16_t) data[1]) >= 0xdc00)
n = 0x10000 + (((n - 0xd800) << 10) | (((uint32) (uint16) data[1]) - 0xdc00)); n = 0x10000 + (((n - 0xd800) << 10) | (((std::uint32_t) (std::uint16_t) data[1]) - 0xdc00));
return (beast_wchar) n; return (beast_wchar) n;
} }
@@ -102,7 +103,7 @@ public:
{ {
const beast_wchar n = *data++; const beast_wchar n = *data++;
if (n >= 0xd800 && n <= 0xdfff && ((uint32) (uint16) *data) >= 0xdc00) if (n >= 0xd800 && n <= 0xdfff && ((std::uint32_t) (std::uint16_t) *data) >= 0xdc00)
++data; ++data;
return *this; return *this;
@@ -123,10 +124,10 @@ public:
advances the pointer to point to the next character. */ advances the pointer to point to the next character. */
beast_wchar getAndAdvance() noexcept beast_wchar getAndAdvance() noexcept
{ {
uint32 n = (uint32) (uint16) *data++; std::uint32_t n = (std::uint32_t) (std::uint16_t) *data++;
if (n >= 0xd800 && n <= 0xdfff && ((uint32) (uint16) *data) >= 0xdc00) if (n >= 0xd800 && n <= 0xdfff && ((std::uint32_t) (std::uint16_t) *data) >= 0xdc00)
n = 0x10000 + ((((n - 0xd800) << 10) | (((uint32) (uint16) *data++) - 0xdc00))); n = 0x10000 + ((((n - 0xd800) << 10) | (((std::uint32_t) (std::uint16_t) *data++) - 0xdc00)));
return (beast_wchar) n; return (beast_wchar) n;
} }
@@ -418,12 +419,12 @@ public:
} }
/** Parses this string as a 64-bit integer. */ /** Parses this string as a 64-bit integer. */
int64 getIntValue64() const noexcept std::int64_t getIntValue64() const noexcept
{ {
#if BEAST_WINDOWS #if BEAST_WINDOWS
return _wtoi64 (data); return _wtoi64 (data);
#else #else
return CharacterFunctions::getIntValue <int64, CharPointer_UTF16> (*this); return CharacterFunctions::getIntValue <std::int64_t, CharPointer_UTF16> (*this);
#endif #endif
} }
@@ -447,7 +448,7 @@ public:
while (--maxBytesToRead >= 0 && *dataToTest != 0) while (--maxBytesToRead >= 0 && *dataToTest != 0)
{ {
const uint32 n = (uint32) (uint16) *dataToTest++; const std::uint32_t n = (std::uint32_t) (std::uint16_t) *dataToTest++;
if (n >= 0xd800) if (n >= 0xd800)
{ {
@@ -459,7 +460,7 @@ public:
if (n > 0xdc00) if (n > 0xdc00)
return false; return false;
const uint32 nextChar = (uint32) (uint16) *dataToTest++; const std::uint32_t nextChar = (std::uint32_t) (std::uint16_t) *dataToTest++;
if (nextChar < 0xdc00 || nextChar > 0xdfff) if (nextChar < 0xdc00 || nextChar > 0xdfff)
return false; return false;
@@ -491,10 +492,10 @@ public:
static bool isByteOrderMarkBigEndian (const void* possibleByteOrder) noexcept static bool isByteOrderMarkBigEndian (const void* possibleByteOrder) noexcept
{ {
bassert (possibleByteOrder != nullptr); bassert (possibleByteOrder != nullptr);
const uint8* const c = static_cast<const uint8*> (possibleByteOrder); const std::uint8_t* const c = static_cast<const std::uint8_t*> (possibleByteOrder);
return c[0] == (uint8) byteOrderMarkBE1 return c[0] == (std::uint8_t) byteOrderMarkBE1
&& c[1] == (uint8) byteOrderMarkBE2; && c[1] == (std::uint8_t) byteOrderMarkBE2;
} }
/** Returns true if the first pair of bytes in this pointer are the UTF16 byte-order mark (little endian). /** Returns true if the first pair of bytes in this pointer are the UTF16 byte-order mark (little endian).
@@ -503,10 +504,10 @@ public:
static bool isByteOrderMarkLittleEndian (const void* possibleByteOrder) noexcept static bool isByteOrderMarkLittleEndian (const void* possibleByteOrder) noexcept
{ {
bassert (possibleByteOrder != nullptr); bassert (possibleByteOrder != nullptr);
const uint8* const c = static_cast<const uint8*> (possibleByteOrder); const std::uint8_t* const c = static_cast<const std::uint8_t*> (possibleByteOrder);
return c[0] == (uint8) byteOrderMarkLE1 return c[0] == (std::uint8_t) byteOrderMarkLE1
&& c[1] == (uint8) byteOrderMarkLE2; && c[1] == (std::uint8_t) byteOrderMarkLE2;
} }
private: private:

View File

@@ -341,7 +341,7 @@ public:
/** Parses this string as a 32-bit integer. */ /** Parses this string as a 32-bit integer. */
int getIntValue32() const noexcept { return CharacterFunctions::getIntValue <int, CharPointer_UTF32> (*this); } int getIntValue32() const noexcept { return CharacterFunctions::getIntValue <int, CharPointer_UTF32> (*this); }
/** Parses this string as a 64-bit integer. */ /** Parses this string as a 64-bit integer. */
int64 getIntValue64() const noexcept { return CharacterFunctions::getIntValue <int64, CharPointer_UTF32> (*this); } std::int64_t getIntValue64() const noexcept { return CharacterFunctions::getIntValue <std::int64_t, CharPointer_UTF32> (*this); }
/** Parses this string as a floating point double. */ /** Parses this string as a floating point double. */
double getDoubleValue() const noexcept { return CharacterFunctions::getDoubleValue (*this); } double getDoubleValue() const noexcept { return CharacterFunctions::getDoubleValue (*this); }

View File

@@ -90,11 +90,11 @@ public:
const signed char byte = (signed char) *data; const signed char byte = (signed char) *data;
if (byte >= 0) if (byte >= 0)
return (beast_wchar) (uint8) byte; return (beast_wchar) (std::uint8_t) byte;
uint32 n = (uint32) (uint8) byte; std::uint32_t n = (std::uint32_t) (std::uint8_t) byte;
uint32 mask = 0x7f; std::uint32_t mask = 0x7f;
uint32 bit = 0x40; std::uint32_t bit = 0x40;
size_t numExtraValues = 0; size_t numExtraValues = 0;
while ((n & bit) != 0 && bit > 0x10) while ((n & bit) != 0 && bit > 0x10)
@@ -108,7 +108,7 @@ public:
for (size_t i = 1; i <= numExtraValues; ++i) for (size_t i = 1; i <= numExtraValues; ++i)
{ {
const uint8 nextByte = (uint8) data [i]; const std::uint8_t nextByte = (std::uint8_t) data [i];
if ((nextByte & 0xc0) != 0x80) if ((nextByte & 0xc0) != 0x80)
break; break;
@@ -157,11 +157,11 @@ public:
const signed char byte = (signed char) *data++; const signed char byte = (signed char) *data++;
if (byte >= 0) if (byte >= 0)
return (beast_wchar) (uint8) byte; return (beast_wchar) (std::uint8_t) byte;
uint32 n = (uint32) (uint8) byte; std::uint32_t n = (std::uint32_t) (std::uint8_t) byte;
uint32 mask = 0x7f; std::uint32_t mask = 0x7f;
uint32 bit = 0x40; std::uint32_t bit = 0x40;
int numExtraValues = 0; int numExtraValues = 0;
while ((n & bit) != 0 && bit > 0x8) while ((n & bit) != 0 && bit > 0x8)
@@ -175,7 +175,7 @@ public:
while (--numExtraValues >= 0) while (--numExtraValues >= 0)
{ {
const uint32 nextByte = (uint32) (uint8) *data++; const std::uint32_t nextByte = (std::uint32_t) (std::uint8_t) *data++;
if ((nextByte & 0xc0) != 0x80) if ((nextByte & 0xc0) != 0x80)
break; break;
@@ -248,11 +248,11 @@ public:
for (;;) for (;;)
{ {
const uint32 n = (uint32) (uint8) *d++; const std::uint32_t n = (std::uint32_t) (std::uint8_t) *d++;
if ((n & 0x80) != 0) if ((n & 0x80) != 0)
{ {
uint32 bit = 0x40; std::uint32_t bit = 0x40;
while ((n & bit) != 0) while ((n & bit) != 0)
{ {
@@ -299,7 +299,7 @@ public:
static size_t getBytesRequiredFor (const beast_wchar charToWrite) noexcept static size_t getBytesRequiredFor (const beast_wchar charToWrite) noexcept
{ {
size_t num = 1; size_t num = 1;
const uint32 c = (uint32) charToWrite; const std::uint32_t c = (std::uint32_t) charToWrite;
if (c >= 0x80) if (c >= 0x80)
{ {
@@ -340,7 +340,7 @@ public:
/** Writes a unicode character to this string, and advances this pointer to point to the next position. */ /** Writes a unicode character to this string, and advances this pointer to point to the next position. */
void write (const beast_wchar charToWrite) noexcept void write (const beast_wchar charToWrite) noexcept
{ {
const uint32 c = (uint32) charToWrite; const std::uint32_t c = (std::uint32_t) charToWrite;
if (c >= 0x80) if (c >= 0x80)
{ {
@@ -352,7 +352,7 @@ public:
++numExtraBytes; ++numExtraBytes;
} }
*data++ = (CharType) ((uint32) (0xff << (7 - numExtraBytes)) | (c >> (numExtraBytes * 6))); *data++ = (CharType) ((std::uint32_t) (0xff << (7 - numExtraBytes)) | (c >> (numExtraBytes * 6)));
while (--numExtraBytes >= 0) while (--numExtraBytes >= 0)
*data++ = (CharType) (0x80 | (0x3f & (c >> (numExtraBytes * 6)))); *data++ = (CharType) (0x80 | (0x3f & (c >> (numExtraBytes * 6))));
@@ -488,14 +488,14 @@ public:
int getIntValue32() const noexcept { return atoi (data); } int getIntValue32() const noexcept { return atoi (data); }
/** Parses this string as a 64-bit integer. */ /** Parses this string as a 64-bit integer. */
int64 getIntValue64() const noexcept std::int64_t getIntValue64() const noexcept
{ {
#if BEAST_LINUX || BEAST_ANDROID #if BEAST_LINUX || BEAST_ANDROID
return atoll (data); return atoll (data);
#elif BEAST_WINDOWS #elif BEAST_WINDOWS
return _atoi64 (data); return _atoi64 (data);
#else #else
return CharacterFunctions::getIntValue <int64, CharPointer_UTF8> (*this); return CharacterFunctions::getIntValue <std::int64_t, CharPointer_UTF8> (*this);
#endif #endif
} }
@@ -520,7 +520,7 @@ public:
if (byte < 0) if (byte < 0)
{ {
uint8 bit = 0x40; std::uint8_t bit = 0x40;
int numExtraValues = 0; int numExtraValues = 0;
while ((byte & bit) != 0) while ((byte & bit) != 0)
@@ -569,11 +569,11 @@ public:
static bool isByteOrderMark (const void* possibleByteOrder) noexcept static bool isByteOrderMark (const void* possibleByteOrder) noexcept
{ {
bassert (possibleByteOrder != nullptr); bassert (possibleByteOrder != nullptr);
const uint8* const c = static_cast<const uint8*> (possibleByteOrder); const std::uint8_t* const c = static_cast<const std::uint8_t*> (possibleByteOrder);
return c[0] == (uint8) byteOrderMark1 return c[0] == (std::uint8_t) byteOrderMark1
&& c[1] == (uint8) byteOrderMark2 && c[1] == (std::uint8_t) byteOrderMark2
&& c[2] == (uint8) byteOrderMark3; && c[2] == (std::uint8_t) byteOrderMark3;
} }
private: private:

View File

@@ -27,9 +27,10 @@
#include <limits> #include <limits>
#include "../Config.h" #include "../Config.h"
#include "../CStdInt.h"
#include "../Memory.h" #include "../Memory.h"
#include <cstdint>
namespace beast { namespace beast {
//============================================================================== //==============================================================================
@@ -50,7 +51,7 @@ namespace beast {
/** A platform-independent 32-bit unicode character type. */ /** A platform-independent 32-bit unicode character type. */
typedef wchar_t beast_wchar; typedef wchar_t beast_wchar;
#else #else
typedef uint32 beast_wchar; typedef std::uint32_t beast_wchar;
#endif #endif
#ifndef DOXYGEN #ifndef DOXYGEN
@@ -78,7 +79,7 @@ namespace beast {
@see String, CharPointer_UTF8, CharPointer_UTF16, CharPointer_UTF32 @see String, CharPointer_UTF8, CharPointer_UTF16, CharPointer_UTF32
*/ */
class BEAST_API CharacterFunctions class CharacterFunctions
{ {
public: public:
//============================================================================== //==============================================================================

View File

@@ -41,7 +41,7 @@ namespace beast {
The exact character sequence that will be used for the new-line can be set and The exact character sequence that will be used for the new-line can be set and
retrieved with OutputStream::setNewLineString() and OutputStream::getNewLineString(). retrieved with OutputStream::setNewLineString() and OutputStream::getNewLineString().
*/ */
class BEAST_API NewLine class NewLine
{ {
public: public:
/** Returns the default new-line sequence that the library uses. /** Returns the default new-line sequence that the library uses.
@@ -72,7 +72,7 @@ extern NewLine newLine;
myString << "Hello World" << newLine << newLine; myString << "Hello World" << newLine << newLine;
@endcode @endcode
*/ */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, const NewLine&); String& operator<< (String& string1, const NewLine&);
} }

View File

@@ -25,7 +25,6 @@
#define BEAST_STRINGS_STRING_H_INCLUDED #define BEAST_STRINGS_STRING_H_INCLUDED
#include "../Config.h" #include "../Config.h"
#include "../CStdInt.h"
#include "../Memory.h" #include "../Memory.h"
#include "CharacterFunctions.h" #include "CharacterFunctions.h"
@@ -44,6 +43,7 @@
#include "StringFromNumber.h" #include "StringFromNumber.h"
#include "String.h" #include "String.h"
#include <cstdint>
#include <ostream> #include <ostream>
namespace beast { namespace beast {
@@ -66,7 +66,7 @@ namespace beast {
@see StringArray, StringPairArray @see StringArray, StringPairArray
*/ */
class BEAST_API String class String
{ {
public: public:
//============================================================================== //==============================================================================
@@ -193,7 +193,7 @@ public:
int hashCode() const noexcept; int hashCode() const noexcept;
/** Generates a probably-unique 64-bit hashcode from this string. */ /** Generates a probably-unique 64-bit hashcode from this string. */
int64 hashCode64() const noexcept; std::int64_t hashCode64() const noexcept;
/** Returns a hash value suitable for use with std::hash. */ /** Returns a hash value suitable for use with std::hash. */
std::size_t hash() const noexcept; std::size_t hash() const noexcept;
@@ -920,15 +920,13 @@ public:
*/ */
explicit String (unsigned short decimalInteger); explicit String (unsigned short decimalInteger);
/** Creates a string containing this signed 64-bit integer as a decimal number. explicit String (long largeIntegerValue);
@see getLargeIntValue, getFloatValue, getDoubleValue, toHexString
*/
explicit String (int64 largeIntegerValue);
/** Creates a string containing this unsigned 64-bit integer as a decimal number. explicit String (unsigned long largeIntegerValue);
@see getLargeIntValue, getFloatValue, getDoubleValue, toHexString
*/ explicit String (long long largeIntegerValue);
explicit String (uint64 largeIntegerValue);
explicit String (unsigned long long largeIntegerValue);
/** Creates a string representing this floating-point number. /** Creates a string representing this floating-point number.
@param floatValue the value to convert to a string @param floatValue the value to convert to a string
@@ -971,7 +969,7 @@ public:
@returns the value of the string as a 64 bit signed base-10 integer. @returns the value of the string as a 64 bit signed base-10 integer.
*/ */
int64 getLargeIntValue() const noexcept; std::int64_t getLargeIntValue() const noexcept;
/** Parses a decimal number from the end of the string. /** Parses a decimal number from the end of the string.
@@ -1018,13 +1016,13 @@ public:
@returns a 64-bit number which is the value of the string in hex. @returns a 64-bit number which is the value of the string in hex.
*/ */
int64 getHexValue64() const noexcept; std::int64_t getHexValue64() const noexcept;
/** Creates a string representing this 32-bit value in hexadecimal. */ /** Creates a string representing this 32-bit value in hexadecimal. */
static String toHexString (int number); static String toHexString (int number);
/** Creates a string representing this 64-bit value in hexadecimal. */ /** Creates a string representing this 64-bit value in hexadecimal. */
static String toHexString (int64 number); static String toHexString (std::int64_t number);
/** Creates a string representing this 16-bit value in hexadecimal. */ /** Creates a string representing this 16-bit value in hexadecimal. */
static String toHexString (short number); static String toHexString (short number);
@@ -1273,103 +1271,103 @@ inline String String::fromNumber <double> (double number, int numberOfDecimalPla
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** Concatenates two strings. */ /** Concatenates two strings. */
BEAST_API String BEAST_CALLTYPE operator+ (const char* string1, const String& string2); String operator+ (const char* string1, const String& string2);
/** Concatenates two strings. */ /** Concatenates two strings. */
BEAST_API String BEAST_CALLTYPE operator+ (const wchar_t* string1, const String& string2); String operator+ (const wchar_t* string1, const String& string2);
/** Concatenates two strings. */ /** Concatenates two strings. */
BEAST_API String BEAST_CALLTYPE operator+ (char string1, const String& string2); String operator+ (char string1, const String& string2);
/** Concatenates two strings. */ /** Concatenates two strings. */
BEAST_API String BEAST_CALLTYPE operator+ (wchar_t string1, const String& string2); String operator+ (wchar_t string1, const String& string2);
#if ! BEAST_NATIVE_WCHAR_IS_UTF32 #if ! BEAST_NATIVE_WCHAR_IS_UTF32
/** Concatenates two strings. */ /** Concatenates two strings. */
BEAST_API String BEAST_CALLTYPE operator+ (beast_wchar string1, const String& string2); String operator+ (beast_wchar string1, const String& string2);
#endif #endif
/** Concatenates two strings. */ /** Concatenates two strings. */
BEAST_API String BEAST_CALLTYPE operator+ (String string1, const String& string2); String operator+ (String string1, const String& string2);
/** Concatenates two strings. */ /** Concatenates two strings. */
BEAST_API String BEAST_CALLTYPE operator+ (String string1, const char* string2); String operator+ (String string1, const char* string2);
/** Concatenates two strings. */ /** Concatenates two strings. */
BEAST_API String BEAST_CALLTYPE operator+ (String string1, const wchar_t* string2); String operator+ (String string1, const wchar_t* string2);
/** Concatenates two strings. */ /** Concatenates two strings. */
BEAST_API String BEAST_CALLTYPE operator+ (String string1, char characterToAppend); String operator+ (String string1, char characterToAppend);
/** Concatenates two strings. */ /** Concatenates two strings. */
BEAST_API String BEAST_CALLTYPE operator+ (String string1, wchar_t characterToAppend); String operator+ (String string1, wchar_t characterToAppend);
#if ! BEAST_NATIVE_WCHAR_IS_UTF32 #if ! BEAST_NATIVE_WCHAR_IS_UTF32
/** Concatenates two strings. */ /** Concatenates two strings. */
BEAST_API String BEAST_CALLTYPE operator+ (String string1, beast_wchar characterToAppend); String operator+ (String string1, beast_wchar characterToAppend);
#endif #endif
//============================================================================== //==============================================================================
/** Appends a character at the end of a string. */ /** Appends a character at the end of a string. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, char characterToAppend); String& operator<< (String& string1, char characterToAppend);
/** Appends a character at the end of a string. */ /** Appends a character at the end of a string. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, wchar_t characterToAppend); String& operator<< (String& string1, wchar_t characterToAppend);
#if ! BEAST_NATIVE_WCHAR_IS_UTF32 #if ! BEAST_NATIVE_WCHAR_IS_UTF32
/** Appends a character at the end of a string. */ /** Appends a character at the end of a string. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, beast_wchar characterToAppend); String& operator<< (String& string1, beast_wchar characterToAppend);
#endif #endif
/** Appends a string to the end of the first one. */ /** Appends a string to the end of the first one. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, const char* string2); String& operator<< (String& string1, const char* string2);
/** Appends a string to the end of the first one. */ /** Appends a string to the end of the first one. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, const wchar_t* string2); String& operator<< (String& string1, const wchar_t* string2);
/** Appends a string to the end of the first one. */ /** Appends a string to the end of the first one. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, const String& string2); String& operator<< (String& string1, const String& string2);
/** Appends a decimal number at the end of a string. */ /** Appends a decimal number at the end of a string. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, short number); String& operator<< (String& string1, short number);
/** Appends a decimal number at the end of a string. */ /** Appends a decimal number at the end of a string. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, int number); String& operator<< (String& string1, int number);
/** Appends a decimal number at the end of a string. */ /** Appends a decimal number at the end of a string. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, long number); String& operator<< (String& string1, long number);
/** Appends a decimal number at the end of a string. */ /** Appends a decimal number at the end of a string. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, int64 number); String& operator<< (String& string1, std::int64_t number);
/** Appends a decimal number at the end of a string. */ /** Appends a decimal number at the end of a string. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, float number); String& operator<< (String& string1, float number);
/** Appends a decimal number at the end of a string. */ /** Appends a decimal number at the end of a string. */
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, double number); String& operator<< (String& string1, double number);
//============================================================================== //==============================================================================
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator== (const String& string1, const String& string2) noexcept; bool operator== (const String& string1, const String& string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator== (const String& string1, const char* string2) noexcept; bool operator== (const String& string1, const char* string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator== (const String& string1, const wchar_t* string2) noexcept; bool operator== (const String& string1, const wchar_t* string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator== (const String& string1, const CharPointer_UTF8 string2) noexcept; bool operator== (const String& string1, const CharPointer_UTF8 string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator== (const String& string1, const CharPointer_UTF16 string2) noexcept; bool operator== (const String& string1, const CharPointer_UTF16 string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator== (const String& string1, const CharPointer_UTF32 string2) noexcept; bool operator== (const String& string1, const CharPointer_UTF32 string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator!= (const String& string1, const String& string2) noexcept; bool operator!= (const String& string1, const String& string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator!= (const String& string1, const char* string2) noexcept; bool operator!= (const String& string1, const char* string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator!= (const String& string1, const wchar_t* string2) noexcept; bool operator!= (const String& string1, const wchar_t* string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator!= (const String& string1, const CharPointer_UTF8 string2) noexcept; bool operator!= (const String& string1, const CharPointer_UTF8 string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator!= (const String& string1, const CharPointer_UTF16 string2) noexcept; bool operator!= (const String& string1, const CharPointer_UTF16 string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator!= (const String& string1, const CharPointer_UTF32 string2) noexcept; bool operator!= (const String& string1, const CharPointer_UTF32 string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator> (const String& string1, const String& string2) noexcept; bool operator> (const String& string1, const String& string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator< (const String& string1, const String& string2) noexcept; bool operator< (const String& string1, const String& string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator>= (const String& string1, const String& string2) noexcept; bool operator>= (const String& string1, const String& string2) noexcept;
/** Case-sensitive comparison of two strings. */ /** Case-sensitive comparison of two strings. */
BEAST_API bool BEAST_CALLTYPE operator<= (const String& string1, const String& string2) noexcept; bool operator<= (const String& string1, const String& string2) noexcept;
//============================================================================== //==============================================================================
/** This operator allows you to write a beast String directly to std output streams. /** This operator allows you to write a beast String directly to std output streams.
This is handy for writing strings to std::cout, std::cerr, etc. This is handy for writing strings to std::cout, std::cerr, etc.
*/ */
template <class traits> template <class traits>
std::basic_ostream <char, traits>& BEAST_CALLTYPE operator<< (std::basic_ostream <char, traits>& stream, const String& stringToWrite) std::basic_ostream <char, traits>& operator<< (std::basic_ostream <char, traits>& stream, const String& stringToWrite)
{ {
return stream << stringToWrite.toRawUTF8(); return stream << stringToWrite.toRawUTF8();
} }
@@ -1378,7 +1376,7 @@ std::basic_ostream <char, traits>& BEAST_CALLTYPE operator<< (std::basic_ostream
This is handy for writing strings to std::wcout, std::wcerr, etc. This is handy for writing strings to std::wcout, std::wcerr, etc.
*/ */
template <class traits> template <class traits>
std::basic_ostream <wchar_t, traits>& BEAST_CALLTYPE operator<< (std::basic_ostream <wchar_t, traits>& stream, const String& stringToWrite) std::basic_ostream <wchar_t, traits>& operator<< (std::basic_ostream <wchar_t, traits>& stream, const String& stringToWrite)
{ {
return stream << stringToWrite.toWideCharPointer(); return stream << stringToWrite.toWideCharPointer();
} }

View File

@@ -75,13 +75,13 @@ public:
if (std::numeric_limits <IntegerType>::is_signed) if (std::numeric_limits <IntegerType>::is_signed)
{ {
if (n >= 0) if (n >= 0)
return printDigits (t, static_cast <uint64> (n)); return printDigits (t, static_cast <std::uint64_t> (n));
// NB: this needs to be careful not to call // NB: this needs to be careful not to call
// -std::numeric_limits<int64>::min(), // -std::numeric_limits<std::int64_t>::min(),
// which has undefined behaviour // which has undefined behaviour
// //
t = printDigits (t, static_cast <uint64> (-(n + 1)) + 1); t = printDigits (t, static_cast <std::uint64_t> (-(n + 1)) + 1);
*--t = '-'; *--t = '-';
return t; return t;
} }
@@ -123,7 +123,7 @@ public:
{ {
char* const end = buffer + numChars; char* const end = buffer + numChars;
char* t = end; char* t = end;
int64 v = (int64) (pow (10.0, numDecPlaces) * std::abs (n) + 0.5); std::int64_t v = (std::int64_t) (pow (10.0, numDecPlaces) * std::abs (n) + 0.5);
*--t = (char) 0; *--t = (char) 0;
while (numDecPlaces >= 0 || v > 0) while (numDecPlaces >= 0 || v > 0)

View File

@@ -381,8 +381,10 @@ String::String (const int number) : text (NumberToStringConverters::c
String::String (const unsigned int number) : text (NumberToStringConverters::createFromInteger (number)) {} String::String (const unsigned int number) : text (NumberToStringConverters::createFromInteger (number)) {}
String::String (const short number) : text (NumberToStringConverters::createFromInteger ((int) number)) {} String::String (const short number) : text (NumberToStringConverters::createFromInteger ((int) number)) {}
String::String (const unsigned short number) : text (NumberToStringConverters::createFromInteger ((unsigned int) number)) {} String::String (const unsigned short number) : text (NumberToStringConverters::createFromInteger ((unsigned int) number)) {}
String::String (const int64 number) : text (NumberToStringConverters::createFromInteger (number)) {} String::String (const long number) : text (NumberToStringConverters::createFromInteger (number)) {}
String::String (const uint64 number) : text (NumberToStringConverters::createFromInteger (number)) {} String::String (const unsigned long number) : text (NumberToStringConverters::createFromInteger (number)) {}
String::String (const long long number) : text (NumberToStringConverters::createFromInteger (number)) {}
String::String (const unsigned long long number) : text (NumberToStringConverters::createFromInteger (number)) {}
String::String (const float number) : text (NumberToStringConverters::createFromDouble ((double) number, 0)) {} String::String (const float number) : text (NumberToStringConverters::createFromDouble ((double) number, 0)) {}
String::String (const double number) : text (NumberToStringConverters::createFromDouble (number, 0)) {} String::String (const double number) : text (NumberToStringConverters::createFromDouble (number, 0)) {}
@@ -434,9 +436,9 @@ int String::hashCode() const noexcept
return detail::HashGenerator<int> ::calculate (text); return detail::HashGenerator<int> ::calculate (text);
} }
int64 String::hashCode64() const noexcept std::int64_t String::hashCode64() const noexcept
{ {
return detail::HashGenerator<int64> ::calculate (text); return detail::HashGenerator<std::int64_t> ::calculate (text);
} }
std::size_t String::hash() const noexcept std::size_t String::hash() const noexcept
@@ -445,22 +447,22 @@ std::size_t String::hash() const noexcept
} }
//============================================================================== //==============================================================================
BEAST_API bool BEAST_CALLTYPE operator== (const String& s1, const String& s2) noexcept { return s1.compare (s2) == 0; } bool operator== (const String& s1, const String& s2) noexcept { return s1.compare (s2) == 0; }
BEAST_API bool BEAST_CALLTYPE operator== (const String& s1, const char* const s2) noexcept { return s1.compare (s2) == 0; } bool operator== (const String& s1, const char* const s2) noexcept { return s1.compare (s2) == 0; }
BEAST_API bool BEAST_CALLTYPE operator== (const String& s1, const wchar_t* const s2) noexcept { return s1.compare (s2) == 0; } bool operator== (const String& s1, const wchar_t* const s2) noexcept { return s1.compare (s2) == 0; }
BEAST_API bool BEAST_CALLTYPE operator== (const String& s1, const CharPointer_UTF8 s2) noexcept { return s1.getCharPointer().compare (s2) == 0; } bool operator== (const String& s1, const CharPointer_UTF8 s2) noexcept { return s1.getCharPointer().compare (s2) == 0; }
BEAST_API bool BEAST_CALLTYPE operator== (const String& s1, const CharPointer_UTF16 s2) noexcept { return s1.getCharPointer().compare (s2) == 0; } bool operator== (const String& s1, const CharPointer_UTF16 s2) noexcept { return s1.getCharPointer().compare (s2) == 0; }
BEAST_API bool BEAST_CALLTYPE operator== (const String& s1, const CharPointer_UTF32 s2) noexcept { return s1.getCharPointer().compare (s2) == 0; } bool operator== (const String& s1, const CharPointer_UTF32 s2) noexcept { return s1.getCharPointer().compare (s2) == 0; }
BEAST_API bool BEAST_CALLTYPE operator!= (const String& s1, const String& s2) noexcept { return s1.compare (s2) != 0; } bool operator!= (const String& s1, const String& s2) noexcept { return s1.compare (s2) != 0; }
BEAST_API bool BEAST_CALLTYPE operator!= (const String& s1, const char* const s2) noexcept { return s1.compare (s2) != 0; } bool operator!= (const String& s1, const char* const s2) noexcept { return s1.compare (s2) != 0; }
BEAST_API bool BEAST_CALLTYPE operator!= (const String& s1, const wchar_t* const s2) noexcept { return s1.compare (s2) != 0; } bool operator!= (const String& s1, const wchar_t* const s2) noexcept { return s1.compare (s2) != 0; }
BEAST_API bool BEAST_CALLTYPE operator!= (const String& s1, const CharPointer_UTF8 s2) noexcept { return s1.getCharPointer().compare (s2) != 0; } bool operator!= (const String& s1, const CharPointer_UTF8 s2) noexcept { return s1.getCharPointer().compare (s2) != 0; }
BEAST_API bool BEAST_CALLTYPE operator!= (const String& s1, const CharPointer_UTF16 s2) noexcept { return s1.getCharPointer().compare (s2) != 0; } bool operator!= (const String& s1, const CharPointer_UTF16 s2) noexcept { return s1.getCharPointer().compare (s2) != 0; }
BEAST_API bool BEAST_CALLTYPE operator!= (const String& s1, const CharPointer_UTF32 s2) noexcept { return s1.getCharPointer().compare (s2) != 0; } bool operator!= (const String& s1, const CharPointer_UTF32 s2) noexcept { return s1.getCharPointer().compare (s2) != 0; }
BEAST_API bool BEAST_CALLTYPE operator> (const String& s1, const String& s2) noexcept { return s1.compare (s2) > 0; } bool operator> (const String& s1, const String& s2) noexcept { return s1.compare (s2) > 0; }
BEAST_API bool BEAST_CALLTYPE operator< (const String& s1, const String& s2) noexcept { return s1.compare (s2) < 0; } bool operator< (const String& s1, const String& s2) noexcept { return s1.compare (s2) < 0; }
BEAST_API bool BEAST_CALLTYPE operator>= (const String& s1, const String& s2) noexcept { return s1.compare (s2) >= 0; } bool operator>= (const String& s1, const String& s2) noexcept { return s1.compare (s2) >= 0; }
BEAST_API bool BEAST_CALLTYPE operator<= (const String& s1, const String& s2) noexcept { return s1.compare (s2) <= 0; } bool operator<= (const String& s1, const String& s2) noexcept { return s1.compare (s2) <= 0; }
bool String::equalsIgnoreCase (const wchar_t* const t) const noexcept bool String::equalsIgnoreCase (const wchar_t* const t) const noexcept
{ {
@@ -612,52 +614,52 @@ String& String::operator+= (const int number)
} }
//============================================================================== //==============================================================================
BEAST_API String BEAST_CALLTYPE operator+ (const char* const string1, const String& string2) String operator+ (const char* const string1, const String& string2)
{ {
String s (string1); String s (string1);
return s += string2; return s += string2;
} }
BEAST_API String BEAST_CALLTYPE operator+ (const wchar_t* const string1, const String& string2) String operator+ (const wchar_t* const string1, const String& string2)
{ {
String s (string1); String s (string1);
return s += string2; return s += string2;
} }
BEAST_API String BEAST_CALLTYPE operator+ (const char s1, const String& s2) { return String::charToString ((beast_wchar) (uint8) s1) + s2; } String operator+ (const char s1, const String& s2) { return String::charToString ((beast_wchar) (std::uint8_t) s1) + s2; }
BEAST_API String BEAST_CALLTYPE operator+ (const wchar_t s1, const String& s2) { return String::charToString (s1) + s2; } String operator+ (const wchar_t s1, const String& s2) { return String::charToString (s1) + s2; }
#if ! BEAST_NATIVE_WCHAR_IS_UTF32 #if ! BEAST_NATIVE_WCHAR_IS_UTF32
BEAST_API String BEAST_CALLTYPE operator+ (const beast_wchar s1, const String& s2) { return String::charToString (s1) + s2; } String operator+ (const beast_wchar s1, const String& s2) { return String::charToString (s1) + s2; }
#endif #endif
BEAST_API String BEAST_CALLTYPE operator+ (String s1, const String& s2) { return s1 += s2; } String operator+ (String s1, const String& s2) { return s1 += s2; }
BEAST_API String BEAST_CALLTYPE operator+ (String s1, const char* const s2) { return s1 += s2; } String operator+ (String s1, const char* const s2) { return s1 += s2; }
BEAST_API String BEAST_CALLTYPE operator+ (String s1, const wchar_t* s2) { return s1 += s2; } String operator+ (String s1, const wchar_t* s2) { return s1 += s2; }
BEAST_API String BEAST_CALLTYPE operator+ (String s1, const char s2) { return s1 += s2; } String operator+ (String s1, const char s2) { return s1 += s2; }
BEAST_API String BEAST_CALLTYPE operator+ (String s1, const wchar_t s2) { return s1 += s2; } String operator+ (String s1, const wchar_t s2) { return s1 += s2; }
#if ! BEAST_NATIVE_WCHAR_IS_UTF32 #if ! BEAST_NATIVE_WCHAR_IS_UTF32
BEAST_API String BEAST_CALLTYPE operator+ (String s1, const beast_wchar s2) { return s1 += s2; } String operator+ (String s1, const beast_wchar s2) { return s1 += s2; }
#endif #endif
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const char s2) { return s1 += s2; } String& operator<< (String& s1, const char s2) { return s1 += s2; }
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const wchar_t s2) { return s1 += s2; } String& operator<< (String& s1, const wchar_t s2) { return s1 += s2; }
#if ! BEAST_NATIVE_WCHAR_IS_UTF32 #if ! BEAST_NATIVE_WCHAR_IS_UTF32
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const beast_wchar s2) { return s1 += s2; } String& operator<< (String& s1, const beast_wchar s2) { return s1 += s2; }
#endif #endif
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const char* const s2) { return s1 += s2; } String& operator<< (String& s1, const char* const s2) { return s1 += s2; }
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const wchar_t* const s2) { return s1 += s2; } String& operator<< (String& s1, const wchar_t* const s2) { return s1 += s2; }
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const String& s2) { return s1 += s2; } String& operator<< (String& s1, const String& s2) { return s1 += s2; }
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const short number) { return s1 += (int) number; } String& operator<< (String& s1, const short number) { return s1 += (int) number; }
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const int number) { return s1 += number; } String& operator<< (String& s1, const int number) { return s1 += number; }
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const long number) { return s1 += (int) number; } String& operator<< (String& s1, const long number) { return s1 += (int) number; }
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const int64 number) { return s1 << String (number); } String& operator<< (String& s1, const long long number) { return s1 << String (number); }
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const float number) { return s1 += String (number); } String& operator<< (String& s1, const float number) { return s1 += String (number); }
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const double number) { return s1 += String (number); } String& operator<< (String& s1, const double number) { return s1 += String (number); }
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, const NewLine&) String& operator<< (String& string1, const NewLine&)
{ {
return string1 += NewLine::getDefault(); return string1 += NewLine::getDefault();
} }
@@ -1711,7 +1713,7 @@ int String::getTrailingIntValue() const noexcept
return n; return n;
} }
int64 String::getLargeIntValue() const noexcept std::int64_t String::getLargeIntValue() const noexcept
{ {
return text.getIntValue64(); return text.getIntValue64();
} }
@@ -1769,9 +1771,9 @@ String String::toHexString (const int number)
return HexConverter <unsigned int>::hexToString ((unsigned int) number); return HexConverter <unsigned int>::hexToString ((unsigned int) number);
} }
String String::toHexString (const int64 number) String String::toHexString (const std::int64_t number)
{ {
return HexConverter <uint64>::hexToString ((uint64) number); return HexConverter <std::uint64_t>::hexToString ((std::uint64_t) number);
} }
String String::toHexString (const short number) String String::toHexString (const short number)
@@ -1808,12 +1810,12 @@ String String::toHexString (const void* const d, const int size, const int group
} }
int String::getHexValue32() const noexcept { return HexConverter<int> ::stringToHex (text); } int String::getHexValue32() const noexcept { return HexConverter<int> ::stringToHex (text); }
int64 String::getHexValue64() const noexcept { return HexConverter<int64>::stringToHex (text); } std::int64_t String::getHexValue64() const noexcept { return HexConverter<std::int64_t>::stringToHex (text); }
//============================================================================== //==============================================================================
String String::createStringFromData (const void* const unknownData, const int size) String String::createStringFromData (const void* const unknownData, const int size)
{ {
const uint8* const data = static_cast<const uint8*> (unknownData); const std::uint8_t* const data = static_cast<const std::uint8_t*> (unknownData);
if (size <= 0 || data == nullptr) if (size <= 0 || data == nullptr)
return empty; return empty;
@@ -1828,7 +1830,7 @@ String String::createStringFromData (const void* const unknownData, const int si
StringCreationHelper builder ((size_t) numChars); StringCreationHelper builder ((size_t) numChars);
const uint16* const src = (const uint16*) (data + 2); const std::uint16_t* const src = (const std::uint16_t*) (data + 2);
if (CharPointer_UTF16::isByteOrderMarkBigEndian (data)) if (CharPointer_UTF16::isByteOrderMarkBigEndian (data))
{ {
@@ -1845,7 +1847,7 @@ String String::createStringFromData (const void* const unknownData, const int si
return builder.result; return builder.result;
} }
const uint8* start = data; const std::uint8_t* start = data;
if (size >= 3 && CharPointer_UTF8::isByteOrderMark (data)) if (size >= 3 && CharPointer_UTF8::isByteOrderMark (data))
start += 3; start += 3;
@@ -1932,7 +1934,7 @@ struct StringCopier
{ {
static size_t copyToBuffer (const CharPointerType_Src source, typename CharPointerType_Dest::CharType* const buffer, const size_t maxBufferSizeBytes) static size_t copyToBuffer (const CharPointerType_Src source, typename CharPointerType_Dest::CharType* const buffer, const size_t maxBufferSizeBytes)
{ {
bassert (((ssize_t) maxBufferSizeBytes) >= 0); // keep this value positive! bassert (((std::ptrdiff_t) maxBufferSizeBytes) >= 0); // keep this value positive!
if (buffer == nullptr) if (buffer == nullptr)
return CharPointerType_Dest::getBytesRequiredFor (source) + sizeof (typename CharPointerType_Dest::CharType); return CharPointerType_Dest::getBytesRequiredFor (source) + sizeof (typename CharPointerType_Dest::CharType);

View File

@@ -74,13 +74,13 @@ public:
static Page* create (size_type pageBytes) static Page* create (size_type pageBytes)
{ {
return new (new uint8[pageBytes + overhead()]) Page (pageBytes); return new (new std::uint8_t[pageBytes + overhead()]) Page (pageBytes);
} }
static void destroy (Page* page) static void destroy (Page* page)
{ {
page->~Page(); page->~Page();
delete[] ((uint8*)page); delete[] ((std::uint8_t*)page);
} }
void reset () void reset ()
@@ -599,10 +599,10 @@ private:
(*item)(); (*item)();
typename Allocator::template rebind <uint8>::other a (m_alloc); typename Allocator::template rebind <std::uint8_t>::other a (m_alloc);
std::size_t const size (item->size()); std::size_t const size (item->size());
item->~Item(); item->~Item();
a.deallocate (reinterpret_cast<uint8*>(item), size); a.deallocate (reinterpret_cast<std::uint8_t*>(item), size);
return 1; return 1;
} }

View File

@@ -44,7 +44,7 @@ namespace beast {
@see CriticalSection @see CriticalSection
*/ */
class BEAST_API SpinLock : public Uncopyable class SpinLock : public Uncopyable
{ {
public: public:
/** Provides the type of scoped lock to use for locking a SpinLock. */ /** Provides the type of scoped lock to use for locking a SpinLock. */

View File

@@ -45,7 +45,7 @@ namespace beast {
@see CriticalSection, WaitableEvent, Process, ThreadWithProgressWindow, @see CriticalSection, WaitableEvent, Process, ThreadWithProgressWindow,
MessageManagerLock MessageManagerLock
*/ */
class BEAST_API Thread : LeakChecked <Thread>, public Uncopyable class Thread : LeakChecked <Thread>, public Uncopyable
{ {
public: public:
//============================================================================== //==============================================================================
@@ -185,7 +185,7 @@ public:
@see setCurrentThreadAffinityMask @see setCurrentThreadAffinityMask
*/ */
void setAffinityMask (uint32 affinityMask); void setAffinityMask (std::uint32_t affinityMask);
/** Changes the affinity mask for the caller thread. /** Changes the affinity mask for the caller thread.
@@ -193,14 +193,14 @@ public:
@see setAffinityMask @see setAffinityMask
*/ */
static void setCurrentThreadAffinityMask (uint32 affinityMask); static void setCurrentThreadAffinityMask (std::uint32_t affinityMask);
//============================================================================== //==============================================================================
// this can be called from any thread that needs to pause.. // this can be called from any thread that needs to pause..
static void BEAST_CALLTYPE sleep (int milliseconds); static void sleep (int milliseconds);
/** Yields the calling thread's current time-slot. */ /** Yields the calling thread's current time-slot. */
static void BEAST_CALLTYPE yield(); static void yield();
//============================================================================== //==============================================================================
/** Makes the thread wait for a notification. /** Makes the thread wait for a notification.
@@ -275,11 +275,11 @@ private:
RecursiveMutex startStopLock; RecursiveMutex startStopLock;
WaitableEvent startSuspensionEvent, defaultEvent; WaitableEvent startSuspensionEvent, defaultEvent;
int threadPriority; int threadPriority;
uint32 affinityMask; std::uint32_t affinityMask;
bool volatile shouldExit; bool volatile shouldExit;
#ifndef DOXYGEN #ifndef DOXYGEN
friend void BEAST_API beast_threadEntryPoint (void*); friend void beast_threadEntryPoint (void*);
#endif #endif
void launchThread(); void launchThread();

View File

@@ -106,7 +106,7 @@ void Thread::threadEntryPoint()
} }
// used to wrap the incoming call from the platform-specific code // used to wrap the incoming call from the platform-specific code
void BEAST_API beast_threadEntryPoint (void* userData) void beast_threadEntryPoint (void* userData)
{ {
static_cast <Thread*> (userData)->threadEntryPoint(); static_cast <Thread*> (userData)->threadEntryPoint();
} }
@@ -162,7 +162,7 @@ bool Thread::waitForThreadToExit (const int timeOutMilliseconds) const
// Doh! So how exactly do you expect this thread to wait for itself to stop?? // Doh! So how exactly do you expect this thread to wait for itself to stop??
bassert (getThreadId() != getCurrentThreadId() || getCurrentThreadId() == 0); bassert (getThreadId() != getCurrentThreadId() || getCurrentThreadId() == 0);
const uint32 timeoutEnd = Time::getMillisecondCounter() + (uint32) timeOutMilliseconds; const std::uint32_t timeoutEnd = Time::getMillisecondCounter() + (std::uint32_t) timeOutMilliseconds;
while (isThreadRunning()) while (isThreadRunning())
{ {
@@ -252,7 +252,7 @@ bool Thread::setCurrentThreadPriority (const int newPriority)
return setThreadPriority (0, newPriority); return setThreadPriority (0, newPriority);
} }
void Thread::setAffinityMask (const uint32 newAffinityMask) void Thread::setAffinityMask (const std::uint32_t newAffinityMask)
{ {
affinityMask = newAffinityMask; affinityMask = newAffinityMask;
} }
@@ -299,7 +299,7 @@ namespace beast {
HWND beast_messageWindowHandle = 0; // (this is used by other parts of the codebase) HWND beast_messageWindowHandle = 0; // (this is used by other parts of the codebase)
void BEAST_API beast_threadEntryPoint (void*); void beast_threadEntryPoint (void*);
static unsigned int __stdcall threadEntryProc (void* userData) static unsigned int __stdcall threadEntryProc (void* userData)
{ {
@@ -367,7 +367,7 @@ void Thread::setCurrentThreadName (const String& name)
Thread::ThreadID Thread::getCurrentThreadId() Thread::ThreadID Thread::getCurrentThreadId()
{ {
return (ThreadID) (pointer_sized_int) GetCurrentThreadId(); return (ThreadID) (std::intptr_t) GetCurrentThreadId();
} }
bool Thread::setThreadPriority (void* handle, int priority) bool Thread::setThreadPriority (void* handle, int priority)
@@ -387,7 +387,7 @@ bool Thread::setThreadPriority (void* handle, int priority)
return SetThreadPriority (handle, pri) != FALSE; return SetThreadPriority (handle, pri) != FALSE;
} }
void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) void Thread::setCurrentThreadAffinityMask (const std::uint32_t affinityMask)
{ {
SetThreadAffinityMask (GetCurrentThread(), affinityMask); SetThreadAffinityMask (GetCurrentThread(), affinityMask);
} }
@@ -414,7 +414,7 @@ struct SleepEvent
static SleepEvent sleepEvent; static SleepEvent sleepEvent;
void BEAST_CALLTYPE Thread::sleep (const int millisecs) void Thread::sleep (const int millisecs)
{ {
if (millisecs >= 10 || sleepEvent.handle == 0) if (millisecs >= 10 || sleepEvent.handle == 0)
{ {
@@ -458,7 +458,7 @@ namespace beast{
namespace beast { namespace beast {
void BEAST_CALLTYPE Thread::sleep (int millisecs) void Thread::sleep (int millisecs)
{ {
struct timespec time; struct timespec time;
time.tv_sec = millisecs / 1000; time.tv_sec = millisecs / 1000;
@@ -466,7 +466,7 @@ void BEAST_CALLTYPE Thread::sleep (int millisecs)
nanosleep (&time, nullptr); nanosleep (&time, nullptr);
} }
void BEAST_API beast_threadEntryPoint (void*); void beast_threadEntryPoint (void*);
extern "C" void* threadEntryProcBeast (void*); extern "C" void* threadEntryProcBeast (void*);
extern "C" void* threadEntryProcBeast (void* userData) extern "C" void* threadEntryProcBeast (void* userData)
@@ -576,7 +576,7 @@ void Thread::yield()
#define SUPPORT_AFFINITIES 1 #define SUPPORT_AFFINITIES 1
#endif #endif
void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) void Thread::setCurrentThreadAffinityMask (const std::uint32_t affinityMask)
{ {
#if SUPPORT_AFFINITIES #if SUPPORT_AFFINITIES
cpu_set_t affinity; cpu_set_t affinity;

View File

@@ -93,9 +93,9 @@ public:
int a2[3]; int a2[3];
expect (numElementsInArray(a2) == 3); expect (numElementsInArray(a2) == 3);
expect (ByteOrder::swap ((uint16) 0x1122) == 0x2211); expect (ByteOrder::swap ((std::uint16_t) 0x1122) == 0x2211);
expect (ByteOrder::swap ((uint32) 0x11223344) == 0x44332211); expect (ByteOrder::swap ((std::uint32_t) 0x11223344) == 0x44332211);
expect (ByteOrder::swap ((uint64) literal64bit (0x1122334455667788)) == literal64bit (0x8877665544332211)); expect (ByteOrder::swap ((std::uint64_t) 0x1122334455667788LL) == 0x8877665544332211LL);
testcase ("int"); testcase ("int");
testInteger <int> (); testInteger <int> ();
@@ -103,11 +103,11 @@ public:
testcase ("unsigned int"); testcase ("unsigned int");
testInteger <unsigned int> (); testInteger <unsigned int> ();
testcase ("int32"); testcase ("std::int32_t");
testInteger <int32> (); testInteger <std::int32_t> ();
testcase ("uint32"); testcase ("std::uint32_t");
testInteger <uint32> (); testInteger <std::uint32_t> ();
testcase ("long"); testcase ("long");
testInteger <long> (); testInteger <long> ();
@@ -122,11 +122,11 @@ public:
testFloat <float> (); testFloat <float> ();
#if ! BEAST_64BIT_ATOMICS_UNAVAILABLE // 64-bit intrinsics aren't available on some old platforms #if ! BEAST_64BIT_ATOMICS_UNAVAILABLE // 64-bit intrinsics aren't available on some old platforms
testcase ("int64"); testcase ("std::int64_t");
testInteger <int64> (); testInteger <std::int64_t> ();
testcase ("uint64"); testcase ("std::uint64_t");
testInteger <uint64> (); testInteger <std::uint64_t> ();
testcase ("double"); testcase ("double");
testFloat <double> (); testFloat <double> ();

View File

@@ -39,11 +39,11 @@ public:
void start () { m_startTime = Time::getHighResolutionTicks (); } void start () { m_startTime = Time::getHighResolutionTicks (); }
double getElapsed () double getElapsed ()
{ {
int64 const now = Time::getHighResolutionTicks(); std::int64_t const now = Time::getHighResolutionTicks();
return Time::highResolutionTicksToSeconds (now - m_startTime); return Time::highResolutionTicksToSeconds (now - m_startTime);
} }
private: private:
int64 m_startTime; std::int64_t m_startTime;
}; };
static int const callsPerThread = 50000; static int const callsPerThread = 50000;
@@ -57,7 +57,7 @@ public:
Random m_random; Random m_random;
String m_string; String m_string;
Consumer (int id, int64 seedValue, ServiceType& service) Consumer (int id, std::int64_t seedValue, ServiceType& service)
: Thread ("C#" + String::fromNumber (id)) : Thread ("C#" + String::fromNumber (id))
, m_service (service) , m_service (service)
, m_random (seedValue) , m_random (seedValue)
@@ -103,7 +103,7 @@ public:
Random m_random; Random m_random;
String m_string; String m_string;
Producer (int id, int64 seedValue, ServiceType& service) Producer (int id, std::int64_t seedValue, ServiceType& service)
: Thread ("P#" + String::fromNumber (id)) : Thread ("P#" + String::fromNumber (id))
, m_service (service) , m_service (service)
, m_random (seedValue) , m_random (seedValue)
@@ -208,7 +208,7 @@ public:
ServiceQueue& m_service; ServiceQueue& m_service;
String m_string; String m_string;
ServiceThread (int id, int64 seedValue, ServiceThread (int id, std::int64_t seedValue,
ServiceQueue& service) ServiceQueue& service)
: Thread ("#" + String::fromNumber (id)) : Thread ("#" + String::fromNumber (id))
, m_random (seedValue) , m_random (seedValue)

View File

@@ -20,7 +20,6 @@
#ifndef BEAST_UTILITY_PROPERTYSTREAM_H_INCLUDED #ifndef BEAST_UTILITY_PROPERTYSTREAM_H_INCLUDED
#define BEAST_UTILITY_PROPERTYSTREAM_H_INCLUDED #define BEAST_UTILITY_PROPERTYSTREAM_H_INCLUDED
#include "../CStdInt.h"
#include "../Uncopyable.h" #include "../Uncopyable.h"
#include "../intrusive/List.h" #include "../intrusive/List.h"
#include "../threads/SharedData.h" #include "../threads/SharedData.h"

View File

@@ -98,7 +98,7 @@ private:
static StaticData& get () static StaticData& get ()
{ {
static uint8 storage [sizeof (StaticData)]; static std::uint8_t storage [sizeof (StaticData)];
return *(reinterpret_cast <StaticData*> (&storage [0])); return *(reinterpret_cast <StaticData*> (&storage [0]));
} }

View File

@@ -23,9 +23,6 @@
#include "impl/Error.cpp" #include "impl/Error.cpp"
// For Journal and Debug
#include "../../modules/beast_core/beast_core.h"
#include "impl/Debug.cpp" #include "impl/Debug.cpp"
#include "impl/Journal.cpp" #include "impl/Journal.cpp"
#include "impl/LeakChecked.cpp" #include "impl/LeakChecked.cpp"

View File

@@ -19,6 +19,7 @@
#include "../Debug.h" #include "../Debug.h"
#include "../../unit_test/suite.h" #include "../../unit_test/suite.h"
#include "../../../modules/beast_core/system/SystemStats.h"
namespace beast { namespace beast {

View File

@@ -18,6 +18,7 @@
//============================================================================== //==============================================================================
#include "../Journal.h" #include "../Journal.h"
#include "../../../modules/beast_core/memory/SharedSingleton.h"
namespace beast { namespace beast {

View File

@@ -18,6 +18,7 @@
//============================================================================== //==============================================================================
#include "../LeakChecked.h" #include "../LeakChecked.h"
#include "../../../modules/beast_core/logging/Logger.h"
namespace beast { namespace beast {

View File

@@ -35,13 +35,13 @@ class FixedInputBuffer
protected: protected:
struct CtorParams struct CtorParams
{ {
CtorParams (uint8 const* begin_, std::size_t bytes_) CtorParams (std::uint8_t const* begin_, std::size_t bytes_)
: begin (begin_) : begin (begin_)
, bytes (bytes_) , bytes (bytes_)
{ {
} }
uint8 const* begin; std::uint8_t const* begin;
std::size_t bytes; std::size_t bytes;
}; };
@@ -107,7 +107,7 @@ public:
return read_impl (sizeof (T), t) != nullptr; return read_impl (sizeof (T), t) != nullptr;
} }
uint8 operator[] (std::size_t index) const noexcept std::uint8_t operator[] (std::size_t index) const noexcept
{ {
bassert (index >= 0 && index < size ()); bassert (index >= 0 && index < size ());
return m_iter [index]; return m_iter [index];
@@ -153,9 +153,9 @@ protected:
} }
private: private:
uint8 const* m_begin; std::uint8_t const* m_begin;
uint8 const* m_iter; std::uint8_t const* m_iter;
uint8 const* m_end; std::uint8_t const* m_end;
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -170,7 +170,7 @@ protected:
SizedCtorParams (ConstBufferSequence const& buffers, Storage& storage) SizedCtorParams (ConstBufferSequence const& buffers, Storage& storage)
{ {
boost::asio::mutable_buffer buffer (boost::asio::buffer (storage)); boost::asio::mutable_buffer buffer (boost::asio::buffer (storage));
data = boost::asio::buffer_cast <uint8 const*> (buffer); data = boost::asio::buffer_cast <std::uint8_t const*> (buffer);
bytes = boost::asio::buffer_copy (buffer, buffers); bytes = boost::asio::buffer_copy (buffer, buffers);
} }
@@ -179,7 +179,7 @@ protected:
return CtorParams (data, bytes); return CtorParams (data, bytes);
} }
uint8 const* data; std::uint8_t const* data;
std::size_t bytes; std::size_t bytes;
}; };
@@ -191,7 +191,7 @@ public:
} }
private: private:
boost::array <uint8, Bytes> m_storage; boost::array <std::uint8_t, Bytes> m_storage;
boost::asio::mutable_buffer m_buffer; boost::asio::mutable_buffer m_buffer;
}; };

View File

@@ -21,6 +21,8 @@
#include "../../../beast/asio/placeholders.h" #include "../../../beast/asio/placeholders.h"
#include "../../../beast/unit_test/suite.h" #include "../../../beast/unit_test/suite.h"
#include "../../../beast/cxx14/memory.h" // <memory>
namespace beast { namespace beast {
namespace asio { namespace asio {
@@ -190,7 +192,7 @@ public:
String m_get_string; String m_get_string;
WaitableEvent m_done; WaitableEvent m_done;
ScopedPointer <abstract_socket> m_stream; std::unique_ptr <abstract_socket> m_stream;
struct State struct State
{ {
@@ -387,7 +389,8 @@ public:
if (m_url.scheme () == "https") if (m_url.scheme () == "https")
{ {
typedef boost::asio::ssl::stream <socket&> ssl_stream; typedef boost::asio::ssl::stream <socket&> ssl_stream;
m_stream = new socket_wrapper <ssl_stream> (m_socket, m_context); m_stream = std::make_unique <
socket_wrapper <ssl_stream>> (m_socket, m_context);
/* /*
m_stream->set_verify_mode ( m_stream->set_verify_mode (
boost::asio::ssl::verify_peer | boost::asio::ssl::verify_peer |
@@ -399,7 +402,7 @@ public:
return; return;
} }
m_stream = new socket_wrapper <socket&> (m_socket); m_stream = std::make_unique <socket_wrapper <socket&>> (m_socket);
handle_handshake (ec); handle_handshake (ec);
} }
@@ -637,7 +640,7 @@ public:
void testSync (String const& s, double timeoutSeconds) void testSync (String const& s, double timeoutSeconds)
{ {
ScopedPointer <HTTPClientBase> client ( std::unique_ptr <HTTPClientBase> client (
HTTPClientBase::New (Journal(), timeoutSeconds)); HTTPClientBase::New (Journal(), timeoutSeconds));
HTTPClientBase::result_type const& result ( HTTPClientBase::result_type const& result (
@@ -649,7 +652,7 @@ public:
void testAsync (String const& s, double timeoutSeconds) void testAsync (String const& s, double timeoutSeconds)
{ {
IoServiceThread t; IoServiceThread t;
ScopedPointer <HTTPClientBase> client ( std::unique_ptr <HTTPClientBase> client (
HTTPClientBase::New (Journal(), timeoutSeconds)); HTTPClientBase::New (Journal(), timeoutSeconds));
client->async_get (t.get_io_service (), ParsedURL (s).url (), client->async_get (t.get_io_service (), ParsedURL (s).url (),

View File

@@ -79,7 +79,7 @@ public:
protected: protected:
Type m_type; Type m_type;
ScopedPointer <HTTPParserImpl> m_impl; std::unique_ptr <HTTPParserImpl> m_impl;
SharedPtr <HTTPRequest> m_request; SharedPtr <HTTPRequest> m_request;
SharedPtr <HTTPResponse> m_response; SharedPtr <HTTPResponse> m_response;
}; };

View File

@@ -50,8 +50,8 @@ public:
IPv4Address sourceAddress; IPv4Address sourceAddress;
IPv4Address destAddress; IPv4Address destAddress;
uint16 sourcePort; std::uint16_t sourcePort;
uint16 destPort; std::uint16_t destPort;
}; };
explicit HandshakeDetectLogicPROXY (arg_type const&) explicit HandshakeDetectLogicPROXY (arg_type const&)

View File

@@ -27,14 +27,14 @@ namespace asio {
// //
// http://tools.ietf.org/html/rfc5246#appendix-E.2 // http://tools.ietf.org/html/rfc5246#appendix-E.2
// //
// uint8 V2CipherSpec[3]; // std::uint8_t V2CipherSpec[3];
// struct { // struct {
// uint16 msg_length; // std::uint16_t msg_length;
// uint8 msg_type; // std::uint8_t msg_type;
// Version version; Should be 'ProtocolVersion'? // Version version; Should be 'ProtocolVersion'?
// uint16 cipher_spec_length; // std::uint16_t cipher_spec_length;
// uint16 session_id_length; // std::uint16_t session_id_length;
// uint16 challenge_length; // std::uint16_t challenge_length;
// ... // ...
// //
class HandshakeDetectLogicSSL2 : public HandshakeDetectLogic class HandshakeDetectLogicSSL2 : public HandshakeDetectLogic
@@ -67,7 +67,7 @@ public:
FixedInputBufferSize <bytesNeeded> in (buffer); FixedInputBufferSize <bytesNeeded> in (buffer);
{ {
uint8 byte; std::uint8_t byte;
if (! in.peek (&byte)) if (! in.peek (&byte))
return; return;
@@ -80,7 +80,7 @@ public:
// The remaining bits contain the // The remaining bits contain the
// length of the following data in bytes. // length of the following data in bytes.
// //
uint16 msg_length; std::uint16_t msg_length;
if (! in.readNetworkInteger(&msg_length)) if (! in.readNetworkInteger(&msg_length))
return; return;
@@ -95,7 +95,7 @@ public:
if (msg_length < 9) if (msg_length < 9)
return fail (); return fail ();
uint8 msg_type; std::uint8_t msg_type;
if (! in.read (&msg_type)) if (! in.read (&msg_type))
return; return;

View File

@@ -56,10 +56,10 @@ public:
template <typename ConstBufferSequence> template <typename ConstBufferSequence>
void analyze (ConstBufferSequence const& buffer) void analyze (ConstBufferSequence const& buffer)
{ {
uint16 version; std::uint16_t version;
FixedInputBufferSize <bytesNeeded> in (buffer); FixedInputBufferSize <bytesNeeded> in (buffer);
uint8 msg_type; std::uint8_t msg_type;
if (! in.read (&msg_type)) if (! in.read (&msg_type))
return; return;
@@ -72,7 +72,7 @@ public:
return; return;
version = fromNetworkByteOrder (version); version = fromNetworkByteOrder (version);
uint16 length; std::uint16_t length;
if (! in.read (&length)) if (! in.read (&length))
return; return;

View File

@@ -230,7 +230,7 @@ struct Get <Digit>
// An unsigned 32 bit number expressed as a string // An unsigned 32 bit number expressed as a string
struct UInt32Str struct UInt32Str
{ {
uint32 value; std::uint32_t value;
}; };
template <> template <>
@@ -239,7 +239,7 @@ struct Get <UInt32Str>
static State func (Input in, UInt32Str& t) static State func (Input in, UInt32Str& t)
{ {
State state; State state;
uint32 value (0); std::uint32_t value (0);
Digit digit; Digit digit;
// have to have at least one digit // have to have at least one digit
@@ -266,7 +266,7 @@ struct Get <UInt32Str>
if (value == 0) if (value == 0)
return State::fail; return State::fail;
uint32 newValue = (value * 10) + digit.value; std::uint32_t newValue = (value * 10) + digit.value;
// overflow // overflow
if (newValue < value) if (newValue < value)
@@ -284,7 +284,7 @@ struct Get <UInt32Str>
// An unsigned 16 bit number expressed as a string // An unsigned 16 bit number expressed as a string
struct UInt16Str struct UInt16Str
{ {
uint16 value; std::uint16_t value;
}; };
template <> template <>
@@ -298,7 +298,7 @@ struct Get <UInt16Str>
{ {
if (v.value <= 65535) if (v.value <= 65535)
{ {
t.value = uint16(v.value); t.value = std::uint16_t(v.value);
return State::pass; return State::pass;
} }
return State::fail; return State::fail;
@@ -312,7 +312,7 @@ struct Get <UInt16Str>
// An unsigned 8 bit number expressed as a string // An unsigned 8 bit number expressed as a string
struct UInt8Str struct UInt8Str
{ {
uint8 value; std::uint8_t value;
}; };
template <> template <>
@@ -326,7 +326,7 @@ struct Get <UInt8Str>
{ {
if (v.value <= 255) if (v.value <= 255)
{ {
t.value = uint8(v.value); t.value = std::uint8_t(v.value);
return State::pass; return State::pass;
} }
return State::fail; return State::fail;
@@ -340,7 +340,7 @@ struct Get <UInt8Str>
// An dotted IPv4 address // An dotted IPv4 address
struct IPv4Address struct IPv4Address
{ {
uint8 value [4]; std::uint8_t value [4];
String toString () const String toString () const
{ {

View File

@@ -157,18 +157,12 @@
#include "text/StringArray.cpp" #include "text/StringArray.cpp"
#include "text/StringPairArray.cpp" #include "text/StringPairArray.cpp"
#include "thread/impl/TrackedMutex.cpp"
#include "thread/DeadlineTimer.cpp" #include "thread/DeadlineTimer.cpp"
#include "thread/Workers.cpp" #include "thread/Workers.cpp"
#include "threads/ChildProcess.cpp"
#include "time/AtExitHook.cpp" #include "time/AtExitHook.cpp"
#include "time/Time.cpp" #include "time/Time.cpp"
#include "xml/XmlDocument.cpp"
#include "xml/XmlElement.cpp"
#if BEAST_MAC || BEAST_IOS #if BEAST_MAC || BEAST_IOS
#include "native/osx_ObjCHelpers.h" #include "native/osx_ObjCHelpers.h"
#endif #endif
@@ -183,7 +177,6 @@
#if BEAST_MAC || BEAST_IOS #if BEAST_MAC || BEAST_IOS
#include "native/mac_Files.mm" #include "native/mac_Files.mm"
#include "native/mac_Network.mm"
#include "native/mac_Strings.mm" #include "native/mac_Strings.mm"
#include "native/mac_SystemStats.mm" #include "native/mac_SystemStats.mm"
#include "native/mac_Threads.mm" #include "native/mac_Threads.mm"
@@ -191,34 +184,28 @@
#elif BEAST_WINDOWS #elif BEAST_WINDOWS
#include "native/win32_ComSmartPtr.h" #include "native/win32_ComSmartPtr.h"
#include "native/win32_Files.cpp" #include "native/win32_Files.cpp"
#include "native/win32_Network.cpp"
#include "native/win32_Registry.cpp" #include "native/win32_Registry.cpp"
#include "native/win32_SystemStats.cpp" #include "native/win32_SystemStats.cpp"
#include "native/win32_Threads.cpp" #include "native/win32_Threads.cpp"
#elif BEAST_LINUX #elif BEAST_LINUX
#include "native/linux_Files.cpp" #include "native/linux_Files.cpp"
#include "native/linux_Network.cpp"
#include "native/linux_SystemStats.cpp" #include "native/linux_SystemStats.cpp"
#include "native/linux_Threads.cpp" #include "native/linux_Threads.cpp"
#elif BEAST_BSD #elif BEAST_BSD
#include "native/bsd_Files.cpp" #include "native/bsd_Files.cpp"
#include "native/bsd_Network.cpp"
#include "native/bsd_SystemStats.cpp" #include "native/bsd_SystemStats.cpp"
#include "native/bsd_Threads.cpp" #include "native/bsd_Threads.cpp"
#elif BEAST_ANDROID #elif BEAST_ANDROID
#include "native/android_Files.cpp" #include "native/android_Files.cpp"
#include "native/android_Misc.cpp" #include "native/android_Misc.cpp"
#include "native/android_Network.cpp"
#include "native/android_SystemStats.cpp" #include "native/android_SystemStats.cpp"
#include "native/android_Threads.cpp" #include "native/android_Threads.cpp"
#endif #endif
#include "threads/HighResolutionTimer.cpp"
// Has to be outside the beast namespace // Has to be outside the beast namespace
extern "C" { extern "C" {
void beast_reportFatalError (char const* message, char const* fileName, int lineNumber) void beast_reportFatalError (char const* message, char const* fileName, int lineNumber)

View File

@@ -44,7 +44,6 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// New header-only library modeled more closely according to boost // New header-only library modeled more closely according to boost
#include "../../beast/CStdInt.h"
#include "../../beast/SmartPtr.h" #include "../../beast/SmartPtr.h"
#include "../../beast/StaticAssert.h" #include "../../beast/StaticAssert.h"
#include "../../beast/Uncopyable.h" #include "../../beast/Uncopyable.h"
@@ -74,12 +73,11 @@ class OutputStream;
class FileInputStream; class FileInputStream;
class FileOutputStream; class FileOutputStream;
} // namespace beast } // beast
// Order matters, since headers don't have their own #include lines. // Order matters, since headers don't have their own #include lines.
// Add new includes to the bottom. // Add new includes to the bottom.
#include "diagnostic/Throw.h"
#include "system/Functional.h" #include "system/Functional.h"
#include "time/AtExitHook.h" #include "time/AtExitHook.h"
@@ -143,14 +141,12 @@ class FileOutputStream;
#include "files/File.h" #include "files/File.h"
#include "thread/MutexTraits.h" #include "thread/MutexTraits.h"
#include "thread/TrackedMutex.h"
#include "diagnostic/FatalError.h" #include "diagnostic/FatalError.h"
#include "text/LexicalCast.h" #include "text/LexicalCast.h"
#include "maths/Math.h" #include "maths/Math.h"
#include "logging/Logger.h" #include "logging/Logger.h"
#include "containers/LinkedListPointer.h" #include "containers/LinkedListPointer.h"
#include "maths/Random.h" #include "maths/Random.h"
#include "containers/OwnedArray.h"
#include "text/StringPairArray.h" #include "text/StringPairArray.h"
#include "containers/ScopedValueSetter.h" #include "containers/ScopedValueSetter.h"
#include "maths/Range.h" #include "maths/Range.h"
@@ -171,13 +167,8 @@ class FileOutputStream;
#include "system/SystemStats.h" #include "system/SystemStats.h"
#include "diagnostic/SemanticVersion.h" #include "diagnostic/SemanticVersion.h"
#include "threads/ChildProcess.h"
#include "threads/DynamicLibrary.h" #include "threads/DynamicLibrary.h"
#include "threads/HighResolutionTimer.h"
#include "threads/InterProcessLock.h"
#include "threads/Process.h" #include "threads/Process.h"
#include "xml/XmlDocument.h"
#include "xml/XmlElement.h"
#include "diagnostic/UnitTestUtilities.h" #include "diagnostic/UnitTestUtilities.h"
#include "diagnostic/MeasureFunctionCallTime.h" #include "diagnostic/MeasureFunctionCallTime.h"

View File

@@ -24,8 +24,11 @@
#ifndef BEAST_ARRAY_H_INCLUDED #ifndef BEAST_ARRAY_H_INCLUDED
#define BEAST_ARRAY_H_INCLUDED #define BEAST_ARRAY_H_INCLUDED
namespace beast #include "ArrayAllocationBase.h"
{ #include "ElementComparator.h"
#include "../threads/CriticalSection.h"
namespace beast {
//============================================================================== //==============================================================================
/** /**
@@ -39,17 +42,13 @@ namespace beast
- it must be able to be relocated in memory by a memcpy without this causing any problems - so - it must be able to be relocated in memory by a memcpy without this causing any problems - so
objects whose functionality relies on external pointers or references to themselves can be used. objects whose functionality relies on external pointers or references to themselves can be used.
You can of course have an array of pointers to any kind of object, e.g. Array <MyClass*>, but if
you do this, the array doesn't take any ownership of the objects - see the OwnedArray class or the
SharedObjectArray class for more powerful ways of holding lists of objects.
For holding lists of strings, you can use Array\<String\>, but it's usually better to use the For holding lists of strings, you can use Array\<String\>, but it's usually better to use the
specialised class StringArray, which provides more useful functions. specialised class StringArray, which provides more useful functions.
To make all the array's methods thread-safe, pass in "CriticalSection" as the templated To make all the array's methods thread-safe, pass in "CriticalSection" as the templated
TypeOfCriticalSectionToUse parameter, instead of the default DummyCriticalSection. TypeOfCriticalSectionToUse parameter, instead of the default DummyCriticalSection.
@see OwnedArray, SharedObjectArray, StringArray, CriticalSection @see SharedObjectArray, StringArray, CriticalSection
*/ */
template <typename ElementType, template <typename ElementType,
typename TypeOfCriticalSectionToUse = DummyCriticalSection, typename TypeOfCriticalSectionToUse = DummyCriticalSection,
@@ -57,7 +56,7 @@ template <typename ElementType,
class Array class Array
{ {
private: private:
typedef PARAMETER_TYPE (ElementType) ParameterType; typedef ElementType ParameterType;
public: public:
//============================================================================== //==============================================================================
@@ -1055,6 +1054,6 @@ private:
} }
}; };
} // namespace beast } // beast
#endif // BEAST_ARRAY_H_INCLUDED #endif // BEAST_ARRAY_H_INCLUDED

View File

@@ -24,8 +24,9 @@
#ifndef BEAST_ARRAYALLOCATIONBASE_H_INCLUDED #ifndef BEAST_ARRAYALLOCATIONBASE_H_INCLUDED
#define BEAST_ARRAYALLOCATIONBASE_H_INCLUDED #define BEAST_ARRAYALLOCATIONBASE_H_INCLUDED
namespace beast #include "../../../beast/HeapBlock.h"
{
namespace beast {
//============================================================================== //==============================================================================
/** /**
@@ -37,7 +38,7 @@ namespace beast
It inherits from a critical section class to allow the arrays to use It inherits from a critical section class to allow the arrays to use
the "empty base class optimisation" pattern to reduce their footprint. the "empty base class optimisation" pattern to reduce their footprint.
@see Array, OwnedArray, SharedObjectArray @see Array, SharedObjectArray
*/ */
template <class ElementType, class TypeOfCriticalSectionToUse> template <class ElementType, class TypeOfCriticalSectionToUse>
class ArrayAllocationBase class ArrayAllocationBase
@@ -129,6 +130,6 @@ public:
int numAllocated; int numAllocated;
}; };
} // namespace beast } // beast
#endif // BEAST_ARRAYALLOCATIONBASE_H_INCLUDED #endif // BEAST_ARRAYALLOCATIONBASE_H_INCLUDED

View File

@@ -179,7 +179,7 @@ template <class ElementType>
class DefaultElementComparator class DefaultElementComparator
{ {
private: private:
typedef PARAMETER_TYPE (ElementType) ParameterType; typedef ElementType ParameterType;
public: public:
static int compareElements (ParameterType first, ParameterType second) static int compareElements (ParameterType first, ParameterType second)
@@ -188,7 +188,7 @@ public:
} }
}; };
} // namespace beast } // beast
#endif #endif

View File

@@ -360,6 +360,6 @@ private:
ObjectType* item; ObjectType* item;
}; };
} // namespace beast } // beast
#endif // BEAST_LINKEDLISTPOINTER_H_INCLUDED #endif // BEAST_LINKEDLISTPOINTER_H_INCLUDED

View File

@@ -1,893 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Portions of this file are from JUCE.
Copyright (c) 2013 - Raw Material Software Ltd.
Please visit http://www.juce.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.
*/
//==============================================================================
#ifndef BEAST_OWNEDARRAY_H_INCLUDED
#define BEAST_OWNEDARRAY_H_INCLUDED
namespace beast
{
//==============================================================================
/** An array designed for holding objects.
This holds a list of pointers to objects, and will automatically
delete the objects when they are removed from the array, or when the
array is itself deleted.
Declare it in the form: OwnedArray<MyObjectClass>
..and then add new objects, e.g. myOwnedArray.add (new MyObjectClass());
After adding objects, they are 'owned' by the array and will be deleted when
removed or replaced.
To make all the array's methods thread-safe, pass in "CriticalSection" as the templated
TypeOfCriticalSectionToUse parameter, instead of the default DummyCriticalSection.
@see Array, SharedObjectArray, StringArray, CriticalSection
*/
template <class ObjectClass,
class TypeOfCriticalSectionToUse = DummyCriticalSection>
class OwnedArray
: LeakChecked <OwnedArray <ObjectClass, TypeOfCriticalSectionToUse> >
, public Uncopyable
{
public:
//==============================================================================
/** Creates an empty array. */
OwnedArray() noexcept
: numUsed (0)
{
}
/** Deletes the array and also deletes any objects inside it.
To get rid of the array without deleting its objects, use its
clear (false) method before deleting it.
*/
~OwnedArray()
{
deleteAllObjects();
}
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
OwnedArray (OwnedArray&& other) noexcept
: data (static_cast <ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse>&&> (other.data)),
numUsed (other.numUsed)
{
other.numUsed = 0;
}
OwnedArray& operator= (OwnedArray&& other) noexcept
{
const ScopedLockType lock (getLock());
deleteAllObjects();
data = static_cast <ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse>&&> (other.data);
numUsed = other.numUsed;
other.numUsed = 0;
return *this;
}
#endif
//==============================================================================
/** Clears the array, optionally deleting the objects inside it first. */
void clear (bool deleteObjects = true)
{
const ScopedLockType lock (getLock());
if (deleteObjects)
deleteAllObjects();
data.setAllocatedSize (0);
numUsed = 0;
}
/** Clears the array, optionally deleting the objects inside it first.
The array's allocated storage is preserved.
@see clear
*/
void clearQuick(bool deleteObjects = true)
{
const ScopedLockType lock (getLock());
if (deleteObjects)
deleteAllObjects();
numUsed = 0;
}
//==============================================================================
/** Returns the number of items currently in the array.
@see operator[]
*/
inline int size() const noexcept
{
return numUsed;
}
/** Returns a pointer to the object at this index in the array.
If the index is out-of-range, this will return a null pointer, (and
it could be null anyway, because it's ok for the array to hold null
pointers as well as objects).
@see getUnchecked
*/
inline ObjectClass* operator[] (const int index) const noexcept
{
const ScopedLockType lock (getLock());
if (isPositiveAndBelow (index, numUsed))
{
bassert (data.elements != nullptr);
return data.elements [index];
}
return nullptr;
}
/** Returns a pointer to the object at this index in the array, without checking whether the index is in-range.
This is a faster and less safe version of operator[] which doesn't check the index passed in, so
it can be used when you're sure the index is always going to be legal.
*/
inline ObjectClass* getUnchecked (const int index) const noexcept
{
const ScopedLockType lock (getLock());
bassert (isPositiveAndBelow (index, numUsed) && data.elements != nullptr);
return data.elements [index];
}
/** Returns a pointer to the first object in the array.
This will return a null pointer if the array's empty.
@see getLast
*/
inline ObjectClass* getFirst() const noexcept
{
const ScopedLockType lock (getLock());
return numUsed > 0 ? data.elements [0]
: static_cast <ObjectClass*> (nullptr);
}
/** Returns a pointer to the last object in the array.
This will return a null pointer if the array's empty.
@see getFirst
*/
inline ObjectClass* getLast() const noexcept
{
const ScopedLockType lock (getLock());
return numUsed > 0 ? data.elements [numUsed - 1]
: static_cast <ObjectClass*> (nullptr);
}
/** Returns a pointer to the actual array data.
This pointer will only be valid until the next time a non-const method
is called on the array.
*/
inline ObjectClass** getRawDataPointer() noexcept
{
return data.elements;
}
//==============================================================================
/** Returns a pointer to the first element in the array.
This method is provided for compatibility with standard C++ iteration mechanisms.
*/
inline ObjectClass** begin() const noexcept
{
return data.elements;
}
/** Returns a pointer to the element which follows the last element in the array.
This method is provided for compatibility with standard C++ iteration mechanisms.
*/
inline ObjectClass** end() const noexcept
{
return data.elements + numUsed;
}
//==============================================================================
/** Finds the index of an object which might be in the array.
@param objectToLookFor the object to look for
@returns the index at which the object was found, or -1 if it's not found
*/
int indexOf (const ObjectClass* const objectToLookFor) const noexcept
{
const ScopedLockType lock (getLock());
ObjectClass* const* e = data.elements.getData();
ObjectClass* const* const end_ = e + numUsed;
for (; e != end_; ++e)
if (objectToLookFor == *e)
return static_cast <int> (e - data.elements.getData());
return -1;
}
/** Returns true if the array contains a specified object.
@param objectToLookFor the object to look for
@returns true if the object is in the array
*/
bool contains (const ObjectClass* const objectToLookFor) const noexcept
{
const ScopedLockType lock (getLock());
ObjectClass* const* e = data.elements.getData();
ObjectClass* const* const end_ = e + numUsed;
for (; e != end_; ++e)
if (objectToLookFor == *e)
return true;
return false;
}
//==============================================================================
/** Appends a new object to the end of the array.
Note that the this object will be deleted by the OwnedArray when it
is removed, so be careful not to delete it somewhere else.
Also be careful not to add the same object to the array more than once,
as this will obviously cause deletion of dangling pointers.
@param newObject the new object to add to the array
@see set, insert, addIfNotAlreadyThere, addSorted
*/
ObjectClass* add (ObjectClass* const newObject) noexcept
{
const ScopedLockType lock (getLock());
data.ensureAllocatedSize (numUsed + 1);
bassert (data.elements != nullptr);
data.elements [numUsed++] = const_cast <ObjectClass*> (newObject);
return const_cast <ObjectClass*> (newObject);
}
/** Inserts a new object into the array at the given index.
Note that the this object will be deleted by the OwnedArray when it
is removed, so be careful not to delete it somewhere else.
If the index is less than 0 or greater than the size of the array, the
element will be added to the end of the array.
Otherwise, it will be inserted into the array, moving all the later elements
along to make room.
Be careful not to add the same object to the array more than once,
as this will obviously cause deletion of dangling pointers.
@param indexToInsertAt the index at which the new element should be inserted
@param newObject the new object to add to the array
@see add, addSorted, addIfNotAlreadyThere, set
*/
void insert (int indexToInsertAt,
ObjectClass* const newObject) noexcept
{
if (indexToInsertAt >= 0)
{
const ScopedLockType lock (getLock());
if (indexToInsertAt > numUsed)
indexToInsertAt = numUsed;
data.ensureAllocatedSize (numUsed + 1);
bassert (data.elements != nullptr);
ObjectClass** const e = data.elements + indexToInsertAt;
const int numToMove = numUsed - indexToInsertAt;
if (numToMove > 0)
memmove (e + 1, e, sizeof (ObjectClass*) * (size_t) numToMove);
*e = const_cast <ObjectClass*> (newObject);
++numUsed;
}
else
{
add (newObject);
}
}
/** Inserts an array of values into this array at a given position.
If the index is less than 0 or greater than the size of the array, the
new elements will be added to the end of the array.
Otherwise, they will be inserted into the array, moving all the later elements
along to make room.
@param indexToInsertAt the index at which the first new element should be inserted
@param newObjects the new values to add to the array
@param numberOfElements how many items are in the array
@see insert, add, addSorted, set
*/
void insertArray (int indexToInsertAt,
ObjectClass* const* newObjects,
int numberOfElements)
{
if (numberOfElements > 0)
{
const ScopedLockType lock (getLock());
data.ensureAllocatedSize (numUsed + numberOfElements);
ObjectClass** insertPos = data.elements;
if (isPositiveAndBelow (indexToInsertAt, numUsed))
{
insertPos += indexToInsertAt;
const size_t numberToMove = (size_t) (numUsed - indexToInsertAt);
memmove (insertPos + numberOfElements, insertPos, numberToMove * sizeof (ObjectClass*));
}
else
{
insertPos += numUsed;
}
numUsed += numberOfElements;
while (--numberOfElements >= 0)
*insertPos++ = *newObjects++;
}
}
/** Appends a new object at the end of the array as long as the array doesn't
already contain it.
If the array already contains a matching object, nothing will be done.
@param newObject the new object to add to the array
*/
void addIfNotAlreadyThere (ObjectClass* const newObject) noexcept
{
const ScopedLockType lock (getLock());
if (! contains (newObject))
add (newObject);
}
/** Replaces an object in the array with a different one.
If the index is less than zero, this method does nothing.
If the index is beyond the end of the array, the new object is added to the end of the array.
Be careful not to add the same object to the array more than once,
as this will obviously cause deletion of dangling pointers.
@param indexToChange the index whose value you want to change
@param newObject the new value to set for this index.
@param deleteOldElement whether to delete the object that's being replaced with the new one
@see add, insert, remove
*/
void set (const int indexToChange,
const ObjectClass* const newObject,
const bool deleteOldElement = true)
{
if (indexToChange >= 0)
{
ObjectClass* toDelete = nullptr;
{
const ScopedLockType lock (getLock());
if (indexToChange < numUsed)
{
if (deleteOldElement)
{
toDelete = data.elements [indexToChange];
if (toDelete == newObject)
toDelete = nullptr;
}
data.elements [indexToChange] = const_cast <ObjectClass*> (newObject);
}
else
{
data.ensureAllocatedSize (numUsed + 1);
data.elements [numUsed++] = const_cast <ObjectClass*> (newObject);
}
}
// don't want to use a ScopedPointer here because if the
// object has a private destructor, both OwnedArray and
// ScopedPointer would need to be friend classes..
ContainerDeletePolicy <ObjectClass>::destroy (toDelete);
}
else
{
bassertfalse; // you're trying to set an object at a negative index, which doesn't have
// any effect - but since the object is not being added, it may be leaking..
}
}
/** Adds elements from another array to the end of this array.
@param arrayToAddFrom the array from which to copy the elements
@param startIndex the first element of the other array to start copying from
@param numElementsToAdd how many elements to add from the other array. If this
value is negative or greater than the number of available elements,
all available elements will be copied.
@see add
*/
template <class OtherArrayType>
void addArray (const OtherArrayType& arrayToAddFrom,
int startIndex = 0,
int numElementsToAdd = -1)
{
const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock());
const ScopedLockType lock2 (getLock());
if (startIndex < 0)
{
bassertfalse;
startIndex = 0;
}
if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size())
numElementsToAdd = arrayToAddFrom.size() - startIndex;
data.ensureAllocatedSize (numUsed + numElementsToAdd);
bassert (numElementsToAdd <= 0 || data.elements != nullptr);
while (--numElementsToAdd >= 0)
{
data.elements [numUsed] = arrayToAddFrom.getUnchecked (startIndex++);
++numUsed;
}
}
/** Adds copies of the elements in another array to the end of this array.
The other array must be either an OwnedArray of a compatible type of object, or an Array
containing pointers to the same kind of object. The objects involved must provide
a copy constructor, and this will be used to create new copies of each element, and
add them to this array.
@param arrayToAddFrom the array from which to copy the elements
@param startIndex the first element of the other array to start copying from
@param numElementsToAdd how many elements to add from the other array. If this
value is negative or greater than the number of available elements,
all available elements will be copied.
@see add
*/
template <class OtherArrayType>
void addCopiesOf (const OtherArrayType& arrayToAddFrom,
int startIndex = 0,
int numElementsToAdd = -1)
{
const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock());
const ScopedLockType lock2 (getLock());
if (startIndex < 0)
{
bassertfalse;
startIndex = 0;
}
if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size())
numElementsToAdd = arrayToAddFrom.size() - startIndex;
data.ensureAllocatedSize (numUsed + numElementsToAdd);
bassert (numElementsToAdd <= 0 || data.elements != nullptr);
while (--numElementsToAdd >= 0)
{
data.elements [numUsed] = new ObjectClass (*arrayToAddFrom.getUnchecked (startIndex++));
++numUsed;
}
}
/** Inserts a new object into the array assuming that the array is sorted.
This will use a comparator to find the position at which the new object
should go. If the array isn't sorted, the behaviour of this
method will be unpredictable.
@param comparator the comparator to use to compare the elements - see the sort method
for details about this object's structure
@param newObject the new object to insert to the array
@returns the index at which the new object was added
@see add, sort, indexOfSorted
*/
template <class ElementComparator>
int addSorted (ElementComparator& comparator, ObjectClass* const newObject) noexcept
{
(void) comparator; // if you pass in an object with a static compareElements() method, this
// avoids getting warning messages about the parameter being unused
const ScopedLockType lock (getLock());
const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed);
insert (index, newObject);
return index;
}
/** Finds the index of an object in the array, assuming that the array is sorted.
This will use a comparator to do a binary-chop to find the index of the given
element, if it exists. If the array isn't sorted, the behaviour of this
method will be unpredictable.
@param comparator the comparator to use to compare the elements - see the sort()
method for details about the form this object should take
@param objectToLookFor the object to search for
@returns the index of the element, or -1 if it's not found
@see addSorted, sort
*/
template <typename ElementComparator>
int indexOfSorted (ElementComparator& comparator, const ObjectClass* const objectToLookFor) const noexcept
{
(void) comparator;
const ScopedLockType lock (getLock());
int s = 0, e = numUsed;
while (s < e)
{
if (comparator.compareElements (objectToLookFor, data.elements [s]) == 0)
return s;
const int halfway = (s + e) / 2;
if (halfway == s)
break;
if (comparator.compareElements (objectToLookFor, data.elements [halfway]) >= 0)
s = halfway;
else
e = halfway;
}
return -1;
}
//==============================================================================
/** Removes an object from the array.
This will remove the object at a given index (optionally also
deleting it) and move back all the subsequent objects to close the gap.
If the index passed in is out-of-range, nothing will happen.
@param indexToRemove the index of the element to remove
@param deleteObject whether to delete the object that is removed
@see removeObject, removeRange
*/
void remove (const int indexToRemove,
const bool deleteObject = true)
{
ObjectClass* toDelete = nullptr;
{
const ScopedLockType lock (getLock());
if (isPositiveAndBelow (indexToRemove, numUsed))
{
ObjectClass** const e = data.elements + indexToRemove;
if (deleteObject)
toDelete = *e;
--numUsed;
const int numToShift = numUsed - indexToRemove;
if (numToShift > 0)
memmove (e, e + 1, sizeof (ObjectClass*) * (size_t) numToShift);
}
}
// don't want to use a ScopedPointer here because if the
// object has a private destructor, both OwnedArray and
// ScopedPointer would need to be friend classes..
ContainerDeletePolicy <ObjectClass>::destroy (toDelete);
if ((numUsed << 1) < data.numAllocated)
minimiseStorageOverheads();
}
/** Removes and returns an object from the array without deleting it.
This will remove the object at a given index and return it, moving back all
the subsequent objects to close the gap. If the index passed in is out-of-range,
nothing will happen.
@param indexToRemove the index of the element to remove
@see remove, removeObject, removeRange
*/
ObjectClass* removeAndReturn (const int indexToRemove)
{
ObjectClass* removedItem = nullptr;
const ScopedLockType lock (getLock());
if (isPositiveAndBelow (indexToRemove, numUsed))
{
ObjectClass** const e = data.elements + indexToRemove;
removedItem = *e;
--numUsed;
const int numToShift = numUsed - indexToRemove;
if (numToShift > 0)
memmove (e, e + 1, sizeof (ObjectClass*) * (size_t) numToShift);
if ((numUsed << 1) < data.numAllocated)
minimiseStorageOverheads();
}
return removedItem;
}
/** Removes a specified object from the array.
If the item isn't found, no action is taken.
@param objectToRemove the object to try to remove
@param deleteObject whether to delete the object (if it's found)
@see remove, removeRange
*/
void removeObject (const ObjectClass* const objectToRemove,
const bool deleteObject = true)
{
const ScopedLockType lock (getLock());
ObjectClass** const e = data.elements.getData();
for (int i = 0; i < numUsed; ++i)
{
if (objectToRemove == e[i])
{
remove (i, deleteObject);
break;
}
}
}
/** Removes a range of objects from the array.
This will remove a set of objects, starting from the given index,
and move any subsequent elements down to close the gap.
If the range extends beyond the bounds of the array, it will
be safely clipped to the size of the array.
@param startIndex the index of the first object to remove
@param numberToRemove how many objects should be removed
@param deleteObjects whether to delete the objects that get removed
@see remove, removeObject
*/
void removeRange (int startIndex,
const int numberToRemove,
const bool deleteObjects = true)
{
const ScopedLockType lock (getLock());
const int endIndex = blimit (0, numUsed, startIndex + numberToRemove);
startIndex = blimit (0, numUsed, startIndex);
if (endIndex > startIndex)
{
if (deleteObjects)
{
for (int i = startIndex; i < endIndex; ++i)
{
ContainerDeletePolicy <ObjectClass>::destroy (data.elements [i]);
data.elements [i] = nullptr; // (in case one of the destructors accesses this array and hits a dangling pointer)
}
}
const int rangeSize = endIndex - startIndex;
ObjectClass** e = data.elements + startIndex;
int numToShift = numUsed - endIndex;
numUsed -= rangeSize;
while (--numToShift >= 0)
{
*e = e [rangeSize];
++e;
}
if ((numUsed << 1) < data.numAllocated)
minimiseStorageOverheads();
}
}
/** Removes the last n objects from the array.
@param howManyToRemove how many objects to remove from the end of the array
@param deleteObjects whether to also delete the objects that are removed
@see remove, removeObject, removeRange
*/
void removeLast (int howManyToRemove = 1,
const bool deleteObjects = true)
{
const ScopedLockType lock (getLock());
if (howManyToRemove >= numUsed)
clear (deleteObjects);
else
removeRange (numUsed - howManyToRemove, howManyToRemove, deleteObjects);
}
/** Swaps a pair of objects in the array.
If either of the indexes passed in is out-of-range, nothing will happen,
otherwise the two objects at these positions will be exchanged.
*/
void swap (const int index1,
const int index2) noexcept
{
const ScopedLockType lock (getLock());
if (isPositiveAndBelow (index1, numUsed)
&& isPositiveAndBelow (index2, numUsed))
{
std::swap (data.elements [index1],
data.elements [index2]);
}
}
/** Moves one of the objects to a different position.
This will move the object to a specified index, shuffling along
any intervening elements as required.
So for example, if you have the array { 0, 1, 2, 3, 4, 5 } then calling
move (2, 4) would result in { 0, 1, 3, 4, 2, 5 }.
@param currentIndex the index of the object to be moved. If this isn't a
valid index, then nothing will be done
@param newIndex the index at which you'd like this object to end up. If this
is less than zero, it will be moved to the end of the array
*/
void move (const int currentIndex,
int newIndex) noexcept
{
if (currentIndex != newIndex)
{
const ScopedLockType lock (getLock());
if (isPositiveAndBelow (currentIndex, numUsed))
{
if (! isPositiveAndBelow (newIndex, numUsed))
newIndex = numUsed - 1;
ObjectClass* const value = data.elements [currentIndex];
if (newIndex > currentIndex)
{
memmove (data.elements + currentIndex,
data.elements + currentIndex + 1,
sizeof (ObjectClass*) * (size_t) (newIndex - currentIndex));
}
else
{
memmove (data.elements + newIndex + 1,
data.elements + newIndex,
sizeof (ObjectClass*) * (size_t) (currentIndex - newIndex));
}
data.elements [newIndex] = value;
}
}
}
/** This swaps the contents of this array with those of another array.
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
because it just swaps their internal pointers.
*/
template <class OtherArrayType>
void swapWith (OtherArrayType& otherArray) noexcept
{
const ScopedLockType lock1 (getLock());
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
data.swapWith (otherArray.data);
std::swap (numUsed, otherArray.numUsed);
}
//==============================================================================
/** Reduces the amount of storage being used by the array.
Arrays typically allocate slightly more storage than they need, and after
removing elements, they may have quite a lot of unused space allocated.
This method will reduce the amount of allocated storage to a minimum.
*/
void minimiseStorageOverheads() noexcept
{
const ScopedLockType lock (getLock());
data.shrinkToNoMoreThan (numUsed);
}
/** Increases the array's internal storage to hold a minimum number of elements.
Calling this before adding a large known number of elements means that
the array won't have to keep dynamically resizing itself as the elements
are added, and it'll therefore be more efficient.
*/
void ensureStorageAllocated (const int minNumElements) noexcept
{
const ScopedLockType lock (getLock());
data.ensureAllocatedSize (minNumElements);
}
//==============================================================================
/** Sorts the elements in the array.
This will use a comparator object to sort the elements into order. The object
passed must have a method of the form:
@code
int compareElements (ElementType first, ElementType second);
@endcode
..and this method must return:
- a value of < 0 if the first comes before the second
- a value of 0 if the two objects are equivalent
- a value of > 0 if the second comes before the first
To improve performance, the compareElements() method can be declared as static or const.
@param comparator the comparator to use for comparing elements.
@param retainOrderOfEquivalentItems if this is true, then items
which the comparator says are equivalent will be
kept in the order in which they currently appear
in the array. This is slower to perform, but may
be important in some cases. If it's false, a faster
algorithm is used, but equivalent elements may be
rearranged.
@see sortArray, indexOfSorted
*/
template <class ElementComparator>
void sort (ElementComparator& comparator,
const bool retainOrderOfEquivalentItems = false) const noexcept
{
(void) comparator; // if you pass in an object with a static compareElements() method, this
// avoids getting warning messages about the parameter being unused
const ScopedLockType lock (getLock());
sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems);
}
//==============================================================================
/** Returns the CriticalSection that locks this array.
To lock, you can call getLock().enter() and getLock().exit(), or preferably use
an object of ScopedLockType as an RAII lock for it.
*/
inline const TypeOfCriticalSectionToUse& getLock() const noexcept { return data; }
/** Returns the type of scoped lock to use for locking this array */
typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType;
private:
//==============================================================================
ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse> data;
int numUsed;
void deleteAllObjects()
{
while (numUsed > 0)
ContainerDeletePolicy <ObjectClass>::destroy (data.elements [--numUsed]);
}
};
} // namespace beast
#endif

View File

@@ -91,6 +91,6 @@ private:
const ValueType originalValue; const ValueType originalValue;
}; };
} // namespace beast } // beast
#endif // BEAST_SCOPEDVALUESETTER_H_INCLUDED #endif // BEAST_SCOPEDVALUESETTER_H_INCLUDED

View File

@@ -91,7 +91,7 @@ FatalError::FatalError (char const* message, char const* fileName, int lineNumbe
static LockType s_mutex; static LockType s_mutex;
LockType::ScopedLockType lock (s_mutex); std::lock_guard <LockType> lock (s_mutex);
String const backtraceString = SystemStats::getStackBacktrace (); String const backtraceString = SystemStats::getStackBacktrace ();

View File

@@ -149,6 +149,6 @@ private:
static Reporter* s_reporter; static Reporter* s_reporter;
}; };
} // namespace beast } // beast
#endif #endif

View File

@@ -28,7 +28,7 @@ namespace beast
template <typename Function> template <typename Function>
double measureFunctionCallTime (Function f) double measureFunctionCallTime (Function f)
{ {
int64 const startTime (Time::getHighResolutionTicks ()); std::int64_t const startTime (Time::getHighResolutionTicks ());
f (); f ();
return Time::highResolutionTicksToSeconds ( return Time::highResolutionTicksToSeconds (
Time::getHighResolutionTicks () - startTime); Time::getHighResolutionTicks () - startTime);
@@ -40,7 +40,7 @@ template <typename Function,
typename P5, typename P6, typename P7, typename P8> typename P5, typename P6, typename P7, typename P8>
double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8)
{ {
int64 const startTime (Time::getHighResolutionTicks ()); std::int64_t const startTime (Time::getHighResolutionTicks ());
f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8); f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8);
return Time::highResolutionTicksToSeconds ( return Time::highResolutionTicksToSeconds (
Time::getHighResolutionTicks () - startTime); Time::getHighResolutionTicks () - startTime);
@@ -51,7 +51,7 @@ template <typename Function,
typename P5, typename P6, typename P7, typename P8> typename P5, typename P6, typename P7, typename P8>
double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8)
{ {
int64 const startTime (Time::getHighResolutionTicks ()); std::int64_t const startTime (Time::getHighResolutionTicks ());
f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8); f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8);
return Time::highResolutionTicksToSeconds ( return Time::highResolutionTicksToSeconds (
Time::getHighResolutionTicks () - startTime); Time::getHighResolutionTicks () - startTime);
@@ -62,7 +62,7 @@ template <typename Function,
typename P5, typename P6, typename P7, typename P8> typename P5, typename P6, typename P7, typename P8>
double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8)
{ {
int64 const startTime (Time::getHighResolutionTicks ()); std::int64_t const startTime (Time::getHighResolutionTicks ());
f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8); f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8);
return Time::highResolutionTicksToSeconds ( return Time::highResolutionTicksToSeconds (
Time::getHighResolutionTicks () - startTime); Time::getHighResolutionTicks () - startTime);
@@ -73,13 +73,13 @@ template <typename Function,
typename P5, typename P6, typename P7, typename P8> typename P5, typename P6, typename P7, typename P8>
double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8)
{ {
int64 const startTime (Time::getHighResolutionTicks ()); std::int64_t const startTime (Time::getHighResolutionTicks ());
f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8); f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8);
return Time::highResolutionTicksToSeconds ( return Time::highResolutionTicksToSeconds (
Time::getHighResolutionTicks () - startTime); Time::getHighResolutionTicks () - startTime);
} }
#endif #endif
} // namespace beast } // beast
#endif #endif

View File

@@ -30,7 +30,7 @@ namespace beast
http://semver.org/ http://semver.org/
*/ */
class BEAST_API SemanticVersion class SemanticVersion
{ {
public: public:
int majorVersion; int majorVersion;
@@ -74,6 +74,6 @@ private:
static bool chopIdentifiers (StringArray* value, bool preRelease, String& input); static bool chopIdentifiers (StringArray* value, bool preRelease, String& input);
}; };
} // namespace beast } // beast
#endif #endif

View File

@@ -1,44 +0,0 @@
//------------------------------------------------------------------------------
/*
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.
*/
//==============================================================================
#ifndef BEAST_THROW_H_INCLUDED
#define BEAST_THROW_H_INCLUDED
namespace beast
{
/** Throw an exception, with a debugger hook.
This provides an opportunity to utilize the debugger before
the stack is unwound.
*/
namespace Debug
{
extern void breakPoint ();
};
template <class Exception>
void Throw (Exception const& e, char const* = "", int = 0)
{
throw e;
}
} // namespace beast
#endif

View File

@@ -36,7 +36,7 @@ void repeatableShuffle (int const numberOfItems, T& arrayOfItems, Random& r)
} }
template <class T> template <class T>
void repeatableShuffle (int const numberOfItems, T& arrayOfItems, int64 seedValue) void repeatableShuffle (int const numberOfItems, T& arrayOfItems, std::int64_t seedValue)
{ {
Random r (seedValue); Random r (seedValue);
repeatableShuffle (numberOfItems, arrayOfItems, r); repeatableShuffle (numberOfItems, arrayOfItems, r);
@@ -64,7 +64,7 @@ struct Payload
@param maximumBytes The largest number of bytes in the resulting payload. @param maximumBytes The largest number of bytes in the resulting payload.
@param seedValue The value to seed the random number generator with. @param seedValue The value to seed the random number generator with.
*/ */
void repeatableRandomFill (int minimumBytes, int maximumBytes, int64 seedValue) noexcept void repeatableRandomFill (int minimumBytes, int maximumBytes, std::int64_t seedValue) noexcept
{ {
bassert (minimumBytes >=0 && maximumBytes <= bufferSize); bassert (minimumBytes >=0 && maximumBytes <= bufferSize);

View File

@@ -68,7 +68,7 @@ bool DirectoryIterator::next()
return next (nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); return next (nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
} }
bool DirectoryIterator::next (bool* const isDirResult, bool* const isHiddenResult, int64* const fileSize, bool DirectoryIterator::next (bool* const isDirResult, bool* const isHiddenResult, std::int64_t* const fileSize,
Time* const modTime, Time* const creationTime, bool* const isReadOnly) Time* const modTime, Time* const creationTime, bool* const isReadOnly)
{ {
hasBeenAdvanced = true; hasBeenAdvanced = true;
@@ -156,4 +156,4 @@ float DirectoryIterator::getEstimatedProgress() const
return detailedIndex / totalNumFiles; return detailedIndex / totalNumFiles;
} }
} // namespace beast } // beast

View File

@@ -40,7 +40,7 @@ namespace beast
It can also guess how far it's got using a wildly inaccurate algorithm. It can also guess how far it's got using a wildly inaccurate algorithm.
*/ */
class BEAST_API DirectoryIterator : LeakChecked <DirectoryIterator>, public Uncopyable class DirectoryIterator : LeakChecked <DirectoryIterator>, public Uncopyable
{ {
public: public:
//============================================================================== //==============================================================================
@@ -95,7 +95,7 @@ public:
*/ */
bool next (bool* isDirectory, bool next (bool* isDirectory,
bool* isHidden, bool* isHidden,
int64* fileSize, std::int64_t* fileSize,
Time* modTime, Time* modTime,
Time* creationTime, Time* creationTime,
bool* isReadOnly); bool* isReadOnly);
@@ -122,7 +122,7 @@ private:
~NativeIterator(); ~NativeIterator();
bool next (String& filenameFound, bool next (String& filenameFound,
bool* isDirectory, bool* isHidden, int64* fileSize, bool* isDirectory, bool* isHidden, std::int64_t* fileSize,
Time* modTime, Time* creationTime, bool* isReadOnly); Time* modTime, Time* creationTime, bool* isReadOnly);
class Pimpl; class Pimpl;
@@ -146,6 +146,6 @@ private:
File currentFile; File currentFile;
}; };
} // namespace beast } // beast
#endif // BEAST_DIRECTORYITERATOR_H_INCLUDED #endif // BEAST_DIRECTORYITERATOR_H_INCLUDED

View File

@@ -354,7 +354,7 @@ bool File::isAChildOf (const File& potentialParent) const
} }
int File::hashCode() const { return fullPath.hashCode(); } int File::hashCode() const { return fullPath.hashCode(); }
int64 File::hashCode64() const { return fullPath.hashCode64(); } std::int64_t File::hashCode64() const { return fullPath.hashCode64(); }
//============================================================================== //==============================================================================
bool File::isAbsolutePath (const String& path) bool File::isAbsolutePath (const String& path)
@@ -422,7 +422,7 @@ File File::getSiblingFile (const String& fileName) const
} }
//============================================================================== //==============================================================================
String File::descriptionOfSizeInBytes (const int64 bytes) String File::descriptionOfSizeInBytes (const std::int64_t bytes)
{ {
const char* suffix; const char* suffix;
double divisor = 0; double divisor = 0;
@@ -477,9 +477,9 @@ Result File::createDirectory() const
} }
//============================================================================== //==============================================================================
Time File::getLastModificationTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (m); } Time File::getLastModificationTime() const { std::int64_t m, a, c; getFileTimesInternal (m, a, c); return Time (m); }
Time File::getLastAccessTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (a); } Time File::getLastAccessTime() const { std::int64_t m, a, c; getFileTimesInternal (m, a, c); return Time (a); }
Time File::getCreationTime() const { int64 m, a, c; getFileTimesInternal (m, a, c); return Time (c); } Time File::getCreationTime() const { std::int64_t m, a, c; getFileTimesInternal (m, a, c); return Time (c); }
bool File::setLastModificationTime (Time t) const { return setFileTimesInternal (t.toMilliseconds(), 0, 0); } bool File::setLastModificationTime (Time t) const { return setFileTimesInternal (t.toMilliseconds(), 0, 0); }
bool File::setLastAccessTime (Time t) const { return setFileTimesInternal (0, t.toMilliseconds(), 0); } bool File::setLastAccessTime (Time t) const { return setFileTimesInternal (0, t.toMilliseconds(), 0); }
@@ -694,7 +694,7 @@ FileOutputStream* File::createOutputStream (const size_t bufferSize) const
bool File::appendData (const void* const dataToAppend, bool File::appendData (const void* const dataToAppend,
const size_t numberOfBytes) const const size_t numberOfBytes) const
{ {
bassert (((ssize_t) numberOfBytes) >= 0); bassert (((std::ptrdiff_t) numberOfBytes) >= 0);
if (numberOfBytes == 0) if (numberOfBytes == 0)
return true; return true;

View File

@@ -24,8 +24,17 @@
#ifndef BEAST_FILE_H_INCLUDED #ifndef BEAST_FILE_H_INCLUDED
#define BEAST_FILE_H_INCLUDED #define BEAST_FILE_H_INCLUDED
namespace beast #include "../containers/Array.h"
{ #include "../memory/MemoryBlock.h"
#include "../misc/Result.h"
#include "../time/Time.h"
#include "../text/StringArray.h"
#include "../threads/CriticalSection.h"
namespace beast {
class FileInputStream;
class FileOutputStream;
//============================================================================== //==============================================================================
/** /**
@@ -39,7 +48,7 @@ namespace beast
@see FileInputStream, FileOutputStream @see FileInputStream, FileOutputStream
*/ */
class BEAST_API File class File
{ {
public: public:
//============================================================================== //==============================================================================
@@ -123,14 +132,14 @@ public:
@returns the number of bytes in the file, or 0 if it doesn't exist. @returns the number of bytes in the file, or 0 if it doesn't exist.
*/ */
int64 getSize() const; std::int64_t getSize() const;
/** Utility function to convert a file size in bytes to a neat string description. /** Utility function to convert a file size in bytes to a neat string description.
So for example 100 would return "100 bytes", 2000 would return "2 KB", So for example 100 would return "100 bytes", 2000 would return "2 KB",
2000000 would produce "2 MB", etc. 2000000 would produce "2 MB", etc.
*/ */
static String descriptionOfSizeInBytes (int64 bytes); static String descriptionOfSizeInBytes (std::int64_t bytes);
//============================================================================== //==============================================================================
/** Returns the complete, absolute path of this file. /** Returns the complete, absolute path of this file.
@@ -235,7 +244,7 @@ public:
This is based on the filename. Obviously it's possible, although unlikely, that This is based on the filename. Obviously it's possible, although unlikely, that
two files will have the same hash-code. two files will have the same hash-code.
*/ */
int64 hashCode64() const; std::int64_t hashCode64() const;
//============================================================================== //==============================================================================
/** Returns a file that represents a relative (or absolute) sub-path of the current one. /** Returns a file that represents a relative (or absolute) sub-path of the current one.
@@ -698,14 +707,14 @@ public:
@returns the number of bytes free, or 0 if there's a problem finding this out @returns the number of bytes free, or 0 if there's a problem finding this out
@see getVolumeTotalSize @see getVolumeTotalSize
*/ */
int64 getBytesFreeOnVolume() const; std::int64_t getBytesFreeOnVolume() const;
/** Returns the total size of the drive that contains this file. /** Returns the total size of the drive that contains this file.
@returns the total number of bytes that the volume can hold @returns the total number of bytes that the volume can hold
@see getBytesFreeOnVolume @see getBytesFreeOnVolume
*/ */
int64 getVolumeTotalSize() const; std::int64_t getVolumeTotalSize() const;
/** Returns true if this file is on a CD or DVD drive. */ /** Returns true if this file is on a CD or DVD drive. */
bool isOnCDRomDrive() const; bool isOnCDRomDrive() const;
@@ -842,7 +851,7 @@ public:
@see SpecialLocationType @see SpecialLocationType
*/ */
static File BEAST_CALLTYPE getSpecialLocation (const SpecialLocationType type); static File getSpecialLocation (const SpecialLocationType type);
//============================================================================== //==============================================================================
/** Returns a temporary file in the system's temp directory. /** Returns a temporary file in the system's temp directory.
@@ -946,12 +955,12 @@ private:
Result createDirectoryInternal (const String&) const; Result createDirectoryInternal (const String&) const;
bool copyInternal (const File&) const; bool copyInternal (const File&) const;
bool moveInternal (const File&) const; bool moveInternal (const File&) const;
bool setFileTimesInternal (int64 m, int64 a, int64 c) const; bool setFileTimesInternal (std::int64_t m, std::int64_t a, std::int64_t c) const;
void getFileTimesInternal (int64& m, int64& a, int64& c) const; void getFileTimesInternal (std::int64_t& m, std::int64_t& a, std::int64_t& c) const;
bool setFileReadOnlyInternal (bool) const; bool setFileReadOnlyInternal (bool) const;
}; };
} // namespace beast } // beast
#endif #endif

View File

@@ -24,7 +24,7 @@
namespace beast namespace beast
{ {
int64 beast_fileSetPosition (void* handle, int64 pos); std::int64_t beast_fileSetPosition (void* handle, std::int64_t pos);
//============================================================================== //==============================================================================
FileInputStream::FileInputStream (const File& f) FileInputStream::FileInputStream (const File& f)
@@ -43,7 +43,7 @@ FileInputStream::~FileInputStream()
} }
//============================================================================== //==============================================================================
int64 FileInputStream::getTotalLength() std::int64_t FileInputStream::getTotalLength()
{ {
return file.getSize(); return file.getSize();
} }
@@ -72,18 +72,18 @@ bool FileInputStream::isExhausted()
return currentPosition >= getTotalLength(); return currentPosition >= getTotalLength();
} }
int64 FileInputStream::getPosition() std::int64_t FileInputStream::getPosition()
{ {
return currentPosition; return currentPosition;
} }
bool FileInputStream::setPosition (int64 pos) bool FileInputStream::setPosition (std::int64_t pos)
{ {
bassert (openedOk()); bassert (openedOk());
if (pos != currentPosition) if (pos != currentPosition)
{ {
pos = blimit ((int64) 0, getTotalLength(), pos); pos = blimit ((std::int64_t) 0, getTotalLength(), pos);
needToSeek |= (currentPosition != pos); needToSeek |= (currentPosition != pos);
currentPosition = pos; currentPosition = pos;
@@ -92,4 +92,4 @@ bool FileInputStream::setPosition (int64 pos)
return true; return true;
} }
} // namespace beast } // beast

View File

@@ -33,7 +33,7 @@ namespace beast
@see InputStream, FileOutputStream, File::createInputStream @see InputStream, FileOutputStream, File::createInputStream
*/ */
class BEAST_API FileInputStream class FileInputStream
: public InputStream : public InputStream
, LeakChecked <FileInputStream> , LeakChecked <FileInputStream>
{ {
@@ -71,17 +71,17 @@ public:
//============================================================================== //==============================================================================
int64 getTotalLength(); std::int64_t getTotalLength();
int read (void* destBuffer, int maxBytesToRead); int read (void* destBuffer, int maxBytesToRead);
bool isExhausted(); bool isExhausted();
int64 getPosition(); std::int64_t getPosition();
bool setPosition (int64 pos); bool setPosition (std::int64_t pos);
private: private:
//============================================================================== //==============================================================================
File file; File file;
void* fileHandle; void* fileHandle;
int64 currentPosition; std::int64_t currentPosition;
Result status; Result status;
bool needToSeek; bool needToSeek;
@@ -90,6 +90,6 @@ private:
size_t readInternal (void* buffer, size_t numBytes); size_t readInternal (void* buffer, size_t numBytes);
}; };
} // namespace beast } // beast
#endif // BEAST_FILEINPUTSTREAM_H_INCLUDED #endif // BEAST_FILEINPUTSTREAM_H_INCLUDED

View File

@@ -24,7 +24,7 @@
namespace beast namespace beast
{ {
int64 beast_fileSetPosition (void* handle, int64 pos); std::int64_t beast_fileSetPosition (void* handle, std::int64_t pos);
//============================================================================== //==============================================================================
FileOutputStream::FileOutputStream (const File& f, const size_t bufferSizeToUse) FileOutputStream::FileOutputStream (const File& f, const size_t bufferSizeToUse)
@@ -46,12 +46,12 @@ FileOutputStream::~FileOutputStream()
closeHandle(); closeHandle();
} }
int64 FileOutputStream::getPosition() std::int64_t FileOutputStream::getPosition()
{ {
return currentPosition; return currentPosition;
} }
bool FileOutputStream::setPosition (int64 newPosition) bool FileOutputStream::setPosition (std::int64_t newPosition)
{ {
if (newPosition != currentPosition) if (newPosition != currentPosition)
{ {
@@ -68,7 +68,7 @@ bool FileOutputStream::flushBuffer()
if (bytesInBuffer > 0) if (bytesInBuffer > 0)
{ {
ok = (writeInternal (buffer, bytesInBuffer) == (ssize_t) bytesInBuffer); ok = (writeInternal (buffer, bytesInBuffer) == (std::ptrdiff_t) bytesInBuffer);
bytesInBuffer = 0; bytesInBuffer = 0;
} }
@@ -83,7 +83,7 @@ void FileOutputStream::flush()
bool FileOutputStream::write (const void* const src, const size_t numBytes) bool FileOutputStream::write (const void* const src, const size_t numBytes)
{ {
bassert (src != nullptr && ((ssize_t) numBytes) >= 0); bassert (src != nullptr && ((std::ptrdiff_t) numBytes) >= 0);
if (bytesInBuffer + numBytes < bufferSize) if (bytesInBuffer + numBytes < bufferSize)
{ {
@@ -104,22 +104,22 @@ bool FileOutputStream::write (const void* const src, const size_t numBytes)
} }
else else
{ {
const ssize_t bytesWritten = writeInternal (src, numBytes); const std::ptrdiff_t bytesWritten = writeInternal (src, numBytes);
if (bytesWritten < 0) if (bytesWritten < 0)
return false; return false;
currentPosition += bytesWritten; currentPosition += bytesWritten;
return bytesWritten == (ssize_t) numBytes; return bytesWritten == (std::ptrdiff_t) numBytes;
} }
} }
return true; return true;
} }
bool FileOutputStream::writeRepeatedByte (uint8 byte, size_t numBytes) bool FileOutputStream::writeRepeatedByte (std::uint8_t byte, size_t numBytes)
{ {
bassert (((ssize_t) numBytes) >= 0); bassert (((std::ptrdiff_t) numBytes) >= 0);
if (bytesInBuffer + numBytes < bufferSize) if (bytesInBuffer + numBytes < bufferSize)
{ {
@@ -132,4 +132,4 @@ bool FileOutputStream::writeRepeatedByte (uint8 byte, size_t numBytes)
return OutputStream::writeRepeatedByte (byte, numBytes); return OutputStream::writeRepeatedByte (byte, numBytes);
} }
} // namespace beast } // beast

View File

@@ -33,7 +33,7 @@ namespace beast
@see OutputStream, FileInputStream, File::createOutputStream @see OutputStream, FileInputStream, File::createOutputStream
*/ */
class BEAST_API FileOutputStream class FileOutputStream
: public OutputStream : public OutputStream
, LeakChecked <FileOutputStream> , LeakChecked <FileOutputStream>
{ {
@@ -87,10 +87,10 @@ public:
//============================================================================== //==============================================================================
void flush() override; void flush() override;
int64 getPosition() override; std::int64_t getPosition() override;
bool setPosition (int64) override; bool setPosition (std::int64_t) override;
bool write (const void*, size_t) override; bool write (const void*, size_t) override;
bool writeRepeatedByte (uint8 byte, size_t numTimesToRepeat) override; bool writeRepeatedByte (std::uint8_t byte, size_t numTimesToRepeat) override;
private: private:
@@ -98,7 +98,7 @@ private:
File file; File file;
void* fileHandle; void* fileHandle;
Result status; Result status;
int64 currentPosition; std::int64_t currentPosition;
size_t bufferSize, bytesInBuffer; size_t bufferSize, bytesInBuffer;
HeapBlock <char> buffer; HeapBlock <char> buffer;
@@ -106,10 +106,10 @@ private:
void closeHandle(); void closeHandle();
void flushInternal(); void flushInternal();
bool flushBuffer(); bool flushBuffer();
int64 setPositionInternal (int64); std::int64_t setPositionInternal (std::int64_t);
ssize_t writeInternal (const void*, size_t); std::ptrdiff_t writeInternal (const void*, size_t);
}; };
} // namespace beast } // beast
#endif #endif

View File

@@ -168,4 +168,4 @@ bool FileSearchPath::isFileInPath (const File& fileToCheck,
return false; return false;
} }
} // namespace beast } // beast

View File

@@ -33,7 +33,7 @@ namespace beast
@see File @see File
*/ */
class BEAST_API FileSearchPath : LeakChecked <FileSearchPath> class FileSearchPath : LeakChecked <FileSearchPath>
{ {
public: public:
//============================================================================== //==============================================================================
@@ -158,6 +158,6 @@ private:
void init (const String& path); void init (const String& path);
}; };
} // namespace beast } // beast
#endif // BEAST_FILESEARCHPATH_H_INCLUDED #endif // BEAST_FILESEARCHPATH_H_INCLUDED

View File

@@ -68,7 +68,7 @@ Result RandomAccessFile::read (void* buffer, ByteCount numBytes, ByteCount* pAct
Result RandomAccessFile::write (const void* data, ByteCount numBytes, ByteCount* pActualAmount) Result RandomAccessFile::write (const void* data, ByteCount numBytes, ByteCount* pActualAmount)
{ {
bassert (data != nullptr && ((ssize_t) numBytes) >= 0); bassert (data != nullptr && ((std::ptrdiff_t) numBytes) >= 0);
Result result (Result::ok ()); Result result (Result::ok ());
@@ -128,7 +128,7 @@ public:
static void createRecords (HeapBlock <Record>& records, static void createRecords (HeapBlock <Record>& records,
int numRecords, int numRecords,
int maxBytes, int maxBytes,
int64 seedValue) std::int64_t seedValue)
{ {
using namespace UnitTestUtilities; using namespace UnitTestUtilities;
@@ -157,7 +157,7 @@ public:
void writeRecords (RandomAccessFile& file, void writeRecords (RandomAccessFile& file,
int numRecords, int numRecords,
HeapBlock <Record> const& records, HeapBlock <Record> const& records,
int64 seedValue) std::int64_t seedValue)
{ {
using namespace UnitTestUtilities; using namespace UnitTestUtilities;
@@ -181,7 +181,7 @@ public:
void readRecords (RandomAccessFile& file, void readRecords (RandomAccessFile& file,
int numRecords, int numRecords,
HeapBlock <Record> const& records, HeapBlock <Record> const& records,
int64 seedValue) std::int64_t seedValue)
{ {
using namespace UnitTestUtilities; using namespace UnitTestUtilities;

View File

@@ -39,14 +39,14 @@ namespace beast
@see FileInputStream, FileOutputStream @see FileInputStream, FileOutputStream
*/ */
class BEAST_API RandomAccessFile : public Uncopyable, LeakChecked <RandomAccessFile> class RandomAccessFile : public Uncopyable, LeakChecked <RandomAccessFile>
{ {
public: public:
/** The type of an FileOffset. /** The type of an FileOffset.
This can be useful when writing templates. This can be useful when writing templates.
*/ */
typedef int64 FileOffset; typedef std::int64_t FileOffset;
/** The type of a byte count. /** The type of a byte count.
@@ -194,7 +194,7 @@ private:
FileOffset currentPosition; FileOffset currentPosition;
}; };
} // namespace beast } // beast
#endif #endif

View File

@@ -114,4 +114,4 @@ bool TemporaryFile::deleteTemporaryFile() const
return false; return false;
} }
} // namespace beast } // beast

View File

@@ -65,7 +65,7 @@ namespace beast
@see File, FileOutputStream @see File, FileOutputStream
*/ */
class BEAST_API TemporaryFile : LeakChecked <TemporaryFile>, public Uncopyable class TemporaryFile : LeakChecked <TemporaryFile>, public Uncopyable
{ {
public: public:
//============================================================================== //==============================================================================
@@ -161,6 +161,6 @@ private:
const File temporaryFile, targetFile; const File temporaryFile, targetFile;
}; };
} // namespace beast } // beast
#endif // BEAST_TEMPORARYFILE_H_INCLUDED #endif // BEAST_TEMPORARYFILE_H_INCLUDED

View File

@@ -60,4 +60,4 @@ void logAssertion (const char* const filename, const int lineNum)
} }
#endif #endif
} // namespace beast } // beast

View File

@@ -37,7 +37,7 @@ namespace beast
The logger class also contains methods for writing messages to the debugger's The logger class also contains methods for writing messages to the debugger's
output stream. output stream.
*/ */
class BEAST_API Logger class Logger
{ {
public: public:
//============================================================================== //==============================================================================
@@ -51,7 +51,7 @@ public:
the caller must make sure that it is not deleted while still being used. the caller must make sure that it is not deleted while still being used.
A null pointer can be passed-in to disable any logging. A null pointer can be passed-in to disable any logging.
*/ */
static void BEAST_CALLTYPE setCurrentLogger (Logger* newLogger) noexcept; static void setCurrentLogger (Logger* newLogger) noexcept;
/** Returns the current logger, or nullptr if none has been set. */ /** Returns the current logger, or nullptr if none has been set. */
static Logger* getCurrentLogger() noexcept; static Logger* getCurrentLogger() noexcept;
@@ -63,7 +63,7 @@ public:
@see logMessage @see logMessage
*/ */
static void BEAST_CALLTYPE writeToLog (const String& message); static void writeToLog (const String& message);
//============================================================================== //==============================================================================
@@ -72,7 +72,7 @@ public:
This can be called directly, or by using the DBG() macro in This can be called directly, or by using the DBG() macro in
CompilerConfig.h (which will avoid calling the method in non-debug builds). CompilerConfig.h (which will avoid calling the method in non-debug builds).
*/ */
static void BEAST_CALLTYPE outputDebugString (const String& text); static void outputDebugString (const String& text);
protected: protected:
@@ -88,6 +88,6 @@ private:
static Logger* currentLogger; static Logger* currentLogger;
}; };
} // namespace beast } // beast
#endif // BEAST_LOGGER_H_INCLUDED #endif // BEAST_LOGGER_H_INCLUDED

View File

@@ -84,6 +84,6 @@ inline T radiansToDegrees (U radians)
return deg; return deg;
} }
} // namespace beast } // beast
#endif #endif

View File

@@ -25,7 +25,7 @@
namespace beast { namespace beast {
Random::Random (const int64 seedValue) noexcept Random::Random (const std::int64_t seedValue) noexcept
: seed (seedValue) : seed (seedValue)
{ {
nextInt (); // fixes a bug where the first int is always 0 nextInt (); // fixes a bug where the first int is always 0
@@ -41,23 +41,23 @@ Random::~Random() noexcept
{ {
} }
void Random::setSeed (const int64 newSeed) noexcept void Random::setSeed (const std::int64_t newSeed) noexcept
{ {
seed = newSeed; seed = newSeed;
nextInt (); // fixes a bug where the first int is always 0 nextInt (); // fixes a bug where the first int is always 0
} }
void Random::combineSeed (const int64 seedValue) noexcept void Random::combineSeed (const std::int64_t seedValue) noexcept
{ {
seed ^= nextInt64() ^ seedValue; seed ^= nextInt64() ^ seedValue;
} }
void Random::setSeedRandomly() void Random::setSeedRandomly()
{ {
static int64 globalSeed = 0; static std::int64_t globalSeed = 0;
combineSeed (globalSeed ^ (int64) (pointer_sized_int) this); combineSeed (globalSeed ^ (std::int64_t) (std::intptr_t) this);
combineSeed (Time::getMillisecondCounter()); combineSeed (Time::getMillisecondCounter());
combineSeed (Time::getHighResolutionTicks()); combineSeed (Time::getHighResolutionTicks());
combineSeed (Time::getHighResolutionTicksPerSecond()); combineSeed (Time::getHighResolutionTicksPerSecond());
@@ -76,7 +76,7 @@ Random& Random::getSystemRandom() noexcept
//============================================================================== //==============================================================================
int Random::nextInt() noexcept int Random::nextInt() noexcept
{ {
seed = (seed * literal64bit (0x5deece66d) + 11) & literal64bit (0xffffffffffff); seed = (seed * 0x5deece66dLL + 11) & 0xffffffffffffULL;
return (int) (seed >> 16); return (int) (seed >> 16);
} }
@@ -84,12 +84,12 @@ int Random::nextInt() noexcept
int Random::nextInt (const int maxValue) noexcept int Random::nextInt (const int maxValue) noexcept
{ {
bassert (maxValue > 0); bassert (maxValue > 0);
return (int) ((((unsigned int) nextInt()) * (uint64) maxValue) >> 32); return (int) ((((unsigned int) nextInt()) * (std::uint64_t) maxValue) >> 32);
} }
int64 Random::nextInt64() noexcept std::int64_t Random::nextInt64() noexcept
{ {
return (((int64) nextInt()) << 32) | (int64) (uint64) (uint32) nextInt(); return (((std::int64_t) nextInt()) << 32) | (std::int64_t) (std::uint64_t) (std::uint32_t) nextInt();
} }
bool Random::nextBool() noexcept bool Random::nextBool() noexcept
@@ -99,12 +99,12 @@ bool Random::nextBool() noexcept
float Random::nextFloat() noexcept float Random::nextFloat() noexcept
{ {
return static_cast <uint32> (nextInt()) / (float) 0xffffffff; return static_cast <std::uint32_t> (nextInt()) / (float) 0xffffffff;
} }
double Random::nextDouble() noexcept double Random::nextDouble() noexcept
{ {
return static_cast <uint32> (nextInt()) / (double) 0xffffffff; return static_cast <std::uint32_t> (nextInt()) / (double) 0xffffffff;
} }
void Random::fillBitsRandomly (void* const buffer, size_t bytes) void Random::fillBitsRandomly (void* const buffer, size_t bytes)

View File

@@ -45,7 +45,7 @@ public:
new Random (Time::currentTimeMillis()) new Random (Time::currentTimeMillis())
*/ */
explicit Random (int64 seedValue) noexcept; explicit Random (std::int64_t seedValue) noexcept;
/** Creates a Random object using a random seed value. /** Creates a Random object using a random seed value.
Internally, this calls setSeedRandomly() to randomise the seed. Internally, this calls setSeedRandomly() to randomise the seed.
@@ -71,7 +71,7 @@ public:
@returns a random integer from the full range 0x8000000000000000 to 0x7fffffffffffffff @returns a random integer from the full range 0x8000000000000000 to 0x7fffffffffffffff
*/ */
int64 nextInt64() noexcept; std::int64_t nextInt64() noexcept;
/** Returns the next random floating-point number. /** Returns the next random floating-point number.
@@ -94,13 +94,13 @@ public:
//============================================================================== //==============================================================================
/** Resets this Random object to a given seed value. */ /** Resets this Random object to a given seed value. */
void setSeed (int64 newSeed) noexcept; void setSeed (std::int64_t newSeed) noexcept;
/** Merges this object's seed with another value. /** Merges this object's seed with another value.
This sets the seed to be a value created by combining the current seed and this This sets the seed to be a value created by combining the current seed and this
new value. new value.
*/ */
void combineSeed (int64 seedValue) noexcept; void combineSeed (std::int64_t seedValue) noexcept;
/** Reseeds this generator using a value generated from various semi-random system /** Reseeds this generator using a value generated from various semi-random system
properties like the current time, etc. properties like the current time, etc.
@@ -120,9 +120,9 @@ public:
private: private:
//============================================================================== //==============================================================================
int64 seed; std::int64_t seed;
}; };
} // namespace beast } // beast
#endif // BEAST_RANDOM_H_INCLUDED #endif // BEAST_RANDOM_H_INCLUDED

View File

@@ -258,6 +258,6 @@ private:
ValueType start, end; ValueType start, end;
}; };
} // namespace beast } // beast
#endif // BEAST_RANGE_H_INCLUDED #endif // BEAST_RANGE_H_INCLUDED

View File

@@ -56,7 +56,7 @@ MemoryBlock::MemoryBlock (const MemoryBlock& other)
MemoryBlock::MemoryBlock (const void* const dataToInitialiseFrom, const size_t sizeInBytes) MemoryBlock::MemoryBlock (const void* const dataToInitialiseFrom, const size_t sizeInBytes)
: size (sizeInBytes) : size (sizeInBytes)
{ {
bassert (((ssize_t) sizeInBytes) >= 0); bassert (((std::ptrdiff_t) sizeInBytes) >= 0);
if (size > 0) if (size > 0)
{ {
@@ -160,7 +160,7 @@ void MemoryBlock::swapWith (MemoryBlock& other) noexcept
} }
//============================================================================== //==============================================================================
void MemoryBlock::fillWith (const uint8 value) noexcept void MemoryBlock::fillWith (const std::uint8_t value) noexcept
{ {
memset (data, (int) value, size); memset (data, (int) value, size);
} }
@@ -295,16 +295,16 @@ void MemoryBlock::setBitRange (const size_t bitRangeStart, size_t numBits, int b
{ {
size_t byte = bitRangeStart >> 3; size_t byte = bitRangeStart >> 3;
size_t offsetInByte = bitRangeStart & 7; size_t offsetInByte = bitRangeStart & 7;
uint32 mask = ~((((uint32) 0xffffffff) << (32 - numBits)) >> (32 - numBits)); std::uint32_t mask = ~((((std::uint32_t) 0xffffffff) << (32 - numBits)) >> (32 - numBits));
while (numBits > 0 && (size_t) byte < size) while (numBits > 0 && (size_t) byte < size)
{ {
const size_t bitsThisTime = bmin (numBits, 8 - offsetInByte); const size_t bitsThisTime = bmin (numBits, 8 - offsetInByte);
const uint32 tempMask = (mask << offsetInByte) | ~((((uint32) 0xffffffff) >> offsetInByte) << offsetInByte); const std::uint32_t tempMask = (mask << offsetInByte) | ~((((std::uint32_t) 0xffffffff) >> offsetInByte) << offsetInByte);
const uint32 tempBits = (uint32) bitsToSet << offsetInByte; const std::uint32_t tempBits = (std::uint32_t) bitsToSet << offsetInByte;
data[byte] = (char) (((uint32) data[byte] & tempMask) | tempBits); data[byte] = (char) (((std::uint32_t) data[byte] & tempMask) | tempBits);
++byte; ++byte;
numBits -= bitsThisTime; numBits -= bitsThisTime;
@@ -366,7 +366,7 @@ String MemoryBlock::toBase64Encoding() const
d.write ('.'); d.write ('.');
for (size_t i = 0; i < numChars; ++i) for (size_t i = 0; i < numChars; ++i)
d.write ((beast_wchar) (uint8) base64EncodingTable [getBitRange (i * 6, 6)]); d.write ((beast_wchar) (std::uint8_t) base64EncodingTable [getBitRange (i * 6, 6)]);
d.writeNull(); d.writeNull();
return destString; return destString;
@@ -407,4 +407,4 @@ bool MemoryBlock::fromBase64Encoding (const String& s)
return true; return true;
} }
} // namespace beast } // beast

View File

@@ -24,15 +24,16 @@
#ifndef BEAST_MEMORYBLOCK_H_INCLUDED #ifndef BEAST_MEMORYBLOCK_H_INCLUDED
#define BEAST_MEMORYBLOCK_H_INCLUDED #define BEAST_MEMORYBLOCK_H_INCLUDED
namespace beast #include "../../../beast/utility/LeakChecked.h"
{
namespace beast {
//============================================================================== //==============================================================================
/** /**
A class to hold a resizable block of raw data. A class to hold a resizable block of raw data.
*/ */
class BEAST_API MemoryBlock : LeakChecked <MemoryBlock> class MemoryBlock : LeakChecked <MemoryBlock>
{ {
public: public:
//============================================================================== //==============================================================================
@@ -160,7 +161,7 @@ public:
This is handy for clearing a block of memory to zero. This is handy for clearing a block of memory to zero.
*/ */
void fillWith (uint8 valueToUse) noexcept; void fillWith (std::uint8_t valueToUse) noexcept;
/** Adds another block of data to the end of this one. /** Adds another block of data to the end of this one.
The data pointer must not be null. This block's size will be increased accordingly. The data pointer must not be null. This block's size will be increased accordingly.
@@ -267,7 +268,7 @@ private:
size_t size; size_t size;
}; };
} // namespace beast } // beast
#endif #endif

View File

@@ -20,6 +20,10 @@
#ifndef BEAST_SHAREDSINGLETON_H_INCLUDED #ifndef BEAST_SHAREDSINGLETON_H_INCLUDED
#define BEAST_SHAREDSINGLETON_H_INCLUDED #define BEAST_SHAREDSINGLETON_H_INCLUDED
#include "../../../beast/threads/SpinLock.h"
#include "../../../beast/smart_ptr/SharedPtr.h"
#include "../time/AtExitHook.h"
namespace beast namespace beast
{ {
@@ -38,7 +42,7 @@ namespace beast
@ingroup beast_core @ingroup beast_core
*/ */
/** @{ */ /** @{ */
class BEAST_API SingletonLifetime class SingletonLifetime
{ {
public: public:
// It would be nice if we didn't have to qualify the enumeration but // It would be nice if we didn't have to qualify the enumeration but
@@ -88,7 +92,7 @@ public:
SharedSingleton* instance = staticData.instance; SharedSingleton* instance = staticData.instance;
if (instance == nullptr) if (instance == nullptr)
{ {
LockType::ScopedLockType lock (staticData.mutex); std::lock_guard <LockType> lock (staticData.mutex);
instance = staticData.instance; instance = staticData.instance;
if (instance == nullptr) if (instance == nullptr)
{ {
@@ -138,7 +142,7 @@ private:
// //
{ {
StaticData& staticData (getStaticData ()); StaticData& staticData (getStaticData ());
LockType::ScopedLockType lock (staticData.mutex); std::lock_guard <LockType> lock (staticData.mutex);
if (this->getReferenceCount() != 0) if (this->getReferenceCount() != 0)
{ {
@@ -180,7 +184,7 @@ private:
static StaticData& getStaticData () static StaticData& getStaticData ()
{ {
static uint8 storage [sizeof (StaticData)]; static std::uint8_t storage [sizeof (StaticData)];
return *(reinterpret_cast <StaticData*> (&storage [0])); return *(reinterpret_cast <StaticData*> (&storage [0]));
} }
@@ -193,6 +197,6 @@ private:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
} // namespace beast } // beast
#endif #endif

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