beast cleaning and tidying:

* Consolidate small modules into one
* Remove Android-specific platform support
* Remove Chrono.h from beast_core.h
* Removed files:
  - TypeTraits.h
  - Utility.h
  - Net.h
  - Asio.h
* Remove zlib support:
  - Remove inline zlib library sources
  - Remove GZIPCompressorOutputStream
  - Remove GZIPDecompressorInputStream
* Remove obsolete or unused classes:
  - AbstractObject
  - BigInteger
  - BufferedInputStream
  - CacheLine
  - CPUMeter
  - DatagramSocket
  - DynamicObject
  - FileLogger
  - FPUFlags
  - Identifier
  - JSON
  - LocalisedStrings
  - MACAddress
  - MemoryAlignment
  - MemoryInputStream
  - MemoryMappedFile
  - NamedValueSet
  - OptionalScopedPointer
  - PerformanceCounter
  - PropertySet
  - ScopedTimeInterval
  - SparseSet
  - SpinDelay
  - StreamingSocket
  - StringPool
  - SubregionStream
  - Uuid
  - Variant
This commit is contained in:
Vinnie Falco
2014-03-20 18:08:54 -07:00
parent 693a5927a9
commit e344cb3d62
160 changed files with 152 additions and 25208 deletions

View File

@@ -71,20 +71,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</None>
<None Include="..\..\modules\beast_core\native\java\BeastAppActivity.java">
<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\zip\zlib\README" />
<None Include="..\..\README.md" />
<None Include="..\..\scripts\compile.sh" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\BeastConfig.h" />
<ClInclude Include="..\..\beast\Arithmetic.h" />
<ClInclude Include="..\..\beast\Asio.h" />
<ClInclude Include="..\..\beast\asio\abstract_socket.h" />
<ClInclude Include="..\..\beast\asio\bind_handler.h" />
<ClInclude Include="..\..\beast\asio\buffer_sequence.h" />
@@ -104,11 +96,9 @@
<ClInclude Include="..\..\beast\chrono\basic_seconds_clock.h" />
<ClInclude Include="..\..\beast\chrono\chrono_io.h" />
<ClInclude Include="..\..\beast\chrono\chrono_util.h" />
<ClInclude Include="..\..\beast\chrono\CPUMeter.h" />
<ClInclude Include="..\..\beast\chrono\manual_clock.h" />
<ClInclude Include="..\..\beast\chrono\ratio_io.h" />
<ClInclude Include="..\..\beast\chrono\RelativeTime.h" />
<ClInclude Include="..\..\beast\chrono\ScopedTimeInterval.h" />
<ClInclude Include="..\..\beast\Config.h" />
<ClInclude Include="..\..\beast\config\CompilerConfig.h" />
<ClInclude Include="..\..\beast\config\compiler\Clang.h" />
@@ -159,7 +149,6 @@
<ClInclude Include="..\..\beast\cxx14\utility.h" />
<ClInclude Include="..\..\beast\FixedArray.h" />
<ClInclude Include="..\..\beast\HeapBlock.h" />
<ClInclude Include="..\..\beast\HTTP.h" />
<ClInclude Include="..\..\beast\http\basic_message.h" />
<ClInclude Include="..\..\beast\http\impl\http-parser\http_parser.h" />
<ClInclude Include="..\..\beast\http\impl\joyent_parser.h" />
@@ -188,9 +177,6 @@
<ClInclude Include="..\..\beast\intrusive\List.h" />
<ClInclude Include="..\..\beast\intrusive\LockFreeStack.h" />
<ClInclude Include="..\..\beast\Memory.h" />
<ClInclude Include="..\..\beast\MPL.h" />
<ClInclude Include="..\..\beast\mpl\IsCallPossible.h" />
<ClInclude Include="..\..\beast\Net.h" />
<ClInclude Include="..\..\beast\net\detail\Parse.h" />
<ClInclude Include="..\..\beast\net\DynamicBuffer.h" />
<ClInclude Include="..\..\beast\net\IPAddress.h" />
@@ -198,7 +184,6 @@
<ClInclude Include="..\..\beast\net\IPAddressV6.h" />
<ClInclude Include="..\..\beast\net\IPEndpoint.h" />
<ClInclude Include="..\..\beast\SmartPtr.h" />
<ClInclude Include="..\..\beast\smart_ptr\AbstractObject.h" />
<ClInclude Include="..\..\beast\smart_ptr\ContainerDeletePolicy.h" />
<ClInclude Include="..\..\beast\smart_ptr\ScopedPointer.h" />
<ClInclude Include="..\..\beast\smart_ptr\SharedObject.h" />
@@ -235,23 +220,19 @@
<ClInclude Include="..\..\beast\threads\UnlockGuard.h" />
<ClInclude Include="..\..\beast\threads\WaitableEvent.h" />
<ClInclude Include="..\..\beast\threads\ScopedWrapperContext.h" />
<ClInclude Include="..\..\beast\TypeTraits.h" />
<ClInclude Include="..\..\beast\type_traits\IntegralConstant.h" />
<ClInclude Include="..\..\beast\type_traits\IsIntegral.h" />
<ClInclude Include="..\..\beast\type_traits\IsSigned.h" />
<ClInclude Include="..\..\beast\type_traits\maybe_const.h" />
<ClInclude Include="..\..\beast\Uncopyable.h" />
<ClInclude Include="..\..\beast\Utility.h" />
<ClInclude Include="..\..\beast\utility\Debug.h" />
<ClInclude Include="..\..\beast\utility\empty_base_optimization.h" />
<ClInclude Include="..\..\beast\utility\Error.h" />
<ClInclude Include="..\..\beast\utility\hash_pair.h" />
<ClInclude Include="..\..\beast\utility\is_call_possible.h" />
<ClInclude Include="..\..\beast\utility\Journal.h" />
<ClInclude Include="..\..\beast\utility\LeakChecked.h" />
<ClInclude Include="..\..\beast\utility\maybe_const.h" />
<ClInclude Include="..\..\beast\utility\noexcept.h" />
<ClInclude Include="..\..\beast\utility\PropertyStream.h" />
<ClInclude Include="..\..\beast\utility\StaticObject.h" />
<ClInclude Include="..\..\beast\Version.h" />
<ClInclude Include="..\..\beast\workaround\noexcept.h" />
<ClInclude Include="..\..\modules\beast_asio\async\AsyncObject.h" />
<ClInclude Include="..\..\modules\beast_asio\basics\FixedInputBuffer.h" />
<ClInclude Include="..\..\modules\beast_asio\basics\PeerRole.h" />
@@ -293,17 +274,11 @@
<ClInclude Include="..\..\modules\beast_core\beast_core.h" />
<ClInclude Include="..\..\modules\beast_core\containers\Array.h" />
<ClInclude Include="..\..\modules\beast_core\containers\ArrayAllocationBase.h" />
<ClInclude Include="..\..\modules\beast_core\containers\DynamicObject.h" />
<ClInclude Include="..\..\modules\beast_core\containers\ElementComparator.h" />
<ClInclude Include="..\..\modules\beast_core\containers\LinkedListPointer.h" />
<ClInclude Include="..\..\modules\beast_core\containers\NamedValueSet.h" />
<ClInclude Include="..\..\modules\beast_core\containers\OwnedArray.h" />
<ClInclude Include="..\..\modules\beast_core\containers\PropertySet.h" />
<ClInclude Include="..\..\modules\beast_core\containers\ScopedValueSetter.h" />
<ClInclude Include="..\..\modules\beast_core\containers\SparseSet.h" />
<ClInclude Include="..\..\modules\beast_core\containers\Variant.h" />
<ClInclude Include="..\..\modules\beast_core\diagnostic\FatalError.h" />
<ClInclude Include="..\..\modules\beast_core\diagnostic\FPUFlags.h" />
<ClInclude Include="..\..\modules\beast_core\diagnostic\SemanticVersion.h" />
<ClInclude Include="..\..\modules\beast_core\diagnostic\Throw.h" />
<ClInclude Include="..\..\modules\beast_core\diagnostic\UnitTest.h" />
@@ -314,40 +289,26 @@
<ClInclude Include="..\..\modules\beast_core\files\FileInputStream.h" />
<ClInclude Include="..\..\modules\beast_core\files\FileOutputStream.h" />
<ClInclude Include="..\..\modules\beast_core\files\FileSearchPath.h" />
<ClInclude Include="..\..\modules\beast_core\files\MemoryMappedFile.h" />
<ClInclude Include="..\..\modules\beast_core\files\RandomAccessFile.h" />
<ClInclude Include="..\..\modules\beast_core\files\TemporaryFile.h" />
<ClInclude Include="..\..\modules\beast_core\json\JSON.h" />
<ClInclude Include="..\..\modules\beast_core\logging\FileLogger.h" />
<ClInclude Include="..\..\modules\beast_core\logging\Logger.h" />
<ClInclude Include="..\..\modules\beast_core\maths\BigInteger.h" />
<ClInclude Include="..\..\modules\beast_core\maths\Math.h" />
<ClInclude Include="..\..\modules\beast_core\maths\Random.h" />
<ClInclude Include="..\..\modules\beast_core\maths\Range.h" />
<ClInclude Include="..\..\modules\beast_core\memory\CacheLine.h" />
<ClInclude Include="..\..\modules\beast_core\memory\MemoryAlignment.h" />
<ClInclude Include="..\..\modules\beast_core\memory\MemoryBlock.h" />
<ClInclude Include="..\..\modules\beast_core\memory\OptionalScopedPointer.h" />
<ClInclude Include="..\..\modules\beast_core\memory\SharedSingleton.h" />
<ClInclude Include="..\..\modules\beast_core\misc\Main.h" />
<ClInclude Include="..\..\modules\beast_core\misc\Result.h" />
<ClInclude Include="..\..\modules\beast_core\misc\Uuid.h" />
<ClInclude Include="..\..\modules\beast_core\misc\WindowsRegistry.h" />
<ClInclude Include="..\..\modules\beast_core\native\android_JNIHelpers.h" />
<ClInclude Include="..\..\modules\beast_core\native\BasicNativeHeaders.h" />
<ClInclude Include="..\..\modules\beast_core\native\osx_ObjCHelpers.h" />
<ClInclude Include="..\..\modules\beast_core\native\posix_SharedCode.h" />
<ClInclude Include="..\..\modules\beast_core\native\win32_ComSmartPtr.h" />
<ClInclude Include="..\..\modules\beast_core\network\MACAddress.h" />
<ClInclude Include="..\..\modules\beast_core\network\Socket.h" />
<ClInclude Include="..\..\modules\beast_core\streams\BufferedInputStream.h" />
<ClInclude Include="..\..\modules\beast_core\streams\FileInputSource.h" />
<ClInclude Include="..\..\modules\beast_core\streams\InputSource.h" />
<ClInclude Include="..\..\modules\beast_core\streams\InputStream.h" />
<ClInclude Include="..\..\modules\beast_core\streams\MemoryInputStream.h" />
<ClInclude Include="..\..\modules\beast_core\streams\MemoryOutputStream.h" />
<ClInclude Include="..\..\modules\beast_core\streams\OutputStream.h" />
<ClInclude Include="..\..\modules\beast_core\streams\SubregionStream.h" />
<ClInclude Include="..\..\modules\beast_core\system\Functional.h" />
<ClInclude Include="..\..\modules\beast_core\system\StandardIncludes.h" />
<ClInclude Include="..\..\modules\beast_core\system\SystemStats.h" />
@@ -355,12 +316,9 @@
<ClInclude Include="..\..\modules\beast_core\system\BoostIncludes.h" />
<ClInclude Include="..\..\modules\beast_core\system\BoostPlaceholdersFix.h" />
<ClInclude Include="..\..\modules\beast_core\system\FunctionalIncludes.h" />
<ClInclude Include="..\..\modules\beast_core\text\Identifier.h" />
<ClInclude Include="..\..\modules\beast_core\text\LexicalCast.h" />
<ClInclude Include="..\..\modules\beast_core\text\LocalisedStrings.h" />
<ClInclude Include="..\..\modules\beast_core\text\StringArray.h" />
<ClInclude Include="..\..\modules\beast_core\text\StringPairArray.h" />
<ClInclude Include="..\..\modules\beast_core\text\StringPool.h" />
<ClInclude Include="..\..\modules\beast_core\threads\ChildProcess.h" />
<ClInclude Include="..\..\modules\beast_core\threads\CriticalSection.h" />
<ClInclude Include="..\..\modules\beast_core\threads\DynamicLibrary.h" />
@@ -368,7 +326,6 @@
<ClInclude Include="..\..\modules\beast_core\threads\InterProcessLock.h" />
<ClInclude Include="..\..\modules\beast_core\threads\Process.h" />
<ClInclude Include="..\..\modules\beast_core\threads\ScopedLock.h" />
<ClInclude Include="..\..\modules\beast_core\threads\SpinDelay.h" />
<ClInclude Include="..\..\modules\beast_core\thread\DeadlineTimer.h" />
<ClInclude Include="..\..\modules\beast_core\thread\Workers.h" />
<ClInclude Include="..\..\modules\beast_core\thread\detail\ScopedLock.h" />
@@ -378,25 +335,10 @@
<ClInclude Include="..\..\modules\beast_core\thread\impl\UntrackedMutexType.h" />
<ClInclude Include="..\..\modules\beast_core\thread\MutexTraits.h" />
<ClInclude Include="..\..\modules\beast_core\thread\TrackedMutex.h" />
<ClInclude Include="..\..\modules\beast_core\time\PerformanceCounter.h" />
<ClInclude Include="..\..\modules\beast_core\time\AtExitHook.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_core\zip\GZIPCompressorOutputStream.h" />
<ClInclude Include="..\..\modules\beast_core\zip\GZIPDecompressorInputStream.h" />
<ClInclude Include="..\..\modules\beast_core\zip\ZipFile.h" />
<ClInclude Include="..\..\modules\beast_core\zip\zlib\crc32.h" />
<ClInclude Include="..\..\modules\beast_core\zip\zlib\deflate.h" />
<ClInclude Include="..\..\modules\beast_core\zip\zlib\inffast.h" />
<ClInclude Include="..\..\modules\beast_core\zip\zlib\inffixed.h" />
<ClInclude Include="..\..\modules\beast_core\zip\zlib\inflate.h" />
<ClInclude Include="..\..\modules\beast_core\zip\zlib\inftrees.h" />
<ClInclude Include="..\..\modules\beast_core\zip\zlib\trees.h" />
<ClInclude Include="..\..\modules\beast_core\zip\zlib\zconf.h" />
<ClInclude Include="..\..\modules\beast_core\zip\zlib\zconf.in.h" />
<ClInclude Include="..\..\modules\beast_core\zip\zlib\zlib.h" />
<ClInclude Include="..\..\modules\beast_core\zip\zlib\zutil.h" />
<ClInclude Include="..\..\modules\beast_sqdb\api\backend.h" />
<ClInclude Include="..\..\modules\beast_sqdb\api\blob.h" />
<ClInclude Include="..\..\modules\beast_sqdb\api\into.h" />
@@ -677,12 +619,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\beast\net\Net.cpp" />
<ClCompile Include="..\..\beast\smart_ptr\impl\AbstractObject.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="..\..\beast\smart_ptr\SmartPtr.cpp" />
<ClCompile Include="..\..\beast\streams\streams.cpp" />
<ClCompile Include="..\..\beast\strings\impl\CharacterFunctions.cpp">
@@ -922,40 +858,10 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\beast_core.cpp" />
<ClCompile Include="..\..\modules\beast_core\containers\DynamicObject.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\containers\NamedValueSet.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\containers\PropertySet.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\containers\Variant.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\diagnostic\FatalError.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\diagnostic\FPUFlags.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\diagnostic\SemanticVersion.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -1016,30 +922,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\json\JSON.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\logging\FileLogger.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\logging\Logger.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\maths\BigInteger.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\maths\Random.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1064,42 +952,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\misc\Uuid.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\android_Files.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\android_Misc.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\android_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\android_SystemStats.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\android_Threads.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_Files.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1148,24 +1000,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\posix_FPUFlags.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\win32_Files.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_FPUFlags.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</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>
@@ -1190,24 +1030,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\network\MACAddress.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\network\Socket.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\streams\BufferedInputStream.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\streams\FileInputSource.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1220,12 +1042,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\streams\MemoryInputStream.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\streams\MemoryOutputStream.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1238,12 +1054,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\streams\SubregionStream.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\system\SystemStats.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1256,24 +1066,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\text\Identifier.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\text\LexicalCast.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\text\LocalisedStrings.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\text\StringArray.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1286,12 +1084,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\text\StringPool.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\ChildProcess.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1304,12 +1096,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\threads\SpinDelay.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\thread\DeadlineTimer.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -1328,12 +1114,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\time\PerformanceCounter.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\time\AtExitHook.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -1358,90 +1138,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\GZIPCompressorOutputStream.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\zip\GZIPDecompressorInputStream.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\zip\ZipFile.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\zip\zlib\adler32.c">
<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\zip\zlib\compress.c">
<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\zip\zlib\crc32.c">
<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\zip\zlib\deflate.c">
<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\zip\zlib\infback.c">
<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\zip\zlib\inffast.c">
<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\zip\zlib\inflate.c">
<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\zip\zlib\inftrees.c">
<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\zip\zlib\trees.c">
<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\zip\zlib\uncompr.c">
<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\zip\zlib\zutil.c">
<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\source\blob.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>

View File

@@ -16,12 +16,6 @@
<None Include="..\..\modules\beast_core\native\mac_Threads.mm">
<Filter>beast_core\native</Filter>
</None>
<None Include="..\..\modules\beast_core\zip\zlib\README">
<Filter>beast_core\zip\zlib</Filter>
</None>
<None Include="..\..\modules\beast_core\native\java\BeastAppActivity.java">
<Filter>beast_core\native\java</Filter>
</None>
<None Include="..\..\.gitattributes">
<Filter>_meta</Filter>
</None>
@@ -90,9 +84,6 @@
<Filter Include="beast_core\files">
<UniqueIdentifier>{3b7d8d7e-eabc-423c-a631-2ff37bf9b9eb}</UniqueIdentifier>
</Filter>
<Filter Include="beast_core\json">
<UniqueIdentifier>{abe24d69-c1d1-49e2-98a1-1e7bf760b97a}</UniqueIdentifier>
</Filter>
<Filter Include="beast_core\maths">
<UniqueIdentifier>{e2339099-bb8e-4437-ae8b-d4f64ef1e3f3}</UniqueIdentifier>
</Filter>
@@ -105,9 +96,6 @@
<Filter Include="beast_core\native">
<UniqueIdentifier>{1d018a70-71b3-4d70-9280-02efd4f348de}</UniqueIdentifier>
</Filter>
<Filter Include="beast_core\network">
<UniqueIdentifier>{ad675f57-9303-4712-9ff2-c7f59f959e7b}</UniqueIdentifier>
</Filter>
<Filter Include="beast_core\streams">
<UniqueIdentifier>{016d839c-4860-4bc3-8f6c-e965f50c2bfa}</UniqueIdentifier>
</Filter>
@@ -126,15 +114,6 @@
<Filter Include="beast_core\xml">
<UniqueIdentifier>{a1a38659-7779-41d6-8a3c-068433c4deaf}</UniqueIdentifier>
</Filter>
<Filter Include="beast_core\zip">
<UniqueIdentifier>{df5f5a69-5919-4a24-bbce-b3f87e4903cf}</UniqueIdentifier>
</Filter>
<Filter Include="beast_core\native\java">
<UniqueIdentifier>{b0d206d9-c002-4be1-b503-4ad16aca838a}</UniqueIdentifier>
</Filter>
<Filter Include="beast_core\zip\zlib">
<UniqueIdentifier>{31038502-9139-4c19-bd67-8f90f08a70ca}</UniqueIdentifier>
</Filter>
<Filter Include="beast_core\diagnostic">
<UniqueIdentifier>{69e28551-92ea-420b-a465-75ed248e3b59}</UniqueIdentifier>
</Filter>
@@ -195,18 +174,12 @@
<Filter Include="beast">
<UniqueIdentifier>{92d1bb42-289a-4444-85c7-cb87540f2fff}</UniqueIdentifier>
</Filter>
<Filter Include="beast\mpl">
<UniqueIdentifier>{5904368f-a0f2-4d26-a031-8cbe4448dc3f}</UniqueIdentifier>
</Filter>
<Filter Include="beast\net">
<UniqueIdentifier>{5faa76ea-5691-4e63-8833-577f92991356}</UniqueIdentifier>
</Filter>
<Filter Include="beast\net\impl">
<UniqueIdentifier>{93670bc9-a748-42bd-8118-8de30c468b16}</UniqueIdentifier>
</Filter>
<Filter Include="beast\type_traits">
<UniqueIdentifier>{85158eb2-9340-4b3d-a136-f7631c7f1b7c}</UniqueIdentifier>
</Filter>
<Filter Include="beast\utility">
<UniqueIdentifier>{56d34c67-7027-44ba-9f09-4591ce4afb36}</UniqueIdentifier>
</Filter>
@@ -270,9 +243,6 @@
<Filter Include="beast\asio\impl">
<UniqueIdentifier>{30b0fdfb-02b6-47dd-bdd9-ffc1f57e1f2c}</UniqueIdentifier>
</Filter>
<Filter Include="beast\smart_ptr\impl">
<UniqueIdentifier>{df4f2935-13a1-4afe-90cc-d86472ec2466}</UniqueIdentifier>
</Filter>
<Filter Include="beast\insight">
<UniqueIdentifier>{174b9125-76a7-4796-be97-79c2dcc751f1}</UniqueIdentifier>
</Filter>
@@ -315,9 +285,6 @@
<Filter Include="beast\asio\tests">
<UniqueIdentifier>{f2594738-6447-447b-8f51-2d42fbe8a6ee}</UniqueIdentifier>
</Filter>
<Filter Include="beast\workaround">
<UniqueIdentifier>{84acd0d5-5531-470e-b9a7-42af9003aa64}</UniqueIdentifier>
</Filter>
<Filter Include="beast\streams">
<UniqueIdentifier>{899ea9a6-1969-4cde-b26d-8ad60acebfa4}</UniqueIdentifier>
</Filter>
@@ -335,33 +302,18 @@
<ClInclude Include="..\..\modules\beast_core\containers\ArrayAllocationBase.h">
<Filter>beast_core\containers</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\containers\DynamicObject.h">
<Filter>beast_core\containers</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\containers\ElementComparator.h">
<Filter>beast_core\containers</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\containers\LinkedListPointer.h">
<Filter>beast_core\containers</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\containers\NamedValueSet.h">
<Filter>beast_core\containers</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\containers\OwnedArray.h">
<Filter>beast_core\containers</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\containers\PropertySet.h">
<Filter>beast_core\containers</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\containers\ScopedValueSetter.h">
<Filter>beast_core\containers</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\containers\SparseSet.h">
<Filter>beast_core\containers</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\containers\Variant.h">
<Filter>beast_core\containers</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\files\DirectoryIterator.h">
<Filter>beast_core\files</Filter>
</ClInclude>
@@ -377,24 +329,12 @@
<ClInclude Include="..\..\modules\beast_core\files\FileSearchPath.h">
<Filter>beast_core\files</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\files\MemoryMappedFile.h">
<Filter>beast_core\files</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\files\TemporaryFile.h">
<Filter>beast_core\files</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\json\JSON.h">
<Filter>beast_core\json</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\logging\FileLogger.h">
<Filter>beast_core\logging</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\logging\Logger.h">
<Filter>beast_core\logging</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\maths\BigInteger.h">
<Filter>beast_core\maths</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\maths\Random.h">
<Filter>beast_core\maths</Filter>
</ClInclude>
@@ -404,21 +344,12 @@
<ClInclude Include="..\..\modules\beast_core\memory\MemoryBlock.h">
<Filter>beast_core\memory</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\memory\OptionalScopedPointer.h">
<Filter>beast_core\memory</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\misc\Result.h">
<Filter>beast_core\misc</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\misc\Uuid.h">
<Filter>beast_core\misc</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\misc\WindowsRegistry.h">
<Filter>beast_core\misc</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\native\android_JNIHelpers.h">
<Filter>beast_core\native</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\native\BasicNativeHeaders.h">
<Filter>beast_core\native</Filter>
</ClInclude>
@@ -431,15 +362,6 @@
<ClInclude Include="..\..\modules\beast_core\native\win32_ComSmartPtr.h">
<Filter>beast_core\native</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\network\MACAddress.h">
<Filter>beast_core\network</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\network\Socket.h">
<Filter>beast_core\network</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\streams\BufferedInputStream.h">
<Filter>beast_core\streams</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\streams\FileInputSource.h">
<Filter>beast_core\streams</Filter>
</ClInclude>
@@ -449,33 +371,18 @@
<ClInclude Include="..\..\modules\beast_core\streams\InputStream.h">
<Filter>beast_core\streams</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\streams\MemoryInputStream.h">
<Filter>beast_core\streams</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\streams\MemoryOutputStream.h">
<Filter>beast_core\streams</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\streams\OutputStream.h">
<Filter>beast_core\streams</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\streams\SubregionStream.h">
<Filter>beast_core\streams</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\text\Identifier.h">
<Filter>beast_core\text</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\text\LocalisedStrings.h">
<Filter>beast_core\text</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\text\StringArray.h">
<Filter>beast_core\text</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\text\StringPairArray.h">
<Filter>beast_core\text</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\text\StringPool.h">
<Filter>beast_core\text</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\threads\ChildProcess.h">
<Filter>beast_core\threads</Filter>
</ClInclude>
@@ -497,9 +404,6 @@
<ClInclude Include="..\..\modules\beast_core\threads\ScopedLock.h">
<Filter>beast_core\threads</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\time\PerformanceCounter.h">
<Filter>beast_core\time</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\time\Time.h">
<Filter>beast_core\time</Filter>
</ClInclude>
@@ -509,60 +413,6 @@
<ClInclude Include="..\..\modules\beast_core\xml\XmlElement.h">
<Filter>beast_core\xml</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\GZIPCompressorOutputStream.h">
<Filter>beast_core\zip</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\GZIPDecompressorInputStream.h">
<Filter>beast_core\zip</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\ZipFile.h">
<Filter>beast_core\zip</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\zlib\crc32.h">
<Filter>beast_core\zip\zlib</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\zlib\deflate.h">
<Filter>beast_core\zip\zlib</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\zlib\inffast.h">
<Filter>beast_core\zip\zlib</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\zlib\inffixed.h">
<Filter>beast_core\zip\zlib</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\zlib\inflate.h">
<Filter>beast_core\zip\zlib</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\zlib\inftrees.h">
<Filter>beast_core\zip\zlib</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\zlib\trees.h">
<Filter>beast_core\zip\zlib</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\zlib\zconf.h">
<Filter>beast_core\zip\zlib</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\zlib\zconf.in.h">
<Filter>beast_core\zip\zlib</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\zlib\zlib.h">
<Filter>beast_core\zip\zlib</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\zip\zlib\zutil.h">
<Filter>beast_core\zip\zlib</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\memory\CacheLine.h">
<Filter>beast_core\memory</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\memory\MemoryAlignment.h">
<Filter>beast_core\memory</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\threads\SpinDelay.h">
<Filter>beast_core\threads</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\diagnostic\FPUFlags.h">
<Filter>beast_core\diagnostic</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\diagnostic\Throw.h">
<Filter>beast_core\diagnostic</Filter>
</ClInclude>
@@ -818,33 +668,9 @@
<ClInclude Include="..\..\beast\CStdInt.h">
<Filter>beast</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\MPL.h">
<Filter>beast</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\Net.h">
<Filter>beast</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\TypeTraits.h">
<Filter>beast</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\type_traits\IsSigned.h">
<Filter>beast\type_traits</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\type_traits\IntegralConstant.h">
<Filter>beast\type_traits</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\type_traits\IsIntegral.h">
<Filter>beast\type_traits</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\utility\Journal.h">
<Filter>beast\utility</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\Utility.h">
<Filter>beast</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\mpl\IsCallPossible.h">
<Filter>beast\mpl</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\Uncopyable.h">
<Filter>beast</Filter>
</ClInclude>
@@ -869,9 +695,6 @@
<ClInclude Include="..\..\beast\http\impl\http-parser\http_parser.h">
<Filter>beast\http\impl\http-parser</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\HTTP.h">
<Filter>beast</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\strings\CharacterFunctions.h">
<Filter>beast\strings</Filter>
</ClInclude>
@@ -1088,18 +911,12 @@
<ClInclude Include="..\..\beast\threads\ScopedWrapperContext.h">
<Filter>beast\threads</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\Asio.h">
<Filter>beast</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\asio\IPAddressConversion.h">
<Filter>beast\asio</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\crypto\MurmurHash.h">
<Filter>beast\crypto</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\smart_ptr\AbstractObject.h">
<Filter>beast\smart_ptr</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\Insight.h">
<Filter>beast</Filter>
</ClInclude>
@@ -1202,9 +1019,6 @@
<ClInclude Include="..\..\beast\chrono\chrono_util.h">
<Filter>beast\chrono</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\chrono\CPUMeter.h">
<Filter>beast\chrono</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\chrono\manual_clock.h">
<Filter>beast\chrono</Filter>
</ClInclude>
@@ -1214,12 +1028,6 @@
<ClInclude Include="..\..\beast\chrono\RelativeTime.h">
<Filter>beast\chrono</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\chrono\ScopedTimeInterval.h">
<Filter>beast\chrono</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\type_traits\maybe_const.h">
<Filter>beast\type_traits</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\utility\empty_base_optimization.h">
<Filter>beast\utility</Filter>
</ClInclude>
@@ -1335,9 +1143,6 @@
<ClInclude Include="..\..\beast\container\cyclic_iterator.h">
<Filter>beast\container</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\workaround\noexcept.h">
<Filter>beast\workaround</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\streams\abstract_ostream.h">
<Filter>beast\streams</Filter>
</ClInclude>
@@ -1347,20 +1152,17 @@
<ClInclude Include="..\..\beast\streams\basic_scoped_ostream.h">
<Filter>beast\streams</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\utility\maybe_const.h">
<Filter>beast\utility</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\utility\is_call_possible.h">
<Filter>beast\utility</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\utility\noexcept.h">
<Filter>beast\utility</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\modules\beast_core\containers\DynamicObject.cpp">
<Filter>beast_core\containers</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\containers\NamedValueSet.cpp">
<Filter>beast_core\containers</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\containers\PropertySet.cpp">
<Filter>beast_core\containers</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\containers\Variant.cpp">
<Filter>beast_core\containers</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\files\DirectoryIterator.cpp">
<Filter>beast_core\files</Filter>
</ClCompile>
@@ -1379,18 +1181,9 @@
<ClCompile Include="..\..\modules\beast_core\files\TemporaryFile.cpp">
<Filter>beast_core\files</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\json\JSON.cpp">
<Filter>beast_core\json</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\logging\FileLogger.cpp">
<Filter>beast_core\logging</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\logging\Logger.cpp">
<Filter>beast_core\logging</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\maths\BigInteger.cpp">
<Filter>beast_core\maths</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\maths\Random.cpp">
<Filter>beast_core\maths</Filter>
</ClCompile>
@@ -1400,24 +1193,6 @@
<ClCompile Include="..\..\modules\beast_core\misc\Result.cpp">
<Filter>beast_core\misc</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\misc\Uuid.cpp">
<Filter>beast_core\misc</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\android_Files.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\android_Misc.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\android_Network.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\android_SystemStats.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\android_Threads.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\linux_Files.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
@@ -1445,57 +1220,30 @@
<ClCompile Include="..\..\modules\beast_core\native\win32_Threads.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\network\MACAddress.cpp">
<Filter>beast_core\network</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\network\Socket.cpp">
<Filter>beast_core\network</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\streams\BufferedInputStream.cpp">
<Filter>beast_core\streams</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\streams\FileInputSource.cpp">
<Filter>beast_core\streams</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\streams\InputStream.cpp">
<Filter>beast_core\streams</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\streams\MemoryInputStream.cpp">
<Filter>beast_core\streams</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\streams\MemoryOutputStream.cpp">
<Filter>beast_core\streams</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\streams\OutputStream.cpp">
<Filter>beast_core\streams</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\streams\SubregionStream.cpp">
<Filter>beast_core\streams</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\text\Identifier.cpp">
<Filter>beast_core\text</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\text\LocalisedStrings.cpp">
<Filter>beast_core\text</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\text\StringArray.cpp">
<Filter>beast_core\text</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\text\StringPairArray.cpp">
<Filter>beast_core\text</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\text\StringPool.cpp">
<Filter>beast_core\text</Filter>
</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\PerformanceCounter.cpp">
<Filter>beast_core\time</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\time\Time.cpp">
<Filter>beast_core\time</Filter>
</ClCompile>
@@ -1505,48 +1253,6 @@
<ClCompile Include="..\..\modules\beast_core\xml\XmlElement.cpp">
<Filter>beast_core\xml</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\GZIPCompressorOutputStream.cpp">
<Filter>beast_core\zip</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\GZIPDecompressorInputStream.cpp">
<Filter>beast_core\zip</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\ZipFile.cpp">
<Filter>beast_core\zip</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\zlib\adler32.c">
<Filter>beast_core\zip\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\zlib\compress.c">
<Filter>beast_core\zip\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\zlib\crc32.c">
<Filter>beast_core\zip\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\zlib\deflate.c">
<Filter>beast_core\zip\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\zlib\infback.c">
<Filter>beast_core\zip\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\zlib\inffast.c">
<Filter>beast_core\zip\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\zlib\inflate.c">
<Filter>beast_core\zip\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\zlib\inftrees.c">
<Filter>beast_core\zip\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\zlib\trees.c">
<Filter>beast_core\zip\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\zlib\uncompr.c">
<Filter>beast_core\zip\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\zip\zlib\zutil.c">
<Filter>beast_core\zip\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\bsd_SystemStats.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
@@ -1559,18 +1265,6 @@
<ClCompile Include="..\..\modules\beast_core\native\bsd_Threads.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\diagnostic\FPUFlags.cpp">
<Filter>beast_core\diagnostic</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\threads\SpinDelay.cpp">
<Filter>beast_core\threads</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\posix_FPUFlags.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\native\win32_FPUFlags.cpp">
<Filter>beast_core\native</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_core\diagnostic\UnitTest.cpp">
<Filter>beast_core\diagnostic</Filter>
</ClCompile>
@@ -1844,9 +1538,6 @@
<ClCompile Include="..\..\beast\crypto\impl\MurmurHash.cpp">
<Filter>beast\crypto\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\beast\smart_ptr\impl\AbstractObject.cpp">
<Filter>beast\smart_ptr\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\beast\insight\Insight.cpp">
<Filter>beast\insight</Filter>
</ClCompile>

View File

@@ -27,7 +27,7 @@
#include "Config.h"
#include "CStdInt.h"
#include "workaround/noexcept.h"
#include "utility/noexcept.h"
#include <cmath>
#include <algorithm>

View File

@@ -1,23 +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_ASIO_H_INCLUDED
#define BEAST_ASIO_H_INCLUDED
#endif

View File

@@ -28,7 +28,7 @@
#include "CStdInt.h"
#include "StaticAssert.h"
#include "workaround/noexcept.h"
#include "utility/noexcept.h"
namespace beast {

View File

@@ -27,8 +27,6 @@
#include "chrono/manual_clock.h"
#include "chrono/ratio_io.h"
#include "chrono/CPUMeter.h"
#include "chrono/RelativeTime.h"
#include "chrono/ScopedTimeInterval.h"
#endif

View File

@@ -1,26 +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_HTTP_H_INCLUDED
#define BEAST_HTTP_H_INCLUDED
#include "http/URL.h"
#include "http/ParsedURL.h"
#endif

View File

@@ -1,25 +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_MPL_H_INCLUDED
#define BEAST_MPL_H_INCLUDED
#include "mpl/IsCallPossible.h"
#endif

View File

@@ -1,30 +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_NET_H_INCLUDED
#define BEAST_NET_H_INCLUDED
#include "net/DynamicBuffer.h"
#include "net/IPEndpoint.h"
#include "net/IPAddressV4.h"
#include "net/IPAddressV6.h"
#include "net/IPEndpoint.h"
#endif

View File

@@ -22,7 +22,6 @@
#include "Config.h"
#include "smart_ptr/AbstractObject.h"
#include "smart_ptr/ContainerDeletePolicy.h"
#include "smart_ptr/SharedObject.h"
#include "smart_ptr/SharedPtr.h"

View File

@@ -1,27 +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_TYPETRAITS_H_INCLUDED
#define BEAST_TYPETRAITS_H_INCLUDED
#include "type_traits/IntegralConstant.h"
#include "type_traits/IsIntegral.h"
#include "type_traits/IsSigned.h"
#endif

View File

@@ -1,33 +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_UTILITY_H_INCLUDED
#define BEAST_UTILITY_H_INCLUDED
#include "utility/Debug.h"
#include "utility/Error.h"
#include "utility/Journal.h"
#include "utility/LeakChecked.h"
#include "utility/PropertyStream.h"
#include "utility/StaticObject.h"
#include "utility/hash_pair.h"
#endif

View File

@@ -22,7 +22,7 @@
#include <boost/asio/buffer.hpp>
#include "../workaround/noexcept.h"
#include "../utility/noexcept.h"
#include <algorithm>
#include <iterator>
#include "../cxx14/type_traits.h" // <type_traits>

View File

@@ -22,7 +22,7 @@
#include "wrap_handler.h"
#include "../mpl/IsCallPossible.h"
#include "../utility/is_call_possible.h"
#include <boost/asio/detail/handler_alloc_helpers.hpp>
#include <boost/asio/detail/handler_cont_helpers.hpp>

View File

@@ -24,7 +24,7 @@
#include <boost/asio/buffer.hpp>
#include "../workaround/noexcept.h"
#include "../utility/noexcept.h"
#include <cstddef>
#include <memory>
#include <type_traits>

View File

@@ -22,14 +22,14 @@
#include "../Config.h"
#include "../mpl/IsCallPossible.h"
#include "../utility/is_call_possible.h"
#include <boost/utility/base_from_member.hpp>
#include <boost/asio/detail/handler_alloc_helpers.hpp>
#include <boost/asio/detail/handler_cont_helpers.hpp>
#include <boost/asio/detail/handler_invoke_helpers.hpp>
#include "../workaround/noexcept.h"
#include "../utility/noexcept.h"
#include <functional>
#include <memory>
#include "../cxx14/type_traits.h" // <type_traits>

View File

@@ -23,7 +23,7 @@
#include "abstract_socket.h"
#include "bind_handler.h"
#include "../workaround/noexcept.h"
#include "../utility/noexcept.h"
namespace beast {
namespace asio {

View File

@@ -1,159 +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_CHRONO_CPUMETER_H_INCLUDED
#define BEAST_CHRONO_CPUMETER_H_INCLUDED
#include "RelativeTime.h"
#include "ScopedTimeInterval.h"
#include "../threads/SharedData.h"
#include "../Atomic.h"
namespace beast {
/** Measurements of CPU utilization. */
class CPUMeter
{
private:
struct MeasureIdle
{
explicit MeasureIdle (CPUMeter& meter)
: m_meter (&meter)
{ }
void operator() (RelativeTime const& interval) const
{ m_meter->addIdleTime (interval); }
CPUMeter* m_meter;
};
struct MeasureActive
{
explicit MeasureActive (CPUMeter& meter)
: m_meter (&meter)
{ }
void operator() (RelativeTime const& interval) const
{ m_meter->addActiveTime (interval); }
CPUMeter* m_meter;
};
enum
{
// The amount of time an aggregate must accrue before a swap
secondsPerAggregate = 3
// The number of aggregates in the rolling history buffer
,numberOfAggregates = 20
};
// Aggregated sample data
struct Aggregate
{
RelativeTime idle;
RelativeTime active;
// Returns the total number of seconds in the aggregate
double seconds () const
{ return idle.inSeconds() + active.inSeconds(); }
// Reset the accumulated times
void clear ()
{ idle = RelativeTime (0); active = RelativeTime (0); }
Aggregate& operator+= (Aggregate const& other)
{ idle += other.idle; active += other.active; return *this; }
Aggregate& operator-= (Aggregate const& other)
{ idle -= other.idle; active -= other.active; return *this; }
};
struct State
{
State () : index (0)
{
}
// Returns a reference to the current aggregate
Aggregate& front ()
{
return history [index];
}
// Checks the current aggregate to see if we should advance
void update()
{
if (front().seconds() >= secondsPerAggregate)
advance();
}
// Advance the index in the rolling history
void advance ()
{
usage += history [index];
index = (index+1) % numberOfAggregates;
usage -= history [index];
history [index].clear ();
}
// Index of the current aggregate we are accumulating
int index;
// Delta summed usage over the entire history buffer
Aggregate usage;
// The rolling history buffer
Aggregate history [numberOfAggregates];
};
typedef SharedData <State> SharedState;
SharedState m_state;
void addIdleTime (RelativeTime const& interval)
{
SharedState::Access state (m_state);
state->front().idle += interval;
state->update();
}
void addActiveTime (RelativeTime const& interval)
{
SharedState::Access state (m_state);
state->front().active += interval;
state->update();
}
public:
/** The type of container that measures idle time. */
typedef ScopedTimeInterval <MeasureIdle> ScopedIdleTime;
typedef ScopedTimeInterval <MeasureActive> ScopedActiveTime;
/** Returns the fraction of time that the CPU is being used. */
double getUtilization () const
{
SharedState::ConstAccess state (m_state);
double const seconds (state->usage.seconds());
if (seconds > 0)
return (state->usage.active.inSeconds() / seconds);
return 0;
}
};
}
#endif

View File

@@ -28,5 +28,4 @@
#include "impl/chrono_io.cpp"
#include "impl/basic_seconds_clock.cpp"
#include "impl/CPUMeter.cpp"
#include "impl/RelativeTime.cpp"

View File

@@ -27,7 +27,7 @@
#include "../Config.h"
#include "../strings/String.h"
#include "../workaround/noexcept.h"
#include "../utility/noexcept.h"
#include <string>
#include <sstream>

View File

@@ -1,62 +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_CHRONO_SCOPEDTIMEINTERVAL_H_INCLUDED
#define BEAST_CHRONO_SCOPEDTIMEINTERVAL_H_INCLUDED
#include "../Uncopyable.h"
#include "RelativeTime.h"
namespace beast {
/** Time measurement using scoped RAII container.
UnaryFunction will be called with this signature:
void (RelativeTime const& interval);
*/
template <class UnaryFunction>
class ScopedTimeInterval : public Uncopyable
{
public:
/** Create the measurement with a default-constructed UnaryFunction. */
ScopedTimeInterval ()
: m_start (RelativeTime::fromStartup())
{
}
/** Create the measurement with UnaryFunction constructed from one argument. */
template <typename Arg>
explicit ScopedTimeInterval (Arg& arg)
: m_func (arg)
, m_start (RelativeTime::fromStartup ())
{
}
~ScopedTimeInterval ()
{
m_func (RelativeTime::fromStartup() - m_start);
}
private:
UnaryFunction m_func;
RelativeTime m_start;
};
}
#endif

View File

@@ -29,7 +29,7 @@
#include "../Config.h"
#include "../workaround/noexcept.h"
#include "../utility/noexcept.h"
#include <ctime>
#include <locale>

View File

@@ -1,21 +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.
*/
//==============================================================================
#include "../CPUMeter.h"

View File

@@ -19,4 +19,4 @@
// Microsoft Visual C++ compiler configuration
#include "../../workaround/noexcept.h"
#include "../../utility/noexcept.h"

View File

@@ -19,7 +19,7 @@
#include <typeinfo>
#include "../IPAddress.h"
#include "../IPEndpoint.h"
#include "../detail/Parse.h"
namespace beast {

View File

@@ -1,255 +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_SMARTPTR_ABSTRACTOBJECT_H_INCLUDED
#define BEAST_SMARTPTR_ABSTRACTOBJECT_H_INCLUDED
#include <list>
#include <memory>
#include <stdexcept>
#include <typeinfo>
#include "../Atomic.h"
#include "../Config.h"
#include "../Uncopyable.h"
#include "../intrusive/LockFreeStack.h"
namespace beast {
namespace abstract {
/** Base for all abstract interfaces. */
class BasicInterface
{
public:
virtual ~BasicInterface() { }
/** Returns the unique ID of this interface type.
The ID must be the same for all instances of the
derived interface.
*/
virtual std::size_t id () const = 0;
/** Returns the unique ID associated with the Derived type. */
template <typename Derived>
static std::size_t type_id ()
{
static std::size_t const value (next_id ());
return value;
}
private:
// Returns a new unique id
static std::size_t next_id ()
{
static Atomic <std::size_t> value;
return ++value;
}
};
//------------------------------------------------------------------------------
/** Base for a derived interface. */
template <typename Derived>
class Interface : public BasicInterface
{
public:
// Returns the unique ID for all instances of Derived
std::size_t id () const
{
return BasicInterface::type_id <Derived> ();
}
};
//------------------------------------------------------------------------------
/** Factory for producing interfaces on a specific object. */
template <typename Object>
class Factory
{
public:
class Callback;
private:
struct Item;
typedef LockFreeStack <Item> Items;
struct Item : Items::Node
{
Item (Callback& owner_)
: owner (owner_)
{ }
Callback& owner;
};
Items m_items;
public:
/** Base for hooking object creation. */
class Callback
{
public:
/** Create the callback and insert it into the factory. */
explicit Callback (Factory& factory)
: m_item (*this)
{
factory.m_items.push_front (&m_item);
}
/** Called when Object is created.
Object must be fully constructed. The order of calls to callbacks
is not defined.
*/
virtual void create_interfaces (Object& object) = 0;
private:
Item m_item;
};
/** Invokes the callbacks for an instance of Object.
This must be called after the object is fully constructed, for example
as the last statement in the constructor.
*/
void create_interfaces (Object& object)
{
for (typename Items::iterator iter (m_items.begin());
iter != m_items.end(); ++iter)
iter->owner.create_interfaces (object);
}
};
//------------------------------------------------------------------------------
/** A container of polymorphic interfaces.
The Object type associated with the container is used to gain access
to the corresponding factory.
*/
template <typename Object>
class Interfaces : public Uncopyable
{
public:
Interfaces ()
{
}
/** Returns a reference to the specified interface.
The interface must exist in the container or an exception is thrown.
Requirements:
Derived must be a subclass of Interface
*/
/** @{ */
template <typename Derived>
Derived& get_interface()
{
Derived* derived (find_interface <Derived> ());
if (derived == nullptr)
throw std::bad_cast ();
return *derived;
}
template <typename Derived>
Derived const& get_interface() const
{
Derived const* derived (find_interface <Derived> ());
if (derived == nullptr)
throw std::bad_cast ();
return *derived;
}
/** @} */
/** Returns a pointer to the specified interface.
If the interface does not exist, `nullptr` is returned.
Requirements:
Derived must be a subclass of Interface
*/
/** @{ */
template <typename Derived>
Derived* find_interface()
{
std::size_t const id = BasicInterface::type_id <Derived> ();
for (typename Set::iterator iter (m_set.begin());
iter != m_set.end(); ++iter)
{
if ((*iter)->id() == id)
{
Derived* const derived (
dynamic_cast <Derived*> (iter->get()));
check_postcondition (derived != nullptr);
return derived;
}
}
return nullptr;
}
template <typename Derived>
Derived const* find_interface() const
{
std::size_t const id = BasicInterface::type_id <Derived> ();
for (typename Set::const_iterator iter (m_set.begin());
iter != m_set.end(); ++iter)
{
if ((*iter)->id() == id)
{
Derived const* const derived (
dynamic_cast <Derived const*> (iter->get()));
check_postcondition (derived != nullptr);
return derived;
}
}
return nullptr;
}
template <typename Derived>
bool has_interface() const
{
return find_interface <Derived> () != nullptr;
}
/** @} */
/** Adds the specified interface to the container.
Ownership of the object, which must be allocated via operator new,
is transferred to the container. If the interface already exists,
an exception is thrown.
Requirements:
Derived must be a subclass of Interface
*/
template <typename Derived>
void add_interface (Derived* derived)
{
std::unique_ptr <BasicInterface> base_interface (
derived);
if (has_interface <Derived> ())
throw std::invalid_argument ("non-unique");
m_set.emplace_back (base_interface.release ());
}
private:
typedef std::list <std::unique_ptr <BasicInterface>> Set;
Set m_set;
};
}
}
#endif

View File

@@ -29,5 +29,3 @@
#include "SharedPtr.h"
#include "../../modules/beast_core/beast_core.h" // for UnitTest
#include "impl/AbstractObject.cpp"

View File

@@ -1,147 +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.
*/
//==============================================================================
#include "../AbstractObject.h"
namespace beast {
namespace abstract {
class AbstractObjectTests : public UnitTest
{
public:
class Object : public Interfaces <Object>
{
public:
explicit Object (UnitTest& test)
: m_test (test)
{
}
UnitTest& test ()
{
return m_test;
}
private:
UnitTest& m_test;
};
//--------------------------------------------------------------------------
class Interface1 : public Interface <Interface1>
{
public:
Interface1 ()
{
}
};
class Callback1 : public Factory <Object>::Callback
{
public:
explicit Callback1 (Factory <Object>& factory)
: Factory <Object>::Callback (factory)
{
}
void create_interfaces (Object& object)
{
object.add_interface (new Interface1);
}
};
//--------------------------------------------------------------------------
class Interface2 : public Interface <Interface2>
{
public:
Interface2 ()
{
}
};
class Callback2 : public Factory <Object>::Callback
{
public:
explicit Callback2 (Factory <Object>& factory)
: Factory <Object>::Callback (factory)
{
}
void create_interfaces (Object& object)
{
object.add_interface (new Interface2);
}
};
//--------------------------------------------------------------------------
void runTest ()
{
beginTestCase ("create");
Factory <Object> factory;
Callback1 callback1 (factory);
Callback2 callback2 (factory);
Object object (*this);
factory.create_interfaces (object);
// find existing interfaces
expect (object.find_interface <Interface1> () != nullptr);
expect (object.find_interface <Interface2> () != nullptr);
// add duplicate interface
try
{
object.add_interface (new Interface1);
fail ("uncaught exeption");
}
catch (std::invalid_argument const&)
{
pass ();
}
// request missing interface
try
{
struct MissingInterface { };
object.get_interface <MissingInterface> ();
fail ("uncaught exeption");
}
catch (std::bad_cast const&)
{
pass ();
}
}
AbstractObjectTests () : UnitTest (
"AbstractObject", "beast", runManual)
{
}
};
static AbstractObjectTests abstractObjectTests;
}
}

View File

@@ -20,7 +20,6 @@
#ifndef BEAST_THREADS_SERVICEQUEUE_H_INCLUDED
#define BEAST_THREADS_SERVICEQUEUE_H_INCLUDED
#include "../chrono/CPUMeter.h"
#include "../intrusive/List.h"
#include "SharedData.h"
#include "ThreadLocalValue.h"
@@ -395,7 +394,6 @@ protected:
typedef SharedData <State> SharedState;
SharedState m_state;
CPUMeter m_cpuMeter;
Atomic <int> m_stopped;
static ThreadLocalValue <ServiceQueueBase*> s_service;
@@ -463,10 +461,6 @@ public:
}
}
/** Returns the percentage of time the queue is using the CPU. */
double getUtilization () const
{ return m_cpuMeter.getUtilization(); }
/** Returns the allocator associated with the container. */
allocator_type get_allocator() const
{

View File

@@ -53,8 +53,6 @@ ServiceQueueBase::~ServiceQueueBase()
std::size_t ServiceQueueBase::poll ()
{
CPUMeter::ScopedActiveTime interval (m_cpuMeter);
std::size_t total (0);
ScopedServiceThread thread (this);
for (;;)
@@ -69,8 +67,6 @@ std::size_t ServiceQueueBase::poll ()
std::size_t ServiceQueueBase::poll_one ()
{
CPUMeter::ScopedActiveTime interval (m_cpuMeter);
ScopedServiceThread thread (this);
return dequeue();
}
@@ -81,15 +77,8 @@ std::size_t ServiceQueueBase::run ()
ScopedServiceThread thread (this);
while (! stopped())
{
{
CPUMeter::ScopedActiveTime interval (m_cpuMeter);
total += poll ();
}
{
CPUMeter::ScopedIdleTime interval (m_cpuMeter);
wait ();
}
total += poll ();
wait ();
}
return total;
}
@@ -100,17 +89,10 @@ std::size_t ServiceQueueBase::run_one ()
ScopedServiceThread (this);
for (;;)
{
{
CPUMeter::ScopedActiveTime interval (m_cpuMeter);
n = poll_one();
if (n != 0)
break;
}
{
CPUMeter::ScopedIdleTime interval (m_cpuMeter);
wait();
}
n = poll_one();
if (n != 0)
break;
wait();
}
return n;
}

View File

@@ -1,40 +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_TYPE_TRAITS_INTEGRALCONSTANT_H_INCLUDED
#define BEAST_TYPE_TRAITS_INTEGRALCONSTANT_H_INCLUDED
namespace beast {
// ideas from boost
template <class T, T val>
struct IntegralConstant
{
typedef IntegralConstant <T, val> type;
typedef T value_type;
static const T value = val;
};
typedef IntegralConstant <bool, true> TrueType;
typedef IntegralConstant <bool, false> FalseType;
}
#endif

View File

@@ -1,42 +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_TYPE_TRAITS_ISINTEGRAL_H_INCLUDED
#define BEAST_TYPE_TRAITS_ISINTEGRAL_H_INCLUDED
#include "../CStdInt.h"
#include "IntegralConstant.h"
namespace beast {
template <typename T> struct IsIntegral : FalseType { };
template <> struct IsIntegral <int8> : TrueType { };
template <> struct IsIntegral <int16> : TrueType { };
template <> struct IsIntegral <int32> : TrueType { };
template <> struct IsIntegral <int64> : TrueType { };
template <> struct IsIntegral <uint8> : TrueType { };
template <> struct IsIntegral <uint16> : TrueType { };
template <> struct IsIntegral <uint32> : TrueType { };
template <> struct IsIntegral <uint64> : TrueType { };
template <> struct IsIntegral <wchar_t> : TrueType { };
}
#endif

View File

@@ -1,40 +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_TYPE_TRAITS_ISSIGNED_H_INCLUDED
#define BEAST_TYPE_TRAITS_ISSIGNED_H_INCLUDED
#include "IntegralConstant.h"
#include "../CStdInt.h"
namespace beast {
template <typename T> struct IsSigned : FalseType { };
template <> struct IsSigned <int8> : TrueType { };
template <> struct IsSigned <int16> : TrueType { };
template <> struct IsSigned <int32> : TrueType { };
template <> struct IsSigned <int64> : TrueType { };
template <> struct IsSigned <float> : TrueType { };
template <> struct IsSigned <double> : TrueType { };
template <> struct IsSigned <wchar_t> : TrueType { };
}
#endif

View File

@@ -20,7 +20,7 @@
#ifndef BEAST_UTILITY_EMPTY_BASE_OPTIMIZATION_H_INCLUDED
#define BEAST_UTILITY_EMPTY_BASE_OPTIMIZATION_H_INCLUDED
#include "../workaround/noexcept.h"
#include "../utility/noexcept.h"
#include <type_traits>
#include <utility>

View File

@@ -17,13 +17,12 @@
*/
//==============================================================================
#ifndef BEAST_MPL_ISCALLPOSSIBLE_H_INCLUDED
#define BEAST_MPL_ISCALLPOSSIBLE_H_INCLUDED
#ifndef BEAST_UTILITY_ISCALLPOSSIBLE_H_INCLUDED
#define BEAST_UTILITY_ISCALLPOSSIBLE_H_INCLUDED
#include "../cxx14/type_traits.h" // <type_traits>
namespace beast {
namespace mpl {
// inspired by Roman Perepelitsa's presentation from comp.lang.c++.moderated
// based on the implementation here: http://www.rsdn.ru/forum/cpp/2759773.1.aspx
@@ -176,7 +175,7 @@ private:
private: derived (); \
}; \
\
typedef typename beast::mpl::is_call_possible_detail::clone_constness<T, derived>::type derived_type; \
typedef typename beast::is_call_possible_detail::clone_constness<T, derived>::type derived_type; \
\
template <typename U, typename Result> \
struct return_value_check \
@@ -184,7 +183,7 @@ private:
static yes deduce(Result); \
static no deduce(...); \
static no deduce(no); \
static no deduce(beast::mpl::is_call_possible_detail::void_exp_result<T>); \
static no deduce(beast::is_call_possible_detail::void_exp_result<T>); \
}; \
\
template <typename U> \
@@ -203,25 +202,25 @@ private:
template <typename Result> \
struct impl<true, Result(void)> \
{ \
static typename beast::mpl::is_call_possible_detail::add_reference<derived_type>::type test_me; \
static typename beast::is_call_possible_detail::add_reference<derived_type>::type test_me; \
\
static const bool value = \
sizeof( \
return_value_check<T, Result>::deduce( \
(test_me.member_function_name(), beast::mpl::is_call_possible_detail::void_exp_result<T>())) \
(test_me.member_function_name(), beast::is_call_possible_detail::void_exp_result<T>())) \
) == sizeof(yes); \
}; \
\
template <typename Result, typename Arg> \
struct impl<true, Result(Arg)> \
{ \
static typename beast::mpl::is_call_possible_detail::add_reference<derived_type>::type test_me; \
static typename beast::mpl::is_call_possible_detail::add_reference<Arg>::type arg; \
static typename beast::is_call_possible_detail::add_reference<derived_type>::type test_me; \
static typename beast::is_call_possible_detail::add_reference<Arg>::type arg; \
\
static const bool value = \
sizeof( \
return_value_check<T, Result>::deduce( \
(test_me.member_function_name(arg), beast::mpl::is_call_possible_detail::void_exp_result<T>()) \
(test_me.member_function_name(arg), beast::is_call_possible_detail::void_exp_result<T>()) \
) \
) == sizeof(yes); \
}; \
@@ -229,14 +228,14 @@ private:
template <typename Result, typename Arg1, typename Arg2> \
struct impl<true, Result(Arg1,Arg2)> \
{ \
static typename beast::mpl::is_call_possible_detail::add_reference<derived_type>::type test_me; \
static typename beast::mpl::is_call_possible_detail::add_reference<Arg1>::type arg1; \
static typename beast::mpl::is_call_possible_detail::add_reference<Arg2>::type arg2; \
static typename beast::is_call_possible_detail::add_reference<derived_type>::type test_me; \
static typename beast::is_call_possible_detail::add_reference<Arg1>::type arg1; \
static typename beast::is_call_possible_detail::add_reference<Arg2>::type arg2; \
\
static const bool value = \
sizeof( \
return_value_check<T, Result>::deduce( \
(test_me.member_function_name(arg1,arg2), beast::mpl::is_call_possible_detail::void_exp_result<T>()) \
(test_me.member_function_name(arg1,arg2), beast::is_call_possible_detail::void_exp_result<T>()) \
) \
) == sizeof(yes); \
}; \
@@ -244,15 +243,15 @@ private:
template <typename Result, typename Arg1, typename Arg2, typename Arg3> \
struct impl<true, Result(Arg1,Arg2,Arg3)> \
{ \
static typename beast::mpl::is_call_possible_detail::add_reference<derived_type>::type test_me; \
static typename beast::mpl::is_call_possible_detail::add_reference<Arg1>::type arg1; \
static typename beast::mpl::is_call_possible_detail::add_reference<Arg2>::type arg2; \
static typename beast::mpl::is_call_possible_detail::add_reference<Arg3>::type arg3; \
static typename beast::is_call_possible_detail::add_reference<derived_type>::type test_me; \
static typename beast::is_call_possible_detail::add_reference<Arg1>::type arg1; \
static typename beast::is_call_possible_detail::add_reference<Arg2>::type arg2; \
static typename beast::is_call_possible_detail::add_reference<Arg3>::type arg3; \
\
static const bool value = \
sizeof( \
return_value_check<T, Result>::deduce( \
(test_me.member_function_name(arg1,arg2,arg3), beast::mpl::is_call_possible_detail::void_exp_result<T>()) \
(test_me.member_function_name(arg1,arg2,arg3), beast::is_call_possible_detail::void_exp_result<T>()) \
) \
) == sizeof(yes); \
}; \
@@ -260,17 +259,17 @@ private:
template <typename Result, typename Arg1, typename Arg2, typename Arg3, typename Arg4> \
struct impl<true, Result(Arg1,Arg2,Arg3,Arg4)> \
{ \
static typename beast::mpl::is_call_possible_detail::add_reference<derived_type>::type test_me; \
static typename beast::mpl::is_call_possible_detail::add_reference<Arg1>::type arg1; \
static typename beast::mpl::is_call_possible_detail::add_reference<Arg2>::type arg2; \
static typename beast::mpl::is_call_possible_detail::add_reference<Arg3>::type arg3; \
static typename beast::mpl::is_call_possible_detail::add_reference<Arg4>::type arg4; \
static typename beast::is_call_possible_detail::add_reference<derived_type>::type test_me; \
static typename beast::is_call_possible_detail::add_reference<Arg1>::type arg1; \
static typename beast::is_call_possible_detail::add_reference<Arg2>::type arg2; \
static typename beast::is_call_possible_detail::add_reference<Arg3>::type arg3; \
static typename beast::is_call_possible_detail::add_reference<Arg4>::type arg4; \
\
static const bool value = \
sizeof( \
return_value_check<T, Result>::deduce( \
(test_me.member_function_name(arg1,arg2,arg3,arg4), \
beast::mpl::is_call_possible_detail::void_exp_result<T>()) \
beast::is_call_possible_detail::void_exp_result<T>()) \
) \
) == sizeof(yes); \
}; \
@@ -280,7 +279,6 @@ private:
IsCallPossibleSignature>::value; \
}
}
}
} // beast
#endif

View File

@@ -26,8 +26,8 @@
// This module requires boost and possibly OpenSSL
#include "system/BoostIncludes.h"
#include "../../beast/Utility.h"
#include "../../beast/HTTP.h"
#include "../../beast/http/URL.h"
#include "../../beast/http/ParsedURL.h"
#include "../../beast/asio/IPAddressConversion.h"

View File

@@ -20,6 +20,8 @@
#ifndef BEAST_ASIO_HTTPMESSAGE_H_INCLUDED
#define BEAST_ASIO_HTTPMESSAGE_H_INCLUDED
#include "../../../beast/net/DynamicBuffer.h"
namespace beast {
/** A complete HTTP message.

View File

@@ -126,13 +126,7 @@
#undef _aligned_msize
#endif
#include "containers/DynamicObject.cpp"
#include "containers/NamedValueSet.cpp"
#include "containers/PropertySet.cpp"
#include "containers/Variant.cpp"
#include "diagnostic/FatalError.cpp"
#include "diagnostic/FPUFlags.cpp"
#include "diagnostic/SemanticVersion.cpp"
#include "diagnostic/UnitTest.cpp"
#include "diagnostic/UnitTestUtilities.cpp"
@@ -145,68 +139,42 @@
#include "files/RandomAccessFile.cpp"
#include "files/TemporaryFile.cpp"
#include "json/JSON.cpp"
#include "logging/FileLogger.cpp"
#include "logging/Logger.cpp"
#include "maths/BigInteger.cpp"
#include "maths/Random.cpp"
#include "memory/MemoryBlock.cpp"
#include "misc/Main.cpp"
#include "misc/Result.cpp"
#include "misc/Uuid.cpp"
#include "network/MACAddress.cpp"
#include "network/Socket.cpp"
#include "streams/BufferedInputStream.cpp"
#include "streams/FileInputSource.cpp"
#include "streams/InputStream.cpp"
#include "streams/MemoryInputStream.cpp"
#include "streams/MemoryOutputStream.cpp"
#include "streams/OutputStream.cpp"
#include "streams/SubregionStream.cpp"
#include "system/SystemStats.cpp"
#include "text/LexicalCast.cpp"
#include "text/Identifier.cpp"
#include "text/LocalisedStrings.cpp"
#include "text/StringArray.cpp"
#include "text/StringPairArray.cpp"
#include "text/StringPool.cpp"
#include "thread/impl/TrackedMutex.cpp"
#include "thread/DeadlineTimer.cpp"
#include "thread/Workers.cpp"
#include "threads/ChildProcess.cpp"
#include "threads/SpinDelay.cpp"
#include "time/PerformanceCounter.cpp"
#include "time/AtExitHook.cpp"
#include "time/Time.cpp"
#include "xml/XmlDocument.cpp"
#include "xml/XmlElement.cpp"
#include "zip/GZIPDecompressorInputStream.cpp"
#include "zip/GZIPCompressorOutputStream.cpp"
#include "zip/ZipFile.cpp"
#if BEAST_MAC || BEAST_IOS
#include "native/osx_ObjCHelpers.h"
#endif
#if BEAST_WINDOWS
#include "native/win32_FPUFlags.cpp"
#else
#include "native/posix_FPUFlags.cpp"
#endif
#if BEAST_ANDROID
#include "native/android_JNIHelpers.h"
#endif

View File

@@ -54,12 +54,15 @@
#include "../../beast/HeapBlock.h"
#include "../../beast/Memory.h"
#include "../../beast/Intrusive.h"
#include "../../beast/Net.h"
#include "../../beast/Strings.h"
#include "../../beast/TypeTraits.h"
#include "../../beast/Threads.h"
#include "../../beast/Utility.h"
#include "../../beast/Chrono.h"
#include "../../beast/utility/Debug.h"
#include "../../beast/utility/Error.h"
#include "../../beast/utility/Journal.h"
#include "../../beast/utility/LeakChecked.h"
#include "../../beast/utility/PropertyStream.h"
#include "../../beast/utility/StaticObject.h"
#include "system/StandardIncludes.h"
@@ -78,7 +81,6 @@ class FileOutputStream;
#include "diagnostic/Throw.h"
#include "system/Functional.h"
#include "threads/SpinDelay.h"
#include "time/AtExitHook.h"
#include "time/Time.h"
@@ -139,30 +141,19 @@ class FileOutputStream;
#include "text/StringArray.h"
#include "memory/MemoryBlock.h"
#include "files/File.h"
#include "time/PerformanceCounter.h"
#include "memory/MemoryAlignment.h"
#include "memory/CacheLine.h"
#include "thread/MutexTraits.h"
#include "thread/TrackedMutex.h"
#include "diagnostic/FatalError.h"
#include "text/LexicalCast.h"
#include "maths/Math.h"
#include "logging/Logger.h"
#include "diagnostic/FPUFlags.h"
#include "text/Identifier.h"
#include "containers/Variant.h"
#include "containers/LinkedListPointer.h"
#include "containers/NamedValueSet.h"
#include "containers/DynamicObject.h"
#include "maths/BigInteger.h"
#include "maths/Random.h"
#include "containers/OwnedArray.h"
#include "text/StringPairArray.h"
#include "containers/PropertySet.h"
#include "containers/ScopedValueSetter.h"
#include "maths/Range.h"
#include "containers/SparseSet.h"
#include "files/DirectoryIterator.h"
#include "streams/InputStream.h"
#include "files/FileInputStream.h"
@@ -171,28 +162,16 @@ class FileOutputStream;
#include "streams/OutputStream.h"
#include "files/FileOutputStream.h"
#include "files/FileSearchPath.h"
#include "files/MemoryMappedFile.h"
#include "files/RandomAccessFile.h"
#include "files/TemporaryFile.h"
#include "json/JSON.h"
#include "logging/FileLogger.h"
#include "logging/Logger.h"
#include "memory/OptionalScopedPointer.h"
#include "memory/SharedSingleton.h"
#include "misc/Main.h"
#include "misc/Uuid.h"
#include "misc/WindowsRegistry.h"
#include "network/MACAddress.h"
#include "network/Socket.h"
#include "streams/BufferedInputStream.h"
#include "streams/MemoryInputStream.h"
#include "streams/MemoryOutputStream.h"
#include "streams/SubregionStream.h"
#include "system/SystemStats.h"
#include "text/LocalisedStrings.h"
#include "diagnostic/SemanticVersion.h"
#include "text/StringPool.h"
#include "threads/ChildProcess.h"
#include "threads/DynamicLibrary.h"
#include "threads/HighResolutionTimer.h"
@@ -202,9 +181,6 @@ class FileOutputStream;
#include "xml/XmlDocument.h"
#include "xml/XmlElement.h"
#include "diagnostic/UnitTestUtilities.h"
#include "zip/GZIPCompressorOutputStream.h"
#include "zip/GZIPDecompressorInputStream.h"
#include "zip/ZipFile.h"
#include "diagnostic/MeasureFunctionCallTime.h"

View File

@@ -1,79 +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.
*/
//==============================================================================
namespace beast
{
DynamicObject::DynamicObject()
{
}
DynamicObject::~DynamicObject()
{
}
bool DynamicObject::hasProperty (const Identifier& propertyName) const
{
const var* const v = properties.getVarPointer (propertyName);
return v != nullptr && ! v->isMethod();
}
var DynamicObject::getProperty (const Identifier& propertyName) const
{
return properties [propertyName];
}
void DynamicObject::setProperty (const Identifier& propertyName, const var& newValue)
{
properties.set (propertyName, newValue);
}
void DynamicObject::removeProperty (const Identifier& propertyName)
{
properties.remove (propertyName);
}
bool DynamicObject::hasMethod (const Identifier& methodName) const
{
return getProperty (methodName).isMethod();
}
var DynamicObject::invokeMethod (const Identifier& methodName,
const var* parameters,
int numParameters)
{
return properties [methodName].invokeMethod (this, parameters, numParameters);
}
void DynamicObject::setMethod (const Identifier& name,
var::MethodFunction methodFunction)
{
properties.set (name, var (methodFunction));
}
void DynamicObject::clear()
{
properties.clear();
}
} // namespace beast

View File

@@ -1,120 +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_DYNAMICOBJECT_H_INCLUDED
#define BEAST_DYNAMICOBJECT_H_INCLUDED
namespace beast
{
//==============================================================================
/**
Represents a dynamically implemented object.
This class is primarily intended for wrapping scripting language objects,
but could be used for other purposes.
An instance of a DynamicObject can be used to store named properties, and
by subclassing hasMethod() and invokeMethod(), you can give your object
methods.
*/
class BEAST_API DynamicObject
: public SharedObject
, LeakChecked <DynamicObject>
{
public:
//==============================================================================
DynamicObject();
/** Destructor. */
virtual ~DynamicObject();
typedef SharedPtr<DynamicObject> Ptr;
//==============================================================================
/** Returns true if the object has a property with this name.
Note that if the property is actually a method, this will return false.
*/
virtual bool hasProperty (const Identifier& propertyName) const;
/** Returns a named property.
This returns a void if no such property exists.
*/
virtual var getProperty (const Identifier& propertyName) const;
/** Sets a named property. */
virtual void setProperty (const Identifier& propertyName, const var& newValue);
/** Removes a named property. */
virtual void removeProperty (const Identifier& propertyName);
//==============================================================================
/** Checks whether this object has the specified method.
The default implementation of this just checks whether there's a property
with this name that's actually a method, but this can be overridden for
building objects with dynamic invocation.
*/
virtual bool hasMethod (const Identifier& methodName) const;
/** Invokes a named method on this object.
The default implementation looks up the named property, and if it's a method
call, then it invokes it.
This method is virtual to allow more dynamic invocation to used for objects
where the methods may not already be set as properies.
*/
virtual var invokeMethod (const Identifier& methodName,
const var* parameters,
int numParameters);
/** Sets up a method.
This is basically the same as calling setProperty (methodName, (var::MethodFunction) myFunction), but
helps to avoid accidentally invoking the wrong type of var constructor. It also makes
the code easier to read,
The compiler will probably force you to use an explicit cast your method to a (var::MethodFunction), e.g.
@code
setMethod ("doSomething", (var::MethodFunction) &MyClass::doSomething);
@endcode
*/
void setMethod (const Identifier& methodName,
var::MethodFunction methodFunction);
//==============================================================================
/** Removes all properties and methods from the object. */
void clear();
/** Returns the NamedValueSet that holds the object's properties. */
NamedValueSet& getProperties() noexcept { return properties; }
private:
//==============================================================================
NamedValueSet properties;
};
} // namespace beast
#endif // BEAST_DYNAMICOBJECT_H_INCLUDED

View File

@@ -1,211 +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_INTRUSIVE_LOCKFREEQUEUE_H_INCLUDED
#define BEAST_INTRUSIVE_LOCKFREEQUEUE_H_INCLUDED
/** Multiple Producer, Single Consumer (MPSC) intrusive FIFO.
This container uses the same intrusive interface as List. It is wait-free
for producers and lock-free for consumers. The caller is responsible for
preventing the ABA problem (http://en.wikipedia.org/wiki/ABA_problem)
Invariants:
- Any thread may call push_back() at any time (Multiple Producer).
- Only one thread may call try_pop_front() at a time (Single Consumer)
- The queue is signaled if there are one or more elements.
@param Tag A type name used to distinguish lists and nodes, for
putting objects in multiple lists. If this parameter is
omitted, the default tag is used.
@ingroup beast_core intrusive
*/
template <class Element, class Tag = void>
class LockFreeQueue
{
public:
class Node : public Uncopyable
{
public:
Node () { }
explicit Node (Node* next) : m_next (next) { }
AtomicPointer <Node> m_next;
};
public:
/** Create an empty list.
*/
LockFreeQueue ()
: m_head (&m_null)
, m_tail (&m_null)
, m_null (nullptr)
{
}
/** Determine if the list is empty.
This is not thread safe, the caller must synchronize.
@return true if the list is empty.
*/
bool empty () const
{
return (m_head.get () == m_tail);
}
/** Put an element into the list.
This operation is wait-free.
@param node The element to enqueue.
@return true if the list was previously empty.
*/
bool push_back (Node* node)
{
node->m_next.set (0);
Node* prev = m_head.exchange (node);
// (*) If a try_pop_front() happens at this point, it might not see the
// element we are pushing. This only happens when the list is empty,
// and furthermore it is detectable.
prev->m_next.set (node);
return prev == &m_null;
}
/** Retrieve an element from the list.
This operation is lock-free.
@return The element, or nullptr if the list was empty.
*/
Element* pop_front ()
{
Element* elem;
// Avoid the SpinDelay ctor if possible
if (!try_pop_front (&elem))
{
SpinDelay delay;
do
{
delay.pause ();
}
while (!try_pop_front (&elem));
}
return elem;
}
/** Attempt to retrieve an element.
This attempts to pop an element from the front of the list. The return
value indicates if the operation was successful. An operation is
successful if there is no contention for the list. On a successful
operation, an element is returned if the list was non empty, else nullptr
is returned. On failure, the returned element is undefined.
This operation is wait-free.
@param[out] pElem The element that was retrieved, or nullptr if the
list was empty.
@return true if the list was uncontended.
*/
bool try_pop_front (Element** pElem)
{
Node* tail = m_tail;
Node* next = tail->m_next.get ();
if (tail == &m_null)
{
if (next == 0)
{
// (*) If a push_back() happens at this point,
// we might not see the element.
if (m_head.get () == tail)
{
*pElem = nullptr;
return true; // success, but queue empty
}
else
{
return false; // failure: a push_back() caused contention
}
}
m_tail = next;
tail = next;
next = next->m_next.get ();
}
if (next)
{
m_tail = next;
*pElem = static_cast <Element*> (tail);
return true;
}
Node* head = m_head.get ();
if (tail == head)
{
push_back (&m_null);
next = tail->m_next.get ();
if (next)
{
m_tail = next;
*pElem = static_cast <Element*> (tail);
return true;
}
}
// (*) If a push_back() happens at this point,
// we might not see the element.
if (head == m_tail)
{
*pElem = nullptr;
return true; // success, but queue empty
}
else
{
return false; // failure: a push_back() caused contention
}
}
private:
// Elements are pushed on to the head and popped from the tail.
AtomicPointer <Node> m_head;
Node* m_tail;
Node m_null;
};
#endif

View File

@@ -1,309 +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.
*/
//==============================================================================
namespace beast
{
NamedValueSet::NamedValue::NamedValue() noexcept
{
}
inline NamedValueSet::NamedValue::NamedValue (const Identifier n, const var& v)
: name (n), value (v)
{
}
NamedValueSet::NamedValue::NamedValue (const NamedValue& other)
: name (other.name), value (other.value)
{
}
NamedValueSet::NamedValue& NamedValueSet::NamedValue::operator= (const NamedValueSet::NamedValue& other)
{
name = other.name;
value = other.value;
return *this;
}
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
NamedValueSet::NamedValue::NamedValue (NamedValue&& other) noexcept
: nextListItem (static_cast <LinkedListPointer<NamedValue>&&> (other.nextListItem)),
name (static_cast <Identifier&&> (other.name)),
value (static_cast <var&&> (other.value))
{
}
inline NamedValueSet::NamedValue::NamedValue (const Identifier n, var&& v)
: name (n), value (static_cast <var&&> (v))
{
}
NamedValueSet::NamedValue& NamedValueSet::NamedValue::operator= (NamedValue&& other) noexcept
{
nextListItem = static_cast <LinkedListPointer<NamedValue>&&> (other.nextListItem);
name = static_cast <Identifier&&> (other.name);
value = static_cast <var&&> (other.value);
return *this;
}
#endif
bool NamedValueSet::NamedValue::operator== (const NamedValueSet::NamedValue& other) const noexcept
{
return name == other.name && value == other.value;
}
//==============================================================================
NamedValueSet::NamedValueSet() noexcept
{
}
NamedValueSet::NamedValueSet (const NamedValueSet& other)
{
values.addCopyOfList (other.values);
}
NamedValueSet& NamedValueSet::operator= (const NamedValueSet& other)
{
clear();
values.addCopyOfList (other.values);
return *this;
}
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
NamedValueSet::NamedValueSet (NamedValueSet&& other) noexcept
: values (static_cast <LinkedListPointer<NamedValue>&&> (other.values))
{
}
NamedValueSet& NamedValueSet::operator= (NamedValueSet&& other) noexcept
{
other.values.swapWith (values);
return *this;
}
#endif
NamedValueSet::~NamedValueSet()
{
clear();
}
void NamedValueSet::clear()
{
values.deleteAll();
}
bool NamedValueSet::operator== (const NamedValueSet& other) const
{
const NamedValue* i1 = values;
const NamedValue* i2 = other.values;
while (i1 != nullptr && i2 != nullptr)
{
if (! (*i1 == *i2))
return false;
i1 = i1->nextListItem;
i2 = i2->nextListItem;
}
return true;
}
bool NamedValueSet::operator!= (const NamedValueSet& other) const
{
return ! operator== (other);
}
int NamedValueSet::size() const noexcept
{
return values.size();
}
const var& NamedValueSet::operator[] (const Identifier name) const
{
for (NamedValue* i = values; i != nullptr; i = i->nextListItem)
if (i->name == name)
return i->value;
return var::null;
}
var NamedValueSet::getWithDefault (const Identifier name, const var& defaultReturnValue) const
{
if (const var* const v = getVarPointer (name))
return *v;
return defaultReturnValue;
}
var* NamedValueSet::getVarPointer (const Identifier name) const noexcept
{
for (NamedValue* i = values; i != nullptr; i = i->nextListItem)
if (i->name == name)
return &(i->value);
return nullptr;
}
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
bool NamedValueSet::set (const Identifier name, var&& newValue)
{
LinkedListPointer<NamedValue>* i = &values;
while (i->get() != nullptr)
{
NamedValue* const v = i->get();
if (v->name == name)
{
if (v->value.equalsWithSameType (newValue))
return false;
v->value = static_cast <var&&> (newValue);
return true;
}
i = &(v->nextListItem);
}
i->insertNext (new NamedValue (name, static_cast <var&&> (newValue)));
return true;
}
#endif
bool NamedValueSet::set (const Identifier name, const var& newValue)
{
LinkedListPointer<NamedValue>* i = &values;
while (i->get() != nullptr)
{
NamedValue* const v = i->get();
if (v->name == name)
{
if (v->value.equalsWithSameType (newValue))
return false;
v->value = newValue;
return true;
}
i = &(v->nextListItem);
}
i->insertNext (new NamedValue (name, newValue));
return true;
}
bool NamedValueSet::contains (const Identifier name) const
{
return getVarPointer (name) != nullptr;
}
bool NamedValueSet::remove (const Identifier name)
{
LinkedListPointer<NamedValue>* i = &values;
for (;;)
{
NamedValue* const v = i->get();
if (v == nullptr)
break;
if (v->name == name)
{
delete i->removeNext();
return true;
}
i = &(v->nextListItem);
}
return false;
}
const Identifier NamedValueSet::getName (const int index) const
{
const NamedValue* const v = values[index];
bassert (v != nullptr);
return v->name;
}
const var& NamedValueSet::getValueAt (const int index) const
{
const NamedValue* const v = values[index];
bassert (v != nullptr);
return v->value;
}
void NamedValueSet::setFromXmlAttributes (const XmlElement& xml)
{
clear();
LinkedListPointer<NamedValue>::Appender appender (values);
const int numAtts = xml.getNumAttributes(); // xxx inefficient - should write an att iterator..
for (int i = 0; i < numAtts; ++i)
{
const String& name = xml.getAttributeName (i);
const String& value = xml.getAttributeValue (i);
if (name.startsWith ("base64:"))
{
MemoryBlock mb;
if (mb.fromBase64Encoding (value))
{
appender.append (new NamedValue (name.substring (7), var (mb)));
continue;
}
}
appender.append (new NamedValue (name, var (value)));
}
}
void NamedValueSet::copyToXmlAttributes (XmlElement& xml) const
{
for (NamedValue* i = values; i != nullptr; i = i->nextListItem)
{
if (const MemoryBlock* mb = i->value.getBinaryData())
{
xml.setAttribute ("base64:" + i->name.toString(),
mb->toBase64Encoding());
}
else
{
// These types can't be stored as XML!
bassert (! i->value.isObject());
bassert (! i->value.isMethod());
bassert (! i->value.isArray());
xml.setAttribute (i->name.toString(),
i->value.toString());
}
}
}
} // namespace beast

View File

@@ -1,165 +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_NAMEDVALUESET_H_INCLUDED
#define BEAST_NAMEDVALUESET_H_INCLUDED
namespace beast
{
class XmlElement;
#ifndef DOXYGEN
class JSONFormatter;
#endif
//==============================================================================
/** Holds a set of named var objects.
This can be used as a basic structure to hold a set of var object, which can
be retrieved by using their identifier.
*/
class BEAST_API NamedValueSet
{
public:
/** Creates an empty set. */
NamedValueSet() noexcept;
/** Creates a copy of another set. */
NamedValueSet (const NamedValueSet& other);
/** Replaces this set with a copy of another set. */
NamedValueSet& operator= (const NamedValueSet& other);
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
NamedValueSet (NamedValueSet&& other) noexcept;
NamedValueSet& operator= (NamedValueSet&& other) noexcept;
#endif
/** Destructor. */
~NamedValueSet();
bool operator== (const NamedValueSet& other) const;
bool operator!= (const NamedValueSet& other) const;
//==============================================================================
/** Returns the total number of values that the set contains. */
int size() const noexcept;
/** Returns the value of a named item.
If the name isn't found, this will return a void variant.
@see getProperty
*/
const var& operator[] (const Identifier name) const;
/** Tries to return the named value, but if no such value is found, this will
instead return the supplied default value.
*/
var getWithDefault (const Identifier name, const var& defaultReturnValue) const;
/** Changes or adds a named value.
@returns true if a value was changed or added; false if the
value was already set the the value passed-in.
*/
bool set (const Identifier name, const var& newValue);
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
/** Changes or adds a named value.
@returns true if a value was changed or added; false if the
value was already set the the value passed-in.
*/
bool set (const Identifier name, var&& newValue);
#endif
/** Returns true if the set contains an item with the specified name. */
bool contains (const Identifier name) const;
/** Removes a value from the set.
@returns true if a value was removed; false if there was no value
with the name that was given.
*/
bool remove (const Identifier name);
/** Returns the name of the value at a given index.
The index must be between 0 and size() - 1.
*/
const Identifier getName (int index) const;
/** Returns the value of the item at a given index.
The index must be between 0 and size() - 1.
*/
const var& getValueAt (int index) const;
/** Removes all values. */
void clear();
//==============================================================================
/** Returns a pointer to the var that holds a named value, or null if there is
no value with this name.
Do not use this method unless you really need access to the internal var object
for some reason - for normal reading and writing always prefer operator[]() and set().
*/
var* getVarPointer (const Identifier name) const noexcept;
//==============================================================================
/** Sets properties to the values of all of an XML element's attributes. */
void setFromXmlAttributes (const XmlElement& xml);
/** Sets attributes in an XML element corresponding to each of this object's
properties.
*/
void copyToXmlAttributes (XmlElement& xml) const;
private:
//==============================================================================
class NamedValue : LeakChecked <NamedValue>
{
public:
NamedValue() noexcept;
NamedValue (const NamedValue&);
NamedValue (const Identifier name, const var& value);
NamedValue& operator= (const NamedValue&);
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
NamedValue (NamedValue&&) noexcept;
NamedValue (const Identifier name, var&& value);
NamedValue& operator= (NamedValue&&) noexcept;
#endif
bool operator== (const NamedValue& other) const noexcept;
LinkedListPointer<NamedValue> nextListItem;
Identifier name;
var value;
private:
};
friend class LinkedListPointer<NamedValue>;
LinkedListPointer<NamedValue> values;
friend class JSONFormatter;
};
} // namespace beast
#endif // BEAST_NAMEDVALUESET_H_INCLUDED

View File

@@ -1,223 +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.
*/
//==============================================================================
namespace beast
{
PropertySet::PropertySet (const bool ignoreCaseOfKeyNames)
: properties (ignoreCaseOfKeyNames),
fallbackProperties (nullptr),
ignoreCaseOfKeys (ignoreCaseOfKeyNames)
{
}
PropertySet::PropertySet (const PropertySet& other)
: properties (other.properties),
fallbackProperties (other.fallbackProperties),
ignoreCaseOfKeys (other.ignoreCaseOfKeys)
{
}
PropertySet& PropertySet::operator= (const PropertySet& other)
{
properties = other.properties;
fallbackProperties = other.fallbackProperties;
ignoreCaseOfKeys = other.ignoreCaseOfKeys;
propertyChanged();
return *this;
}
PropertySet::~PropertySet()
{
}
void PropertySet::clear()
{
const ScopedLock sl (lock);
if (properties.size() > 0)
{
properties.clear();
propertyChanged();
}
}
String PropertySet::getValue (const String& keyName,
const String& defaultValue) const noexcept
{
const ScopedLock sl (lock);
const int index = properties.getAllKeys().indexOf (keyName, ignoreCaseOfKeys);
if (index >= 0)
return properties.getAllValues() [index];
return fallbackProperties != nullptr ? fallbackProperties->getValue (keyName, defaultValue)
: defaultValue;
}
int PropertySet::getIntValue (const String& keyName,
const int defaultValue) const noexcept
{
const ScopedLock sl (lock);
const int index = properties.getAllKeys().indexOf (keyName, ignoreCaseOfKeys);
if (index >= 0)
return properties.getAllValues() [index].getIntValue();
return fallbackProperties != nullptr ? fallbackProperties->getIntValue (keyName, defaultValue)
: defaultValue;
}
double PropertySet::getDoubleValue (const String& keyName,
const double defaultValue) const noexcept
{
const ScopedLock sl (lock);
const int index = properties.getAllKeys().indexOf (keyName, ignoreCaseOfKeys);
if (index >= 0)
return properties.getAllValues()[index].getDoubleValue();
return fallbackProperties != nullptr ? fallbackProperties->getDoubleValue (keyName, defaultValue)
: defaultValue;
}
bool PropertySet::getBoolValue (const String& keyName,
const bool defaultValue) const noexcept
{
const ScopedLock sl (lock);
const int index = properties.getAllKeys().indexOf (keyName, ignoreCaseOfKeys);
if (index >= 0)
return properties.getAllValues() [index].getIntValue() != 0;
return fallbackProperties != nullptr ? fallbackProperties->getBoolValue (keyName, defaultValue)
: defaultValue;
}
XmlElement* PropertySet::getXmlValue (const String& keyName) const
{
return XmlDocument::parse (getValue (keyName));
}
void PropertySet::setValue (const String& keyName, const var& v)
{
bassert (keyName.isNotEmpty()); // shouldn't use an empty key name!
if (keyName.isNotEmpty())
{
const String value (v.toString());
const ScopedLock sl (lock);
const int index = properties.getAllKeys().indexOf (keyName, ignoreCaseOfKeys);
if (index < 0 || properties.getAllValues() [index] != value)
{
properties.set (keyName, value);
propertyChanged();
}
}
}
void PropertySet::removeValue (const String& keyName)
{
if (keyName.isNotEmpty())
{
const ScopedLock sl (lock);
const int index = properties.getAllKeys().indexOf (keyName, ignoreCaseOfKeys);
if (index >= 0)
{
properties.remove (keyName);
propertyChanged();
}
}
}
void PropertySet::setValue (const String& keyName, const XmlElement* const xml)
{
setValue (keyName, xml == nullptr ? var::null
: var (xml->createDocument (String::empty, true)));
}
bool PropertySet::containsKey (const String& keyName) const noexcept
{
const ScopedLock sl (lock);
return properties.getAllKeys().contains (keyName, ignoreCaseOfKeys);
}
void PropertySet::addAllPropertiesFrom (const PropertySet& source)
{
const ScopedLock sl (source.getLock());
for (int i = 0; i < source.properties.size(); ++i)
setValue (source.properties.getAllKeys() [i],
source.properties.getAllValues() [i]);
}
void PropertySet::setFallbackPropertySet (PropertySet* fallbackProperties_) noexcept
{
const ScopedLock sl (lock);
fallbackProperties = fallbackProperties_;
}
XmlElement* PropertySet::createXml (const String& nodeName) const
{
const ScopedLock sl (lock);
XmlElement* const xml = new XmlElement (nodeName);
for (int i = 0; i < properties.getAllKeys().size(); ++i)
{
XmlElement* const e = xml->createNewChildElement ("VALUE");
e->setAttribute ("name", properties.getAllKeys()[i]);
e->setAttribute ("val", properties.getAllValues()[i]);
}
return xml;
}
void PropertySet::restoreFromXml (const XmlElement& xml)
{
const ScopedLock sl (lock);
clear();
beast_forEachXmlChildElementWithTagName (xml, e, "VALUE")
{
if (e->hasAttribute ("name")
&& e->hasAttribute ("val"))
{
properties.set (e->getStringAttribute ("name"),
e->getStringAttribute ("val"));
}
}
if (properties.size() > 0)
propertyChanged();
}
void PropertySet::propertyChanged()
{
}
} // namespace beast

View File

@@ -1,211 +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_PROPERTYSET_H_INCLUDED
#define BEAST_PROPERTYSET_H_INCLUDED
namespace beast
{
//==============================================================================
/**
A set of named property values, which can be strings, integers, floating point, etc.
Effectively, this just wraps a StringPairArray in an interface that makes it easier
to load and save types other than strings.
See the PropertiesFile class for a subclass of this, which automatically broadcasts change
messages and saves/loads the list from a file.
*/
class BEAST_API PropertySet : LeakChecked <PropertySet>
{
public:
//==============================================================================
/** Creates an empty PropertySet.
@param ignoreCaseOfKeyNames if true, the names of properties are compared in a
case-insensitive way
*/
PropertySet (bool ignoreCaseOfKeyNames = false);
/** Creates a copy of another PropertySet. */
PropertySet (const PropertySet& other);
/** Copies another PropertySet over this one. */
PropertySet& operator= (const PropertySet& other);
/** Destructor. */
virtual ~PropertySet();
//==============================================================================
/** Returns one of the properties as a string.
If the value isn't found in this set, then this will look for it in a fallback
property set (if you've specified one with the setFallbackPropertySet() method),
and if it can't find one there, it'll return the default value passed-in.
@param keyName the name of the property to retrieve
@param defaultReturnValue a value to return if the named property doesn't actually exist
*/
String getValue (const String& keyName,
const String& defaultReturnValue = String::empty) const noexcept;
/** Returns one of the properties as an integer.
If the value isn't found in this set, then this will look for it in a fallback
property set (if you've specified one with the setFallbackPropertySet() method),
and if it can't find one there, it'll return the default value passed-in.
@param keyName the name of the property to retrieve
@param defaultReturnValue a value to return if the named property doesn't actually exist
*/
int getIntValue (const String& keyName,
const int defaultReturnValue = 0) const noexcept;
/** Returns one of the properties as an double.
If the value isn't found in this set, then this will look for it in a fallback
property set (if you've specified one with the setFallbackPropertySet() method),
and if it can't find one there, it'll return the default value passed-in.
@param keyName the name of the property to retrieve
@param defaultReturnValue a value to return if the named property doesn't actually exist
*/
double getDoubleValue (const String& keyName,
const double defaultReturnValue = 0.0) const noexcept;
/** Returns one of the properties as an boolean.
The result will be true if the string found for this key name can be parsed as a non-zero
integer.
If the value isn't found in this set, then this will look for it in a fallback
property set (if you've specified one with the setFallbackPropertySet() method),
and if it can't find one there, it'll return the default value passed-in.
@param keyName the name of the property to retrieve
@param defaultReturnValue a value to return if the named property doesn't actually exist
*/
bool getBoolValue (const String& keyName,
const bool defaultReturnValue = false) const noexcept;
/** Returns one of the properties as an XML element.
The result will a new XMLElement object that the caller must delete. If may return 0 if the
key isn't found, or if the entry contains an string that isn't valid XML.
If the value isn't found in this set, then this will look for it in a fallback
property set (if you've specified one with the setFallbackPropertySet() method),
and if it can't find one there, it'll return the default value passed-in.
@param keyName the name of the property to retrieve
*/
XmlElement* getXmlValue (const String& keyName) const;
//==============================================================================
/** Sets a named property.
@param keyName the name of the property to set. (This mustn't be an empty string)
@param value the new value to set it to
*/
void setValue (const String& keyName, const var& value);
/** Sets a named property to an XML element.
@param keyName the name of the property to set. (This mustn't be an empty string)
@param xml the new element to set it to. If this is zero, the value will be set to
an empty string
@see getXmlValue
*/
void setValue (const String& keyName, const XmlElement* xml);
/** This copies all the values from a source PropertySet to this one.
This won't remove any existing settings, it just adds any that it finds in the source set.
*/
void addAllPropertiesFrom (const PropertySet& source);
//==============================================================================
/** Deletes a property.
@param keyName the name of the property to delete. (This mustn't be an empty string)
*/
void removeValue (const String& keyName);
/** Returns true if the properies include the given key. */
bool containsKey (const String& keyName) const noexcept;
/** Removes all values. */
void clear();
//==============================================================================
/** Returns the keys/value pair array containing all the properties. */
StringPairArray& getAllProperties() noexcept { return properties; }
/** Returns the lock used when reading or writing to this set */
const CriticalSection& getLock() const noexcept { return lock; }
//==============================================================================
/** Returns an XML element which encapsulates all the items in this property set.
The string parameter is the tag name that should be used for the node.
@see restoreFromXml
*/
XmlElement* createXml (const String& nodeName) const;
/** Reloads a set of properties that were previously stored as XML.
The node passed in must have been created by the createXml() method.
@see createXml
*/
void restoreFromXml (const XmlElement& xml);
//==============================================================================
/** Sets up a second PopertySet that will be used to look up any values that aren't
set in this one.
If you set this up to be a pointer to a second property set, then whenever one
of the getValue() methods fails to find an entry in this set, it will look up that
value in the fallback set, and if it finds it, it will return that.
Make sure that you don't delete the fallback set while it's still being used by
another set! To remove the fallback set, just call this method with a null pointer.
@see getFallbackPropertySet
*/
void setFallbackPropertySet (PropertySet* fallbackProperties) noexcept;
/** Returns the fallback property set.
@see setFallbackPropertySet
*/
PropertySet* getFallbackPropertySet() const noexcept { return fallbackProperties; }
protected:
/** Subclasses can override this to be told when one of the properies has been changed. */
virtual void propertyChanged();
private:
StringPairArray properties;
PropertySet* fallbackProperties;
CriticalSection lock;
bool ignoreCaseOfKeys;
};
} // namespace beast
#endif // BEAST_PROPERTYSET_H_INCLUDED

View File

@@ -1,295 +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_SPARSESET_H_INCLUDED
#define BEAST_SPARSESET_H_INCLUDED
namespace beast
{
//==============================================================================
/**
Holds a set of primitive values, storing them as a set of ranges.
This container acts like an array, but can efficiently hold large contiguous
ranges of values. It's quite a specialised class, mostly useful for things
like keeping the set of selected rows in a listbox.
The type used as a template paramter must be an integer type, such as int, short,
int64, etc.
*/
template <class Type>
class SparseSet
{
public:
//==============================================================================
/** Creates a new empty set. */
SparseSet()
{
}
/** Creates a copy of another SparseSet. */
SparseSet (const SparseSet<Type>& other)
: values (other.values)
{
}
//==============================================================================
/** Clears the set. */
void clear()
{
values.clear();
}
/** Checks whether the set is empty.
This is much quicker than using (size() == 0).
*/
bool isEmpty() const noexcept
{
return values.size() == 0;
}
/** Returns the number of values in the set.
Because of the way the data is stored, this method can take longer if there
are a lot of items in the set. Use isEmpty() for a quick test of whether there
are any items.
*/
Type size() const
{
Type total (0);
for (int i = 0; i < values.size(); i += 2)
total += values.getUnchecked (i + 1) - values.getUnchecked (i);
return total;
}
/** Returns one of the values in the set.
@param index the index of the value to retrieve, in the range 0 to (size() - 1).
@returns the value at this index, or 0 if it's out-of-range
*/
Type operator[] (Type index) const
{
for (int i = 0; i < values.size(); i += 2)
{
const Type start (values.getUnchecked (i));
const Type len (values.getUnchecked (i + 1) - start);
if (index < len)
return start + index;
index -= len;
}
return Type();
}
/** Checks whether a particular value is in the set. */
bool contains (const Type valueToLookFor) const
{
for (int i = 0; i < values.size(); ++i)
if (valueToLookFor < values.getUnchecked(i))
return (i & 1) != 0;
return false;
}
//==============================================================================
/** Returns the number of contiguous blocks of values.
@see getRange
*/
int getNumRanges() const noexcept
{
return values.size() >> 1;
}
/** Returns one of the contiguous ranges of values stored.
@param rangeIndex the index of the range to look up, between 0
and (getNumRanges() - 1)
@see getTotalRange
*/
const Range<Type> getRange (const int rangeIndex) const
{
if (isPositiveAndBelow (rangeIndex, getNumRanges()))
return Range<Type> (values.getUnchecked (rangeIndex << 1),
values.getUnchecked ((rangeIndex << 1) + 1));
return Range<Type>();
}
/** Returns the range between the lowest and highest values in the set.
@see getRange
*/
Range<Type> getTotalRange() const
{
if (values.size() > 0)
{
bassert ((values.size() & 1) == 0);
return Range<Type> (values.getUnchecked (0),
values.getUnchecked (values.size() - 1));
}
return Range<Type>();
}
//==============================================================================
/** Adds a range of contiguous values to the set.
e.g. addRange (Range \<int\> (10, 14)) will add (10, 11, 12, 13) to the set.
*/
void addRange (const Range<Type> range)
{
bassert (range.getLength() >= 0);
if (range.getLength() > 0)
{
removeRange (range);
values.addUsingDefaultSort (range.getStart());
values.addUsingDefaultSort (range.getEnd());
simplify();
}
}
/** Removes a range of values from the set.
e.g. removeRange (Range\<int\> (10, 14)) will remove (10, 11, 12, 13) from the set.
*/
void removeRange (const Range<Type> rangeToRemove)
{
bassert (rangeToRemove.getLength() >= 0);
if (rangeToRemove.getLength() > 0
&& values.size() > 0
&& rangeToRemove.getStart() < values.getUnchecked (values.size() - 1)
&& values.getUnchecked(0) < rangeToRemove.getEnd())
{
const bool onAtStart = contains (rangeToRemove.getStart() - 1);
const Type lastValue (bmin (rangeToRemove.getEnd(), values.getLast()));
const bool onAtEnd = contains (lastValue);
for (int i = values.size(); --i >= 0;)
{
if (values.getUnchecked(i) <= lastValue)
{
while (values.getUnchecked(i) >= rangeToRemove.getStart())
{
values.remove (i);
if (--i < 0)
break;
}
break;
}
}
if (onAtStart) values.addUsingDefaultSort (rangeToRemove.getStart());
if (onAtEnd) values.addUsingDefaultSort (lastValue);
simplify();
}
}
/** Does an XOR of the values in a given range. */
void invertRange (const Range<Type> range)
{
SparseSet newItems;
newItems.addRange (range);
for (int i = getNumRanges(); --i >= 0;)
newItems.removeRange (getRange (i));
removeRange (range);
for (int i = newItems.getNumRanges(); --i >= 0;)
addRange (newItems.getRange(i));
}
/** Checks whether any part of a given range overlaps any part of this set. */
bool overlapsRange (const Range<Type> range)
{
if (range.getLength() > 0)
{
for (int i = getNumRanges(); --i >= 0;)
{
if (values.getUnchecked ((i << 1) + 1) <= range.getStart())
return false;
if (values.getUnchecked (i << 1) < range.getEnd())
return true;
}
}
return false;
}
/** Checks whether the whole of a given range is contained within this one. */
bool containsRange (const Range<Type> range)
{
if (range.getLength() > 0)
{
for (int i = getNumRanges(); --i >= 0;)
{
if (values.getUnchecked ((i << 1) + 1) <= range.getStart())
return false;
if (values.getUnchecked (i << 1) <= range.getStart()
&& range.getEnd() <= values.getUnchecked ((i << 1) + 1))
return true;
}
}
return false;
}
//==============================================================================
bool operator== (const SparseSet<Type>& other) noexcept
{
return values == other.values;
}
bool operator!= (const SparseSet<Type>& other) noexcept
{
return values != other.values;
}
private:
//==============================================================================
// alternating start/end values of ranges of values that are present.
Array<Type, DummyCriticalSection> values;
void simplify()
{
bassert ((values.size() & 1) == 0);
for (int i = values.size(); --i > 0;)
if (values.getUnchecked(i) == values.getUnchecked (i - 1))
values.removeRange (--i, 2);
}
};
} // namespace beast
#endif // BEAST_SPARSESET_H_INCLUDED

View File

@@ -1,709 +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.
*/
//==============================================================================
namespace beast
{
enum VariantStreamMarkers
{
varMarker_Int = 1,
varMarker_BoolTrue = 2,
varMarker_BoolFalse = 3,
varMarker_Double = 4,
varMarker_String = 5,
varMarker_Int64 = 6,
varMarker_Array = 7,
varMarker_Binary = 8
};
//==============================================================================
class var::VariantType
{
public:
VariantType() noexcept {}
virtual ~VariantType() noexcept {}
virtual int toInt (const ValueUnion&) const noexcept { return 0; }
virtual int64 toInt64 (const ValueUnion&) const noexcept { return 0; }
virtual double toDouble (const ValueUnion&) const noexcept { return 0; }
virtual String toString (const ValueUnion&) const { return String::empty; }
virtual bool toBool (const ValueUnion&) const noexcept { return false; }
virtual SharedObject* toObject (const ValueUnion&) const noexcept { return nullptr; }
virtual Array<var>* toArray (const ValueUnion&) const noexcept { return nullptr; }
virtual MemoryBlock* toBinary (const ValueUnion&) const noexcept { return nullptr; }
virtual bool isVoid() const noexcept { return false; }
virtual bool isInt() const noexcept { return false; }
virtual bool isInt64() const noexcept { return false; }
virtual bool isBool() const noexcept { return false; }
virtual bool isDouble() const noexcept { return false; }
virtual bool isString() const noexcept { return false; }
virtual bool isObject() const noexcept { return false; }
virtual bool isArray() const noexcept { return false; }
virtual bool isBinary() const noexcept { return false; }
virtual bool isMethod() const noexcept { return false; }
virtual void cleanUp (ValueUnion&) const noexcept {}
virtual void createCopy (ValueUnion& dest, const ValueUnion& source) const { dest = source; }
virtual bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept = 0;
virtual void writeToStream (const ValueUnion& data, OutputStream& output) const = 0;
};
//==============================================================================
class var::VariantType_Void : public var::VariantType
{
public:
VariantType_Void() noexcept {}
static const VariantType_Void instance;
bool isVoid() const noexcept { return true; }
bool equals (const ValueUnion&, const ValueUnion&, const VariantType& otherType) const noexcept { return otherType.isVoid(); }
void writeToStream (const ValueUnion&, OutputStream& output) const { output.writeCompressedInt (0); }
};
//==============================================================================
class var::VariantType_Int : public var::VariantType
{
public:
VariantType_Int() noexcept {}
static const VariantType_Int instance;
int toInt (const ValueUnion& data) const noexcept { return data.intValue; };
int64 toInt64 (const ValueUnion& data) const noexcept { return (int64) data.intValue; };
double toDouble (const ValueUnion& data) const noexcept { return (double) data.intValue; }
String toString (const ValueUnion& data) const { return String (data.intValue); }
bool toBool (const ValueUnion& data) const noexcept { return data.intValue != 0; }
bool isInt() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
{
return otherType.toInt (otherData) == data.intValue;
}
void writeToStream (const ValueUnion& data, OutputStream& output) const
{
output.writeCompressedInt (5);
output.writeByte (varMarker_Int);
output.writeInt (data.intValue);
}
};
//==============================================================================
class var::VariantType_Int64 : public var::VariantType
{
public:
VariantType_Int64() noexcept {}
static const VariantType_Int64 instance;
int toInt (const ValueUnion& data) const noexcept { return (int) data.int64Value; };
int64 toInt64 (const ValueUnion& data) const noexcept { return data.int64Value; };
double toDouble (const ValueUnion& data) const noexcept { return (double) data.int64Value; }
String toString (const ValueUnion& data) const { return String (data.int64Value); }
bool toBool (const ValueUnion& data) const noexcept { return data.int64Value != 0; }
bool isInt64() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
{
return otherType.toInt64 (otherData) == data.int64Value;
}
void writeToStream (const ValueUnion& data, OutputStream& output) const
{
output.writeCompressedInt (9);
output.writeByte (varMarker_Int64);
output.writeInt64 (data.int64Value);
}
};
//==============================================================================
class var::VariantType_Double : public var::VariantType
{
public:
VariantType_Double() noexcept {}
static const VariantType_Double instance;
int toInt (const ValueUnion& data) const noexcept { return (int) data.doubleValue; };
int64 toInt64 (const ValueUnion& data) const noexcept { return (int64) data.doubleValue; };
double toDouble (const ValueUnion& data) const noexcept { return data.doubleValue; }
String toString (const ValueUnion& data) const { return String (data.doubleValue); }
bool toBool (const ValueUnion& data) const noexcept { return data.doubleValue != 0; }
bool isDouble() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
{
return std::abs (otherType.toDouble (otherData) - data.doubleValue) < std::numeric_limits<double>::epsilon();
}
void writeToStream (const ValueUnion& data, OutputStream& output) const
{
output.writeCompressedInt (9);
output.writeByte (varMarker_Double);
output.writeDouble (data.doubleValue);
}
};
//==============================================================================
class var::VariantType_Bool : public var::VariantType
{
public:
VariantType_Bool() noexcept {}
static const VariantType_Bool instance;
int toInt (const ValueUnion& data) const noexcept { return data.boolValue ? 1 : 0; };
int64 toInt64 (const ValueUnion& data) const noexcept { return data.boolValue ? 1 : 0; };
double toDouble (const ValueUnion& data) const noexcept { return data.boolValue ? 1.0 : 0.0; }
String toString (const ValueUnion& data) const { return String::charToString (data.boolValue ? (beast_wchar) '1' : (beast_wchar) '0'); }
bool toBool (const ValueUnion& data) const noexcept { return data.boolValue; }
bool isBool() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
{
return otherType.toBool (otherData) == data.boolValue;
}
void writeToStream (const ValueUnion& data, OutputStream& output) const
{
output.writeCompressedInt (1);
output.writeByte (data.boolValue ? (char) varMarker_BoolTrue : (char) varMarker_BoolFalse);
}
};
//==============================================================================
class var::VariantType_String : public var::VariantType
{
public:
VariantType_String() noexcept {}
static const VariantType_String instance;
void cleanUp (ValueUnion& data) const noexcept { getString (data)-> ~String(); }
void createCopy (ValueUnion& dest, const ValueUnion& source) const { new (dest.stringValue) String (*getString (source)); }
bool isString() const noexcept { return true; }
int toInt (const ValueUnion& data) const noexcept { return getString (data)->getIntValue(); };
int64 toInt64 (const ValueUnion& data) const noexcept { return getString (data)->getLargeIntValue(); };
double toDouble (const ValueUnion& data) const noexcept { return getString (data)->getDoubleValue(); }
String toString (const ValueUnion& data) const { return *getString (data); }
bool toBool (const ValueUnion& data) const noexcept { return getString (data)->getIntValue() != 0
|| getString (data)->trim().equalsIgnoreCase ("true")
|| getString (data)->trim().equalsIgnoreCase ("yes"); }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
{
return otherType.toString (otherData) == *getString (data);
}
void writeToStream (const ValueUnion& data, OutputStream& output) const
{
const String* const s = getString (data);
const size_t len = s->getNumBytesAsUTF8() + 1;
HeapBlock<char> temp (len);
s->copyToUTF8 (temp, len);
output.writeCompressedInt ((int) (len + 1));
output.writeByte (varMarker_String);
output.write (temp, len);
}
private:
static inline const String* getString (const ValueUnion& data) noexcept { return reinterpret_cast <const String*> (data.stringValue); }
static inline String* getString (ValueUnion& data) noexcept { return reinterpret_cast <String*> (data.stringValue); }
};
//==============================================================================
class var::VariantType_Object : public var::VariantType
{
public:
VariantType_Object() noexcept {}
static const VariantType_Object instance;
void cleanUp (ValueUnion& data) const noexcept { if (data.objectValue != nullptr) data.objectValue->decReferenceCount(); }
void createCopy (ValueUnion& dest, const ValueUnion& source) const
{
dest.objectValue = source.objectValue;
if (dest.objectValue != nullptr)
dest.objectValue->incReferenceCount();
}
String toString (const ValueUnion& data) const { return "Object 0x" + String::toHexString ((int) (pointer_sized_int) data.objectValue); }
bool toBool (const ValueUnion& data) const noexcept { return data.objectValue != 0; }
SharedObject* toObject (const ValueUnion& data) const noexcept { return data.objectValue; }
bool isObject() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
{
return otherType.toObject (otherData) == data.objectValue;
}
void writeToStream (const ValueUnion&, OutputStream& output) const
{
bassertfalse; // Can't write an object to a stream!
output.writeCompressedInt (0);
}
};
//==============================================================================
class var::VariantType_Array : public var::VariantType
{
public:
VariantType_Array() noexcept {}
static const VariantType_Array instance;
void cleanUp (ValueUnion& data) const noexcept { delete data.arrayValue; }
void createCopy (ValueUnion& dest, const ValueUnion& source) const { dest.arrayValue = new Array<var> (*(source.arrayValue)); }
String toString (const ValueUnion&) const { return "[Array]"; }
bool isArray() const noexcept { return true; }
Array<var>* toArray (const ValueUnion& data) const noexcept { return data.arrayValue; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
{
const Array<var>* const otherArray = otherType.toArray (otherData);
return otherArray != nullptr && *otherArray == *(data.arrayValue);
}
void writeToStream (const ValueUnion& data, OutputStream& output) const
{
MemoryOutputStream buffer (512);
const int numItems = data.arrayValue->size();
buffer.writeCompressedInt (numItems);
for (int i = 0; i < numItems; ++i)
data.arrayValue->getReference(i).writeToStream (buffer);
output.writeCompressedInt (1 + (int) buffer.getDataSize());
output.writeByte (varMarker_Array);
output << buffer;
}
};
//==============================================================================
class var::VariantType_Binary : public var::VariantType
{
public:
VariantType_Binary() noexcept {}
static const VariantType_Binary instance;
void cleanUp (ValueUnion& data) const noexcept { delete data.binaryValue; }
void createCopy (ValueUnion& dest, const ValueUnion& source) const { dest.binaryValue = new MemoryBlock (*source.binaryValue); }
String toString (const ValueUnion& data) const { return data.binaryValue->toBase64Encoding(); }
bool isBinary() const noexcept { return true; }
MemoryBlock* toBinary (const ValueUnion& data) const noexcept { return data.binaryValue; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
{
const MemoryBlock* const otherBlock = otherType.toBinary (otherData);
return otherBlock != nullptr && *otherBlock == *data.binaryValue;
}
void writeToStream (const ValueUnion& data, OutputStream& output) const
{
output.writeCompressedInt (1 + (int) data.binaryValue->getSize());
output.writeByte (varMarker_Binary);
output << *data.binaryValue;
}
};
//==============================================================================
class var::VariantType_Method : public var::VariantType
{
public:
VariantType_Method() noexcept {}
static const VariantType_Method instance;
String toString (const ValueUnion&) const { return "Method"; }
bool toBool (const ValueUnion& data) const noexcept { return data.methodValue != nullptr; }
bool isMethod() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
{
return otherType.isMethod() && otherData.methodValue == data.methodValue;
}
void writeToStream (const ValueUnion&, OutputStream& output) const
{
bassertfalse; // Can't write a method to a stream!
output.writeCompressedInt (0);
}
};
//==============================================================================
const var::VariantType_Void var::VariantType_Void::instance;
const var::VariantType_Int var::VariantType_Int::instance;
const var::VariantType_Int64 var::VariantType_Int64::instance;
const var::VariantType_Bool var::VariantType_Bool::instance;
const var::VariantType_Double var::VariantType_Double::instance;
const var::VariantType_String var::VariantType_String::instance;
const var::VariantType_Object var::VariantType_Object::instance;
const var::VariantType_Array var::VariantType_Array::instance;
const var::VariantType_Binary var::VariantType_Binary::instance;
const var::VariantType_Method var::VariantType_Method::instance;
//==============================================================================
var::var() noexcept : type (&VariantType_Void::instance)
{
}
var::~var() noexcept
{
type->cleanUp (value);
}
const var var::null;
//==============================================================================
var::var (const var& valueToCopy) : type (valueToCopy.type)
{
type->createCopy (value, valueToCopy.value);
}
var::var (const int v) noexcept : type (&VariantType_Int::instance) { value.intValue = v; }
var::var (const int64 v) noexcept : type (&VariantType_Int64::instance) { value.int64Value = v; }
var::var (const bool v) noexcept : type (&VariantType_Bool::instance) { value.boolValue = v; }
var::var (const double v) noexcept : type (&VariantType_Double::instance) { value.doubleValue = v; }
var::var (MethodFunction m) noexcept : type (&VariantType_Method::instance) { value.methodValue = m; }
var::var (const Array<var>& v) : type (&VariantType_Array::instance) { value.arrayValue = new Array<var> (v); }
var::var (const String& v) : type (&VariantType_String::instance) { new (value.stringValue) String (v); }
var::var (const char* const v) : type (&VariantType_String::instance) { new (value.stringValue) String (v); }
var::var (const wchar_t* const v) : type (&VariantType_String::instance) { new (value.stringValue) String (v); }
var::var (const void* v, size_t sz) : type (&VariantType_Binary::instance) { value.binaryValue = new MemoryBlock (v, sz); }
var::var (const MemoryBlock& v) : type (&VariantType_Binary::instance) { value.binaryValue = new MemoryBlock (v); }
var::var (SharedObject* const object) : type (&VariantType_Object::instance)
{
value.objectValue = object;
if (object != nullptr)
object->incReferenceCount();
}
//==============================================================================
bool var::isVoid() const noexcept { return type->isVoid(); }
bool var::isInt() const noexcept { return type->isInt(); }
bool var::isInt64() const noexcept { return type->isInt64(); }
bool var::isBool() const noexcept { return type->isBool(); }
bool var::isDouble() const noexcept { return type->isDouble(); }
bool var::isString() const noexcept { return type->isString(); }
bool var::isObject() const noexcept { return type->isObject(); }
bool var::isArray() const noexcept { return type->isArray(); }
bool var::isBinaryData() const noexcept { return type->isBinary(); }
bool var::isMethod() const noexcept { return type->isMethod(); }
var::operator int() const noexcept { return type->toInt (value); }
var::operator int64() const noexcept { return type->toInt64 (value); }
var::operator bool() const noexcept { return type->toBool (value); }
var::operator float() const noexcept { return (float) type->toDouble (value); }
var::operator double() const noexcept { return type->toDouble (value); }
String var::toString() const { return type->toString (value); }
var::operator String() const { return type->toString (value); }
SharedObject* var::getObject() const noexcept { return type->toObject (value); }
Array<var>* var::getArray() const noexcept { return type->toArray (value); }
MemoryBlock* var::getBinaryData() const noexcept { return type->toBinary (value); }
DynamicObject* var::getDynamicObject() const noexcept { return dynamic_cast <DynamicObject*> (getObject()); }
//==============================================================================
void var::swapWith (var& other) noexcept
{
std::swap (type, other.type);
std::swap (value, other.value);
}
var& var::operator= (const var& v) { type->cleanUp (value); type = v.type; type->createCopy (value, v.value); return *this; }
var& var::operator= (const int v) { type->cleanUp (value); type = &VariantType_Int::instance; value.intValue = v; return *this; }
var& var::operator= (const int64 v) { type->cleanUp (value); type = &VariantType_Int64::instance; value.int64Value = v; return *this; }
var& var::operator= (const bool v) { type->cleanUp (value); type = &VariantType_Bool::instance; value.boolValue = v; return *this; }
var& var::operator= (const double v) { type->cleanUp (value); type = &VariantType_Double::instance; value.doubleValue = v; return *this; }
var& var::operator= (const char* const v) { type->cleanUp (value); type = &VariantType_String::instance; new (value.stringValue) String (v); return *this; }
var& var::operator= (const wchar_t* const v) { type->cleanUp (value); type = &VariantType_String::instance; new (value.stringValue) String (v); return *this; }
var& var::operator= (const String& v) { type->cleanUp (value); type = &VariantType_String::instance; new (value.stringValue) String (v); return *this; }
var& var::operator= (const Array<var>& v) { var v2 (v); swapWith (v2); return *this; }
var& var::operator= (SharedObject* v) { var v2 (v); swapWith (v2); return *this; }
var& var::operator= (MethodFunction v) { var v2 (v); swapWith (v2); return *this; }
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
var::var (var&& other) noexcept
: type (other.type),
value (other.value)
{
other.type = &VariantType_Void::instance;
}
var& var::operator= (var&& other) noexcept
{
swapWith (other);
return *this;
}
var::var (String&& v) : type (&VariantType_String::instance)
{
new (value.stringValue) String (static_cast<String&&> (v));
}
var::var (MemoryBlock&& v) : type (&VariantType_Binary::instance)
{
value.binaryValue = new MemoryBlock (static_cast<MemoryBlock&&> (v));
}
var& var::operator= (String&& v)
{
type->cleanUp (value);
type = &VariantType_String::instance;
new (value.stringValue) String (static_cast<String&&> (v));
return *this;
}
#endif
//==============================================================================
bool var::equals (const var& other) const noexcept
{
return type->equals (value, other.value, *other.type);
}
bool var::equalsWithSameType (const var& other) const noexcept
{
return type == other.type && equals (other);
}
bool operator== (const var& v1, const var& v2) noexcept { return v1.equals (v2); }
bool operator!= (const var& v1, const var& v2) noexcept { return ! v1.equals (v2); }
bool operator== (const var& v1, const String& v2) { return v1.toString() == v2; }
bool operator!= (const var& v1, const String& v2) { return v1.toString() != v2; }
bool operator== (const var& v1, const char* const v2) { return v1.toString() == v2; }
bool operator!= (const var& v1, const char* const v2) { return v1.toString() != v2; }
//==============================================================================
var var::operator[] (const Identifier propertyName) const
{
if (DynamicObject* const o = getDynamicObject())
return o->getProperty (propertyName);
return var::null;
}
var var::operator[] (const char* const propertyName) const
{
return operator[] (Identifier (propertyName));
}
var var::getProperty (const Identifier propertyName, const var& defaultReturnValue) const
{
if (DynamicObject* const o = getDynamicObject())
return o->getProperties().getWithDefault (propertyName, defaultReturnValue);
return defaultReturnValue;
}
var var::invoke (const Identifier method, const var* arguments, int numArguments) const
{
if (DynamicObject* const o = getDynamicObject())
return o->invokeMethod (method, arguments, numArguments);
return var::null;
}
var var::invokeMethod (DynamicObject* const target, const var* const arguments, const int numArguments) const
{
bassert (target != nullptr);
if (isMethod())
return (target->*(value.methodValue)) (arguments, numArguments);
return var::null;
}
var var::call (const Identifier method) const
{
return invoke (method, nullptr, 0);
}
var var::call (const Identifier method, const var& arg1) const
{
return invoke (method, &arg1, 1);
}
var var::call (const Identifier method, const var& arg1, const var& arg2) const
{
var args[] = { arg1, arg2 };
return invoke (method, args, 2);
}
var var::call (const Identifier method, const var& arg1, const var& arg2, const var& arg3)
{
var args[] = { arg1, arg2, arg3 };
return invoke (method, args, 3);
}
var var::call (const Identifier method, const var& arg1, const var& arg2, const var& arg3, const var& arg4) const
{
var args[] = { arg1, arg2, arg3, arg4 };
return invoke (method, args, 4);
}
var var::call (const Identifier method, const var& arg1, const var& arg2, const var& arg3, const var& arg4, const var& arg5) const
{
var args[] = { arg1, arg2, arg3, arg4, arg5 };
return invoke (method, args, 5);
}
//==============================================================================
int var::size() const
{
if (const Array<var>* const array = getArray())
return array->size();
return 0;
}
const var& var::operator[] (int arrayIndex) const
{
const Array<var>* const array = getArray();
// When using this method, the var must actually be an array, and the index
// must be in-range!
bassert (array != nullptr && isPositiveAndBelow (arrayIndex, array->size()));
return array->getReference (arrayIndex);
}
var& var::operator[] (int arrayIndex)
{
const Array<var>* const array = getArray();
// When using this method, the var must actually be an array, and the index
// must be in-range!
bassert (array != nullptr && isPositiveAndBelow (arrayIndex, array->size()));
return array->getReference (arrayIndex);
}
Array<var>* var::convertToArray()
{
Array<var>* array = getArray();
if (array == nullptr)
{
const Array<var> tempVar;
var v (tempVar);
array = v.value.arrayValue;
if (! isVoid())
array->add (*this);
swapWith (v);
}
return array;
}
void var::append (const var& n)
{
convertToArray()->add (n);
}
void var::remove (const int index)
{
if (Array<var>* const array = getArray())
array->remove (index);
}
void var::insert (const int index, const var& n)
{
convertToArray()->insert (index, n);
}
void var::resize (const int numArrayElementsWanted)
{
convertToArray()->resize (numArrayElementsWanted);
}
int var::indexOf (const var& n) const
{
if (const Array<var>* const array = getArray())
return array->indexOf (n);
return -1;
}
//==============================================================================
void var::writeToStream (OutputStream& output) const
{
type->writeToStream (value, output);
}
var var::readFromStream (InputStream& input)
{
const int numBytes = input.readCompressedInt();
if (numBytes > 0)
{
switch (input.readByte())
{
case varMarker_Int: return var (input.readInt());
case varMarker_Int64: return var (input.readInt64());
case varMarker_BoolTrue: return var (true);
case varMarker_BoolFalse: return var (false);
case varMarker_Double: return var (input.readDouble());
case varMarker_String:
{
MemoryOutputStream mo;
mo.writeFromInputStream (input, numBytes - 1);
return var (mo.toUTF8());
}
case varMarker_Binary:
{
MemoryBlock mb ((size_t) numBytes - 1);
if (numBytes > 1)
{
const int numRead = input.read (mb.getData(), numBytes - 1);
mb.setSize ((size_t) numRead);
}
return var (mb);
}
case varMarker_Array:
{
var v;
Array<var>* const destArray = v.convertToArray();
for (int i = input.readCompressedInt(); --i >= 0;)
destArray->add (readFromStream (input));
return v;
}
default:
input.skipNextBytes (numBytes - 1); break;
}
}
return var::null;
}
} // namespace beast

View File

@@ -1,301 +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_VARIANT_H_INCLUDED
#define BEAST_VARIANT_H_INCLUDED
namespace beast
{
#ifndef DOXYGEN
class SharedObject;
class DynamicObject;
#endif
//==============================================================================
/**
A variant class, that can be used to hold a range of primitive values.
A var object can hold a range of simple primitive values, strings, or
any kind of SharedObject. The var class is intended to act like
the kind of values used in dynamic scripting languages.
You can save/load var objects either in a small, proprietary binary format
using writeToStream()/readFromStream(), or as JSON by using the JSON class.
@see JSON, DynamicObject
*/
class BEAST_API var
{
public:
//==============================================================================
typedef const var (DynamicObject::*MethodFunction) (const var* arguments, int numArguments);
typedef Identifier identifier;
//==============================================================================
/** Creates a void variant. */
var() noexcept;
/** Destructor. */
~var() noexcept;
/** A static var object that can be used where you need an empty variant object. */
static const var null;
var (const var& valueToCopy);
var (int value) noexcept;
var (int64 value) noexcept;
var (bool value) noexcept;
var (double value) noexcept;
var (const char* value);
var (const wchar_t* value);
var (const String& value);
var (const Array<var>& value);
var (SharedObject* object);
var (MethodFunction method) noexcept;
var (const void* binaryData, size_t dataSize);
var (const MemoryBlock& binaryData);
var& operator= (const var& valueToCopy);
var& operator= (int value);
var& operator= (int64 value);
var& operator= (bool value);
var& operator= (double value);
var& operator= (const char* value);
var& operator= (const wchar_t* value);
var& operator= (const String& value);
var& operator= (const Array<var>& value);
var& operator= (SharedObject* object);
var& operator= (MethodFunction method);
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
var (var&& other) noexcept;
var (String&& value);
var (MemoryBlock&& binaryData);
var& operator= (var&& other) noexcept;
var& operator= (String&& value);
#endif
void swapWith (var& other) noexcept;
//==============================================================================
operator int() const noexcept;
operator int64() const noexcept;
operator bool() const noexcept;
operator float() const noexcept;
operator double() const noexcept;
operator String() const;
String toString() const;
/** If this variant holds an array, this provides access to it.
NOTE: Beware when you use this - the array pointer is only valid for the lifetime
of the variant that returned it, so be very careful not to call this method on temporary
var objects that are the return-value of a function, and which may go out of scope before
you use the array!
*/
Array<var>* getArray() const noexcept;
/** If this variant holds a memory block, this provides access to it.
NOTE: Beware when you use this - the MemoryBlock pointer is only valid for the lifetime
of the variant that returned it, so be very careful not to call this method on temporary
var objects that are the return-value of a function, and which may go out of scope before
you use the MemoryBlock!
*/
MemoryBlock* getBinaryData() const noexcept;
SharedObject* getObject() const noexcept;
DynamicObject* getDynamicObject() const noexcept;
//==============================================================================
bool isVoid() const noexcept;
bool isInt() const noexcept;
bool isInt64() const noexcept;
bool isBool() const noexcept;
bool isDouble() const noexcept;
bool isString() const noexcept;
bool isObject() const noexcept;
bool isArray() const noexcept;
bool isBinaryData() const noexcept;
bool isMethod() const noexcept;
/** Returns true if this var has the same value as the one supplied.
Note that this ignores the type, so a string var "123" and an integer var with the
value 123 are considered to be equal.
@see equalsWithSameType
*/
bool equals (const var& other) const noexcept;
/** Returns true if this var has the same value and type as the one supplied.
This differs from equals() because e.g. "123" and 123 will be considered different.
@see equals
*/
bool equalsWithSameType (const var& other) const noexcept;
//==============================================================================
/** If the var is an array, this returns the number of elements.
If the var isn't actually an array, this will return 0.
*/
int size() const;
/** If the var is an array, this can be used to return one of its elements.
To call this method, you must make sure that the var is actually an array, and
that the index is a valid number. If these conditions aren't met, behaviour is
undefined.
For more control over the array's contents, you can call getArray() and manipulate
it directly as an Array\<var\>.
*/
const var& operator[] (int arrayIndex) const;
/** If the var is an array, this can be used to return one of its elements.
To call this method, you must make sure that the var is actually an array, and
that the index is a valid number. If these conditions aren't met, behaviour is
undefined.
For more control over the array's contents, you can call getArray() and manipulate
it directly as an Array\<var\>.
*/
var& operator[] (int arrayIndex);
/** Appends an element to the var, converting it to an array if it isn't already one.
If the var isn't an array, it will be converted to one, and if its value was non-void,
this value will be kept as the first element of the new array. The parameter value
will then be appended to it.
For more control over the array's contents, you can call getArray() and manipulate
it directly as an Array\<var\>.
*/
void append (const var& valueToAppend);
/** Inserts an element to the var, converting it to an array if it isn't already one.
If the var isn't an array, it will be converted to one, and if its value was non-void,
this value will be kept as the first element of the new array. The parameter value
will then be inserted into it.
For more control over the array's contents, you can call getArray() and manipulate
it directly as an Array\<var\>.
*/
void insert (int index, const var& value);
/** If the var is an array, this removes one of its elements.
If the index is out-of-range or the var isn't an array, nothing will be done.
For more control over the array's contents, you can call getArray() and manipulate
it directly as an Array\<var\>.
*/
void remove (int index);
/** Treating the var as an array, this resizes it to contain the specified number of elements.
If the var isn't an array, it will be converted to one, and if its value was non-void,
this value will be kept as the first element of the new array before resizing.
For more control over the array's contents, you can call getArray() and manipulate
it directly as an Array\<var\>.
*/
void resize (int numArrayElementsWanted);
/** If the var is an array, this searches it for the first occurrence of the specified value,
and returns its index.
If the var isn't an array, or if the value isn't found, this returns -1.
*/
int indexOf (const var& value) const;
//==============================================================================
/** If this variant is an object, this returns one of its properties. */
var operator[] (const Identifier propertyName) const;
/** If this variant is an object, this returns one of its properties. */
var operator[] (const char* propertyName) const;
/** If this variant is an object, this returns one of its properties, or a default
fallback value if the property is not set. */
var getProperty (const Identifier propertyName, const var& defaultReturnValue) const;
/** If this variant is an object, this invokes one of its methods with no arguments. */
var call (const Identifier method) const;
/** If this variant is an object, this invokes one of its methods with one argument. */
var call (const Identifier method, const var& arg1) const;
/** If this variant is an object, this invokes one of its methods with 2 arguments. */
var call (const Identifier method, const var& arg1, const var& arg2) const;
/** If this variant is an object, this invokes one of its methods with 3 arguments. */
var call (const Identifier method, const var& arg1, const var& arg2, const var& arg3);
/** If this variant is an object, this invokes one of its methods with 4 arguments. */
var call (const Identifier method, const var& arg1, const var& arg2, const var& arg3, const var& arg4) const;
/** If this variant is an object, this invokes one of its methods with 5 arguments. */
var call (const Identifier method, const var& arg1, const var& arg2, const var& arg3, const var& arg4, const var& arg5) const;
/** If this variant is an object, this invokes one of its methods with a list of arguments. */
var invoke (const Identifier method, const var* arguments, int numArguments) const;
//==============================================================================
/** Writes a binary representation of this value to a stream.
The data can be read back later using readFromStream().
@see JSON
*/
void writeToStream (OutputStream& output) const;
/** Reads back a stored binary representation of a value.
The data in the stream must have been written using writeToStream(), or this
will have unpredictable results.
@see JSON
*/
static var readFromStream (InputStream& input);
private:
//==============================================================================
class VariantType; friend class VariantType;
class VariantType_Void; friend class VariantType_Void;
class VariantType_Int; friend class VariantType_Int;
class VariantType_Int64; friend class VariantType_Int64;
class VariantType_Double; friend class VariantType_Double;
class VariantType_Bool; friend class VariantType_Bool;
class VariantType_String; friend class VariantType_String;
class VariantType_Object; friend class VariantType_Object;
class VariantType_Array; friend class VariantType_Array;
class VariantType_Binary; friend class VariantType_Binary;
class VariantType_Method; friend class VariantType_Method;
union ValueUnion
{
int intValue;
int64 int64Value;
bool boolValue;
double doubleValue;
char stringValue [sizeof (String)];
SharedObject* objectValue;
Array<var>* arrayValue;
MemoryBlock* binaryValue;
MethodFunction methodValue;
};
const VariantType* type;
ValueUnion value;
Array<var>* convertToArray();
friend class DynamicObject;
var invokeMethod (DynamicObject*, const var*, int) const;
};
/** Compares the values of two var objects, using the var::equals() comparison. */
bool operator== (const var& v1, const var& v2) noexcept;
/** Compares the values of two var objects, using the var::equals() comparison. */
bool operator!= (const var& v1, const var& v2) noexcept;
bool operator== (const var& v1, const String& v2);
bool operator!= (const var& v1, const String& v2);
bool operator== (const var& v1, const char* v2);
bool operator!= (const var& v1, const char* v2);
} // namespace beast
#endif // BEAST_VARIANT_H_INCLUDED

View File

@@ -1,45 +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.
*/
//==============================================================================
namespace beast
{
void FPUFlags::clearUnsetFlagsFrom (FPUFlags const& flags)
{
if (!flags.getMaskNaNs ().is_set ()) m_maskNaNs.clear ();
if (!flags.getMaskDenormals ().is_set ()) m_maskDenormals.clear ();
if (!flags.getMaskZeroDivides ().is_set ()) m_maskZeroDivides.clear ();
if (!flags.getMaskOverflows ().is_set ()) m_maskOverflows.clear ();
if (!flags.getMaskUnderflows ().is_set ()) m_maskUnderflows.clear ();
//if (!flags.getMaskInexacts().is_set ()) m_maskInexacts.clear ();
if (!flags.getFlushDenormals ().is_set ()) m_flushDenormals.clear ();
if (!flags.getInfinitySigned ().is_set ()) m_infinitySigned.clear ();
if (!flags.getRounding ().is_set ()) m_rounding.clear ();
if (!flags.getPrecision ().is_set ()) m_precision.clear ();
}
} // namespace beast

View File

@@ -1,340 +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_FPUFLAGS_H_INCLUDED
#define BEAST_FPUFLAGS_H_INCLUDED
namespace beast
{
/*============================================================================*/
/**
A set of IEEE FPU flags.
Description.
@ingroup beast_core
*/
class BEAST_API FPUFlags
{
public:
/** An individual FPU flag */
struct Flag
{
Flag () : m_set (false) { }
Flag (Flag const& flag) : m_set (flag.m_set), m_value (flag.m_value) { }
Flag& operator= (Flag const& flag)
{
m_set = flag.m_set;
m_value = flag.m_value;
return *this;
}
bool is_set () const
{
return m_set;
}
bool value () const
{
assert (m_set);
return m_value;
}
void set_value (bool value)
{
m_set = true;
m_value = value;
}
void clear ()
{
m_set = false;
}
private:
bool m_set : 1;
bool m_value : 1;
};
/** A multi-valued FPU setting */
template <typename Constants>
struct Enum
{
Enum () : m_set (false) { }
Enum (Enum const& value) : m_set (value.m_set), m_value (value.m_value) { }
Enum& operator= (Enum const& value)
{
m_set = value.m_set;
m_value = value.m_value;
return *this;
}
bool is_set () const
{
return m_set;
}
Constants value () const
{
return m_value;
}
void set_value (Constants value)
{
m_set = true;
m_value = value;
}
void clear ()
{
m_set = false;
}
private:
bool m_set : 1;
Constants m_value;
};
public:
//
// Exception masks
//
void setMaskNaNs (bool mask = true)
{
m_maskNaNs.set_value (mask);
}
void setMaskDenormals (bool mask = true)
{
m_maskDenormals.set_value (mask);
}
void setMaskZeroDivides (bool mask = true)
{
m_maskZeroDivides.set_value (mask);
}
void setMaskOverflows (bool mask = true)
{
m_maskOverflows.set_value (mask);
}
void setMaskUnderflows (bool mask = true)
{
m_maskUnderflows.set_value (mask);
}
//void setMaskInexacts (bool mask = true) { m_maskInexacts.set_value (mask); }
void setUnmaskAllExceptions (bool unmask = true)
{
setMaskNaNs (!unmask);
setMaskDenormals (!unmask);
setMaskZeroDivides (!unmask);
setMaskOverflows (!unmask);
setMaskUnderflows (!unmask);
//setMaskInexacts (!unmask);
}
//
// Denormal control
//
void setFlushDenormals (bool flush = true)
{
m_flushDenormals.set_value (flush);
}
//
// Infinity control
//
void setInfinitySigned (bool is_signed = true)
{
m_infinitySigned.set_value (is_signed);
}
//
// Rounding control
//
enum Rounding
{
roundChop,
roundUp,
roundDown,
roundNear
};
void setRounding (Rounding rounding)
{
m_rounding.set_value (rounding);
}
//
// Precision control
//
enum Precision
{
bits24,
bits53,
bits64
};
void setPrecision (Precision precision)
{
m_precision.set_value (precision);
}
//
// Retrieval
//
const Flag getMaskNaNs () const
{
return m_maskNaNs;
}
const Flag getMaskDenormals () const
{
return m_maskDenormals;
}
const Flag getMaskZeroDivides () const
{
return m_maskZeroDivides;
}
const Flag getMaskOverflows () const
{
return m_maskOverflows;
}
const Flag getMaskUnderflows () const
{
return m_maskUnderflows;
}
//const Flag getMaskInexacts () const { return m_maskInexacts; }
const Flag getFlushDenormals () const
{
return m_flushDenormals;
}
const Flag getInfinitySigned () const
{
return m_infinitySigned;
}
const Enum <Rounding> getRounding () const
{
return m_rounding;
}
const Enum <Precision> getPrecision () const
{
return m_precision;
}
Flag& getMaskNaNs ()
{
return m_maskNaNs;
}
Flag& getMaskDenormals ()
{
return m_maskDenormals;
}
Flag& getMaskZeroDivides ()
{
return m_maskZeroDivides;
}
Flag& getMaskOverflows ()
{
return m_maskOverflows;
}
Flag& getMaskUnderflows ()
{
return m_maskUnderflows;
}
//Flag& getMaskInexacts () { return m_maskInexacts; }
Flag& getFlushDenormals ()
{
return m_flushDenormals;
}
Flag& getInfinitySigned ()
{
return m_infinitySigned;
}
Enum <Rounding>& getRounding ()
{
return m_rounding;
}
Enum <Precision>& getPrecision ()
{
return m_precision;
}
// Clears our flags if they are not set in another object
void clearUnsetFlagsFrom (FPUFlags const& flags);
// Retrieve the current flags fron the FPU
static FPUFlags getCurrent ();
// Change the current FPU flags based on what is set in flags
static void setCurrent (FPUFlags const& flags);
private:
Flag m_maskNaNs;
Flag m_maskDenormals;
Flag m_maskZeroDivides;
Flag m_maskOverflows;
Flag m_maskUnderflows;
//Flag m_maskInexacts;
Flag m_flushDenormals;
Flag m_infinitySigned;
Enum <Rounding> m_rounding;
Enum <Precision> m_precision;
};
//------------------------------------------------------------------------------
/*============================================================================*/
/**
IEEE FPU flag modifications with scoped lifetime.
An instance of the class saves the FPU flags and updates
FPUFlags flags;
flags.setUnmaskAllExceptions ();
{
ScopedFPUFlags fpu (flags);
// Perform floating point calculations
}
// FPU flags are back to what they were now
@ingroup beast_core
*/
class ScopedFPUFlags
{
public:
ScopedFPUFlags (FPUFlags const& flagsToSet)
{
m_savedFlags = FPUFlags::getCurrent ();
m_savedFlags.clearUnsetFlagsFrom (flagsToSet);
FPUFlags::setCurrent (flagsToSet);
}
~ScopedFPUFlags ()
{
FPUFlags::setCurrent (m_savedFlags);
}
private:
FPUFlags m_savedFlags;
};
} // namespace beast
#endif

View File

@@ -902,19 +902,6 @@ File File::createTempFile (const String& fileNameEnding)
return tempFile;
}
//==============================================================================
MemoryMappedFile::MemoryMappedFile (const File& file, MemoryMappedFile::AccessMode mode)
: address (nullptr), range (0, file.getSize()), fileHandle (0)
{
openInternal (file, mode);
}
MemoryMappedFile::MemoryMappedFile (const File& file, const Range<int64>& fileRange, AccessMode mode)
: address (nullptr), range (fileRange.getIntersectionWith (Range<int64> (0, file.getSize()))), fileHandle (0)
{
openInternal (file, mode);
}
//==============================================================================
class FileTests : public UnitTest
@@ -1049,37 +1036,6 @@ public:
expect (tempFile.getSize() == 10);
}
beginTestCase ("Memory-mapped files");
{
MemoryMappedFile mmf (tempFile, MemoryMappedFile::readOnly);
expect (mmf.getSize() == 10);
expect (mmf.getData() != nullptr);
expect (memcmp (mmf.getData(), "0123456789", 10) == 0);
}
{
const File tempFile2 (tempFile.getNonexistentSibling (false));
expect (tempFile2.create());
expect (tempFile2.appendData ("xxxxxxxxxx", 10));
{
MemoryMappedFile mmf (tempFile2, MemoryMappedFile::readWrite);
expect (mmf.getSize() == 10);
expect (mmf.getData() != nullptr);
memcpy (mmf.getData(), "abcdefghij", 10);
}
{
MemoryMappedFile mmf (tempFile2, MemoryMappedFile::readWrite);
expect (mmf.getSize() == 10);
expect (mmf.getData() != nullptr);
expect (memcmp (mmf.getData(), "abcdefghij", 10) == 0);
}
expect (tempFile2.deleteFile());
}
beginTestCase ("More writing");
expect (tempFile.appendData ("abcdefghij", 10));

View File

@@ -1,111 +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_MEMORYMAPPEDFILE_H_INCLUDED
#define BEAST_MEMORYMAPPEDFILE_H_INCLUDED
namespace beast
{
//==============================================================================
/**
Maps a file into virtual memory for easy reading and/or writing.
*/
class BEAST_API MemoryMappedFile : LeakChecked <MemoryMappedFile>, public Uncopyable
{
public:
/** The read/write flags used when opening a memory mapped file. */
enum AccessMode
{
readOnly, /**< Indicates that the memory can only be read. */
readWrite /**< Indicates that the memory can be read and written to - changes that are
made will be flushed back to disk at the whim of the OS. */
};
/** Opens a file and maps it to an area of virtual memory.
The file should already exist, and should already be the size that you want to work with
when you call this. If the file is resized after being opened, the behaviour is undefined.
If the file exists and the operation succeeds, the getData() and getSize() methods will
return the location and size of the data that can be read or written. Note that the entire
file is not read into memory immediately - the OS simply creates a virtual mapping, which
will lazily pull the data into memory when blocks are accessed.
If the file can't be opened for some reason, the getData() method will return a null pointer.
*/
MemoryMappedFile (const File& file, AccessMode mode);
/** Opens a section of a file and maps it to an area of virtual memory.
The file should already exist, and should already be the size that you want to work with
when you call this. If the file is resized after being opened, the behaviour is undefined.
If the file exists and the operation succeeds, the getData() and getSize() methods will
return the location and size of the data that can be read or written. Note that the entire
file is not read into memory immediately - the OS simply creates a virtual mapping, which
will lazily pull the data into memory when blocks are accessed.
If the file can't be opened for some reason, the getData() method will return a null pointer.
NOTE: the start of the actual range used may be rounded-down to a multiple of the OS's page-size,
so do not assume that the mapped memory will begin at exactly the position you requested - always
use getRange() to check the actual range that is being used.
*/
MemoryMappedFile (const File& file,
const Range<int64>& fileRange,
AccessMode mode);
/** Destructor. */
~MemoryMappedFile();
/** Returns the address at which this file has been mapped, or a null pointer if
the file couldn't be successfully mapped.
*/
void* getData() const noexcept { return address; }
/** Returns the number of bytes of data that are available for reading or writing.
This will normally be the size of the file.
*/
size_t getSize() const noexcept { return (size_t) range.getLength(); }
/** Returns the section of the file at which the mapped memory represents. */
Range<int64> getRange() const noexcept { return range; }
private:
//==============================================================================
void* address;
Range<int64> range;
#if BEAST_WINDOWS
void* fileHandle;
#else
int fileHandle;
#endif
void openInternal (const File&, AccessMode);
};
} // namespace beast
#endif // BEAST_MEMORYMAPPEDFILE_H_INCLUDED

View File

@@ -1,647 +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.
*/
//==============================================================================
namespace beast
{
class JSONParser
{
public:
static Result parseObjectOrArray (String::CharPointerType t, var& result)
{
t = t.findEndOfWhitespace();
switch (t.getAndAdvance())
{
case 0: result = var::null; return Result::ok();
case '{': return parseObject (t, result);
case '[': return parseArray (t, result);
}
return createFail ("Expected '{' or '['", &t);
}
private:
static Result parseAny (String::CharPointerType& t, var& result)
{
t = t.findEndOfWhitespace();
String::CharPointerType t2 (t);
switch (t2.getAndAdvance())
{
case '{': t = t2; return parseObject (t, result);
case '[': t = t2; return parseArray (t, result);
case '"': t = t2; return parseString (t, result);
case '-':
t2 = t2.findEndOfWhitespace();
if (! CharacterFunctions::isDigit (*t2))
break;
t = t2;
return parseNumber (t, result, true);
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
return parseNumber (t, result, false);
case 't': // "true"
if (t2.getAndAdvance() == 'r' && t2.getAndAdvance() == 'u' && t2.getAndAdvance() == 'e')
{
t = t2;
result = var (true);
return Result::ok();
}
break;
case 'f': // "false"
if (t2.getAndAdvance() == 'a' && t2.getAndAdvance() == 'l'
&& t2.getAndAdvance() == 's' && t2.getAndAdvance() == 'e')
{
t = t2;
result = var (false);
return Result::ok();
}
break;
case 'n': // "null"
if (t2.getAndAdvance() == 'u' && t2.getAndAdvance() == 'l' && t2.getAndAdvance() == 'l')
{
t = t2;
result = var::null;
return Result::ok();
}
break;
default:
break;
}
return createFail ("Syntax error", &t);
}
static Result createFail (const char* const message, const String::CharPointerType* location = nullptr)
{
String m (message);
if (location != nullptr)
m << ": \"" << String (*location, 20) << '"';
return Result::fail (m);
}
static Result parseNumber (String::CharPointerType& t, var& result, const bool isNegative)
{
String::CharPointerType oldT (t);
int64 intValue = t.getAndAdvance() - '0';
bassert (intValue >= 0 && intValue < 10);
for (;;)
{
String::CharPointerType previousChar (t);
const beast_wchar c = t.getAndAdvance();
const int digit = ((int) c) - '0';
if (isPositiveAndBelow (digit, 10))
{
intValue = intValue * 10 + digit;
continue;
}
if (c == 'e' || c == 'E' || c == '.')
{
t = oldT;
const double asDouble = CharacterFunctions::readDoubleValue (t);
result = isNegative ? -asDouble : asDouble;
return Result::ok();
}
if (CharacterFunctions::isWhitespace (c)
|| c == ',' || c == '}' || c == ']' || c == 0)
{
t = previousChar;
break;
}
return createFail ("Syntax error in number", &oldT);
}
const int64 correctedValue = isNegative ? -intValue : intValue;
if ((intValue >> 31) != 0)
result = correctedValue;
else
result = (int) correctedValue;
return Result::ok();
}
static Result parseObject (String::CharPointerType& t, var& result)
{
DynamicObject* const resultObject = new DynamicObject();
result = resultObject;
NamedValueSet& resultProperties = resultObject->getProperties();
for (;;)
{
t = t.findEndOfWhitespace();
String::CharPointerType oldT (t);
const beast_wchar c = t.getAndAdvance();
if (c == '}')
break;
if (c == 0)
return createFail ("Unexpected end-of-input in object declaration");
if (c == '"')
{
var propertyNameVar;
Result r (parseString (t, propertyNameVar));
if (r.failed())
return r;
const String propertyName (propertyNameVar.toString());
if (propertyName.isNotEmpty())
{
t = t.findEndOfWhitespace();
oldT = t;
const beast_wchar c2 = t.getAndAdvance();
if (c2 != ':')
return createFail ("Expected ':', but found", &oldT);
resultProperties.set (propertyName, var::null);
var* propertyValue = resultProperties.getVarPointer (propertyName);
Result r2 (parseAny (t, *propertyValue));
if (r2.failed())
return r2;
t = t.findEndOfWhitespace();
oldT = t;
const beast_wchar nextChar = t.getAndAdvance();
if (nextChar == ',')
continue;
if (nextChar == '}')
break;
}
}
return createFail ("Expected object member declaration, but found", &oldT);
}
return Result::ok();
}
static Result parseArray (String::CharPointerType& t, var& result)
{
result = var (Array<var>());
Array<var>* const destArray = result.getArray();
for (;;)
{
t = t.findEndOfWhitespace();
String::CharPointerType oldT (t);
const beast_wchar c = t.getAndAdvance();
if (c == ']')
break;
if (c == 0)
return createFail ("Unexpected end-of-input in array declaration");
t = oldT;
destArray->add (var::null);
Result r (parseAny (t, destArray->getReference (destArray->size() - 1)));
if (r.failed())
return r;
t = t.findEndOfWhitespace();
oldT = t;
const beast_wchar nextChar = t.getAndAdvance();
if (nextChar == ',')
continue;
if (nextChar == ']')
break;
return createFail ("Expected object array item, but found", &oldT);
}
return Result::ok();
}
static Result parseString (String::CharPointerType& t, var& result)
{
MemoryOutputStream buffer (256);
for (;;)
{
beast_wchar c = t.getAndAdvance();
if (c == '"')
break;
if (c == '\\')
{
c = t.getAndAdvance();
switch (c)
{
case '"':
case '\\':
case '/': break;
case 'b': c = '\b'; break;
case 'f': c = '\f'; break;
case 'n': c = '\n'; break;
case 'r': c = '\r'; break;
case 't': c = '\t'; break;
case 'u':
{
c = 0;
for (int i = 4; --i >= 0;)
{
const int digitValue = CharacterFunctions::getHexDigitValue (t.getAndAdvance());
if (digitValue < 0)
return createFail ("Syntax error in unicode escape sequence");
c = (beast_wchar) ((c << 4) + digitValue);
}
break;
}
}
}
if (c == 0)
return createFail ("Unexpected end-of-input in string constant");
buffer.appendUTF8Char (c);
}
result = buffer.toUTF8 ();
return Result::ok();
}
};
//==============================================================================
class JSONFormatter
{
public:
static void write (OutputStream& out, const var& v,
const int indentLevel, const bool allOnOneLine)
{
if (v.isString())
{
writeString (out, v.toString().getCharPointer());
}
else if (v.isVoid())
{
out << "null";
}
else if (v.isBool())
{
out << (static_cast<bool> (v) ? "true" : "false");
}
else if (v.isArray())
{
writeArray (out, *v.getArray(), indentLevel, allOnOneLine);
}
else if (v.isObject())
{
if (DynamicObject* const object = v.getDynamicObject())
writeObject (out, *object, indentLevel, allOnOneLine);
else
bassertfalse; // Only DynamicObjects can be converted to JSON!
}
else
{
// Can't convert these other types of object to JSON!
bassert (! (v.isMethod() || v.isBinaryData()));
out << v.toString();
}
}
private:
enum { indentSize = 2 };
static void writeEscapedChar (OutputStream& out, const unsigned short value)
{
out << "\\u" << String::toHexString ((int) value).paddedLeft ('0', 4);
}
static void writeString (OutputStream& out, String::CharPointerType t)
{
out << '"';
for (;;)
{
const beast_wchar c (t.getAndAdvance());
switch (c)
{
case 0: out << '"'; return;
case '\"': out << "\\\""; break;
case '\\': out << "\\\\"; break;
case '\b': out << "\\b"; break;
case '\f': out << "\\f"; break;
case '\t': out << "\\t"; break;
case '\r': out << "\\r"; break;
case '\n': out << "\\n"; break;
default:
if (c >= 32 && c < 127)
{
out << (char) c;
}
else
{
if (CharPointer_UTF16::getBytesRequiredFor (c) > 2)
{
CharPointer_UTF16::CharType chars[2];
CharPointer_UTF16 utf16 (chars);
utf16.write (c);
for (int i = 0; i < 2; ++i)
writeEscapedChar (out, (unsigned short) chars[i]);
}
else
{
writeEscapedChar (out, (unsigned short) c);
}
}
break;
}
}
}
static void writeSpaces (OutputStream& out, int numSpaces)
{
out.writeRepeatedByte (' ', (size_t) numSpaces);
}
static void writeArray (OutputStream& out, const Array<var>& array,
const int indentLevel, const bool allOnOneLine)
{
out << '[';
if (! allOnOneLine)
out << newLine;
for (int i = 0; i < array.size(); ++i)
{
if (! allOnOneLine)
writeSpaces (out, indentLevel + indentSize);
write (out, array.getReference(i), indentLevel + indentSize, allOnOneLine);
if (i < array.size() - 1)
{
if (allOnOneLine)
out << ", ";
else
out << ',' << newLine;
}
else if (! allOnOneLine)
out << newLine;
}
if (! allOnOneLine)
writeSpaces (out, indentLevel);
out << ']';
}
static void writeObject (OutputStream& out, DynamicObject& object,
const int indentLevel, const bool allOnOneLine)
{
NamedValueSet& props = object.getProperties();
out << '{';
if (! allOnOneLine)
out << newLine;
LinkedListPointer<NamedValueSet::NamedValue>* i = &(props.values);
for (;;)
{
NamedValueSet::NamedValue* const v = i->get();
if (v == nullptr)
break;
if (! allOnOneLine)
writeSpaces (out, indentLevel + indentSize);
writeString (out, v->name);
out << ": ";
write (out, v->value, indentLevel + indentSize, allOnOneLine);
if (v->nextListItem.get() != nullptr)
{
if (allOnOneLine)
out << ", ";
else
out << ',' << newLine;
}
else if (! allOnOneLine)
out << newLine;
i = &(v->nextListItem);
}
if (! allOnOneLine)
writeSpaces (out, indentLevel);
out << '}';
}
};
//==============================================================================
var JSON::parse (const String& text)
{
var result;
if (! JSONParser::parseObjectOrArray (text.getCharPointer(), result))
result = var::null;
return result;
}
var JSON::parse (InputStream& input)
{
return parse (input.readEntireStreamAsString());
}
var JSON::parse (const File& file)
{
return parse (file.loadFileAsString());
}
Result JSON::parse (const String& text, var& result)
{
return JSONParser::parseObjectOrArray (text.getCharPointer(), result);
}
String JSON::toString (const var& data, const bool allOnOneLine)
{
MemoryOutputStream mo (1024);
JSONFormatter::write (mo, data, 0, allOnOneLine);
return mo.toUTF8 ();
}
void JSON::writeToStream (OutputStream& output, const var& data, const bool allOnOneLine)
{
JSONFormatter::write (output, data, 0, allOnOneLine);
}
//==============================================================================
//==============================================================================
class JSONTests : public UnitTest
{
public:
JSONTests() : UnitTest ("JSON", "beast") { }
static String createRandomWideCharString (Random& r)
{
beast_wchar buffer[40] = { 0 };
for (int i = 0; i < numElementsInArray (buffer) - 1; ++i)
{
if (r.nextBool())
{
do
{
buffer[i] = (beast_wchar) (1 + r.nextInt (0x10ffff - 1));
}
while (! CharPointer_UTF16::canRepresent (buffer[i]));
}
else
buffer[i] = (beast_wchar) (1 + r.nextInt (0xff));
}
return CharPointer_UTF32 (buffer);
}
static String createRandomIdentifier (Random& r)
{
char buffer[30] = { 0 };
for (int i = 0; i < numElementsInArray (buffer) - 1; ++i)
{
static const char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-:";
buffer[i] = chars [r.nextInt (sizeof (chars) - 1)];
}
return CharPointer_ASCII (buffer);
}
static var createRandomVar (Random& r, int depth)
{
switch (r.nextInt (depth > 3 ? 6 : 8))
{
case 0: return var::null;
case 1: return r.nextInt();
case 2: return r.nextInt64();
case 3: return r.nextBool();
case 4: return r.nextDouble();
case 5: return createRandomWideCharString (r);
case 6:
{
var v (createRandomVar (r, depth + 1));
for (int i = 1 + r.nextInt (30); --i >= 0;)
v.append (createRandomVar (r, depth + 1));
return v;
}
case 7:
{
DynamicObject* o = new DynamicObject();
for (int i = r.nextInt (30); --i >= 0;)
o->setProperty (createRandomIdentifier (r), createRandomVar (r, depth + 1));
return o;
}
default:
return var::null;
}
}
void runTest()
{
beginTestCase ("JSON");
Random r;
r.setSeedRandomly();
expect (JSON::parse (String::empty) == var::null);
expect (JSON::parse ("{}").isObject());
expect (JSON::parse ("[]").isArray());
expect (JSON::parse ("[ 1234 ]")[0].isInt());
expect (JSON::parse ("[ 12345678901234 ]")[0].isInt64());
expect (JSON::parse ("[ 1.123e3 ]")[0].isDouble());
expect (JSON::parse ("[ -1234]")[0].isInt());
expect (JSON::parse ("[-12345678901234]")[0].isInt64());
expect (JSON::parse ("[-1.123e3]")[0].isDouble());
for (int i = 100; --i >= 0;)
{
var v;
if (i > 0)
v = createRandomVar (r, 0);
const bool oneLine = r.nextBool();
String asString (JSON::toString (v, oneLine));
var parsed = JSON::parse ("[" + asString + "]")[0];
String parsedString (JSON::toString (parsed, oneLine));
expect (asString.isNotEmpty() && parsedString == asString);
}
}
};
static JSONTests jsonTests;
} // namespace beast

View File

@@ -1,114 +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_JSON_H_INCLUDED
#define BEAST_JSON_H_INCLUDED
namespace beast
{
class InputStream;
class OutputStream;
class File;
//==============================================================================
/**
Contains static methods for converting JSON-formatted text to and from var objects.
The var class is structurally compatible with JSON-formatted data, so these
functions allow you to parse JSON into a var object, and to convert a var
object to JSON-formatted text.
@see var
*/
class BEAST_API JSON
{
public:
//==============================================================================
/** Parses a string of JSON-formatted text, and returns a result code containing
any parse errors.
This will return the parsed structure in the parsedResult parameter, and will
return a Result object to indicate whether parsing was successful, and if not,
it will contain an error message.
If you're not interested in the error message, you can use one of the other
shortcut parse methods, which simply return a var::null if the parsing fails.
*/
static Result parse (const String& text, var& parsedResult);
/** Attempts to parse some JSON-formatted text, and returns the result as a var object.
If the parsing fails, this simply returns var::null - if you need to find out more
detail about the parse error, use the alternative parse() method which returns a Result.
*/
static var parse (const String& text);
/** Attempts to parse some JSON-formatted text from a file, and returns the result
as a var object.
Note that this is just a short-cut for reading the entire file into a string and
parsing the result.
If the parsing fails, this simply returns var::null - if you need to find out more
detail about the parse error, use the alternative parse() method which returns a Result.
*/
static var parse (const File& file);
/** Attempts to parse some JSON-formatted text from a stream, and returns the result
as a var object.
Note that this is just a short-cut for reading the entire stream into a string and
parsing the result.
If the parsing fails, this simply returns var::null - if you need to find out more
detail about the parse error, use the alternative parse() method which returns a Result.
*/
static var parse (InputStream& input);
//==============================================================================
/** Returns a string which contains a JSON-formatted representation of the var object.
If allOnOneLine is true, the result will be compacted into a single line of text
with no carriage-returns. If false, it will be laid-out in a more human-readable format.
@see writeToStream
*/
static String toString (const var& objectToFormat,
bool allOnOneLine = false);
/** Writes a JSON-formatted representation of the var object to the given stream.
If allOnOneLine is true, the result will be compacted into a single line of text
with no carriage-returns. If false, it will be laid-out in a more human-readable format.
@see toString
*/
static void writeToStream (OutputStream& output,
const var& objectToFormat,
bool allOnOneLine = false);
private:
//==============================================================================
JSON(); // This class can't be instantiated - just use its static methods.
};
} // namespace beast
#endif // BEAST_JSON_H_INCLUDED

View File

@@ -1,134 +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.
*/
//==============================================================================
namespace beast
{
FileLogger::FileLogger (const File& file,
const String& welcomeMessage,
const int64 maxInitialFileSizeBytes)
: logFile (file)
{
if (maxInitialFileSizeBytes >= 0)
trimFileSize (maxInitialFileSizeBytes);
if (! file.exists())
file.create(); // (to create the parent directories)
String welcome;
welcome << newLine
<< "**********************************************************" << newLine
<< welcomeMessage << newLine
<< "Log started: " << Time::getCurrentTime().toString (true, true) << newLine;
FileLogger::logMessage (welcome);
}
FileLogger::~FileLogger() {}
//==============================================================================
void FileLogger::logMessage (const String& message)
{
const ScopedLock sl (logLock);
BDBG (message);
FileOutputStream out (logFile, 256);
out << message << newLine;
}
void FileLogger::trimFileSize (int64 maxFileSizeBytes) const
{
if (maxFileSizeBytes <= 0)
{
logFile.deleteFile();
}
else
{
const int64 fileSize = logFile.getSize();
if (fileSize > maxFileSizeBytes)
{
TemporaryFile tempFile (logFile);
{
FileOutputStream out (tempFile.getFile());
FileInputStream in (logFile);
if (! (out.openedOk() && in.openedOk()))
return;
in.setPosition (fileSize - maxFileSizeBytes);
for (;;)
{
const char c = in.readByte();
if (c == 0)
return;
if (c == '\n' || c == '\r')
{
out << c;
break;
}
}
out.writeFromInputStream (in, -1);
}
tempFile.overwriteTargetFileWithTemporary();
}
}
}
//==============================================================================
File FileLogger::getSystemLogFileFolder()
{
#if BEAST_MAC
return File ("~/Library/Logs");
#else
return File::getSpecialLocation (File::userApplicationDataDirectory);
#endif
}
FileLogger* FileLogger::createDefaultAppLogger (const String& logFileSubDirectoryName,
const String& logFileName,
const String& welcomeMessage,
const int64 maxInitialFileSizeBytes)
{
return new FileLogger (getSystemLogFileFolder().getChildFile (logFileSubDirectoryName)
.getChildFile (logFileName),
welcomeMessage, maxInitialFileSizeBytes);
}
FileLogger* FileLogger::createDateStampedLogger (const String& logFileSubDirectoryName,
const String& logFileNameRoot,
const String& logFileNameSuffix,
const String& welcomeMessage)
{
return new FileLogger (getSystemLogFileFolder().getChildFile (logFileSubDirectoryName)
.getChildFile (logFileNameRoot + Time::getCurrentTime().formatted ("%Y-%m-%d_%H-%M-%S"))
.withFileExtension (logFileNameSuffix)
.getNonexistentSibling(),
welcomeMessage, 0);
}
} // namespace beast

View File

@@ -1,134 +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_FILELOGGER_H_INCLUDED
#define BEAST_FILELOGGER_H_INCLUDED
namespace beast
{
//==============================================================================
/**
A simple implementation of a Logger that writes to a file.
@see Logger
*/
class BEAST_API FileLogger
: public Logger
, LeakChecked <FileLogger>
, public Uncopyable
{
public:
//==============================================================================
/** Creates a FileLogger for a given file.
@param fileToWriteTo the file that to use - new messages will be appended
to the file. If the file doesn't exist, it will be created,
along with any parent directories that are needed.
@param welcomeMessage when opened, the logger will write a header to the log, along
with the current date and time, and this welcome message
@param maxInitialFileSizeBytes if this is zero or greater, then if the file already exists
but is larger than this number of bytes, then the start of the
file will be truncated to keep the size down. This prevents a log
file getting ridiculously large over time. The file will be truncated
at a new-line boundary. If this value is less than zero, no size limit
will be imposed; if it's zero, the file will always be deleted. Note that
the size is only checked once when this object is created - any logging
that is done later will be appended without any checking
*/
FileLogger (const File& fileToWriteTo,
const String& welcomeMessage,
const int64 maxInitialFileSizeBytes = 128 * 1024);
/** Destructor. */
~FileLogger();
//==============================================================================
/** Returns the file that this logger is writing to. */
const File& getLogFile() const noexcept { return logFile; }
//==============================================================================
/** Helper function to create a log file in the correct place for this platform.
The method might return nullptr if the file can't be created for some reason.
@param logFileSubDirectoryName the name of the subdirectory to create inside the logs folder (as
returned by getSystemLogFileFolder). It's best to use something
like the name of your application here.
@param logFileName the name of the file to create, e.g. "MyAppLog.txt".
@param welcomeMessage a message that will be written to the log when it's opened.
@param maxInitialFileSizeBytes (see the FileLogger constructor for more info on this)
*/
static FileLogger* createDefaultAppLogger (const String& logFileSubDirectoryName,
const String& logFileName,
const String& welcomeMessage,
const int64 maxInitialFileSizeBytes = 128 * 1024);
/** Helper function to create a log file in the correct place for this platform.
The filename used is based on the root and suffix strings provided, along with a
time and date string, meaning that a new, empty log file will be always be created
rather than appending to an exising one.
The method might return nullptr if the file can't be created for some reason.
@param logFileSubDirectoryName the name of the subdirectory to create inside the logs folder (as
returned by getSystemLogFileFolder). It's best to use something
like the name of your application here.
@param logFileNameRoot the start of the filename to use, e.g. "MyAppLog_". This will have
a timestamp and the logFileNameSuffix appended to it
@param logFileNameSuffix the file suffix to use, e.g. ".txt"
@param welcomeMessage a message that will be written to the log when it's opened.
*/
static FileLogger* createDateStampedLogger (const String& logFileSubDirectoryName,
const String& logFileNameRoot,
const String& logFileNameSuffix,
const String& welcomeMessage);
//==============================================================================
/** Returns an OS-specific folder where log-files should be stored.
On Windows this will return a logger with a path such as:
c:\\Documents and Settings\\username\\Application Data\\[logFileSubDirectoryName]\\[logFileName]
On the Mac it'll create something like:
~/Library/Logs/[logFileSubDirectoryName]/[logFileName]
@see createDefaultAppLogger
*/
static File getSystemLogFileFolder();
// (implementation of the Logger virtual method)
void logMessage (const String&);
private:
//==============================================================================
File logFile;
CriticalSection logLock;
void trimFileSize (int64 maxFileSizeBytes) const;
};
} // namespace beast
#endif // BEAST_FILELOGGER_H_INCLUDED

View File

@@ -36,8 +36,6 @@ namespace beast
The logger class also contains methods for writing messages to the debugger's
output stream.
@see FileLogger
*/
class BEAST_API Logger
{

File diff suppressed because it is too large Load Diff

View File

@@ -1,326 +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_BIGINTEGER_H_INCLUDED
#define BEAST_BIGINTEGER_H_INCLUDED
namespace beast
{
//==============================================================================
/**
An arbitrarily large integer class.
A BigInteger can be used in a similar way to a normal integer, but has no size
limit (except for memory and performance constraints).
Negative values are possible, but the value isn't stored as 2s-complement, so
be careful if you use negative values and look at the values of individual bits.
*/
class BEAST_API BigInteger : LeakChecked <BigInteger>
{
public:
//==============================================================================
/** Creates an empty BigInteger */
BigInteger();
/** Creates a BigInteger containing an integer value in its low bits.
The low 32 bits of the number are initialised with this value.
*/
BigInteger (uint32 value);
/** Creates a BigInteger containing an integer value in its low bits.
The low 32 bits of the number are initialised with the absolute value
passed in, and its sign is set to reflect the sign of the number.
*/
BigInteger (int32 value);
/** Creates a BigInteger containing an integer value in its low bits.
The low 64 bits of the number are initialised with the absolute value
passed in, and its sign is set to reflect the sign of the number.
*/
BigInteger (int64 value);
/** Creates a copy of another BigInteger. */
BigInteger (const BigInteger& other);
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
BigInteger (BigInteger&& other) noexcept;
BigInteger& operator= (BigInteger&& other) noexcept;
#endif
/** Destructor. */
~BigInteger();
//==============================================================================
/** Copies another BigInteger onto this one. */
BigInteger& operator= (const BigInteger& other);
/** Swaps the internal contents of this with another object. */
void swapWith (BigInteger& other) noexcept;
//==============================================================================
/** Returns the value of a specified bit in the number.
If the index is out-of-range, the result will be false.
*/
bool operator[] (int bit) const noexcept;
/** Returns true if no bits are set. */
bool isZero() const noexcept;
/** Returns true if the value is 1. */
bool isOne() const noexcept;
/** Attempts to get the lowest bits of the value as an integer.
If the value is bigger than the integer limits, this will return only the lower bits.
*/
int toInteger() const noexcept;
//==============================================================================
/** Resets the value to 0. */
void clear();
/** Clears a particular bit in the number. */
void clearBit (int bitNumber) noexcept;
/** Sets a specified bit to 1. */
void setBit (int bitNumber);
/** Sets or clears a specified bit. */
void setBit (int bitNumber, bool shouldBeSet);
/** Sets a range of bits to be either on or off.
@param startBit the first bit to change
@param numBits the number of bits to change
@param shouldBeSet whether to turn these bits on or off
*/
void setRange (int startBit, int numBits, bool shouldBeSet);
/** Inserts a bit an a given position, shifting up any bits above it. */
void insertBit (int bitNumber, bool shouldBeSet);
/** Returns a range of bits as a new BigInteger.
e.g. getBitRangeAsInt (0, 64) would return the lowest 64 bits.
@see getBitRangeAsInt
*/
BigInteger getBitRange (int startBit, int numBits) const;
/** Returns a range of bits as an integer value.
e.g. getBitRangeAsInt (0, 32) would return the lowest 32 bits.
Asking for more than 32 bits isn't allowed (obviously) - for that, use
getBitRange().
*/
uint32 getBitRangeAsInt (int startBit, int numBits) const noexcept;
/** Sets a range of bits to an integer value.
Copies the given integer onto a range of bits, starting at startBit,
and using up to numBits of the available bits.
*/
void setBitRangeAsInt (int startBit, int numBits, uint32 valueToSet);
/** Shifts a section of bits left or right.
@param howManyBitsLeft how far to move the bits (+ve numbers shift it left, -ve numbers shift it right).
@param startBit the first bit to affect - if this is > 0, only bits above that index will be affected.
*/
void shiftBits (int howManyBitsLeft, int startBit);
/** Returns the total number of set bits in the value. */
int countNumberOfSetBits() const noexcept;
/** Looks for the index of the next set bit after a given starting point.
This searches from startIndex (inclusive) upwards for the first set bit,
and returns its index. If no set bits are found, it returns -1.
*/
int findNextSetBit (int startIndex) const noexcept;
/** Looks for the index of the next clear bit after a given starting point.
This searches from startIndex (inclusive) upwards for the first clear bit,
and returns its index.
*/
int findNextClearBit (int startIndex) const noexcept;
/** Returns the index of the highest set bit in the number.
If the value is zero, this will return -1.
*/
int getHighestBit() const noexcept;
//==============================================================================
// All the standard arithmetic ops...
BigInteger& operator+= (const BigInteger& other);
BigInteger& operator-= (const BigInteger& other);
BigInteger& operator*= (const BigInteger& other);
BigInteger& operator/= (const BigInteger& other);
BigInteger& operator|= (const BigInteger& other);
BigInteger& operator&= (const BigInteger& other);
BigInteger& operator^= (const BigInteger& other);
BigInteger& operator%= (const BigInteger& other);
BigInteger& operator<<= (int numBitsToShift);
BigInteger& operator>>= (int numBitsToShift);
BigInteger& operator++();
BigInteger& operator--();
BigInteger operator++ (int);
BigInteger operator-- (int);
BigInteger operator-() const;
BigInteger operator+ (const BigInteger& other) const;
BigInteger operator- (const BigInteger& other) const;
BigInteger operator* (const BigInteger& other) const;
BigInteger operator/ (const BigInteger& other) const;
BigInteger operator| (const BigInteger& other) const;
BigInteger operator& (const BigInteger& other) const;
BigInteger operator^ (const BigInteger& other) const;
BigInteger operator% (const BigInteger& other) const;
BigInteger operator<< (int numBitsToShift) const;
BigInteger operator>> (int numBitsToShift) const;
bool operator== (const BigInteger& other) const noexcept;
bool operator!= (const BigInteger& other) const noexcept;
bool operator< (const BigInteger& other) const noexcept;
bool operator<= (const BigInteger& other) const noexcept;
bool operator> (const BigInteger& other) const noexcept;
bool operator>= (const BigInteger& other) const noexcept;
//==============================================================================
/** Does a signed comparison of two BigIntegers.
Return values are:
- 0 if the numbers are the same
- < 0 if this number is smaller than the other
- > 0 if this number is bigger than the other
*/
int compare (const BigInteger& other) const noexcept;
/** Compares the magnitudes of two BigIntegers, ignoring their signs.
Return values are:
- 0 if the numbers are the same
- < 0 if this number is smaller than the other
- > 0 if this number is bigger than the other
*/
int compareAbsolute (const BigInteger& other) const noexcept;
/** Divides this value by another one and returns the remainder.
This number is divided by other, leaving the quotient in this number,
with the remainder being copied to the other BigInteger passed in.
*/
void divideBy (const BigInteger& divisor, BigInteger& remainder);
/** Returns the largest value that will divide both this value and the one passed-in.
*/
BigInteger findGreatestCommonDivisor (BigInteger other) const;
/** Performs a combined exponent and modulo operation.
This BigInteger's value becomes (this ^ exponent) % modulus.
*/
void exponentModulo (const BigInteger& exponent, const BigInteger& modulus);
/** Performs an inverse modulo on the value.
i.e. the result is (this ^ -1) mod (modulus).
*/
void inverseModulo (const BigInteger& modulus);
//==============================================================================
/** Returns true if the value is less than zero.
@see setNegative, negate
*/
bool isNegative() const noexcept;
/** Changes the sign of the number to be positive or negative.
@see isNegative, negate
*/
void setNegative (bool shouldBeNegative) noexcept;
/** Inverts the sign of the number.
@see isNegative, setNegative
*/
void negate() noexcept;
//==============================================================================
/** Converts the number to a string.
Specify a base such as 2 (binary), 8 (octal), 10 (decimal), 16 (hex).
If minimumNumCharacters is greater than 0, the returned string will be
padded with leading zeros to reach at least that length.
*/
String toString (int base, int minimumNumCharacters = 1) const;
/** Reads the numeric value from a string.
Specify a base such as 2 (binary), 8 (octal), 10 (decimal), 16 (hex).
Any invalid characters will be ignored.
*/
void parseString (const String& text, int base);
//==============================================================================
/** Turns the number into a block of binary data.
The data is arranged as little-endian, so the first byte of data is the low 8 bits
of the number, and so on.
@see loadFromMemoryBlock
*/
MemoryBlock toMemoryBlock() const;
/** Converts a block of raw data into a number.
The data is arranged as little-endian, so the first byte of data is the low 8 bits
of the number, and so on.
@see toMemoryBlock
*/
void loadFromMemoryBlock (const MemoryBlock& data);
private:
//==============================================================================
HeapBlock <uint32> values;
size_t numValues;
int highestBit;
bool negative;
void ensureSize (size_t numVals);
void shiftLeft (int bits, int startBit);
void shiftRight (int bits, int startBit);
};
/** Writes a BigInteger to an OutputStream as a UTF8 decimal string. */
OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const BigInteger& value);
//==============================================================================
#ifndef DOXYGEN
// For backwards compatibility, BitArray is defined as an alias for BigInteger.
typedef BigInteger BitArray;
#endif
} // namespace beast
#endif // BEAST_BIGINTEGER_H_INCLUDED

View File

@@ -106,19 +106,6 @@ double Random::nextDouble() noexcept
return static_cast <uint32> (nextInt()) / (double) 0xffffffff;
}
BigInteger Random::nextLargeNumber (const BigInteger& maximumValue)
{
BigInteger n;
do
{
fillBitsRandomly (n, 0, maximumValue.getHighestBit() + 1);
}
while (n >= maximumValue);
return n;
}
void Random::fillBitsRandomly (void* const buffer, size_t bytes)
{
int* d = static_cast<int*> (buffer);
@@ -133,27 +120,6 @@ void Random::fillBitsRandomly (void* const buffer, size_t bytes)
}
}
void Random::fillBitsRandomly (BigInteger& arrayToChange, int startBit, int numBits)
{
arrayToChange.setBit (startBit + numBits - 1, true); // to force the array to pre-allocate space
while ((startBit & 31) != 0 && numBits > 0)
{
arrayToChange.setBit (startBit++, nextBool());
--numBits;
}
while (numBits >= 32)
{
arrayToChange.setBitRangeAsInt (startBit, 32, (unsigned int) nextInt());
startBit += 32;
numBits -= 32;
}
while (--numBits >= 0)
arrayToChange.setBit (startBit + numBits, nextBool());
}
//==============================================================================
class RandomTests : public UnitTest

View File

@@ -89,18 +89,9 @@ public:
*/
bool nextBool() noexcept;
/** Returns a BigInteger containing a random number.
@returns a random value in the range 0 to (maximumValue - 1).
*/
BigInteger nextLargeNumber (const BigInteger& maximumValue);
/** Fills a block of memory with random values. */
void fillBitsRandomly (void* bufferToFill, size_t sizeInBytes);
/** Sets a range of bits in a BigInteger to random values. */
void fillBitsRandomly (BigInteger& arrayToChange, int startBit, int numBits);
//==============================================================================
/** Resets this Random object to a given seed value. */
void setSeed (int64 newSeed) noexcept;

View File

@@ -1,422 +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_CACHELINE_H_INCLUDED
#define BEAST_CACHELINE_H_INCLUDED
// Allows turning off of all padding,
// e.g. for memory-constrained systems or testing.
//
#define GLOBAL_PADDING_ENABLED 1
namespace beast
{
namespace CacheLine
{
#if GLOBAL_PADDING_ENABLED
/** Pad an object to start on a cache line boundary.
Up to 8 constructor parameters are passed through.
*/
template <typename T>
class Aligned
{
public:
Aligned ()
{
new (&get()) T;
}
template <class T1>
Aligned (T1 t1)
{
new (&get()) T (t1);
}
template <class T1, class T2>
Aligned (T1 t1, T2 t2)
{
new (&get()) T (t1, t2);
}
template <class T1, class T2, class T3>
Aligned (T1 t1, T2 t2, T3 t3)
{
new (&get()) T (t1, t2, t3);
}
template <class T1, class T2, class T3, class T4>
Aligned (T1 t1, T2 t2, T3 t3, T4 t4)
{
new (&get()) T (t1, t2, t3, t4);
}
template <class T1, class T2, class T3, class T4, class T5>
Aligned (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
{
new (&get()) T (t1, t2, t3, t4, t5);
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
Aligned (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
{
new (&get()) T (t1, t2, t3, t4, t5, t6);
}
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
Aligned (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
{
new (&get()) T (t1, t2, t3, t4, t5, t6, t7);
}
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
Aligned (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
{
new (&get()) T (t1, t2, t3, t4, t5, t6, t7, t8);
}
~Aligned ()
{
get().~T ();
}
T& operator= (T const& other)
{
return (get() = other);
}
T& get () noexcept { return *ptr(); }
T& operator* () noexcept { return get(); }
T* operator-> () noexcept { return &get(); }
operator T& () noexcept { return get(); }
operator T* () noexcept { return &get(); }
T const& get () const noexcept { return *ptr(); }
const T& operator* () const noexcept { return get(); }
const T* operator-> () const noexcept { return &get(); }
operator T const& () const noexcept { return get(); }
operator T const* () const noexcept { return &get(); }
private:
T* ptr () const noexcept
{
return (T*) ((uintptr_t (m_storage) + Memory::cacheLineAlignMask)
& ~Memory::cacheLineAlignMask);
/*
return reinterpret_cast <T*> (Memory::pointerAdjustedForAlignment (
m_storage, Memory::cacheLineBytes));
*/
}
char m_storage [ (sizeof (T) + Memory::cacheLineAlignMask) & ~Memory::cacheLineAlignMask];
};
//------------------------------------------------------------------------------
/** End-pads an object to completely fill straddling CPU cache lines.
The caller must ensure that this object starts at the beginning
of a cache line.
*/
template <typename T>
class Padded
{
public:
Padded ()
{
}
template <class T1>
explicit Padded (T1 t1)
: m_t (t1)
{
}
template <class T1, class T2>
Padded (T1 t1, T2 t2)
: m_t (t1, t2)
{
}
template <class T1, class T2, class T3>
Padded (T1 t1, T2 t2, T3 t3)
: m_t (t1, t2, t3)
{
}
template <class T1, class T2, class T3, class T4>
Padded (T1 t1, T2 t2, T3 t3, T4 t4)
: m_t (t1, t2, t3, t4)
{
}
template <class T1, class T2, class T3, class T4, class T5>
Padded (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
: m_t (t1, t2, t3, t4, t5)
{
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
Padded (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
: m_t (t1, t2, t3, t4, t5, t6)
{
}
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
Padded (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
: m_t (t1, t2, t3, t4, t5, t6, t7)
{
}
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
Padded (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
: m_t (t1, t2, t3, t4, t5, t6, t7, t8)
{
}
T& operator= (T const& other)
{
m_t = other;
return m_t;
}
T& get() noexcept { return m_t;}
T& operator* () noexcept { return get(); }
T* operator-> () noexcept { return &get(); }
operator T& () noexcept { return get(); }
operator T* () noexcept { return &get(); }
T const& get () const noexcept { return m_t; }
const T& operator* () const noexcept { return get(); }
const T* operator-> () const noexcept { return &get(); }
operator T const& () const noexcept { return get(); }
operator T const* () const noexcept { return &get(); }
private:
T m_t;
char pad [Memory::cacheLineAlignBytes - sizeof (T)];
};
#else
template <typename T>
class Aligned
{
public:
Aligned ()
{ }
template <class T1>
explicit Aligned (const T1& t1)
: m_t (t1) { }
template <class T1, class T2>
Aligned (const T1& t1, const T2& t2)
: m_t (t1, t2) { }
template <class T1, class T2, class T3>
Aligned (const T1& t1, const T2& t2, const T3& t3)
: m_t (t1, t2, t3) { }
template <class T1, class T2, class T3, class T4>
Aligned (const T1& t1, const T2& t2, const T3& t3, const T4& t4)
: m_t (t1, t2, t3, t4) { }
template <class T1, class T2, class T3, class T4, class T5>
Aligned (const T1& t1, const T2& t2, const T3& t3,
const T4& t4, const T5& t5)
: m_t (t1, t2, t3, t4, t5) { }
template <class T1, class T2, class T3, class T4, class T5, class T6>
Aligned (const T1& t1, const T2& t2, const T3& t3,
const T4& t4, const T5& t5, const T6& t6)
: m_t (t1, t2, t3, t4, t5, t6) { }
template < class T1, class T2, class T3, class T4,
class T5, class T6, class T7 >
Aligned (const T1& t1, const T2& t2, const T3& t3, const T4& t4,
const T5& t5, const T6& t6, const T7& t7)
: m_t (t1, t2, t3, t4, t5, t6, t7) { }
template < class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8 >
Aligned (const T1& t1, const T2& t2, const T3& t3, const T4& t4,
const T5& t5, const T6& t6, const T7& t7, const T8& t8)
: m_t (t1, t2, t3, t4, t5, t6, t7, t8) { }
T& operator= (const T& other)
{
reutrn (m_t = other);
}
T& get () noexcept { return m_t; }
T& operator* () noexcept { return get(); }
T* operator-> () noexcept { return &get(); }
operator T& () noexcept { return get(); }
operator T* () noexcept { return &get(); }
T const& get () const noexcept { return m_t; }
const T& operator* () const noexcept { return get(); }
const T* operator-> () const noexcept { return &get(); }
operator T const& () const noexcept { return get(); }
operator T const* () const noexcept { return &get(); }
private:
T m_t;
};
template <typename T>
class Padded
{
public:
Padded ()
{ }
template <class T1>
explicit Padded (const T1& t1)
: m_t (t1) { }
template <class T1, class T2>
Padded (const T1& t1, const T2& t2)
: m_t (t1, t2) { }
template <class T1, class T2, class T3>
Padded (const T1& t1, const T2& t2, const T3& t3)
: m_t (t1, t2, t3) { }
template <class T1, class T2, class T3, class T4>
Padded (const T1& t1, const T2& t2, const T3& t3, const T4& t4)
: m_t (t1, t2, t3, t4) { }
template <class T1, class T2, class T3, class T4, class T5>
Padded (const T1& t1, const T2& t2, const T3& t3,
const T4& t4, const T5& t5)
: m_t (t1, t2, t3, t4, t5) { }
template <class T1, class T2, class T3, class T4, class T5, class T6>
Padded (const T1& t1, const T2& t2, const T3& t3,
const T4& t4, const T5& t5, const T6& t6)
: m_t (t1, t2, t3, t4, t5, t6) { }
template < class T1, class T2, class T3, class T4,
class T5, class T6, class T7 >
Padded (const T1& t1, const T2& t2, const T3& t3, const T4& t4,
const T5& t5, const T6& t6, const T7& t7)
: m_t (t1, t2, t3, t4, t5, t6, t7) { }
template < class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8 >
Padded (const T1& t1, const T2& t2, const T3& t3, const T4& t4,
const T5& t5, const T6& t6, const T7& t7, const T8& t8)
: m_t (t1, t2, t3, t4, t5, t6, t7, t8) { }
void operator= (const T& other)
{
m_t = other;
}
T& get () noexcept { return m_t; }
T& operator* () noexcept { return get(); }
T* operator-> () noexcept { return &get(); }
operator T& () noexcept { return get(); }
operator T* () noexcept { return &get(); }
T const& get () const noexcept { return m_t; }
const T& operator* () const noexcept { return get(); }
const T* operator-> () const noexcept { return &get(); }
operator T const& () const noexcept { return get(); }
operator T const* () const noexcept { return &get(); }
private:
T m_t;
};
#endif
//
// Used to remove padding without changing code
//
template <typename T>
class Unpadded
{
public:
Unpadded ()
{ }
template <class T1>
explicit Unpadded (const T1& t1)
: m_t (t1) { }
template <class T1, class T2>
Unpadded (const T1& t1, const T2& t2)
: m_t (t1, t2) { }
template <class T1, class T2, class T3>
Unpadded (const T1& t1, const T2& t2, const T3& t3)
: m_t (t1, t2, t3) { }
template <class T1, class T2, class T3, class T4>
Unpadded (const T1& t1, const T2& t2, const T3& t3, const T4& t4)
: m_t (t1, t2, t3, t4) { }
template <class T1, class T2, class T3, class T4, class T5>
Unpadded (const T1& t1, const T2& t2, const T3& t3,
const T4& t4, const T5& t5)
: m_t (t1, t2, t3, t4, t5) { }
template <class T1, class T2, class T3, class T4, class T5, class T6>
Unpadded (const T1& t1, const T2& t2, const T3& t3,
const T4& t4, const T5& t5, const T6& t6)
: m_t (t1, t2, t3, t4, t5, t6) { }
template < class T1, class T2, class T3, class T4,
class T5, class T6, class T7 >
Unpadded (const T1& t1, const T2& t2, const T3& t3, const T4& t4,
const T5& t5, const T6& t6, const T7& t7)
: m_t (t1, t2, t3, t4, t5, t6, t7) { }
template < class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8 >
Unpadded (const T1& t1, const T2& t2, const T3& t3, const T4& t4,
const T5& t5, const T6& t6, const T7& t7, const T8& t8)
: m_t (t1, t2, t3, t4, t5, t6, t7, t8) { }
T* operator= (const T& other)
{
return (m_t = other);
}
T& get () noexcept { return m_t; }
T& operator* () noexcept { return get(); }
T* operator-> () noexcept { return &get(); }
operator T& () noexcept { return get(); }
operator T* () noexcept { return &get(); }
T const& get () const noexcept { return m_t; }
const T& operator* () const noexcept { return get(); }
const T* operator-> () const noexcept { return &get(); }
operator T const& () const noexcept { return get(); }
operator T const* () const noexcept { return &get(); }
private:
T m_t;
};
} // namespace CacheLine
} // namespace beast
#endif

View File

@@ -1,72 +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_MEMORYALIGNMENT_H_INCLUDED
#define BEAST_MEMORYALIGNMENT_H_INCLUDED
namespace beast
{
namespace Memory
{
//------------------------------------------------------------------------------
// Constants
//
// These need to be set based on the target CPU
//
const int cacheLineAlignBits = 6; // 64 bytes
const int cacheLineAlignBytes = 1 << cacheLineAlignBits;
const int cacheLineAlignMask = cacheLineAlignBytes - 1;
const int allocAlignBits = 3; // 8 bytes
const int allocAlignBytes = 1 << allocAlignBits;
const int allocAlignMask = allocAlignBytes - 1;
//------------------------------------------------------------------------------
// Returns the number of bytes needed to advance p to the correct alignment
template <typename P>
inline size_t bytesNeededForAlignment (P const* const p)
{
return (allocAlignBytes - (uintptr_t (p) & allocAlignMask))
& allocAlignMask;
}
// Returns the number of bytes to make "bytes" an aligned size
inline size_t sizeAdjustedForAlignment (const size_t bytes)
{
return (bytes + allocAlignMask) & ~allocAlignMask;
}
// Returns a pointer with alignment added.
template <typename P>
inline P* pointerAdjustedForAlignment (P* const p)
{
return reinterpret_cast <P*> (reinterpret_cast <char*> (p) +
bytesNeededForAlignment (p));
}
} // namespace Memory
} // namespace beast
#endif

View File

@@ -1,184 +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_OPTIONALSCOPEDPOINTER_H_INCLUDED
#define BEAST_OPTIONALSCOPEDPOINTER_H_INCLUDED
namespace beast
{
//==============================================================================
/**
Holds a pointer to an object which can optionally be deleted when this pointer
goes out of scope.
This acts in many ways like a ScopedPointer, but allows you to specify whether or
not the object is deleted.
@see ScopedPointer
*/
template <class ObjectType>
class OptionalScopedPointer
{
public:
//==============================================================================
/** Creates an empty OptionalScopedPointer. */
OptionalScopedPointer() : shouldDelete (false) {}
/** Creates an OptionalScopedPointer to point to a given object, and specifying whether
the OptionalScopedPointer will delete it.
If takeOwnership is true, then the OptionalScopedPointer will act like a ScopedPointer,
deleting the object when it is itself deleted. If this parameter is false, then the
OptionalScopedPointer just holds a normal pointer to the object, and won't delete it.
*/
OptionalScopedPointer (ObjectType* objectToHold, bool takeOwnership)
: object (objectToHold), shouldDelete (takeOwnership)
{
}
/** Takes ownership of the object that another OptionalScopedPointer holds.
Like a normal ScopedPointer, the objectToTransferFrom object will become null,
as ownership of the managed object is transferred to this object.
The flag to indicate whether or not to delete the managed object is also
copied from the source object.
*/
OptionalScopedPointer (OptionalScopedPointer& objectToTransferFrom)
: object (objectToTransferFrom.release()),
shouldDelete (objectToTransferFrom.shouldDelete)
{
}
/** Takes ownership of the object that another OptionalScopedPointer holds.
Like a normal ScopedPointer, the objectToTransferFrom object will become null,
as ownership of the managed object is transferred to this object.
The ownership flag that says whether or not to delete the managed object is also
copied from the source object.
*/
OptionalScopedPointer& operator= (OptionalScopedPointer& objectToTransferFrom)
{
if (object != objectToTransferFrom.object)
{
clear();
object = objectToTransferFrom.object;
}
shouldDelete = objectToTransferFrom.shouldDelete;
return *this;
}
/** The destructor may or may not delete the object that is being held, depending on the
takeOwnership flag that was specified when the object was first passed into an
OptionalScopedPointer constructor.
*/
~OptionalScopedPointer()
{
clear();
}
//==============================================================================
/** Returns the object that this pointer is managing. */
inline operator ObjectType*() const noexcept { return object; }
/** Returns the object that this pointer is managing. */
inline ObjectType* get() const noexcept { return object; }
/** Returns the object that this pointer is managing. */
inline ObjectType& operator*() const noexcept { return *object; }
/** Lets you access methods and properties of the object that this pointer is holding. */
inline ObjectType* operator->() const noexcept { return object; }
//==============================================================================
/** Removes the current object from this OptionalScopedPointer without deleting it.
This will return the current object, and set this OptionalScopedPointer to a null pointer.
*/
ObjectType* release() noexcept { return object.release(); }
/** Resets this pointer to null, possibly deleting the object that it holds, if it has
ownership of it.
*/
void clear()
{
if (! shouldDelete)
object.release();
}
/** Makes this OptionalScopedPointer point at a new object, specifying whether the
OptionalScopedPointer will take ownership of the object.
If takeOwnership is true, then the OptionalScopedPointer will act like a ScopedPointer,
deleting the object when it is itself deleted. If this parameter is false, then the
OptionalScopedPointer just holds a normal pointer to the object, and won't delete it.
*/
void set (ObjectType* newObject, bool takeOwnership)
{
if (object != newObject)
{
clear();
object = newObject;
}
shouldDelete = takeOwnership;
}
/** Makes this OptionalScopedPointer point at a new object, and take ownership of that object. */
void setOwned (ObjectType* newObject)
{
set (newObject, true);
}
/** Makes this OptionalScopedPointer point at a new object, but will not take ownership of that object. */
void setNonOwned (ObjectType* newObject)
{
set (newObject, false);
}
/** Returns true if the target object will be deleted when this pointer
object is deleted.
*/
bool willDeleteObject() const noexcept { return shouldDelete; }
//==============================================================================
/** Swaps this object with another OptionalScopedPointer.
The two objects simply exchange their states.
*/
void swapWith (OptionalScopedPointer<ObjectType>& other) noexcept
{
object.swapWith (other.object);
std::swap (shouldDelete, other.shouldDelete);
}
private:
//==============================================================================
ScopedPointer<ObjectType> object;
bool shouldDelete;
};
} // namespace beast
#endif // BEAST_OPTIONALSCOPEDPOINTER_H_INCLUDED

View File

@@ -1,114 +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.
*/
//==============================================================================
namespace beast
{
namespace
{
int64 getRandomSeedFromMACAddresses()
{
Array<MACAddress> result;
MACAddress::findAllAddresses (result);
Random r;
for (int i = 0; i < result.size(); ++i)
r.combineSeed (result[i].toInt64());
return r.nextInt64();
}
}
//==============================================================================
Uuid::Uuid()
{
// The normal random seeding is pretty good, but we'll throw some MAC addresses
// into the mix too, to make it very very unlikely that two UUIDs will ever be the same..
static Random r1 (getRandomSeedFromMACAddresses());
Random r2;
for (size_t i = 0; i < sizeof (uuid); ++i)
uuid[i] = (uint8) (r1.nextInt() ^ r2.nextInt());
}
Uuid::~Uuid() noexcept {}
Uuid::Uuid (const Uuid& other) noexcept
{
memcpy (uuid, other.uuid, sizeof (uuid));
}
Uuid& Uuid::operator= (const Uuid& other) noexcept
{
memcpy (uuid, other.uuid, sizeof (uuid));
return *this;
}
bool Uuid::operator== (const Uuid& other) const noexcept { return memcmp (uuid, other.uuid, sizeof (uuid)) == 0; }
bool Uuid::operator!= (const Uuid& other) const noexcept { return ! operator== (other); }
bool Uuid::isNull() const noexcept
{
for (size_t i = 0; i < sizeof (uuid); ++i)
if (uuid[i] != 0)
return false;
return true;
}
String Uuid::toString() const
{
return String::toHexString (uuid, sizeof (uuid), 0);
}
Uuid::Uuid (const String& uuidString)
{
operator= (uuidString);
}
Uuid& Uuid::operator= (const String& uuidString)
{
MemoryBlock mb;
mb.loadFromHexString (uuidString);
mb.ensureSize (sizeof (uuid), true);
mb.copyTo (uuid, 0, sizeof (uuid));
return *this;
}
Uuid::Uuid (const uint8* const rawData)
{
operator= (rawData);
}
Uuid& Uuid::operator= (const uint8* const rawData) noexcept
{
if (rawData != nullptr)
memcpy (uuid, rawData, sizeof (uuid));
else
zeromem (uuid, sizeof (uuid));
return *this;
}
} // namespace beast

View File

@@ -1,108 +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_UUID_H_INCLUDED
#define BEAST_UUID_H_INCLUDED
namespace beast
{
//==============================================================================
/**
A universally unique 128-bit identifier.
This class generates very random unique numbers based on the system time
and MAC addresses if any are available. It's extremely unlikely that two identical
UUIDs would ever be created by chance.
The class includes methods for saving the ID as a string or as raw binary data.
*/
class BEAST_API Uuid : LeakChecked <Uuid>
{
public:
//==============================================================================
/** Creates a new unique ID. */
Uuid();
/** Destructor. */
~Uuid() noexcept;
/** Creates a copy of another UUID. */
Uuid (const Uuid& other) noexcept;
/** Copies another UUID. */
Uuid& operator= (const Uuid& other) noexcept;
//==============================================================================
/** Returns true if the ID is zero. */
bool isNull() const noexcept;
bool operator== (const Uuid& other) const noexcept;
bool operator!= (const Uuid& other) const noexcept;
//==============================================================================
/** Returns a stringified version of this UUID.
A Uuid object can later be reconstructed from this string using operator= or
the constructor that takes a string parameter.
@returns a 32 character hex string.
*/
String toString() const;
/** Creates an ID from an encoded string version.
@see toString
*/
Uuid (const String& uuidString);
/** Copies from a stringified UUID.
The string passed in should be one that was created with the toString() method.
*/
Uuid& operator= (const String& uuidString);
//==============================================================================
/** Returns a pointer to the internal binary representation of the ID.
This is an array of 16 bytes. To reconstruct a Uuid from its data, use
the constructor or operator= method that takes an array of uint8s.
*/
const uint8* getRawData() const noexcept { return uuid; }
/** Creates a UUID from a 16-byte array.
@see getRawData
*/
Uuid (const uint8* rawData);
/** Sets this UUID from 16-bytes of raw data. */
Uuid& operator= (const uint8* rawData) noexcept;
private:
//==============================================================================
uint8 uuid[16];
};
} // namespace beast
#endif // BEAST_UUID_H_INCLUDED

View File

@@ -1,240 +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.
*/
//==============================================================================
namespace beast
{
bool File::copyInternal (const File& dest) const
{
FileInputStream in (*this);
if (dest.deleteFile())
{
{
FileOutputStream out (dest);
if (out.failedToOpen())
return false;
if (out.writeFromInputStream (in, -1) == getSize())
return true;
}
dest.deleteFile();
}
return false;
}
void File::findFileSystemRoots (Array<File>& destArray)
{
destArray.add (File ("/"));
}
//==============================================================================
bool File::isOnCDRomDrive() const
{
return false;
}
bool File::isOnHardDisk() const
{
return true;
}
bool File::isOnRemovableDrive() const
{
return false;
}
bool File::isHidden() const
{
return getFileName().startsWithChar ('.');
}
//==============================================================================
namespace
{
File beast_readlink (const String& file, const File& defaultFile)
{
const int size = 8192;
HeapBlock<char> buffer;
buffer.malloc (size + 4);
const size_t numBytes = readlink (file.toUTF8(), buffer, size);
if (numBytes > 0 && numBytes <= size)
return File (file).getSiblingFile (String::fromUTF8 (buffer, (int) numBytes));
return defaultFile;
}
}
File File::getLinkedTarget() const
{
return beast_readlink (getFullPathName().toUTF8(), *this);
}
//==============================================================================
File File::getSpecialLocation (const SpecialLocationType type)
{
switch (type)
{
case userHomeDirectory:
case userDocumentsDirectory:
case userMusicDirectory:
case userMoviesDirectory:
case userPicturesDirectory:
case userApplicationDataDirectory:
case commonDocumentsDirectory:
case userDesktopDirectory:
return File (android.appDataDir);
case commonApplicationDataDirectory:
return File (android.appDataDir);
case globalApplicationsDirectory:
return File ("/system/app");
case tempDirectory:
return File (android.appDataDir).getChildFile (".temp");
case invokedExecutableFile:
case currentExecutableFile:
case currentApplicationFile:
case hostApplicationPath:
return beast_getExecutableFile();
default:
bassertfalse; // unknown type?
break;
}
return File::nonexistent ();
}
//==============================================================================
String File::getVersion() const
{
return String::empty;
}
//==============================================================================
bool File::moveToTrash() const
{
if (! exists())
return true;
// TODO
return false;
}
//==============================================================================
class DirectoryIterator::NativeIterator::Pimpl : public Uncopyable
{
public:
Pimpl (const File& directory, const String& wildCard_)
: parentDir (File::addTrailingSeparator (directory.getFullPathName())),
wildCard (wildCard_),
dir (opendir (directory.getFullPathName().toUTF8()))
{
}
~Pimpl()
{
if (dir != 0)
closedir (dir);
}
bool next (String& filenameFound,
bool* const isDir, bool* const isHidden, int64* const fileSize,
Time* const modTime, Time* const creationTime, bool* const isReadOnly)
{
if (dir != 0)
{
const char* wildcardUTF8 = nullptr;
for (;;)
{
struct dirent* const de = readdir (dir);
if (de == nullptr)
break;
if (wildcardUTF8 == nullptr)
wildcardUTF8 = wildCard.toUTF8();
if (fnmatch (wildcardUTF8, de->d_name, FNM_CASEFOLD) == 0)
{
filenameFound = CharPointer_UTF8 (de->d_name);
updateStatInfoForFile (parentDir + filenameFound, isDir, fileSize, modTime, creationTime, isReadOnly);
if (isHidden != 0)
*isHidden = filenameFound.startsWithChar ('.');
return true;
}
}
}
return false;
}
private:
String parentDir, wildCard;
DIR* dir;
};
DirectoryIterator::NativeIterator::NativeIterator (const File& directory, const String& wildCard)
: pimpl (new DirectoryIterator::NativeIterator::Pimpl (directory, wildCard))
{
}
DirectoryIterator::NativeIterator::~NativeIterator()
{
}
bool DirectoryIterator::NativeIterator::next (String& filenameFound,
bool* const isDir, bool* const isHidden, int64* const fileSize,
Time* const modTime, Time* const creationTime, bool* const isReadOnly)
{
return pimpl->next (filenameFound, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly);
}
//==============================================================================
bool Process::openDocument (const String& fileName, const String& parameters)
{
const LocalRef<jstring> t (javaString (fileName));
android.activity.callVoidMethod (BeastAppActivity.launchURL, t.get());
return true;
}
void File::revealToUser() const
{
}
} // namespace beast

View File

@@ -1,405 +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_ANDROID_JNIHELPERS_H_INCLUDED
#define BEAST_ANDROID_JNIHELPERS_H_INCLUDED
namespace beast
{
#if ! (defined (BEAST_ANDROID_ACTIVITY_CLASSNAME) && defined (BEAST_ANDROID_ACTIVITY_CLASSPATH))
#error "The BEAST_ANDROID_ACTIVITY_CLASSNAME and BEAST_ANDROID_ACTIVITY_CLASSPATH macros must be set!"
#endif
//==============================================================================
extern JNIEnv* getEnv() noexcept;
//==============================================================================
class GlobalRef
{
public:
inline GlobalRef() noexcept : obj (0) {}
inline explicit GlobalRef (jobject o) : obj (retain (o)) {}
inline GlobalRef (const GlobalRef& other) : obj (retain (other.obj)) {}
~GlobalRef() { clear(); }
inline void clear()
{
if (obj != 0)
{
getEnv()->DeleteGlobalRef (obj);
obj = 0;
}
}
inline GlobalRef& operator= (const GlobalRef& other)
{
jobject newObj = retain (other.obj);
clear();
obj = newObj;
return *this;
}
//==============================================================================
inline operator jobject() const noexcept { return obj; }
inline jobject get() const noexcept { return obj; }
//==============================================================================
#define DECLARE_CALL_TYPE_METHOD(returnType, typeName) \
returnType call##typeName##Method (jmethodID methodID, ... ) const \
{ \
va_list args; \
va_start (args, methodID); \
returnType result = getEnv()->Call##typeName##MethodV (obj, methodID, args); \
va_end (args); \
return result; \
}
DECLARE_CALL_TYPE_METHOD (jobject, Object)
DECLARE_CALL_TYPE_METHOD (jboolean, Boolean)
DECLARE_CALL_TYPE_METHOD (jbyte, Byte)
DECLARE_CALL_TYPE_METHOD (jchar, Char)
DECLARE_CALL_TYPE_METHOD (jshort, Short)
DECLARE_CALL_TYPE_METHOD (jint, Int)
DECLARE_CALL_TYPE_METHOD (jlong, Long)
DECLARE_CALL_TYPE_METHOD (jfloat, Float)
DECLARE_CALL_TYPE_METHOD (jdouble, Double)
#undef DECLARE_CALL_TYPE_METHOD
void callVoidMethod (jmethodID methodID, ... ) const
{
va_list args;
va_start (args, methodID);
getEnv()->CallVoidMethodV (obj, methodID, args);
va_end (args);
}
private:
//==============================================================================
jobject obj;
static inline jobject retain (jobject obj)
{
return obj == 0 ? 0 : getEnv()->NewGlobalRef (obj);
}
};
//==============================================================================
template <typename JavaType>
class LocalRef
{
public:
explicit inline LocalRef (JavaType o) noexcept : obj (o) {}
inline LocalRef (const LocalRef& other) noexcept : obj (retain (other.obj)) {}
~LocalRef() { clear(); }
void clear()
{
if (obj != 0)
getEnv()->DeleteLocalRef (obj);
}
LocalRef& operator= (const LocalRef& other)
{
jobject newObj = retain (other.obj);
clear();
obj = newObj;
return *this;
}
inline operator JavaType() const noexcept { return obj; }
inline JavaType get() const noexcept { return obj; }
private:
JavaType obj;
static JavaType retain (JavaType obj)
{
return obj == 0 ? 0 : (JavaType) getEnv()->NewLocalRef (obj);
}
};
//==============================================================================
namespace
{
String beastString (JNIEnv* env, jstring s)
{
const char* const utf8 = env->GetStringUTFChars (s, nullptr);
CharPointer_UTF8 utf8CP (utf8);
const String result (utf8CP);
env->ReleaseStringUTFChars (s, utf8);
return result;
}
String beastString (jstring s)
{
return beastString (getEnv(), s);
}
LocalRef<jstring> javaString (const String& s)
{
return LocalRef<jstring> (getEnv()->NewStringUTF (s.toUTF8()));
}
LocalRef<jstring> javaStringFromChar (const beast_wchar c)
{
char utf8[8] = { 0 };
CharPointer_UTF8 (utf8).write (c);
return LocalRef<jstring> (getEnv()->NewStringUTF (utf8));
}
}
//==============================================================================
class JNIClassBase : public Uncopyable
{
public:
explicit JNIClassBase (const char* classPath);
virtual ~JNIClassBase();
inline operator jclass() const noexcept { return classRef; }
static void initialiseAllClasses (JNIEnv*);
static void releaseAllClasses (JNIEnv*);
protected:
virtual void initialiseFields (JNIEnv*) = 0;
jmethodID resolveMethod (JNIEnv*, const char* methodName, const char* params);
jmethodID resolveStaticMethod (JNIEnv*, const char* methodName, const char* params);
jfieldID resolveField (JNIEnv*, const char* fieldName, const char* signature);
jfieldID resolveStaticField (JNIEnv*, const char* fieldName, const char* signature);
private:
const char* const classPath;
jclass classRef;
static Array<JNIClassBase*>& getClasses();
void initialise (JNIEnv*);
void release (JNIEnv*);
};
//==============================================================================
#define CREATE_JNI_METHOD(methodID, stringName, params) methodID = resolveMethod (env, stringName, params);
#define CREATE_JNI_STATICMETHOD(methodID, stringName, params) methodID = resolveStaticMethod (env, stringName, params);
#define CREATE_JNI_FIELD(fieldID, stringName, signature) fieldID = resolveField (env, stringName, signature);
#define CREATE_JNI_STATICFIELD(fieldID, stringName, signature) fieldID = resolveStaticField (env, stringName, signature);
#define DECLARE_JNI_METHOD(methodID, stringName, params) jmethodID methodID;
#define DECLARE_JNI_FIELD(fieldID, stringName, signature) jfieldID fieldID;
#define DECLARE_JNI_CLASS(CppClassName, javaPath) \
class CppClassName ## _Class : public JNIClassBase \
{ \
public: \
CppClassName ## _Class() : JNIClassBase (javaPath) {} \
\
void initialiseFields (JNIEnv* env) \
{ \
JNI_CLASS_MEMBERS (CREATE_JNI_METHOD, CREATE_JNI_STATICMETHOD, CREATE_JNI_FIELD, CREATE_JNI_STATICFIELD); \
} \
\
JNI_CLASS_MEMBERS (DECLARE_JNI_METHOD, DECLARE_JNI_METHOD, DECLARE_JNI_FIELD, DECLARE_JNI_FIELD); \
}; \
static CppClassName ## _Class CppClassName;
//==============================================================================
#define BEAST_JNI_CALLBACK(className, methodName, returnType, params) \
extern "C" __attribute__ ((visibility("default"))) returnType BEAST_JOIN_MACRO (BEAST_JOIN_MACRO (Java_, className), _ ## methodName) params
//==============================================================================
class AndroidSystem
{
public:
AndroidSystem();
void initialise (JNIEnv*, jobject activity, jstring appFile, jstring appDataDir);
void shutdown (JNIEnv*);
//==============================================================================
GlobalRef activity;
String appFile, appDataDir;
int screenWidth, screenHeight;
};
extern AndroidSystem android;
//==============================================================================
class ThreadLocalJNIEnvHolder
{
public:
ThreadLocalJNIEnvHolder()
: jvm (nullptr)
{
zeromem (threads, sizeof (threads));
zeromem (envs, sizeof (envs));
}
void initialise (JNIEnv* env)
{
// NB: the DLL can be left loaded by the JVM, so the same static
// objects can end up being reused by subsequent runs of the app
zeromem (threads, sizeof (threads));
zeromem (envs, sizeof (envs));
env->GetJavaVM (&jvm);
addEnv (env);
}
JNIEnv* attach()
{
JNIEnv* env = nullptr;
jvm->AttachCurrentThread (&env, nullptr);
if (env != nullptr)
addEnv (env);
return env;
}
void detach()
{
jvm->DetachCurrentThread();
const pthread_t thisThread = pthread_self();
SpinLock::ScopedLockType sl (addRemoveLock);
for (int i = 0; i < maxThreads; ++i)
if (threads[i] == thisThread)
threads[i] = 0;
}
JNIEnv* getOrAttach() noexcept
{
JNIEnv* env = get();
if (env == nullptr)
env = attach();
bassert (env != nullptr);
return env;
}
JNIEnv* get() const noexcept
{
const pthread_t thisThread = pthread_self();
for (int i = 0; i < maxThreads; ++i)
if (threads[i] == thisThread)
return envs[i];
return nullptr;
}
enum { maxThreads = 32 };
private:
JavaVM* jvm;
pthread_t threads [maxThreads];
JNIEnv* envs [maxThreads];
SpinLock addRemoveLock;
void addEnv (JNIEnv* env)
{
SpinLock::ScopedLockType sl (addRemoveLock);
if (get() == nullptr)
{
const pthread_t thisThread = pthread_self();
for (int i = 0; i < maxThreads; ++i)
{
if (threads[i] == 0)
{
envs[i] = env;
threads[i] = thisThread;
return;
}
}
}
bassertfalse; // too many threads!
}
};
extern ThreadLocalJNIEnvHolder threadLocalJNIEnvHolder;
//==============================================================================
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
METHOD (createNewView, "createNewView", "(Z)L" BEAST_ANDROID_ACTIVITY_CLASSPATH "$ComponentPeerView;") \
METHOD (deleteView, "deleteView", "(L" BEAST_ANDROID_ACTIVITY_CLASSPATH "$ComponentPeerView;)V") \
METHOD (postMessage, "postMessage", "(J)V") \
METHOD (finish, "finish", "()V") \
METHOD (getClipboardContent, "getClipboardContent", "()Ljava/lang/String;") \
METHOD (setClipboardContent, "setClipboardContent", "(Ljava/lang/String;)V") \
METHOD (excludeClipRegion, "excludeClipRegion", "(Landroid/graphics/Canvas;FFFF)V") \
METHOD (renderGlyph, "renderGlyph", "(CLandroid/graphics/Paint;Landroid/graphics/Matrix;Landroid/graphics/Rect;)[I") \
STATICMETHOD (createHTTPStream, "createHTTPStream", "(Ljava/lang/String;Z[BLjava/lang/String;ILjava/lang/StringBuffer;)L" BEAST_ANDROID_ACTIVITY_CLASSPATH "$HTTPStream;") \
METHOD (launchURL, "launchURL", "(Ljava/lang/String;)V") \
METHOD (showMessageBox, "showMessageBox", "(Ljava/lang/String;Ljava/lang/String;J)V") \
METHOD (showOkCancelBox, "showOkCancelBox", "(Ljava/lang/String;Ljava/lang/String;J)V") \
METHOD (showYesNoCancelBox, "showYesNoCancelBox", "(Ljava/lang/String;Ljava/lang/String;J)V") \
STATICMETHOD (getLocaleValue, "getLocaleValue", "(Z)Ljava/lang/String;") \
METHOD (scanFile, "scanFile", "(Ljava/lang/String;)V")
DECLARE_JNI_CLASS (BeastAppActivity, BEAST_ANDROID_ACTIVITY_CLASSPATH);
#undef JNI_CLASS_MEMBERS
//==============================================================================
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
METHOD (constructor, "<init>", "(I)V") \
METHOD (setColor, "setColor", "(I)V") \
METHOD (setAlpha, "setAlpha", "(I)V") \
METHOD (setTypeface, "setTypeface", "(Landroid/graphics/Typeface;)Landroid/graphics/Typeface;") \
METHOD (ascent, "ascent", "()F") \
METHOD (descent, "descent", "()F") \
METHOD (setTextSize, "setTextSize", "(F)V") \
METHOD (getTextWidths, "getTextWidths", "(Ljava/lang/String;[F)I") \
METHOD (setTextScaleX, "setTextScaleX", "(F)V") \
METHOD (getTextPath, "getTextPath", "(Ljava/lang/String;IIFFLandroid/graphics/Path;)V") \
METHOD (setShader, "setShader", "(Landroid/graphics/Shader;)Landroid/graphics/Shader;") \
DECLARE_JNI_CLASS (Paint, "android/graphics/Paint");
#undef JNI_CLASS_MEMBERS
//==============================================================================
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
METHOD (constructor, "<init>", "()V") \
METHOD (setValues, "setValues", "([F)V") \
DECLARE_JNI_CLASS (Matrix, "android/graphics/Matrix");
#undef JNI_CLASS_MEMBERS
//==============================================================================
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
METHOD (constructor, "<init>", "(IIII)V") \
FIELD (left, "left", "I") \
FIELD (right, "right", "I") \
FIELD (top, "top", "I") \
FIELD (bottom, "bottom", "I") \
DECLARE_JNI_CLASS (RectClass, "android/graphics/Rect");
#undef JNI_CLASS_MEMBERS
} // namespace beast
#endif // BEAST_ANDROID_JNIHELPERS_H_INCLUDED

View File

@@ -1,32 +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.
*/
//==============================================================================
namespace beast
{
void Logger::outputDebugString (const String& text)
{
__android_log_print (ANDROID_LOG_INFO, "BEAST", "%", text.toUTF8().getAddress());
}
} // namespace beast

View File

@@ -1,64 +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.
*/
//==============================================================================
namespace beast
{
//==============================================================================
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
METHOD (constructor, "<init>", "()V") \
METHOD (toString, "toString", "()Ljava/lang/String;") \
DECLARE_JNI_CLASS (StringBuffer, "java/lang/StringBuffer");
#undef JNI_CLASS_MEMBERS
//==============================================================================
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
METHOD (release, "release", "()V") \
METHOD (read, "read", "([BI)I") \
METHOD (getPosition, "getPosition", "()J") \
METHOD (getTotalLength, "getTotalLength", "()J") \
METHOD (isExhausted, "isExhausted", "()Z") \
METHOD (setPosition, "setPosition", "(J)Z") \
DECLARE_JNI_CLASS (HTTPStream, BEAST_ANDROID_ACTIVITY_CLASSPATH "$HTTPStream");
#undef JNI_CLASS_MEMBERS
//==============================================================================
void MACAddress::findAllAddresses (Array<MACAddress>& result)
{
// TODO
}
bool Process::openEmailWithAttachments (const String& targetEmailAddress,
const String& emailSubject,
const String& bodyText,
const StringArray& filesToAttach)
{
// TODO
return false;
}
} // namespace beast

View File

@@ -1,306 +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.
*/
//==============================================================================
namespace beast
{
JNIClassBase::JNIClassBase (const char* classPath_)
: classPath (classPath_), classRef (0)
{
getClasses().add (this);
}
JNIClassBase::~JNIClassBase()
{
getClasses().removeFirstMatchingValue (this);
}
Array<JNIClassBase*>& JNIClassBase::getClasses()
{
static Array<JNIClassBase*> classes;
return classes;
}
void JNIClassBase::initialise (JNIEnv* env)
{
classRef = (jclass) env->NewGlobalRef (env->FindClass (classPath));
bassert (classRef != 0);
initialiseFields (env);
}
void JNIClassBase::release (JNIEnv* env)
{
env->DeleteGlobalRef (classRef);
}
void JNIClassBase::initialiseAllClasses (JNIEnv* env)
{
const Array<JNIClassBase*>& classes = getClasses();
for (int i = classes.size(); --i >= 0;)
classes.getUnchecked(i)->initialise (env);
}
void JNIClassBase::releaseAllClasses (JNIEnv* env)
{
const Array<JNIClassBase*>& classes = getClasses();
for (int i = classes.size(); --i >= 0;)
classes.getUnchecked(i)->release (env);
}
jmethodID JNIClassBase::resolveMethod (JNIEnv* env, const char* methodName, const char* params)
{
jmethodID m = env->GetMethodID (classRef, methodName, params);
bassert (m != 0);
return m;
}
jmethodID JNIClassBase::resolveStaticMethod (JNIEnv* env, const char* methodName, const char* params)
{
jmethodID m = env->GetStaticMethodID (classRef, methodName, params);
bassert (m != 0);
return m;
}
jfieldID JNIClassBase::resolveField (JNIEnv* env, const char* fieldName, const char* signature)
{
jfieldID f = env->GetFieldID (classRef, fieldName, signature);
bassert (f != 0);
return f;
}
jfieldID JNIClassBase::resolveStaticField (JNIEnv* env, const char* fieldName, const char* signature)
{
jfieldID f = env->GetStaticFieldID (classRef, fieldName, signature);
bassert (f != 0);
return f;
}
//==============================================================================
ThreadLocalJNIEnvHolder threadLocalJNIEnvHolder;
#if BEAST_DEBUG
static bool systemInitialised = false;
#endif
JNIEnv* getEnv() noexcept
{
#if BEAST_DEBUG
if (! systemInitialised)
{
DBG ("*** Call to getEnv() when system not initialised");
bassertfalse;
exit (0);
}
#endif
return threadLocalJNIEnvHolder.getOrAttach();
}
extern "C" jint JNI_OnLoad (JavaVM*, void*)
{
return JNI_VERSION_1_2;
}
//==============================================================================
AndroidSystem::AndroidSystem() : screenWidth (0), screenHeight (0)
{
}
void AndroidSystem::initialise (JNIEnv* env, jobject activity_,
jstring appFile_, jstring appDataDir_)
{
screenWidth = screenHeight = 0;
JNIClassBase::initialiseAllClasses (env);
threadLocalJNIEnvHolder.initialise (env);
#if BEAST_DEBUG
systemInitialised = true;
#endif
activity = GlobalRef (activity_);
appFile = beastString (env, appFile_);
appDataDir = beastString (env, appDataDir_);
}
void AndroidSystem::shutdown (JNIEnv* env)
{
activity.clear();
#if BEAST_DEBUG
systemInitialised = false;
#endif
JNIClassBase::releaseAllClasses (env);
}
AndroidSystem android;
//==============================================================================
namespace AndroidStatsHelpers
{
//==============================================================================
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
STATICMETHOD (getProperty, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;")
DECLARE_JNI_CLASS (SystemClass, "java/lang/System");
#undef JNI_CLASS_MEMBERS
//==============================================================================
String getSystemProperty (const String& name)
{
return beastString (LocalRef<jstring> ((jstring) getEnv()->CallStaticObjectMethod (SystemClass,
SystemClass.getProperty,
javaString (name).get())));
}
//==============================================================================
String getLocaleValue (bool isRegion)
{
return beastString (LocalRef<jstring> ((jstring) getEnv()->CallStaticObjectMethod (BeastAppActivity,
BeastAppActivity.getLocaleValue,
isRegion)));
}
}
//==============================================================================
SystemStats::OperatingSystemType SystemStats::getOperatingSystemType()
{
return Android;
}
String SystemStats::getOperatingSystemName()
{
return "Android " + AndroidStatsHelpers::getSystemProperty ("os.version");
}
bool SystemStats::isOperatingSystem64Bit()
{
#if BEAST_64BIT
return true;
#else
return false;
#endif
}
String SystemStats::getCpuVendor()
{
return AndroidStatsHelpers::getSystemProperty ("os.arch");
}
int SystemStats::getCpuSpeedInMegaherz()
{
return 0; // TODO
}
int SystemStats::getMemorySizeInMegabytes()
{
#if __ANDROID_API__ >= 9
struct sysinfo sysi;
if (sysinfo (&sysi) == 0)
return (sysi.totalram * sysi.mem_unit / (1024 * 1024));
#endif
return 0;
}
int SystemStats::getPageSize()
{
return sysconf (_SC_PAGESIZE);
}
//==============================================================================
String SystemStats::getLogonName()
{
const char* user = getenv ("USER");
if (user == 0)
{
struct passwd* const pw = getpwuid (getuid());
if (pw != 0)
user = pw->pw_name;
}
return CharPointer_UTF8 (user);
}
String SystemStats::getFullUserName()
{
return getLogonName();
}
String SystemStats::getComputerName()
{
char name [256] = { 0 };
if (gethostname (name, sizeof (name) - 1) == 0)
return name;
return String::empty;
}
String SystemStats::getUserLanguage() { return AndroidStatsHelpers::getLocaleValue (false); }
String SystemStats::getUserRegion() { return AndroidStatsHelpers::getLocaleValue (true); }
String SystemStats::getDisplayLanguage() { return getUserLanguage(); }
//==============================================================================
void CPUInformation::initialise() noexcept
{
numCpus = bmax (1, sysconf (_SC_NPROCESSORS_ONLN));
}
//==============================================================================
uint32 beast_millisecondsSinceStartup() noexcept
{
timespec t;
clock_gettime (CLOCK_MONOTONIC, &t);
return t.tv_sec * 1000 + t.tv_nsec / 1000000;
}
int64 Time::getHighResolutionTicks() noexcept
{
timespec t;
clock_gettime (CLOCK_MONOTONIC, &t);
return (t.tv_sec * (int64) 1000000) + (t.tv_nsec / 1000);
}
int64 Time::getHighResolutionTicksPerSecond() noexcept
{
return 1000000; // (microseconds)
}
double Time::getMillisecondCounterHiRes() noexcept
{
return getHighResolutionTicks() * 0.001;
}
bool Time::setSystemTimeToThisTime() const
{
bassertfalse;
return false;
}
} // namespace beast

View File

@@ -1,76 +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.
*/
//==============================================================================
namespace beast
{
/*
Note that a lot of methods that you'd expect to find in this file actually
live in beast_posix_SharedCode.h!
*/
//==============================================================================
// sets the process to 0=low priority, 1=normal, 2=high, 3=realtime
void Process::setPriority (ProcessPriority prior)
{
// TODO
struct sched_param param;
int policy, maxp, minp;
const int p = (int) prior;
if (p <= 1)
policy = SCHED_OTHER;
else
policy = SCHED_RR;
minp = sched_get_priority_min (policy);
maxp = sched_get_priority_max (policy);
if (p < 2)
param.sched_priority = 0;
else if (p == 2 )
// Set to middle of lower realtime priority range
param.sched_priority = minp + (maxp - minp) / 4;
else
// Set to middle of higher realtime priority range
param.sched_priority = minp + (3 * (maxp - minp) / 4);
pthread_setschedparam (pthread_self(), policy, &param);
}
bool beast_isRunningUnderDebugger()
{
return false;
}
BEAST_API bool BEAST_CALLTYPE Process::isRunningUnderDebugger()
{
return beast_isRunningUnderDebugger();
}
void Process::raisePrivilege() {}
void Process::lowerPrivilege() {}
} // namespace beast

View File

@@ -24,33 +24,6 @@
namespace beast
{
void MACAddress::findAllAddresses (Array<MACAddress>& result)
{
ifaddrs* addrs = nullptr;
if (getifaddrs (&addrs) == 0)
{
for (const ifaddrs* cursor = addrs; cursor != nullptr; cursor = cursor->ifa_next)
{
sockaddr_storage* sto = (sockaddr_storage*) cursor->ifa_addr;
if (sto->ss_family == AF_LINK)
{
const sockaddr_dl* const sadd = (const sockaddr_dl*) cursor->ifa_addr;
#ifndef IFT_ETHER
#define IFT_ETHER 6
#endif
if (sadd->sdl_type == IFT_ETHER)
result.addIfNotAlreadyThere (MACAddress (((const uint8*) sadd->sdl_data) + sadd->sdl_nlen));
}
}
freeifaddrs (addrs);
}
}
bool Process::openEmailWithAttachments (const String& /* targetEmailAddress */,
const String& /* emailSubject */,
const String& /* bodyText */,

View File

@@ -1,697 +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.
*/
//==============================================================================
package com.beast;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.view.*;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.graphics.*;
import android.opengl.*;
import android.text.ClipboardManager;
import android.text.InputType;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.HttpURLConnection;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
//==============================================================================
public final class BeastAppActivity extends Activity
{
//==============================================================================
static
{
System.loadLibrary ("beast_jni");
}
@Override
public final void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
viewHolder = new ViewHolder (this);
setContentView (viewHolder);
setVolumeControlStream (AudioManager.STREAM_MUSIC);
}
@Override
protected final void onDestroy()
{
quitApp();
super.onDestroy();
}
@Override
protected final void onPause()
{
if (viewHolder != null)
viewHolder.onPause();
suspendApp();
super.onPause();
}
@Override
protected final void onResume()
{
super.onResume();
if (viewHolder != null)
viewHolder.onResume();
resumeApp();
}
@Override
public void onConfigurationChanged (Configuration cfg)
{
super.onConfigurationChanged (cfg);
setContentView (viewHolder);
}
private void callAppLauncher()
{
launchApp (getApplicationInfo().publicSourceDir,
getApplicationInfo().dataDir);
}
//==============================================================================
private native void launchApp (String appFile, String appDataDir);
private native void quitApp();
private native void suspendApp();
private native void resumeApp();
private native void setScreenSize (int screenWidth, int screenHeight);
//==============================================================================
public native void deliverMessage (long value);
private android.os.Handler messageHandler = new android.os.Handler();
public final void postMessage (long value)
{
messageHandler.post (new MessageCallback (value));
}
private final class MessageCallback implements Runnable
{
public MessageCallback (long value_) { value = value_; }
public final void run() { deliverMessage (value); }
private long value;
}
//==============================================================================
private ViewHolder viewHolder;
public final ComponentPeerView createNewView (boolean opaque)
{
ComponentPeerView v = new ComponentPeerView (this, opaque);
viewHolder.addView (v);
return v;
}
public final void deleteView (ComponentPeerView view)
{
ViewGroup group = (ViewGroup) (view.getParent());
if (group != null)
group.removeView (view);
}
final class ViewHolder extends ViewGroup
{
public ViewHolder (Context context)
{
super (context);
setDescendantFocusability (ViewGroup.FOCUS_AFTER_DESCENDANTS);
setFocusable (false);
}
protected final void onLayout (boolean changed, int left, int top, int right, int bottom)
{
setScreenSize (getWidth(), getHeight());
if (isFirstResize)
{
isFirstResize = false;
callAppLauncher();
}
}
public final void onPause()
{
for (int i = getChildCount(); --i >= 0;)
{
View v = getChildAt (i);
if (v instanceof ComponentPeerView)
((ComponentPeerView) v).onPause();
}
}
public final void onResume()
{
for (int i = getChildCount(); --i >= 0;)
{
View v = getChildAt (i);
if (v instanceof ComponentPeerView)
((ComponentPeerView) v).onResume();
}
}
private boolean isFirstResize = true;
}
public final void excludeClipRegion (android.graphics.Canvas canvas, float left, float top, float right, float bottom)
{
canvas.clipRect (left, top, right, bottom, android.graphics.Region.Op.DIFFERENCE);
}
//==============================================================================
public final String getClipboardContent()
{
ClipboardManager clipboard = (ClipboardManager) getSystemService (CLIPBOARD_SERVICE);
return clipboard.getText().toString();
}
public final void setClipboardContent (String newText)
{
ClipboardManager clipboard = (ClipboardManager) getSystemService (CLIPBOARD_SERVICE);
clipboard.setText (newText);
}
//==============================================================================
public final void showMessageBox (String title, String message, final long callback)
{
AlertDialog.Builder builder = new AlertDialog.Builder (this);
builder.setTitle (title)
.setMessage (message)
.setCancelable (true)
.setPositiveButton ("OK", new DialogInterface.OnClickListener()
{
public void onClick (DialogInterface dialog, int id)
{
dialog.cancel();
BeastAppActivity.this.alertDismissed (callback, 0);
}
});
builder.create().show();
}
public final void showOkCancelBox (String title, String message, final long callback)
{
AlertDialog.Builder builder = new AlertDialog.Builder (this);
builder.setTitle (title)
.setMessage (message)
.setCancelable (true)
.setPositiveButton ("OK", new DialogInterface.OnClickListener()
{
public void onClick (DialogInterface dialog, int id)
{
dialog.cancel();
BeastAppActivity.this.alertDismissed (callback, 1);
}
})
.setNegativeButton ("Cancel", new DialogInterface.OnClickListener()
{
public void onClick (DialogInterface dialog, int id)
{
dialog.cancel();
BeastAppActivity.this.alertDismissed (callback, 0);
}
});
builder.create().show();
}
public final void showYesNoCancelBox (String title, String message, final long callback)
{
AlertDialog.Builder builder = new AlertDialog.Builder (this);
builder.setTitle (title)
.setMessage (message)
.setCancelable (true)
.setPositiveButton ("Yes", new DialogInterface.OnClickListener()
{
public void onClick (DialogInterface dialog, int id)
{
dialog.cancel();
BeastAppActivity.this.alertDismissed (callback, 1);
}
})
.setNegativeButton ("No", new DialogInterface.OnClickListener()
{
public void onClick (DialogInterface dialog, int id)
{
dialog.cancel();
BeastAppActivity.this.alertDismissed (callback, 2);
}
})
.setNeutralButton ("Cancel", new DialogInterface.OnClickListener()
{
public void onClick (DialogInterface dialog, int id)
{
dialog.cancel();
BeastAppActivity.this.alertDismissed (callback, 0);
}
});
builder.create().show();
}
public native void alertDismissed (long callback, int id);
//==============================================================================
public final class ComponentPeerView extends ViewGroup
implements View.OnFocusChangeListener
{
public ComponentPeerView (Context context, boolean opaque_)
{
super (context);
setWillNotDraw (false);
opaque = opaque_;
setFocusable (true);
setFocusableInTouchMode (true);
setOnFocusChangeListener (this);
requestFocus();
}
//==============================================================================
private native void handlePaint (Canvas canvas);
@Override
public void draw (Canvas canvas)
{
super.draw (canvas);
handlePaint (canvas);
}
@Override
public boolean isOpaque()
{
return opaque;
}
private boolean opaque;
//==============================================================================
private native void handleMouseDown (int index, float x, float y, long time);
private native void handleMouseDrag (int index, float x, float y, long time);
private native void handleMouseUp (int index, float x, float y, long time);
@Override
public boolean onTouchEvent (MotionEvent event)
{
int action = event.getAction();
long time = event.getEventTime();
switch (action & MotionEvent.ACTION_MASK)
{
case MotionEvent.ACTION_DOWN:
handleMouseDown (event.getPointerId(0), event.getX(), event.getY(), time);
return true;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
handleMouseUp (event.getPointerId(0), event.getX(), event.getY(), time);
return true;
case MotionEvent.ACTION_MOVE:
{
int n = event.getPointerCount();
for (int i = 0; i < n; ++i)
handleMouseDrag (event.getPointerId(i), event.getX(i), event.getY(i), time);
return true;
}
case MotionEvent.ACTION_POINTER_UP:
{
int i = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
handleMouseUp (event.getPointerId(i), event.getX(i), event.getY(i), time);
return true;
}
case MotionEvent.ACTION_POINTER_DOWN:
{
int i = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
handleMouseDown (event.getPointerId(i), event.getX(i), event.getY(i), time);
return true;
}
default:
break;
}
return false;
}
//==============================================================================
private native void handleKeyDown (int keycode, int textchar);
private native void handleKeyUp (int keycode, int textchar);
public void showKeyboard (boolean shouldShow)
{
InputMethodManager imm = (InputMethodManager) getSystemService (Context.INPUT_METHOD_SERVICE);
if (imm != null)
{
if (shouldShow)
imm.showSoftInput (this, InputMethodManager.SHOW_FORCED);
else
imm.hideSoftInputFromWindow (getWindowToken(), 0);
}
}
@Override
public boolean onKeyDown (int keyCode, KeyEvent event)
{
handleKeyDown (keyCode, event.getUnicodeChar());
return true;
}
@Override
public boolean onKeyUp (int keyCode, KeyEvent event)
{
handleKeyUp (keyCode, event.getUnicodeChar());
return true;
}
// this is here to make keyboard entry work on a Galaxy Tab2 10.1
@Override
public InputConnection onCreateInputConnection (EditorInfo outAttrs)
{
outAttrs.actionLabel = "";
outAttrs.hintText = "";
outAttrs.initialCapsMode = 0;
outAttrs.initialSelEnd = outAttrs.initialSelStart = -1;
outAttrs.label = "";
outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
outAttrs.inputType = InputType.TYPE_NULL;
return new BaseInputConnection (this, false);
}
//==============================================================================
@Override
protected void onSizeChanged (int w, int h, int oldw, int oldh)
{
super.onSizeChanged (w, h, oldw, oldh);
viewSizeChanged();
}
@Override
protected void onLayout (boolean changed, int left, int top, int right, int bottom)
{
for (int i = getChildCount(); --i >= 0;)
requestTransparentRegion (getChildAt (i));
}
private native void viewSizeChanged();
@Override
public void onFocusChange (View v, boolean hasFocus)
{
if (v == this)
focusChanged (hasFocus);
}
private native void focusChanged (boolean hasFocus);
public void setViewName (String newName) {}
public boolean isVisible() { return getVisibility() == VISIBLE; }
public void setVisible (boolean b) { setVisibility (b ? VISIBLE : INVISIBLE); }
public boolean containsPoint (int x, int y)
{
return true; //xxx needs to check overlapping views
}
public final void onPause()
{
for (int i = getChildCount(); --i >= 0;)
{
View v = getChildAt (i);
if (v instanceof OpenGLView)
((OpenGLView) v).onPause();
}
}
public final void onResume()
{
for (int i = getChildCount(); --i >= 0;)
{
View v = getChildAt (i);
if (v instanceof OpenGLView)
((OpenGLView) v).onResume();
}
}
public OpenGLView createGLView()
{
OpenGLView glView = new OpenGLView (getContext());
addView (glView);
return glView;
}
}
//==============================================================================
public final class OpenGLView extends GLSurfaceView
implements GLSurfaceView.Renderer
{
OpenGLView (Context context)
{
super (context);
setEGLContextClientVersion (2);
setRenderer (this);
setRenderMode (RENDERMODE_WHEN_DIRTY);
}
@Override
public void onSurfaceCreated (GL10 unused, EGLConfig config)
{
contextCreated();
}
@Override
public void onSurfaceChanged (GL10 unused, int width, int height)
{
contextChangedSize();
}
@Override
public void onDrawFrame (GL10 unused)
{
render();
}
private native void contextCreated();
private native void contextChangedSize();
private native void render();
}
//==============================================================================
public final int[] renderGlyph (char glyph, Paint paint, android.graphics.Matrix matrix, Rect bounds)
{
Path p = new Path();
paint.getTextPath (String.valueOf (glyph), 0, 1, 0.0f, 0.0f, p);
RectF boundsF = new RectF();
p.computeBounds (boundsF, true);
matrix.mapRect (boundsF);
boundsF.roundOut (bounds);
bounds.left--;
bounds.right++;
final int w = bounds.width();
final int h = Math.max (1, bounds.height());
Bitmap bm = Bitmap.createBitmap (w, h, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas (bm);
matrix.postTranslate (-bounds.left, -bounds.top);
c.setMatrix (matrix);
c.drawPath (p, paint);
final int sizeNeeded = w * h;
if (cachedRenderArray.length < sizeNeeded)
cachedRenderArray = new int [sizeNeeded];
bm.getPixels (cachedRenderArray, 0, w, 0, 0, w, h);
bm.recycle();
return cachedRenderArray;
}
private int[] cachedRenderArray = new int [256];
//==============================================================================
public static class HTTPStream
{
public HTTPStream (HttpURLConnection connection_) throws IOException
{
connection = connection_;
inputStream = new BufferedInputStream (connection.getInputStream());
}
public final void release()
{
try
{
inputStream.close();
}
catch (IOException e)
{}
connection.disconnect();
}
public final int read (byte[] buffer, int numBytes)
{
int num = 0;
try
{
num = inputStream.read (buffer, 0, numBytes);
}
catch (IOException e)
{}
if (num > 0)
position += num;
return num;
}
public final long getPosition() { return position; }
public final long getTotalLength() { return -1; }
public final boolean isExhausted() { return false; }
public final boolean setPosition (long newPos) { return false; }
private HttpURLConnection connection;
private InputStream inputStream;
private long position;
}
public static final HTTPStream createHTTPStream (String address, boolean isPost, byte[] postData,
String headers, int timeOutMs,
java.lang.StringBuffer responseHeaders)
{
try
{
HttpURLConnection connection = (HttpURLConnection) (new URL (address).openConnection());
if (connection != null)
{
try
{
if (isPost)
{
connection.setConnectTimeout (timeOutMs);
connection.setDoOutput (true);
connection.setChunkedStreamingMode (0);
OutputStream out = connection.getOutputStream();
out.write (postData);
out.flush();
}
return new HTTPStream (connection);
}
catch (Throwable e)
{
connection.disconnect();
}
}
}
catch (Throwable e)
{}
return null;
}
public final void launchURL (String url)
{
startActivity (new Intent (Intent.ACTION_VIEW, Uri.parse (url)));
}
public static final String getLocaleValue (boolean isRegion)
{
java.util.Locale locale = java.util.Locale.getDefault();
return isRegion ? locale.getDisplayCountry (java.util.Locale.US)
: locale.getDisplayLanguage (java.util.Locale.US);
}
//==============================================================================
private final class SingleMediaScanner implements MediaScannerConnectionClient
{
public SingleMediaScanner (Context context, String filename)
{
file = filename;
msc = new MediaScannerConnection (context, this);
msc.connect();
}
@Override
public void onMediaScannerConnected()
{
msc.scanFile (file, null);
}
@Override
public void onScanCompleted (String path, Uri uri)
{
msc.disconnect();
}
private MediaScannerConnection msc;
private String file;
}
public final void scanFile (String filename)
{
new SingleMediaScanner (this, filename);
}
}

View File

@@ -24,35 +24,6 @@
namespace beast
{
void MACAddress::findAllAddresses (Array<MACAddress>& result)
{
const int s = socket (AF_INET, SOCK_DGRAM, 0);
if (s != -1)
{
char buf [1024];
struct ifconf ifc;
ifc.ifc_len = sizeof (buf);
ifc.ifc_buf = buf;
ioctl (s, SIOCGIFCONF, &ifc);
for (unsigned int i = 0; i < ifc.ifc_len / sizeof (struct ifreq); ++i)
{
struct ifreq ifr;
strcpy (ifr.ifr_name, ifc.ifc_req[i].ifr_name);
if (ioctl (s, SIOCGIFFLAGS, &ifr) == 0
&& (ifr.ifr_flags & IFF_LOOPBACK) == 0
&& ioctl (s, SIOCGIFHWADDR, &ifr) == 0)
{
result.addIfNotAlreadyThere (MACAddress ((const uint8*) ifr.ifr_hwaddr.sa_data));
}
}
close (s);
}
}
bool Process::openEmailWithAttachments (const String& /* targetEmailAddress */,
const String& /* emailSubject */,
const String& /* bodyText */,

View File

@@ -24,33 +24,6 @@
namespace beast
{
void MACAddress::findAllAddresses (Array<MACAddress>& result)
{
ifaddrs* addrs = nullptr;
if (getifaddrs (&addrs) == 0)
{
for (const ifaddrs* cursor = addrs; cursor != nullptr; cursor = cursor->ifa_next)
{
sockaddr_storage* sto = (sockaddr_storage*) cursor->ifa_addr;
if (sto->ss_family == AF_LINK)
{
const sockaddr_dl* const sadd = (const sockaddr_dl*) cursor->ifa_addr;
#ifndef IFT_ETHER
#define IFT_ETHER 6
#endif
if (sadd->sdl_type == IFT_ETHER)
result.addIfNotAlreadyThere (MACAddress (((const uint8*) sadd->sdl_data) + sadd->sdl_nlen));
}
}
freeifaddrs (addrs);
}
}
//==============================================================================
bool Process::openEmailWithAttachments (const String& targetEmailAddress,
const String& emailSubject,
const String& bodyText,

View File

@@ -1,34 +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.
*/
//==============================================================================
namespace beast
{
//#pragma message(BEAST_FILEANDLINE_ "Missing platform-specific implementation")
FPUFlags FPUFlags::getCurrent ()
{
return FPUFlags ();
}
void FPUFlags::setCurrent (const FPUFlags& flags)
{
}
} // namespace beast

View File

@@ -598,48 +598,6 @@ String SystemStats::getEnvironmentVariable (const String& name, const String& de
return defaultValue;
}
//==============================================================================
void MemoryMappedFile::openInternal (const File& file, AccessMode mode)
{
bassert (mode == readOnly || mode == readWrite);
if (range.getStart() > 0)
{
const long pageSize = sysconf (_SC_PAGE_SIZE);
range.setStart (range.getStart() - (range.getStart() % pageSize));
}
fileHandle = open (file.getFullPathName().toUTF8(),
mode == readWrite ? (O_CREAT + O_RDWR) : O_RDONLY, 00644);
if (fileHandle != -1)
{
void* m = mmap (0, (size_t) range.getLength(),
mode == readWrite ? (PROT_READ | PROT_WRITE) : PROT_READ,
MAP_SHARED, fileHandle,
(off_t) range.getStart());
if (m != MAP_FAILED)
{
address = m;
madvise (m, (size_t) range.getLength(), MADV_SEQUENTIAL);
}
else
{
range = Range<int64>();
}
}
}
MemoryMappedFile::~MemoryMappedFile()
{
if (address != nullptr)
munmap (address, (size_t) range.getLength());
if (fileHandle != 0)
close (fileHandle);
}
//==============================================================================
#if BEAST_PROBEASTR_LIVE_BUILD
extern "C" const char* beast_getCurrentExecutablePath();

View File

@@ -1,181 +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.
*/
//==============================================================================
namespace beast
{
FPUFlags FPUFlags::getCurrent ()
{
unsigned int currentControl;
const unsigned int newControl = 0;
const unsigned int mask = 0;
errno_t result = _controlfp_s (&currentControl, newControl, mask);
if (result != 0)
Throw (std::runtime_error ("error in _controlfp_s"));
FPUFlags flags;
flags.setMaskNaNs ((currentControl & _EM_INVALID) == _EM_INVALID);
flags.setMaskDenormals ((currentControl & _EM_DENORMAL) == _EM_DENORMAL);
flags.setMaskZeroDivides ((currentControl & _EM_ZERODIVIDE) == _EM_ZERODIVIDE);
flags.setMaskOverflows ((currentControl & _EM_OVERFLOW) == _EM_OVERFLOW);
flags.setMaskUnderflows ((currentControl & _EM_UNDERFLOW) == _EM_UNDERFLOW);
//flags.setMaskInexacts ((currentControl & _EM_INEXACT) == _EM_INEXACT);
flags.setFlushDenormals ((currentControl & _DN_FLUSH) == _DN_FLUSH);
flags.setInfinitySigned ((currentControl & _IC_AFFINE) == _IC_AFFINE);
Rounding rounding = roundDown;
switch (currentControl & _MCW_RC)
{
case _RC_CHOP:
rounding = roundChop;
break;
case _RC_UP:
rounding = roundUp;
break;
case _RC_DOWN:
rounding = roundDown;
break;
case _RC_NEAR:
rounding = roundNear;
break;
default:
Throw (std::runtime_error ("unknown rounding in _controlfp_s"));
};
flags.setRounding (rounding);
Precision precision = bits64;
switch (currentControl & _MCW_PC )
{
case _PC_64:
precision = bits64;
break;
case _PC_53:
precision = bits53;
break;
case _PC_24:
precision = bits24;
break;
default:
Throw (std::runtime_error ("unknown precision in _controlfp_s"));
};
flags.setPrecision (precision);
return flags;
}
static void setControl (const FPUFlags::Flag& flag,
unsigned int& newControl,
unsigned int& mask,
unsigned int constant)
{
if (flag.is_set ())
{
mask |= constant;
if (flag.value ())
newControl |= constant;
}
}
void FPUFlags::setCurrent (const FPUFlags& flags)
{
unsigned int newControl = 0;
unsigned int mask = 0;
setControl (flags.getMaskNaNs (), newControl, mask, _EM_INVALID);
setControl (flags.getMaskDenormals (), newControl, mask, _EM_DENORMAL);
setControl (flags.getMaskZeroDivides (), newControl, mask, _EM_ZERODIVIDE);
setControl (flags.getMaskOverflows (), newControl, mask, _EM_OVERFLOW);
setControl (flags.getMaskUnderflows (), newControl, mask, _EM_UNDERFLOW);
//setControl (flags.getMaskInexacts(), newControl, mask, _EM_INEXACT);
setControl (flags.getFlushDenormals (), newControl, mask, _DN_FLUSH);
setControl (flags.getInfinitySigned (), newControl, mask, _IC_AFFINE);
if (flags.getRounding ().is_set ())
{
Rounding rounding = flags.getRounding ().value ();
switch (rounding)
{
case roundChop:
mask |= _MCW_RC;
newControl |= _RC_CHOP;
break;
case roundUp:
mask |= _MCW_RC;
newControl |= _RC_UP;
break;
case roundDown:
mask |= _MCW_RC;
newControl |= _RC_DOWN;
break;
case roundNear:
mask |= _MCW_RC;
newControl |= _RC_NEAR;
break;
}
}
if (flags.getPrecision ().is_set ())
{
switch (flags.getPrecision ().value ())
{
case bits64:
mask |= _MCW_PC;
newControl |= _PC_64;
break;
case bits53:
mask |= _MCW_PC;
newControl |= _PC_53;
break;
case bits24:
mask |= _MCW_PC;
newControl |= _PC_24;
break;
}
}
unsigned int currentControl;
errno_t result = _controlfp_s (&currentControl, newControl, mask);
if (result != 0)
Throw (std::runtime_error ("error in _controlfp_s"));
}
} // namespace beast

View File

@@ -466,63 +466,8 @@ Result RandomAccessFile::nativeFlush ()
return result;
}
//==============================================================================
void MemoryMappedFile::openInternal (const File& file, AccessMode mode)
{
bassert (mode == readOnly || mode == readWrite);
if (range.getStart() > 0)
{
SYSTEM_INFO systemInfo;
GetNativeSystemInfo (&systemInfo);
range.setStart (range.getStart() - (range.getStart() % systemInfo.dwAllocationGranularity));
}
DWORD accessMode = GENERIC_READ, createType = OPEN_EXISTING;
DWORD protect = PAGE_READONLY, access = FILE_MAP_READ;
if (mode == readWrite)
{
accessMode = GENERIC_READ | GENERIC_WRITE;
createType = OPEN_ALWAYS;
protect = PAGE_READWRITE;
access = FILE_MAP_ALL_ACCESS;
}
HANDLE h = CreateFile (file.getFullPathName().toWideCharPointer(), accessMode, FILE_SHARE_READ, 0,
createType, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0);
if (h != INVALID_HANDLE_VALUE)
{
fileHandle = (void*) h;
HANDLE mappingHandle = CreateFileMapping (h, 0, protect, (DWORD) (range.getEnd() >> 32), (DWORD) range.getEnd(), 0);
if (mappingHandle != 0)
{
address = MapViewOfFile (mappingHandle, access, (DWORD) (range.getStart() >> 32),
(DWORD) range.getStart(), (SIZE_T) range.getLength());
if (address == nullptr)
range = Range<int64>();
CloseHandle (mappingHandle);
}
}
}
MemoryMappedFile::~MemoryMappedFile()
{
if (address != nullptr)
UnmapViewOfFile (address);
if (fileHandle != nullptr)
CloseHandle ((HANDLE) fileHandle);
}
//==============================================================================
int64 File::getSize() const
{
WIN32_FILE_ATTRIBUTE_DATA attributes;

View File

@@ -24,98 +24,6 @@
namespace beast
{
struct GetAdaptersInfoHelper
{
bool callGetAdaptersInfo()
{
DynamicLibrary dll ("iphlpapi.dll");
BEAST_LOAD_WINAPI_FUNCTION (dll, GetAdaptersInfo, getAdaptersInfo, DWORD, (PIP_ADAPTER_INFO, PULONG))
if (getAdaptersInfo == nullptr)
return false;
adapterInfo.malloc (1);
ULONG len = sizeof (IP_ADAPTER_INFO);
if (getAdaptersInfo (adapterInfo, &len) == ERROR_BUFFER_OVERFLOW)
adapterInfo.malloc (len, 1);
return getAdaptersInfo (adapterInfo, &len) == NO_ERROR;
}
HeapBlock<IP_ADAPTER_INFO> adapterInfo;
};
namespace MACAddressHelpers
{
void getViaGetAdaptersInfo (Array<MACAddress>& result)
{
GetAdaptersInfoHelper gah;
if (gah.callGetAdaptersInfo())
{
for (PIP_ADAPTER_INFO adapter = gah.adapterInfo; adapter != nullptr; adapter = adapter->Next)
if (adapter->AddressLength >= 6)
result.addIfNotAlreadyThere (MACAddress (adapter->Address));
}
}
void getViaNetBios (Array<MACAddress>& result)
{
DynamicLibrary dll ("netapi32.dll");
BEAST_LOAD_WINAPI_FUNCTION (dll, Netbios, NetbiosCall, UCHAR, (PNCB))
if (NetbiosCall != 0)
{
LANA_ENUM enums = { 0 };
{
NCB ncb = { 0 };
ncb.ncb_command = NCBENUM;
ncb.ncb_buffer = (unsigned char*) &enums;
ncb.ncb_length = sizeof (LANA_ENUM);
NetbiosCall (&ncb);
}
for (int i = 0; i < enums.length; ++i)
{
NCB ncb2 = { 0 };
ncb2.ncb_command = NCBRESET;
ncb2.ncb_lana_num = enums.lana[i];
if (NetbiosCall (&ncb2) == 0)
{
NCB ncb = { 0 };
memcpy (ncb.ncb_callname, "* ", NCBNAMSZ);
ncb.ncb_command = NCBASTAT;
ncb.ncb_lana_num = enums.lana[i];
struct ASTAT
{
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff [30];
};
ASTAT astat;
zerostruct (astat);
ncb.ncb_buffer = (unsigned char*) &astat;
ncb.ncb_length = sizeof (ASTAT);
if (NetbiosCall (&ncb) == 0 && astat.adapt.adapter_type == 0xfe)
result.addIfNotAlreadyThere (MACAddress (astat.adapt.adapter_address));
}
}
}
}
}
void MACAddress::findAllAddresses (Array<MACAddress>& result)
{
MACAddressHelpers::getViaGetAdaptersInfo (result);
MACAddressHelpers::getViaNetBios (result);
}
//==============================================================================
bool Process::openEmailWithAttachments (const String& targetEmailAddress,
const String& emailSubject,
const String& bodyText,

View File

@@ -1,78 +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.
*/
//==============================================================================
namespace beast
{
MACAddress::MACAddress()
{
zeromem (address, sizeof (address));
}
MACAddress::MACAddress (const MACAddress& other)
{
memcpy (address, other.address, sizeof (address));
}
MACAddress& MACAddress::operator= (const MACAddress& other)
{
memcpy (address, other.address, sizeof (address));
return *this;
}
MACAddress::MACAddress (const uint8 bytes[6])
{
memcpy (address, bytes, sizeof (address));
}
String MACAddress::toString() const
{
String s;
for (size_t i = 0; i < sizeof (address); ++i)
{
s << String::toHexString ((int) address[i]).paddedLeft ('0', 2);
if (i < sizeof (address) - 1)
s << '-';
}
return s;
}
int64 MACAddress::toInt64() const noexcept
{
int64 n = 0;
for (int i = (int) sizeof (address); --i >= 0;)
n = (n << 8) | address[i];
return n;
}
bool MACAddress::isNull() const noexcept { return toInt64() == 0; }
bool MACAddress::operator== (const MACAddress& other) const noexcept { return memcmp (address, other.address, sizeof (address)) == 0; }
bool MACAddress::operator!= (const MACAddress& other) const noexcept { return ! operator== (other); }
} // namespace beast

View File

@@ -1,85 +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_MACADDRESS_H_INCLUDED
#define BEAST_MACADDRESS_H_INCLUDED
namespace beast
{
//==============================================================================
/**
A wrapper for a streaming (TCP) socket.
This allows low-level use of sockets; for an easier-to-use messaging layer on top of
sockets, you could also try the InterprocessConnection class.
@see DatagramSocket, InterprocessConnection, InterprocessConnectionServer
*/
class BEAST_API MACAddress
{
public:
//==============================================================================
/** Populates a list of the MAC addresses of all the available network cards. */
static void findAllAddresses (Array<MACAddress>& results);
//==============================================================================
/** Creates a null address (00-00-00-00-00-00). */
MACAddress();
/** Creates a copy of another address. */
MACAddress (const MACAddress& other);
/** Creates a copy of another address. */
MACAddress& operator= (const MACAddress& other);
/** Creates an address from 6 bytes. */
explicit MACAddress (const uint8 bytes[6]);
/** Returns a pointer to the 6 bytes that make up this address. */
const uint8* getBytes() const noexcept { return address; }
/** Returns a dash-separated string in the form "11-22-33-44-55-66" */
String toString() const;
/** Returns the address in the lower 6 bytes of an int64.
This uses a little-endian arrangement, with the first byte of the address being
stored in the least-significant byte of the result value.
*/
int64 toInt64() const noexcept;
/** Returns true if this address is null (00-00-00-00-00-00). */
bool isNull() const noexcept;
bool operator== (const MACAddress& other) const noexcept;
bool operator!= (const MACAddress& other) const noexcept;
//==============================================================================
private:
uint8 address[6];
};
} // namespace beast
#endif // BEAST_MACADDRESS_H_INCLUDED

View File

@@ -1,66 +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.
*/
//==============================================================================
namespace beast
{
NamedPipe::NamedPipe()
{
}
NamedPipe::~NamedPipe()
{
close();
}
bool NamedPipe::openExisting (const String& pipeName)
{
close();
ScopedWriteLock sl (lock);
currentPipeName = pipeName;
return openInternal (pipeName, false);
}
bool NamedPipe::isOpen() const
{
return pimpl != nullptr;
}
bool NamedPipe::createNewPipe (const String& pipeName)
{
close();
ScopedWriteLock sl (lock);
currentPipeName = pipeName;
return openInternal (pipeName, true);
}
String NamedPipe::getName() const
{
return currentPipeName;
}
// other methods for this class are implemented in the platform-specific files
} // namespace beast

View File

@@ -1,100 +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_NAMEDPIPE_H_INCLUDED
#define BEAST_NAMEDPIPE_H_INCLUDED
namespace beast
{
//==============================================================================
/**
A cross-process pipe that can have data written to and read from it.
Two processes can use NamedPipe objects to exchange blocks of data.
@see InterprocessConnection
*/
class BEAST_API NamedPipe : LeakChecked <NamedPipe>, public Uncopyable
{
public:
//==============================================================================
/** Creates a NamedPipe. */
NamedPipe();
/** Destructor. */
~NamedPipe();
//==============================================================================
/** Tries to open a pipe that already exists.
Returns true if it succeeds.
*/
bool openExisting (const String& pipeName);
/** Tries to create a new pipe.
Returns true if it succeeds.
*/
bool createNewPipe (const String& pipeName);
/** Closes the pipe, if it's open. */
void close();
/** True if the pipe is currently open. */
bool isOpen() const;
/** Returns the last name that was used to try to open this pipe. */
String getName() const;
//==============================================================================
/** Reads data from the pipe.
This will block until another thread has written enough data into the pipe to fill
the number of bytes specified, or until another thread calls the cancelPendingReads()
method.
If the operation fails, it returns -1, otherwise, it will return the number of
bytes read.
If timeOutMilliseconds is less than zero, it will wait indefinitely, otherwise
this is a maximum timeout for reading from the pipe.
*/
int read (void* destBuffer, int maxBytesToRead, int timeOutMilliseconds);
/** Writes some data to the pipe.
@returns the number of bytes written, or -1 on failure.
*/
int write (const void* sourceBuffer, int numBytesToWrite, int timeOutMilliseconds);
private:
//==============================================================================
BEAST_PUBLIC_IN_DLL_BUILD (class Pimpl)
ScopedPointer<Pimpl> pimpl;
String currentPipeName;
ReadWriteLock lock;
bool openInternal (const String& pipeName, const bool createPipe);
};
} // namespace beast
#endif // BEAST_NAMEDPIPE_H_INCLUDED

View File

@@ -1,590 +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.
*/
//==============================================================================
namespace beast
{
#if BEAST_MSVC
#pragma warning (push)
#pragma warning (disable : 4127 4389 4018)
#endif
#ifndef AI_NUMERICSERV // (missing in older Mac SDKs)
#define AI_NUMERICSERV 0x1000
#endif
#if BEAST_WINDOWS
typedef int beast_socklen_t;
typedef SOCKET SocketHandle;
#else
typedef socklen_t beast_socklen_t;
typedef int SocketHandle;
#endif
//==============================================================================
namespace SocketHelpers
{
static void initSockets()
{
#if BEAST_WINDOWS
static bool socketsStarted = false;
if (! socketsStarted)
{
socketsStarted = true;
WSADATA wsaData;
const WORD wVersionRequested = MAKEWORD (1, 1);
WSAStartup (wVersionRequested, &wsaData);
}
#endif
}
static bool resetSocketOptions (const SocketHandle handle, const bool isDatagram, const bool allowBroadcast) noexcept
{
const int sndBufSize = 65536;
const int rcvBufSize = 65536;
const int one = 1;
return handle > 0
&& setsockopt (handle, SOL_SOCKET, SO_RCVBUF, (const char*) &rcvBufSize, sizeof (rcvBufSize)) == 0
&& setsockopt (handle, SOL_SOCKET, SO_SNDBUF, (const char*) &sndBufSize, sizeof (sndBufSize)) == 0
&& (isDatagram ? ((! allowBroadcast) || setsockopt (handle, SOL_SOCKET, SO_BROADCAST, (const char*) &one, sizeof (one)) == 0)
: (setsockopt (handle, IPPROTO_TCP, TCP_NODELAY, (const char*) &one, sizeof (one)) == 0));
}
static bool bindSocketToPort (const SocketHandle handle, const int port) noexcept
{
if (handle <= 0 || port <= 0)
return false;
struct sockaddr_in servTmpAddr;
zerostruct (servTmpAddr); // (can't use "= { 0 }" on this object because it's typedef'ed as a C struct)
servTmpAddr.sin_family = PF_INET;
servTmpAddr.sin_addr.s_addr = htonl (INADDR_ANY);
servTmpAddr.sin_port = htons ((uint16) port);
return ::bind (handle, (struct sockaddr*) &servTmpAddr, sizeof (struct sockaddr_in)) >= 0;
}
static int readSocket (const SocketHandle handle,
void* const destBuffer, const int maxBytesToRead,
bool volatile& connected,
const bool blockUntilSpecifiedAmountHasArrived) noexcept
{
int bytesRead = 0;
while (bytesRead < maxBytesToRead)
{
int bytesThisTime;
#if BEAST_WINDOWS
bytesThisTime = recv (handle, static_cast<char*> (destBuffer) + bytesRead, maxBytesToRead - bytesRead, 0);
#else
while ((bytesThisTime = (int) ::read (handle, addBytesToPointer (destBuffer, bytesRead), (size_t) (maxBytesToRead - bytesRead))) < 0
&& errno == EINTR
&& connected)
{
}
#endif
if (bytesThisTime <= 0 || ! connected)
{
if (bytesRead == 0)
bytesRead = -1;
break;
}
bytesRead += bytesThisTime;
if (! blockUntilSpecifiedAmountHasArrived)
break;
}
return bytesRead;
}
static int waitForReadiness (const SocketHandle handle, const bool forReading, const int timeoutMsecs) noexcept
{
struct timeval timeout;
struct timeval* timeoutp;
if (timeoutMsecs >= 0)
{
timeout.tv_sec = timeoutMsecs / 1000;
timeout.tv_usec = (timeoutMsecs % 1000) * 1000;
timeoutp = &timeout;
}
else
{
timeoutp = 0;
}
fd_set rset, wset;
FD_ZERO (&rset);
FD_SET (handle, &rset);
FD_ZERO (&wset);
FD_SET (handle, &wset);
fd_set* const prset = forReading ? &rset : nullptr;
fd_set* const pwset = forReading ? nullptr : &wset;
#if BEAST_WINDOWS
if (select ((int) handle + 1, prset, pwset, 0, timeoutp) < 0)
return -1;
#else
{
int result;
while ((result = select (handle + 1, prset, pwset, 0, timeoutp)) < 0
&& errno == EINTR)
{
}
if (result < 0)
return -1;
}
#endif
{
int opt;
beast_socklen_t len = sizeof (opt);
if (getsockopt (handle, SOL_SOCKET, SO_ERROR, (char*) &opt, &len) < 0
|| opt != 0)
return -1;
}
return FD_ISSET (handle, forReading ? &rset : &wset) ? 1 : 0;
}
static bool setSocketBlockingState (const SocketHandle handle, const bool shouldBlock) noexcept
{
#if BEAST_WINDOWS
u_long nonBlocking = shouldBlock ? 0 : (u_long) 1;
return ioctlsocket (handle, FIONBIO, &nonBlocking) == 0;
#else
int socketFlags = fcntl (handle, F_GETFL, 0);
if (socketFlags == -1)
return false;
if (shouldBlock)
socketFlags &= ~O_NONBLOCK;
else
socketFlags |= O_NONBLOCK;
return fcntl (handle, F_SETFL, socketFlags) == 0;
#endif
}
static bool connectSocket (int volatile& handle,
const bool isDatagram,
struct addrinfo** const serverAddress,
const String& hostName,
const int portNumber,
const int timeOutMillisecs) noexcept
{
struct addrinfo hints;
zerostruct (hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = isDatagram ? SOCK_DGRAM : SOCK_STREAM;
hints.ai_flags = AI_NUMERICSERV;
struct addrinfo* info = nullptr;
if (getaddrinfo (hostName.toUTF8(), String (portNumber).toUTF8(), &hints, &info) != 0
|| info == nullptr)
return false;
if (handle < 0)
handle = (int) socket (info->ai_family, info->ai_socktype, 0);
if (handle < 0)
{
freeaddrinfo (info);
return false;
}
if (isDatagram)
{
if (*serverAddress != nullptr)
freeaddrinfo (*serverAddress);
*serverAddress = info;
return true;
}
setSocketBlockingState (handle, false);
const int result = ::connect (handle, info->ai_addr, (socklen_t) info->ai_addrlen);
freeaddrinfo (info);
if (result < 0)
{
#if BEAST_WINDOWS
if (result == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK)
#else
if (errno == EINPROGRESS)
#endif
{
if (waitForReadiness (handle, false, timeOutMillisecs) != 1)
{
setSocketBlockingState (handle, true);
return false;
}
}
}
setSocketBlockingState (handle, true);
resetSocketOptions (handle, false, false);
return true;
}
}
//==============================================================================
StreamingSocket::StreamingSocket()
: portNumber (0),
handle (-1),
connected (false),
isListener (false)
{
SocketHelpers::initSockets();
}
StreamingSocket::StreamingSocket (const String& hostName_,
const int portNumber_,
const int handle_)
: hostName (hostName_),
portNumber (portNumber_),
handle (handle_),
connected (true),
isListener (false)
{
SocketHelpers::initSockets();
SocketHelpers::resetSocketOptions (handle_, false, false);
}
StreamingSocket::~StreamingSocket()
{
close();
}
//==============================================================================
int StreamingSocket::read (void* destBuffer, const int maxBytesToRead, const bool blockUntilSpecifiedAmountHasArrived)
{
return (connected && ! isListener) ? SocketHelpers::readSocket (handle, destBuffer, maxBytesToRead, connected, blockUntilSpecifiedAmountHasArrived)
: -1;
}
int StreamingSocket::write (const void* sourceBuffer, const int numBytesToWrite)
{
if (isListener || ! connected)
return -1;
#if BEAST_WINDOWS
return send (handle, (const char*) sourceBuffer, numBytesToWrite, 0);
#else
int result;
while ((result = (int) ::write (handle, sourceBuffer, (size_t) numBytesToWrite)) < 0
&& errno == EINTR)
{
}
return result;
#endif
}
//==============================================================================
int StreamingSocket::waitUntilReady (const bool readyForReading,
const int timeoutMsecs) const
{
return connected ? SocketHelpers::waitForReadiness (handle, readyForReading, timeoutMsecs)
: -1;
}
//==============================================================================
bool StreamingSocket::bindToPort (const int port)
{
return SocketHelpers::bindSocketToPort (handle, port);
}
bool StreamingSocket::connect (const String& remoteHostName,
const int remotePortNumber,
const int timeOutMillisecs)
{
if (isListener)
{
bassertfalse; // a listener socket can't connect to another one!
return false;
}
if (connected)
close();
hostName = remoteHostName;
portNumber = remotePortNumber;
isListener = false;
connected = SocketHelpers::connectSocket (handle, false, nullptr, remoteHostName,
remotePortNumber, timeOutMillisecs);
if (! (connected && SocketHelpers::resetSocketOptions (handle, false, false)))
{
close();
return false;
}
return true;
}
void StreamingSocket::close()
{
#if BEAST_WINDOWS
if (handle != SOCKET_ERROR || connected)
closesocket (handle);
connected = false;
#else
if (connected)
{
connected = false;
if (isListener)
{
// need to do this to interrupt the accept() function..
StreamingSocket temp;
temp.connect ("localhost", portNumber, 1000);
}
}
if (handle != -1)
::close (handle);
#endif
hostName = String::empty;
portNumber = 0;
handle = -1;
isListener = false;
}
//==============================================================================
bool StreamingSocket::createListener (const int newPortNumber, const String& localHostName)
{
if (connected)
close();
hostName = "listener";
portNumber = newPortNumber;
isListener = true;
struct sockaddr_in servTmpAddr;
zerostruct (servTmpAddr);
servTmpAddr.sin_family = PF_INET;
servTmpAddr.sin_addr.s_addr = htonl (INADDR_ANY);
if (localHostName.isNotEmpty())
servTmpAddr.sin_addr.s_addr = ::inet_addr (localHostName.toUTF8());
servTmpAddr.sin_port = htons ((uint16) portNumber);
handle = (int) socket (AF_INET, SOCK_STREAM, 0);
if (handle < 0)
return false;
const int reuse = 1;
setsockopt (handle, SOL_SOCKET, SO_REUSEADDR, (const char*) &reuse, sizeof (reuse));
if (::bind (handle, (struct sockaddr*) &servTmpAddr, sizeof (struct sockaddr_in)) < 0
|| listen (handle, SOMAXCONN) < 0)
{
close();
return false;
}
connected = true;
return true;
}
StreamingSocket* StreamingSocket::waitForNextConnection() const
{
bassert (isListener || ! connected); // to call this method, you first have to use createListener() to
// prepare this socket as a listener.
if (connected && isListener)
{
struct sockaddr_storage address;
beast_socklen_t len = sizeof (address);
const int newSocket = (int) accept (handle, (struct sockaddr*) &address, &len);
if (newSocket >= 0 && connected)
return new StreamingSocket (inet_ntoa (((struct sockaddr_in*) &address)->sin_addr),
portNumber, newSocket);
}
return nullptr;
}
bool StreamingSocket::isLocal() const noexcept
{
return hostName == "127.0.0.1";
}
//==============================================================================
//==============================================================================
DatagramSocket::DatagramSocket (const int localPortNumber, const bool allowBroadcast_)
: portNumber (0),
handle (-1),
connected (true),
allowBroadcast (allowBroadcast_),
serverAddress (nullptr)
{
SocketHelpers::initSockets();
handle = (int) socket (AF_INET, SOCK_DGRAM, 0);
bindToPort (localPortNumber);
}
DatagramSocket::DatagramSocket (const String& hostName_, const int portNumber_,
const int handle_, const int localPortNumber)
: hostName (hostName_),
portNumber (portNumber_),
handle (handle_),
connected (true),
allowBroadcast (false),
serverAddress (nullptr)
{
SocketHelpers::initSockets();
SocketHelpers::resetSocketOptions (handle_, true, allowBroadcast);
bindToPort (localPortNumber);
}
DatagramSocket::~DatagramSocket()
{
close();
if (serverAddress != nullptr)
freeaddrinfo (static_cast <struct addrinfo*> (serverAddress));
}
void DatagramSocket::close()
{
#if BEAST_WINDOWS
closesocket (handle);
connected = false;
#else
connected = false;
::close (handle);
#endif
hostName = String::empty;
portNumber = 0;
handle = -1;
}
bool DatagramSocket::bindToPort (const int port)
{
return SocketHelpers::bindSocketToPort (handle, port);
}
bool DatagramSocket::connect (const String& remoteHostName,
const int remotePortNumber,
const int timeOutMillisecs)
{
if (connected)
close();
hostName = remoteHostName;
portNumber = remotePortNumber;
connected = SocketHelpers::connectSocket (handle, true, (struct addrinfo**) &serverAddress,
remoteHostName, remotePortNumber,
timeOutMillisecs);
if (! (connected && SocketHelpers::resetSocketOptions (handle, true, allowBroadcast)))
{
close();
return false;
}
return true;
}
DatagramSocket* DatagramSocket::waitForNextConnection() const
{
while (waitUntilReady (true, -1) == 1)
{
struct sockaddr_storage address;
beast_socklen_t len = sizeof (address);
char buf[1];
if (recvfrom (handle, buf, 0, 0, (struct sockaddr*) &address, &len) > 0)
return new DatagramSocket (inet_ntoa (((struct sockaddr_in*) &address)->sin_addr),
ntohs (((struct sockaddr_in*) &address)->sin_port),
-1, -1);
}
return nullptr;
}
//==============================================================================
int DatagramSocket::waitUntilReady (const bool readyForReading,
const int timeoutMsecs) const
{
return connected ? SocketHelpers::waitForReadiness (handle, readyForReading, timeoutMsecs)
: -1;
}
int DatagramSocket::read (void* destBuffer, const int maxBytesToRead, const bool blockUntilSpecifiedAmountHasArrived)
{
return connected ? SocketHelpers::readSocket (handle, destBuffer, maxBytesToRead, connected, blockUntilSpecifiedAmountHasArrived)
: -1;
}
int DatagramSocket::write (const void* sourceBuffer, const int numBytesToWrite)
{
// You need to call connect() first to set the server address..
bassert (serverAddress != nullptr && connected);
return connected ? (int) sendto (handle, (const char*) sourceBuffer,
(size_t) numBytesToWrite, 0,
static_cast <const struct addrinfo*> (serverAddress)->ai_addr,
(beast_socklen_t) static_cast <const struct addrinfo*> (serverAddress)->ai_addrlen)
: -1;
}
bool DatagramSocket::isLocal() const noexcept
{
return hostName == "127.0.0.1";
}
#if BEAST_MSVC
#pragma warning (pop)
#endif
} // namespace beast

View File

@@ -1,299 +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_SOCKET_H_INCLUDED
#define BEAST_SOCKET_H_INCLUDED
namespace beast
{
//==============================================================================
/**
A wrapper for a streaming (TCP) socket.
This allows low-level use of sockets; for an easier-to-use messaging layer on top of
sockets, you could also try the InterprocessConnection class.
@see DatagramSocket, InterprocessConnection, InterprocessConnectionServer
*/
class BEAST_API StreamingSocket : LeakChecked <StreamingSocket>, public Uncopyable
{
public:
//==============================================================================
/** Creates an uninitialised socket.
To connect it, use the connect() method, after which you can read() or write()
to it.
To wait for other sockets to connect to this one, the createListener() method
enters "listener" mode, and can be used to spawn new sockets for each connection
that comes along.
*/
StreamingSocket();
/** Destructor. */
~StreamingSocket();
//==============================================================================
/** Binds the socket to the specified local port.
@returns true on success; false may indicate that another socket is already bound
on the same port
*/
bool bindToPort (int localPortNumber);
/** Tries to connect the socket to hostname:port.
If timeOutMillisecs is 0, then this method will block until the operating system
rejects the connection (which could take a long time).
@returns true if it succeeds.
@see isConnected
*/
bool connect (const String& remoteHostname,
int remotePortNumber,
int timeOutMillisecs = 3000);
/** True if the socket is currently connected. */
bool isConnected() const noexcept { return connected; }
/** Closes the connection. */
void close();
/** Returns the name of the currently connected host. */
const String& getHostName() const noexcept { return hostName; }
/** Returns the port number that's currently open. */
int getPort() const noexcept { return portNumber; }
/** True if the socket is connected to this machine rather than over the network. */
bool isLocal() const noexcept;
/** Returns the OS's socket handle that's currently open. */
int getRawSocketHandle() const noexcept { return handle; }
//==============================================================================
/** Waits until the socket is ready for reading or writing.
If readyForReading is true, it will wait until the socket is ready for
reading; if false, it will wait until it's ready for writing.
If the timeout is < 0, it will wait forever, or else will give up after
the specified time.
If the socket is ready on return, this returns 1. If it times-out before
the socket becomes ready, it returns 0. If an error occurs, it returns -1.
*/
int waitUntilReady (bool readyForReading,
int timeoutMsecs) const;
/** Reads bytes from the socket.
If blockUntilSpecifiedAmountHasArrived is true, the method will block until
maxBytesToRead bytes have been read, (or until an error occurs). If this
flag is false, the method will return as much data as is currently available
without blocking.
@returns the number of bytes read, or -1 if there was an error.
@see waitUntilReady
*/
int read (void* destBuffer, int maxBytesToRead,
bool blockUntilSpecifiedAmountHasArrived);
/** Writes bytes to the socket from a buffer.
Note that this method will block unless you have checked the socket is ready
for writing before calling it (see the waitUntilReady() method).
@returns the number of bytes written, or -1 if there was an error.
*/
int write (const void* sourceBuffer, int numBytesToWrite);
//==============================================================================
/** Puts this socket into "listener" mode.
When in this mode, your thread can call waitForNextConnection() repeatedly,
which will spawn new sockets for each new connection, so that these can
be handled in parallel by other threads.
@param portNumber the port number to listen on
@param localHostName the interface address to listen on - pass an empty
string to listen on all addresses
@returns true if it manages to open the socket successfully.
@see waitForNextConnection
*/
bool createListener (int portNumber, const String& localHostName = String::empty);
/** When in "listener" mode, this waits for a connection and spawns it as a new
socket.
The object that gets returned will be owned by the caller.
This method can only be called after using createListener().
@see createListener
*/
StreamingSocket* waitForNextConnection() const;
private:
//==============================================================================
String hostName;
int volatile portNumber, handle;
bool connected, isListener;
StreamingSocket (const String& hostname, int portNumber, int handle);
};
//==============================================================================
/**
A wrapper for a datagram (UDP) socket.
This allows low-level use of sockets; for an easier-to-use messaging layer on top of
sockets, you could also try the InterprocessConnection class.
@see StreamingSocket, InterprocessConnection, InterprocessConnectionServer
*/
class BEAST_API DatagramSocket : LeakChecked <DatagramSocket>, public Uncopyable
{
public:
//==============================================================================
/**
Creates an (uninitialised) datagram socket.
The localPortNumber is the port on which to bind this socket. If this value is 0,
the port number is assigned by the operating system.
To use the socket for sending, call the connect() method. This will not immediately
make a connection, but will save the destination you've provided. After this, you can
call read() or write().
If enableBroadcasting is true, the socket will be allowed to send broadcast messages
(may require extra privileges on linux)
To wait for other sockets to connect to this one, call waitForNextConnection().
*/
DatagramSocket (int localPortNumber,
bool enableBroadcasting = false);
/** Destructor. */
~DatagramSocket();
//==============================================================================
/** Binds the socket to the specified local port.
@returns true on success; false may indicate that another socket is already bound
on the same port
*/
bool bindToPort (int localPortNumber);
/** Tries to connect the socket to hostname:port.
If timeOutMillisecs is 0, then this method will block until the operating system
rejects the connection (which could take a long time).
@returns true if it succeeds.
@see isConnected
*/
bool connect (const String& remoteHostname,
int remotePortNumber,
int timeOutMillisecs = 3000);
/** True if the socket is currently connected. */
bool isConnected() const noexcept { return connected; }
/** Closes the connection. */
void close();
/** Returns the name of the currently connected host. */
const String& getHostName() const noexcept { return hostName; }
/** Returns the port number that's currently open. */
int getPort() const noexcept { return portNumber; }
/** True if the socket is connected to this machine rather than over the network. */
bool isLocal() const noexcept;
/** Returns the OS's socket handle that's currently open. */
int getRawSocketHandle() const noexcept { return handle; }
//==============================================================================
/** Waits until the socket is ready for reading or writing.
If readyForReading is true, it will wait until the socket is ready for
reading; if false, it will wait until it's ready for writing.
If the timeout is < 0, it will wait forever, or else will give up after
the specified time.
If the socket is ready on return, this returns 1. If it times-out before
the socket becomes ready, it returns 0. If an error occurs, it returns -1.
*/
int waitUntilReady (bool readyForReading,
int timeoutMsecs) const;
/** Reads bytes from the socket.
If blockUntilSpecifiedAmountHasArrived is true, the method will block until
maxBytesToRead bytes have been read, (or until an error occurs). If this
flag is false, the method will return as much data as is currently available
without blocking.
@returns the number of bytes read, or -1 if there was an error.
@see waitUntilReady
*/
int read (void* destBuffer, int maxBytesToRead,
bool blockUntilSpecifiedAmountHasArrived);
/** Writes bytes to the socket from a buffer.
Note that this method will block unless you have checked the socket is ready
for writing before calling it (see the waitUntilReady() method).
@returns the number of bytes written, or -1 if there was an error.
*/
int write (const void* sourceBuffer, int numBytesToWrite);
//==============================================================================
/** This waits for incoming data to be sent, and returns a socket that can be used
to read it.
The object that gets returned is owned by the caller, and can't be used for
sending, but can be used to read the data.
*/
DatagramSocket* waitForNextConnection() const;
private:
//==============================================================================
String hostName;
int volatile portNumber, handle;
bool connected, allowBroadcast;
void* serverAddress;
DatagramSocket (const String& hostname, int portNumber, int handle, int localPortNumber);
};
} // namespace beast
#endif // BEAST_SOCKET_H_INCLUDED

View File

@@ -1,198 +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.
*/
//==============================================================================
namespace beast
{
namespace
{
int calcBufferStreamBufferSize (int requestedSize, InputStream* const source) noexcept
{
// You need to supply a real stream when creating a BufferedInputStream
bassert (source != nullptr);
requestedSize = bmax (256, requestedSize);
const int64 sourceSize = source->getTotalLength();
if (sourceSize >= 0 && sourceSize < requestedSize)
requestedSize = bmax (32, (int) sourceSize);
return requestedSize;
}
}
//==============================================================================
BufferedInputStream::BufferedInputStream (InputStream* const sourceStream, const int bufferSize_,
const bool deleteSourceWhenDestroyed)
: source (sourceStream, deleteSourceWhenDestroyed),
bufferSize (calcBufferStreamBufferSize (bufferSize_, sourceStream)),
position (sourceStream->getPosition()),
lastReadPos (0),
bufferStart (position),
bufferOverlap (128)
{
buffer.malloc ((size_t) bufferSize);
}
BufferedInputStream::BufferedInputStream (InputStream& sourceStream, const int bufferSize_)
: source (&sourceStream, false),
bufferSize (calcBufferStreamBufferSize (bufferSize_, &sourceStream)),
position (sourceStream.getPosition()),
lastReadPos (0),
bufferStart (position),
bufferOverlap (128)
{
buffer.malloc ((size_t) bufferSize);
}
BufferedInputStream::~BufferedInputStream()
{
}
//==============================================================================
int64 BufferedInputStream::getTotalLength()
{
return source->getTotalLength();
}
int64 BufferedInputStream::getPosition()
{
return position;
}
bool BufferedInputStream::setPosition (int64 newPosition)
{
position = bmax ((int64) 0, newPosition);
return true;
}
bool BufferedInputStream::isExhausted()
{
return position >= lastReadPos && source->isExhausted();
}
void BufferedInputStream::ensureBuffered()
{
const int64 bufferEndOverlap = lastReadPos - bufferOverlap;
if (position < bufferStart || position >= bufferEndOverlap)
{
int bytesRead;
if (position < lastReadPos
&& position >= bufferEndOverlap
&& position >= bufferStart)
{
const int bytesToKeep = (int) (lastReadPos - position);
memmove (buffer, buffer + (int) (position - bufferStart), (size_t) bytesToKeep);
bufferStart = position;
bytesRead = source->read (buffer + bytesToKeep,
(int) (bufferSize - bytesToKeep));
lastReadPos += bytesRead;
bytesRead += bytesToKeep;
}
else
{
bufferStart = position;
source->setPosition (bufferStart);
bytesRead = source->read (buffer, bufferSize);
lastReadPos = bufferStart + bytesRead;
}
while (bytesRead < bufferSize)
buffer [bytesRead++] = 0;
}
}
int BufferedInputStream::read (void* destBuffer, int maxBytesToRead)
{
bassert (destBuffer != nullptr && maxBytesToRead >= 0);
if (position >= bufferStart
&& position + maxBytesToRead <= lastReadPos)
{
memcpy (destBuffer, buffer + (int) (position - bufferStart), (size_t) maxBytesToRead);
position += maxBytesToRead;
return maxBytesToRead;
}
else
{
if (position < bufferStart || position >= lastReadPos)
ensureBuffered();
int bytesRead = 0;
while (maxBytesToRead > 0)
{
const int bytesAvailable = bmin (maxBytesToRead, (int) (lastReadPos - position));
if (bytesAvailable > 0)
{
memcpy (destBuffer, buffer + (int) (position - bufferStart), (size_t) bytesAvailable);
maxBytesToRead -= bytesAvailable;
bytesRead += bytesAvailable;
position += bytesAvailable;
destBuffer = static_cast <char*> (destBuffer) + bytesAvailable;
}
const int64 oldLastReadPos = lastReadPos;
ensureBuffered();
if (oldLastReadPos == lastReadPos)
break; // if ensureBuffered() failed to read any more data, bail out
if (isExhausted())
break;
}
return bytesRead;
}
}
String BufferedInputStream::readString()
{
if (position >= bufferStart
&& position < lastReadPos)
{
const int maxChars = (int) (lastReadPos - position);
const char* const src = buffer + (int) (position - bufferStart);
for (int i = 0; i < maxChars; ++i)
{
if (src[i] == 0)
{
position += i + 1;
return String::fromUTF8 (src, i);
}
}
}
return InputStream::readString();
}
} // namespace beast

View File

@@ -1,91 +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_BUFFEREDINPUTSTREAM_H_INCLUDED
#define BEAST_BUFFEREDINPUTSTREAM_H_INCLUDED
namespace beast
{
//==============================================================================
/** Wraps another input stream, and reads from it using an intermediate buffer
If you're using an input stream such as a file input stream, and making lots of
small read accesses to it, it's probably sensible to wrap it in one of these,
so that the source stream gets accessed in larger chunk sizes, meaning less
work for the underlying stream.
*/
class BEAST_API BufferedInputStream
: public InputStream
, LeakChecked <BufferedInputStream>
{
public:
//==============================================================================
/** Creates a BufferedInputStream from an input source.
@param sourceStream the source stream to read from
@param bufferSize the size of reservoir to use to buffer the source
@param deleteSourceWhenDestroyed whether the sourceStream that is passed in should be
deleted by this object when it is itself deleted.
*/
BufferedInputStream (InputStream* sourceStream,
int bufferSize,
bool deleteSourceWhenDestroyed);
/** Creates a BufferedInputStream from an input source.
@param sourceStream the source stream to read from - the source stream must not
be deleted until this object has been destroyed.
@param bufferSize the size of reservoir to use to buffer the source
*/
BufferedInputStream (InputStream& sourceStream, int bufferSize);
/** Destructor.
This may also delete the source stream, if that option was chosen when the
buffered stream was created.
*/
~BufferedInputStream();
//==============================================================================
int64 getTotalLength();
int64 getPosition();
bool setPosition (int64 newPosition);
int read (void* destBuffer, int maxBytesToRead);
String readString();
bool isExhausted();
private:
//==============================================================================
OptionalScopedPointer<InputStream> source;
int bufferSize;
int64 position, lastReadPos, bufferStart, bufferOverlap;
HeapBlock <char> buffer;
void ensureBuffered();
};
} // namespace beast
#endif // BEAST_BUFFEREDINPUTSTREAM_H_INCLUDED

View File

@@ -35,7 +35,7 @@ class MemoryBlock;
Input and output streams are used throughout the library - subclasses can override
some or all of the virtual functions to implement their behaviour.
@see OutputStream, MemoryInputStream, BufferedInputStream, FileInputStream
@see OutputStream, FileInputStream
*/
class BEAST_API InputStream
: public Uncopyable

View File

@@ -1,156 +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.
*/
//==============================================================================
namespace beast
{
MemoryInputStream::MemoryInputStream (const void* const sourceData,
const size_t sourceDataSize,
const bool keepInternalCopy)
: data (sourceData),
dataSize (sourceDataSize),
position (0)
{
if (keepInternalCopy)
createInternalCopy();
}
MemoryInputStream::MemoryInputStream (const MemoryBlock& sourceData,
const bool keepInternalCopy)
: data (sourceData.getData()),
dataSize (sourceData.getSize()),
position (0)
{
if (keepInternalCopy)
createInternalCopy();
}
void MemoryInputStream::createInternalCopy()
{
internalCopy.malloc (dataSize);
memcpy (internalCopy, data, dataSize);
data = internalCopy;
}
MemoryInputStream::~MemoryInputStream()
{
}
int64 MemoryInputStream::getTotalLength()
{
return dataSize;
}
int MemoryInputStream::read (void* const buffer, const int howMany)
{
bassert (buffer != nullptr && howMany >= 0);
const int num = bmin (howMany, (int) (dataSize - position));
if (num <= 0)
return 0;
memcpy (buffer, addBytesToPointer (data, position), (size_t) num);
position += (unsigned int) num;
return num;
}
bool MemoryInputStream::isExhausted()
{
return position >= dataSize;
}
bool MemoryInputStream::setPosition (const int64 pos)
{
position = (size_t) blimit ((int64) 0, (int64) dataSize, pos);
return true;
}
int64 MemoryInputStream::getPosition()
{
return position;
}
//==============================================================================
class MemoryStreamTests : public UnitTest
{
public:
MemoryStreamTests() : UnitTest ("MemoryStream", "beast") { }
void runTest()
{
beginTestCase ("Basics");
Random r;
int randomInt = r.nextInt();
int64 randomInt64 = r.nextInt64();
double randomDouble = r.nextDouble();
String randomString (createRandomWideCharString());
MemoryOutputStream mo;
mo.writeInt (randomInt);
mo.writeIntBigEndian (randomInt);
mo.writeCompressedInt (randomInt);
mo.writeString (randomString);
mo.writeInt64 (randomInt64);
mo.writeInt64BigEndian (randomInt64);
mo.writeDouble (randomDouble);
mo.writeDoubleBigEndian (randomDouble);
MemoryInputStream mi (mo.getData(), mo.getDataSize(), false);
expect (mi.readInt() == randomInt);
expect (mi.readIntBigEndian() == randomInt);
expect (mi.readCompressedInt() == randomInt);
expectEquals (mi.readString(), randomString);
expect (mi.readInt64() == randomInt64);
expect (mi.readInt64BigEndian() == randomInt64);
expect (mi.readDouble() == randomDouble);
expect (mi.readDoubleBigEndian() == randomDouble);
}
static String createRandomWideCharString()
{
beast_wchar buffer [50] = { 0 };
Random r;
for (int i = 0; i < numElementsInArray (buffer) - 1; ++i)
{
if (r.nextBool())
{
do
{
buffer[i] = (beast_wchar) (1 + r.nextInt (0x10ffff - 1));
}
while (! CharPointer_UTF16::canRepresent (buffer[i]));
}
else
buffer[i] = (beast_wchar) (1 + r.nextInt (0xff));
}
return CharPointer_UTF32 (buffer);
}
};
static MemoryStreamTests memoryStreamTests;
} // namespace beast

View File

@@ -1,96 +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_MEMORYINPUTSTREAM_H_INCLUDED
#define BEAST_MEMORYINPUTSTREAM_H_INCLUDED
namespace beast
{
//==============================================================================
/**
Allows a block of data to be accessed as a stream.
This can either be used to refer to a shared block of memory, or can make its
own internal copy of the data when the MemoryInputStream is created.
*/
class BEAST_API MemoryInputStream
: public InputStream
, LeakChecked <MemoryInputStream>
{
public:
//==============================================================================
/** Creates a MemoryInputStream.
@param sourceData the block of data to use as the stream's source
@param sourceDataSize the number of bytes in the source data block
@param keepInternalCopyOfData if false, the stream will just keep a pointer to
the source data, so this data shouldn't be changed
for the lifetime of the stream; if this parameter is
true, the stream will make its own copy of the
data and use that.
*/
MemoryInputStream (const void* sourceData,
size_t sourceDataSize,
bool keepInternalCopyOfData = false);
/** Creates a MemoryInputStream.
@param data a block of data to use as the stream's source
@param keepInternalCopyOfData if false, the stream will just keep a reference to
the source data, so this data shouldn't be changed
for the lifetime of the stream; if this parameter is
true, the stream will make its own copy of the
data and use that.
*/
MemoryInputStream (const MemoryBlock& data,
bool keepInternalCopyOfData);
/** Destructor. */
~MemoryInputStream();
/** Returns a pointer to the source data block from which this stream is reading. */
const void* getData() const noexcept { return data; }
/** Returns the number of bytes of source data in the block from which this stream is reading. */
size_t getDataSize() const noexcept { return dataSize; }
//==============================================================================
int64 getPosition();
bool setPosition (int64 pos);
int64 getTotalLength();
bool isExhausted();
int read (void* destBuffer, int maxBytesToRead);
private:
//==============================================================================
const void* data;
size_t dataSize, position;
HeapBlock<char> internalCopy;
void createInternalCopy();
};
} // namespace beast
#endif // BEAST_MEMORYINPUTSTREAM_H_INCLUDED

View File

@@ -1,82 +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.
*/
//==============================================================================
namespace beast
{
SubregionStream::SubregionStream (InputStream* const sourceStream,
const int64 start, const int64 length,
const bool deleteSourceWhenDestroyed)
: source (sourceStream, deleteSourceWhenDestroyed),
startPositionInSourceStream (start),
lengthOfSourceStream (length)
{
SubregionStream::setPosition (0);
}
SubregionStream::~SubregionStream()
{
}
int64 SubregionStream::getTotalLength()
{
const int64 srcLen = source->getTotalLength() - startPositionInSourceStream;
return lengthOfSourceStream >= 0 ? bmin (lengthOfSourceStream, srcLen)
: srcLen;
}
int64 SubregionStream::getPosition()
{
return source->getPosition() - startPositionInSourceStream;
}
bool SubregionStream::setPosition (int64 newPosition)
{
return source->setPosition (bmax ((int64) 0, newPosition + startPositionInSourceStream));
}
int SubregionStream::read (void* destBuffer, int maxBytesToRead)
{
bassert (destBuffer != nullptr && maxBytesToRead >= 0);
if (lengthOfSourceStream < 0)
return source->read (destBuffer, maxBytesToRead);
maxBytesToRead = (int) bmin ((int64) maxBytesToRead, lengthOfSourceStream - getPosition());
if (maxBytesToRead <= 0)
return 0;
return source->read (destBuffer, maxBytesToRead);
}
bool SubregionStream::isExhausted()
{
if (lengthOfSourceStream >= 0 && getPosition() >= lengthOfSourceStream)
return true;
return source->isExhausted();
}
} // namespace beast

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_SUBREGIONSTREAM_H_INCLUDED
#define BEAST_SUBREGIONSTREAM_H_INCLUDED
namespace beast
{
//==============================================================================
/** Wraps another input stream, and reads from a specific part of it.
This lets you take a subsection of a stream and present it as an entire
stream in its own right.
*/
class BEAST_API SubregionStream
: public InputStream
, LeakChecked <SubregionStream>
{
public:
//==============================================================================
/** Creates a SubregionStream from an input source.
@param sourceStream the source stream to read from
@param startPositionInSourceStream this is the position in the source stream that
corresponds to position 0 in this stream
@param lengthOfSourceStream this specifies the maximum number of bytes
from the source stream that will be passed through
by this stream. When the position of this stream
exceeds lengthOfSourceStream, it will cause an end-of-stream.
If the length passed in here is greater than the length
of the source stream (as returned by getTotalLength()),
then the smaller value will be used.
Passing a negative value for this parameter means it
will keep reading until the source's end-of-stream.
@param deleteSourceWhenDestroyed whether the sourceStream that is passed in should be
deleted by this object when it is itself deleted.
*/
SubregionStream (InputStream* sourceStream,
int64 startPositionInSourceStream,
int64 lengthOfSourceStream,
bool deleteSourceWhenDestroyed);
/** Destructor.
This may also delete the source stream, if that option was chosen when the
buffered stream was created.
*/
~SubregionStream();
//==============================================================================
int64 getTotalLength();
int64 getPosition();
bool setPosition (int64 newPosition);
int read (void* destBuffer, int maxBytesToRead);
bool isExhausted();
//==============================================================================
private:
OptionalScopedPointer<InputStream> source;
const int64 startPositionInSourceStream, lengthOfSourceStream;
};
} // namespace beast
#endif // BEAST_SUBREGIONSTREAM_H_INCLUDED

View File

@@ -1,74 +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.
*/
//==============================================================================
namespace beast
{
StringPool& Identifier::getPool()
{
static StringPool pool;
return pool;
}
Identifier::Identifier() noexcept
: name (nullptr)
{
}
Identifier::Identifier (const Identifier& other) noexcept
: name (other.name)
{
}
Identifier& Identifier::operator= (const Identifier other) noexcept
{
name = other.name;
return *this;
}
Identifier::Identifier (const String& nm)
: name (Identifier::getPool().getPooledString (nm))
{
}
Identifier::Identifier (const char* const nm)
: name (Identifier::getPool().getPooledString (nm))
{
/* An Identifier string must be suitable for use as a script variable or XML
attribute, so it can only contain this limited set of characters.. */
bassert (isValidIdentifier (toString()));
}
Identifier::~Identifier()
{
}
Identifier Identifier::null;
bool Identifier::isValidIdentifier (const String& possibleIdentifier) noexcept
{
return possibleIdentifier.isNotEmpty()
&& possibleIdentifier.containsOnly ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-:#@$%");
}
} // namespace beast

View File

@@ -1,110 +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_IDENTIFIER_H_INCLUDED
#define BEAST_IDENTIFIER_H_INCLUDED
namespace beast
{
class StringPool;
//==============================================================================
/**
Represents a string identifier, designed for accessing properties by name.
Identifier objects are very light and fast to copy, but slower to initialise
from a string, so it's much faster to keep a static identifier object to refer
to frequently-used names, rather than constructing them each time you need it.
@see NamedPropertySet, ValueTree
*/
class BEAST_API Identifier
{
public:
/** Creates a null identifier. */
Identifier() noexcept;
/** Creates an identifier with a specified name.
Because this name may need to be used in contexts such as script variables or XML
tags, it must only contain ascii letters and digits, or the underscore character.
*/
Identifier (const char* name);
/** Creates an identifier with a specified name.
Because this name may need to be used in contexts such as script variables or XML
tags, it must only contain ascii letters and digits, or the underscore character.
*/
Identifier (const String& name);
/** Creates a copy of another identifier. */
Identifier (const Identifier& other) noexcept;
/** Creates a copy of another identifier. */
Identifier& operator= (const Identifier other) noexcept;
/** Destructor */
~Identifier();
/** Compares two identifiers. This is a very fast operation. */
inline bool operator== (const Identifier other) const noexcept { return name == other.name; }
/** Compares two identifiers. This is a very fast operation. */
inline bool operator!= (const Identifier other) const noexcept { return name != other.name; }
/** Returns this identifier as a string. */
String toString() const { return name; }
/** Returns this identifier's raw string pointer. */
operator const String::CharPointerType() const noexcept { return name; }
/** Returns this identifier's raw string pointer. */
const String::CharPointerType getCharPointer() const noexcept { return name; }
/** Returns true if this Identifier is not null */
bool isValid() const noexcept { return name.getAddress() != nullptr; }
/** Returns true if this Identifier is null */
bool isNull() const noexcept { return name.getAddress() == nullptr; }
/** A null identifier. */
static Identifier null;
/** Checks a given string for characters that might not be valid in an Identifier.
Since Identifiers are used as a script variables and XML attributes, they should only contain
alphanumeric characters, underscores, or the '-' and ':' characters.
*/
static bool isValidIdentifier (const String& possibleIdentifier) noexcept;
private:
//==============================================================================
String::CharPointerType name;
static StringPool& getPool();
};
} // namespace beast
#endif // BEAST_IDENTIFIER_H_INCLUDED

View File

@@ -1,173 +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.
*/
//==============================================================================
namespace beast
{
LocalisedStrings::LocalisedStrings (const String& fileContents, bool ignoreCase)
{
loadFromText (fileContents, ignoreCase);
}
LocalisedStrings::LocalisedStrings (const File& fileToLoad, bool ignoreCase)
{
loadFromText (fileToLoad.loadFileAsString(), ignoreCase);
}
LocalisedStrings::~LocalisedStrings()
{
}
//==============================================================================
String LocalisedStrings::translate (const String& text) const
{
return translations.getValue (text, text);
}
String LocalisedStrings::translate (const String& text, const String& resultIfNotFound) const
{
return translations.getValue (text, resultIfNotFound);
}
namespace
{
#if BEAST_CHECK_MEMORY_LEAKS
// By using this object to force a LocalisedStrings object to be created
// before the currentMappings object, we can force the static order-of-destruction to
// delete the currentMappings object first, which avoids a bogus leak warning.
// (Oddly, just creating a LocalisedStrings on the stack doesn't work in gcc, it
// has to be created with 'new' for this to work..)
struct LeakAvoidanceTrick
{
LeakAvoidanceTrick()
{
const ScopedPointer<LocalisedStrings> dummy (new LocalisedStrings (String(), false));
}
};
LeakAvoidanceTrick leakAvoidanceTrick;
#endif
SpinLock currentMappingsLock;
ScopedPointer<LocalisedStrings> currentMappings;
int findCloseQuote (const String& text, int startPos)
{
beast_wchar lastChar = 0;
String::CharPointerType t (text.getCharPointer() + startPos);
for (;;)
{
const beast_wchar c = t.getAndAdvance();
if (c == 0 || (c == '"' && lastChar != '\\'))
break;
lastChar = c;
++startPos;
}
return startPos;
}
String unescapeString (const String& s)
{
return s.replace ("\\\"", "\"")
.replace ("\\\'", "\'")
.replace ("\\t", "\t")
.replace ("\\r", "\r")
.replace ("\\n", "\n");
}
}
void LocalisedStrings::loadFromText (const String& fileContents, bool ignoreCase)
{
translations.setIgnoresCase (ignoreCase);
StringArray lines;
lines.addLines (fileContents);
for (int i = 0; i < lines.size(); ++i)
{
String line (lines[i].trim());
if (line.startsWithChar ('"'))
{
int closeQuote = findCloseQuote (line, 1);
const String originalText (unescapeString (line.substring (1, closeQuote)));
if (originalText.isNotEmpty())
{
const int openingQuote = findCloseQuote (line, closeQuote + 1);
closeQuote = findCloseQuote (line, openingQuote + 1);
const String newText (unescapeString (line.substring (openingQuote + 1, closeQuote)));
if (newText.isNotEmpty())
translations.set (originalText, newText);
}
}
else if (line.startsWithIgnoreCase ("language:"))
{
languageName = line.substring (9).trim();
}
else if (line.startsWithIgnoreCase ("countries:"))
{
countryCodes.addTokens (line.substring (10).trim(), true);
countryCodes.trim();
countryCodes.removeEmptyStrings();
}
}
}
//==============================================================================
void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations)
{
const SpinLock::ScopedLockType sl (currentMappingsLock);
currentMappings = newTranslations;
}
LocalisedStrings* LocalisedStrings::getCurrentMappings()
{
return currentMappings;
}
String LocalisedStrings::translateWithCurrentMappings (const String& text) { return beast::translate (text); }
String LocalisedStrings::translateWithCurrentMappings (const char* text) { return beast::translate (text); }
String translate (const String& text) { return beast::translate (text, text); }
String translate (const char* text) { return beast::translate (String (text)); }
String translate (CharPointer_UTF8 text) { return beast::translate (String (text)); }
String translate (const String& text, const String& resultIfNotFound)
{
const SpinLock::ScopedLockType sl (currentMappingsLock);
if (const LocalisedStrings* const mappings = LocalisedStrings::getCurrentMappings())
return mappings->translate (text, resultIfNotFound);
return resultIfNotFound;
}
} // namespace beast

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