simpleble 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +88 -0
- data/LICENSE.txt +21 -0
- data/README.md +350 -0
- data/ext/simpleble/extconf.rb +57 -0
- data/ext/simpleble/simpleble_ruby.c +682 -0
- data/lib/simpleble/adapter.rb +10 -0
- data/lib/simpleble/characteristic.rb +36 -0
- data/lib/simpleble/descriptor.rb +8 -0
- data/lib/simpleble/exceptions.rb +25 -0
- data/lib/simpleble/peripheral.rb +64 -0
- data/lib/simpleble/service.rb +16 -0
- data/lib/simpleble/version.rb +3 -0
- data/lib/simpleble.rb +40 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.0.3/CompilerIdCXX/CMakeCXXCompilerId.cpp +920 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.0.3/CompilerIdCXX/apple-sdk.cpp +1 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.1.0/CompilerIdCXX/CMakeCXXCompilerId.cpp +949 -0
- data/vendor/simpleble/build_simplecble/CMakeFiles/4.1.0/CompilerIdCXX/apple-sdk.cpp +1 -0
- data/vendor/simpleble/build_simplecble/export/simplecble/export.h +43 -0
- data/vendor/simpleble/build_simplecble/simpleble/export/simpleble/export.h +43 -0
- data/vendor/simpleble/dependencies/external/kvn/kvn_bytearray.h +222 -0
- data/vendor/simpleble/dependencies/external/kvn/kvn_safe_callback.hpp +66 -0
- data/vendor/simpleble/dependencies/external/kvn/logfwd.hpp +35 -0
- data/vendor/simpleble/dependencies/internal/fmt/args.h +220 -0
- data/vendor/simpleble/dependencies/internal/fmt/base.h +2962 -0
- data/vendor/simpleble/dependencies/internal/fmt/chrono.h +2338 -0
- data/vendor/simpleble/dependencies/internal/fmt/color.h +610 -0
- data/vendor/simpleble/dependencies/internal/fmt/compile.h +539 -0
- data/vendor/simpleble/dependencies/internal/fmt/core.h +5 -0
- data/vendor/simpleble/dependencies/internal/fmt/format-inl.h +1949 -0
- data/vendor/simpleble/dependencies/internal/fmt/format.h +4244 -0
- data/vendor/simpleble/dependencies/internal/fmt/os.h +427 -0
- data/vendor/simpleble/dependencies/internal/fmt/ostream.h +166 -0
- data/vendor/simpleble/dependencies/internal/fmt/printf.h +633 -0
- data/vendor/simpleble/dependencies/internal/fmt/ranges.h +850 -0
- data/vendor/simpleble/dependencies/internal/fmt/std.h +726 -0
- data/vendor/simpleble/dependencies/internal/fmt/xchar.h +373 -0
- data/vendor/simpleble/dependencies/internal/simplejni/Common.hpp +579 -0
- data/vendor/simpleble/dependencies/internal/simplejni/References.hpp +151 -0
- data/vendor/simpleble/dependencies/internal/simplejni/Registry.hpp +183 -0
- data/vendor/simpleble/dependencies/internal/simplejni/VM.hpp +88 -0
- data/vendor/simpleble/examples/simpleble/src/connect.cpp +67 -0
- data/vendor/simpleble/examples/simpleble/src/connect_safe.cpp +91 -0
- data/vendor/simpleble/examples/simpleble/src/list_adapters.cpp +22 -0
- data/vendor/simpleble/examples/simpleble/src/list_adapters_safe.cpp +33 -0
- data/vendor/simpleble/examples/simpleble/src/list_paired.cpp +27 -0
- data/vendor/simpleble/examples/simpleble/src/multiconnect.cpp +60 -0
- data/vendor/simpleble/examples/simpleble/src/notify.cpp +85 -0
- data/vendor/simpleble/examples/simpleble/src/notify_multi.cpp +101 -0
- data/vendor/simpleble/examples/simpleble/src/power_cycle.cpp +43 -0
- data/vendor/simpleble/examples/simpleble/src/read.cpp +82 -0
- data/vendor/simpleble/examples/simpleble/src/scan.cpp +62 -0
- data/vendor/simpleble/examples/simpleble/src/utils.cpp +59 -0
- data/vendor/simpleble/examples/simpleble/src/utils.hpp +27 -0
- data/vendor/simpleble/examples/simpleble/src/write.cpp +81 -0
- data/vendor/simpleble/examples/simplebluez/ble_nus/ble_nus.cpp +138 -0
- data/vendor/simpleble/examples/simplebluez/connect/connect.cpp +119 -0
- data/vendor/simpleble/examples/simplebluez/list_adapters/list_adapters.cpp +44 -0
- data/vendor/simpleble/examples/simplebluez/list_paired/list_paired.cpp +48 -0
- data/vendor/simpleble/examples/simplebluez/notify/notify.cpp +145 -0
- data/vendor/simpleble/examples/simplebluez/pair/pair.cpp +181 -0
- data/vendor/simpleble/examples/simplebluez/read/read.cpp +141 -0
- data/vendor/simpleble/examples/simplebluez/scan/scan.cpp +85 -0
- data/vendor/simpleble/examples/simplecble/c/connect.c +163 -0
- data/vendor/simpleble/examples/simplecble/c/notify.c +217 -0
- data/vendor/simpleble/examples/simplecble/c/scan.c +164 -0
- data/vendor/simpleble/examples/simpledbus/notification.cpp +24 -0
- data/vendor/simpleble/hitl/src/test_sanity.cpp +48 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Adapter.h +102 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/AdapterSafe.h +58 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Advanced.h +50 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Characteristic.h +39 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Config.h +55 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Descriptor.h +30 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Exceptions.h +72 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Logging.h +73 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Peripheral.h +82 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/PeripheralSafe.h +64 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Service.h +34 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/SimpleBLE.h +8 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Types.h +49 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/Utils.h +13 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/export.h +43 -0
- data/vendor/simpleble/install_simplecble/include/simpleble/kvn/kvn_bytearray.h +222 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/adapter.h +188 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/logging.h +37 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/peripheral.h +304 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/simpleble.h +21 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/types.h +73 -0
- data/vendor/simpleble/install_simplecble/include/simplecble/utils.h +27 -0
- data/vendor/simpleble/simpleble/include/simpleble/Adapter.h +102 -0
- data/vendor/simpleble/simpleble/include/simpleble/AdapterSafe.h +58 -0
- data/vendor/simpleble/simpleble/include/simpleble/Characteristic.h +39 -0
- data/vendor/simpleble/simpleble/include/simpleble/Config.h +55 -0
- data/vendor/simpleble/simpleble/include/simpleble/Descriptor.h +30 -0
- data/vendor/simpleble/simpleble/include/simpleble/Exceptions.h +72 -0
- data/vendor/simpleble/simpleble/include/simpleble/Logging.h +73 -0
- data/vendor/simpleble/simpleble/include/simpleble/Peripheral.h +82 -0
- data/vendor/simpleble/simpleble/include/simpleble/PeripheralSafe.h +64 -0
- data/vendor/simpleble/simpleble/include/simpleble/Service.h +34 -0
- data/vendor/simpleble/simpleble/include/simpleble/SimpleBLE.h +8 -0
- data/vendor/simpleble/simpleble/include/simpleble/Types.h +49 -0
- data/vendor/simpleble/simpleble/include/simpleble/Utils.h +13 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/adapter.h +188 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/logging.h +37 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/peripheral.h +304 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/simpleble.h +21 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/types.h +73 -0
- data/vendor/simpleble/simpleble/include/simpleble_c/utils.h +27 -0
- data/vendor/simpleble/simpleble/src/CommonUtils.h +63 -0
- data/vendor/simpleble/simpleble/src/Exceptions.cpp +31 -0
- data/vendor/simpleble/simpleble/src/Logging.cpp +136 -0
- data/vendor/simpleble/simpleble/src/LoggingInternal.h +85 -0
- data/vendor/simpleble/simpleble/src/Utils.cpp +24 -0
- data/vendor/simpleble/simpleble/src/backends/android/AdapterAndroid.cpp +101 -0
- data/vendor/simpleble/simpleble/src/backends/android/AdapterAndroid.h +70 -0
- data/vendor/simpleble/simpleble/src/backends/android/BackendAndroid.cpp +40 -0
- data/vendor/simpleble/simpleble/src/backends/android/BackendAndroid.h +20 -0
- data/vendor/simpleble/simpleble/src/backends/android/PeripheralAndroid.cpp +365 -0
- data/vendor/simpleble/simpleble/src/backends/android/PeripheralAndroid.h +90 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/BluetoothGattCallback.cpp +432 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/BluetoothGattCallback.h +102 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/ScanCallback.cpp +142 -0
- data/vendor/simpleble/simpleble/src/backends/android/bridge/ScanCallback.h +55 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.cpp +107 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.h +55 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.cpp +68 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.h +54 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.cpp +115 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.h +75 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.cpp +142 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.h +66 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.cpp +67 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.h +46 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.cpp +106 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.h +47 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.cpp +47 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.h +37 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.cpp +69 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.h +41 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.cpp +63 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.h +42 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/os/ParcelUUID.cpp +32 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/os/ParcelUUID.h +30 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/util/SparseArray.cpp +54 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/android/util/SparseArray.h +37 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Iterator.cpp +36 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Iterator.h +28 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/List.cpp +29 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/List.h +27 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Set.cpp +33 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Set.h +28 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/UUID.cpp +26 -0
- data/vendor/simpleble/simpleble/src/backends/android/types/java/util/UUID.h +29 -0
- data/vendor/simpleble/simpleble/src/backends/common/AdapterBase.cpp +53 -0
- data/vendor/simpleble/simpleble/src/backends/common/AdapterBase.h +81 -0
- data/vendor/simpleble/simpleble/src/backends/common/AdapterBaseTypes.h +22 -0
- data/vendor/simpleble/simpleble/src/backends/common/BackendBase.h +20 -0
- data/vendor/simpleble/simpleble/src/backends/common/BackendUtils.h +33 -0
- data/vendor/simpleble/simpleble/src/backends/common/CharacteristicBase.cpp +28 -0
- data/vendor/simpleble/simpleble/src/backends/common/CharacteristicBase.h +38 -0
- data/vendor/simpleble/simpleble/src/backends/common/DescriptorBase.cpp +7 -0
- data/vendor/simpleble/simpleble/src/backends/common/DescriptorBase.h +19 -0
- data/vendor/simpleble/simpleble/src/backends/common/PeripheralBase.h +82 -0
- data/vendor/simpleble/simpleble/src/backends/common/ServiceBase.cpp +18 -0
- data/vendor/simpleble/simpleble/src/backends/common/ServiceBase.h +28 -0
- data/vendor/simpleble/simpleble/src/backends/linux/AdapterLinux.cpp +102 -0
- data/vendor/simpleble/simpleble/src/backends/linux/AdapterLinux.h +55 -0
- data/vendor/simpleble/simpleble/src/backends/linux/BackendBluez.cpp +87 -0
- data/vendor/simpleble/simpleble/src/backends/linux/PeripheralLinux.cpp +376 -0
- data/vendor/simpleble/simpleble/src/backends/linux/PeripheralLinux.h +90 -0
- data/vendor/simpleble/simpleble/src/backends/macos/AdapterBaseMacOS.h +29 -0
- data/vendor/simpleble/simpleble/src/backends/macos/AdapterMac.h +78 -0
- data/vendor/simpleble/simpleble/src/backends/macos/PeripheralBaseMacOS.h +49 -0
- data/vendor/simpleble/simpleble/src/backends/macos/PeripheralMac.h +81 -0
- data/vendor/simpleble/simpleble/src/backends/macos/Utils.h +9 -0
- data/vendor/simpleble/simpleble/src/backends/plain/AdapterPlain.cpp +65 -0
- data/vendor/simpleble/simpleble/src/backends/plain/AdapterPlain.h +49 -0
- data/vendor/simpleble/simpleble/src/backends/plain/BackendPlain.cpp +30 -0
- data/vendor/simpleble/simpleble/src/backends/plain/PeripheralPlain.cpp +159 -0
- data/vendor/simpleble/simpleble/src/backends/plain/PeripheralPlain.h +72 -0
- data/vendor/simpleble/simpleble/src/backends/windows/AdapterWindows.cpp +330 -0
- data/vendor/simpleble/simpleble/src/backends/windows/AdapterWindows.h +89 -0
- data/vendor/simpleble/simpleble/src/backends/windows/BackendWinRT.cpp +67 -0
- data/vendor/simpleble/simpleble/src/backends/windows/BackendWinRT.h +18 -0
- data/vendor/simpleble/simpleble/src/backends/windows/MtaManager.cpp +49 -0
- data/vendor/simpleble/simpleble/src/backends/windows/MtaManager.h +90 -0
- data/vendor/simpleble/simpleble/src/backends/windows/PeripheralWindows.cpp +487 -0
- data/vendor/simpleble/simpleble/src/backends/windows/PeripheralWindows.h +129 -0
- data/vendor/simpleble/simpleble/src/backends/windows/Utils.cpp +146 -0
- data/vendor/simpleble/simpleble/src/backends/windows/Utils.h +47 -0
- data/vendor/simpleble/simpleble/src/builders/BuildVec.h +32 -0
- data/vendor/simpleble/simpleble/src/builders/BuilderBase.h +87 -0
- data/vendor/simpleble/simpleble/src/external/TaskRunner.hpp +99 -0
- data/vendor/simpleble/simpleble/src/external/ThreadRunner.h +52 -0
- data/vendor/simpleble/simpleble/src/external/kvn_safe_callback.hpp +66 -0
- data/vendor/simpleble/simpleble/src/external/kvn_safe_map.hpp +94 -0
- data/vendor/simpleble/simpleble/src/external/kvn_threadrunner.hpp +70 -0
- data/vendor/simpleble/simpleble/src/external/logfwd.hpp +35 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Adapter.cpp +111 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Backend.cpp +83 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Backend.h +76 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Characteristic.cpp +56 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Descriptor.cpp +21 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Peripheral.cpp +113 -0
- data/vendor/simpleble/simpleble/src/frontends/base/Service.cpp +26 -0
- data/vendor/simpleble/simpleble/src/frontends/safe/AdapterSafe.cpp +158 -0
- data/vendor/simpleble/simpleble/src/frontends/safe/PeripheralSafe.cpp +219 -0
- data/vendor/simpleble/simpleble/src_c/adapter.cpp +204 -0
- data/vendor/simpleble/simpleble/src_c/logging.cpp +19 -0
- data/vendor/simpleble/simpleble/src_c/peripheral.cpp +444 -0
- data/vendor/simpleble/simpleble/src_c/simpleble.cpp +5 -0
- data/vendor/simpleble/simpleble/src_c/utils.cpp +15 -0
- data/vendor/simpleble/simpleble/test/src/main.cpp +8 -0
- data/vendor/simpleble/simpleble/test/src/test_bytearray.cpp +246 -0
- data/vendor/simpleble/simpleble/test/src/test_utils.cpp +24 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Adapter.h +46 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Agent.h +52 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Bluez.h +37 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/BluezOrg.h +22 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/BluezOrgBluez.h +26 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/BluezRoot.h +32 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Characteristic.h +46 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Descriptor.h +33 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Device.h +64 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Exceptions.h +43 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Service.h +27 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/Types.h +9 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Adapter1.h +49 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Agent1.h +100 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/AgentManager1.h +24 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Battery1.h +32 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Device1.h +62 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattCharacteristic1.h +48 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattDescriptor1.h +41 -0
- data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattService1.h +28 -0
- data/vendor/simpleble/simplebluez/src/Adapter.cpp +78 -0
- data/vendor/simpleble/simplebluez/src/Agent.cpp +72 -0
- data/vendor/simpleble/simplebluez/src/Bluez.cpp +45 -0
- data/vendor/simpleble/simplebluez/src/BluezOrg.cpp +20 -0
- data/vendor/simpleble/simplebluez/src/BluezOrgBluez.cpp +23 -0
- data/vendor/simpleble/simplebluez/src/BluezRoot.cpp +44 -0
- data/vendor/simpleble/simplebluez/src/Characteristic.cpp +64 -0
- data/vendor/simpleble/simplebluez/src/Descriptor.cpp +27 -0
- data/vendor/simpleble/simplebluez/src/Device.cpp +104 -0
- data/vendor/simpleble/simplebluez/src/Exceptions.cpp +29 -0
- data/vendor/simpleble/simplebluez/src/Logging.cpp +52 -0
- data/vendor/simpleble/simplebluez/src/Logging.h +57 -0
- data/vendor/simpleble/simplebluez/src/Service.cpp +33 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Adapter1.cpp +123 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Agent1.cpp +143 -0
- data/vendor/simpleble/simplebluez/src/interfaces/AgentManager1.cpp +34 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Battery1.cpp +30 -0
- data/vendor/simpleble/simplebluez/src/interfaces/Device1.cpp +170 -0
- data/vendor/simpleble/simplebluez/src/interfaces/GattCharacteristic1.cpp +118 -0
- data/vendor/simpleble/simplebluez/src/interfaces/GattDescriptor1.cpp +78 -0
- data/vendor/simpleble/simplebluez/src/interfaces/GattService1.cpp +28 -0
- data/vendor/simpleble/simplebluez/test/src/helpers/PythonRunner.cpp +53 -0
- data/vendor/simpleble/simplebluez/test/src/helpers/PythonRunner.h +24 -0
- data/vendor/simpleble/simplebluez/test/src/main.cpp +16 -0
- data/vendor/simpleble/simplecble/include/simplecble/adapter.h +188 -0
- data/vendor/simpleble/simplecble/include/simplecble/logging.h +37 -0
- data/vendor/simpleble/simplecble/include/simplecble/peripheral.h +304 -0
- data/vendor/simpleble/simplecble/include/simplecble/simpleble.h +21 -0
- data/vendor/simpleble/simplecble/include/simplecble/types.h +73 -0
- data/vendor/simpleble/simplecble/include/simplecble/utils.h +27 -0
- data/vendor/simpleble/simplecble/src/adapter.cpp +204 -0
- data/vendor/simpleble/simplecble/src/logging.cpp +19 -0
- data/vendor/simpleble/simplecble/src/peripheral.cpp +444 -0
- data/vendor/simpleble/simplecble/src/simpleble.cpp +5 -0
- data/vendor/simpleble/simplecble/src/utils.cpp +15 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/advanced/Interface.h +67 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/advanced/InterfaceRegistry.h +64 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/advanced/Proxy.h +117 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Connection.h +50 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Exceptions.h +56 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Holder.h +147 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Logging.h +57 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Message.h +89 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/base/Path.h +24 -0
- data/vendor/simpleble/simpledbus/include/simpledbus/interfaces/ObjectManager.h +26 -0
- data/vendor/simpleble/simpledbus/src/advanced/Interface.cpp +155 -0
- data/vendor/simpleble/simpledbus/src/advanced/Proxy.cpp +375 -0
- data/vendor/simpleble/simpledbus/src/base/Connection.cpp +222 -0
- data/vendor/simpleble/simpledbus/src/base/Exceptions.cpp +39 -0
- data/vendor/simpleble/simpledbus/src/base/Holder.cpp +739 -0
- data/vendor/simpleble/simpledbus/src/base/Logging.cpp +52 -0
- data/vendor/simpleble/simpledbus/src/base/Message.cpp +622 -0
- data/vendor/simpleble/simpledbus/src/base/Path.cpp +129 -0
- data/vendor/simpleble/simpledbus/src/interfaces/ObjectManager.cpp +58 -0
- data/vendor/simpleble/simpledbus/test/src/helpers/PythonRunner.cpp +53 -0
- data/vendor/simpleble/simpledbus/test/src/helpers/PythonRunner.h +24 -0
- data/vendor/simpleble/simpledbus/test/src/main.cpp +16 -0
- data/vendor/simpleble/simpledbus/test/src/test_holder.cpp +184 -0
- data/vendor/simpleble/simpledbus/test/src/test_message.cpp +397 -0
- data/vendor/simpleble/simpledbus/test/src/test_path.cpp +76 -0
- data/vendor/simpleble/simpledbus/test/src/test_proxy_children.cpp +109 -0
- data/vendor/simpleble/simpledbus/test/src/test_proxy_interfaces.cpp +102 -0
- data/vendor/simpleble/simpledbus/test/src/test_proxy_lifetime.cpp +18 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/ThreadRunner.h +89 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/android_utils.cpp +55 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/android_utils.h +18 -0
- data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/simpleble_android.cpp +813 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/AdapterWrapper.cpp +37 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/AdapterWrapper.h +23 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/Cache.cpp +58 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/Cache.h +34 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/PeripheralWrapper.cpp +17 -0
- data/vendor/simpleble/simplejavable/cpp/src/core/PeripheralWrapper.h +19 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/ArrayList.cpp +257 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/ArrayList.h +78 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/HashMap.cpp +96 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/HashMap.h +54 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Integer.cpp +93 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Integer.h +49 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Iterator.cpp +85 -0
- data/vendor/simpleble/simplejavable/cpp/src/java/lang/Iterator.h +48 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/AdapterCallback.cpp +91 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/AdapterCallback.h +90 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Characteristic.cpp +35 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Characteristic.h +60 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/DataCallback.cpp +33 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/DataCallback.h +45 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Descriptor.cpp +30 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Descriptor.h +49 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/PeripheralCallback.cpp +41 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/PeripheralCallback.h +51 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Service.cpp +33 -0
- data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Service.h +54 -0
- data/vendor/simpleble/simplejavable/cpp/src/simplejavable.cpp +361 -0
- data/vendor/simpleble/simplepyble/src/main.cpp +55 -0
- data/vendor/simpleble/simplepyble/src/wrap_adapter.cpp +106 -0
- data/vendor/simpleble/simplepyble/src/wrap_characteristic.cpp +56 -0
- data/vendor/simpleble/simplepyble/src/wrap_config.cpp +136 -0
- data/vendor/simpleble/simplepyble/src/wrap_descriptor.cpp +21 -0
- data/vendor/simpleble/simplepyble/src/wrap_peripheral.cpp +217 -0
- data/vendor/simpleble/simplepyble/src/wrap_service.cpp +32 -0
- data/vendor/simpleble/simplepyble/src/wrap_types.cpp +21 -0
- data/vendor/simpleble/simplersble/src/bindings/Bindings.cpp +338 -0
- data/vendor/simpleble/simplersble/src/bindings/Bindings.hpp +178 -0
- metadata +430 -0
@@ -0,0 +1,726 @@
|
|
1
|
+
// Formatting library for C++ - formatters for standard library types
|
2
|
+
//
|
3
|
+
// Copyright (c) 2012 - present, Victor Zverovich
|
4
|
+
// All rights reserved.
|
5
|
+
//
|
6
|
+
// For the license information refer to format.h.
|
7
|
+
|
8
|
+
#ifndef FMT_STD_H_
|
9
|
+
#define FMT_STD_H_
|
10
|
+
|
11
|
+
#include "format.h"
|
12
|
+
#include "ostream.h"
|
13
|
+
|
14
|
+
#ifndef FMT_MODULE
|
15
|
+
# include <atomic>
|
16
|
+
# include <bitset>
|
17
|
+
# include <complex>
|
18
|
+
# include <cstdlib>
|
19
|
+
# include <exception>
|
20
|
+
# include <functional>
|
21
|
+
# include <memory>
|
22
|
+
# include <thread>
|
23
|
+
# include <type_traits>
|
24
|
+
# include <typeinfo>
|
25
|
+
# include <utility>
|
26
|
+
# include <vector>
|
27
|
+
|
28
|
+
// Check FMT_CPLUSPLUS to suppress a bogus warning in MSVC.
|
29
|
+
# if FMT_CPLUSPLUS >= 201703L
|
30
|
+
# if FMT_HAS_INCLUDE(<filesystem>) && \
|
31
|
+
(!defined(FMT_CPP_LIB_FILESYSTEM) || FMT_CPP_LIB_FILESYSTEM != 0)
|
32
|
+
# include <filesystem>
|
33
|
+
# endif
|
34
|
+
# if FMT_HAS_INCLUDE(<variant>)
|
35
|
+
# include <variant>
|
36
|
+
# endif
|
37
|
+
# if FMT_HAS_INCLUDE(<optional>)
|
38
|
+
# include <optional>
|
39
|
+
# endif
|
40
|
+
# endif
|
41
|
+
// Use > instead of >= in the version check because <source_location> may be
|
42
|
+
// available after C++17 but before C++20 is marked as implemented.
|
43
|
+
# if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE(<source_location>)
|
44
|
+
# include <source_location>
|
45
|
+
# endif
|
46
|
+
# if FMT_CPLUSPLUS > 202002L && FMT_HAS_INCLUDE(<expected>)
|
47
|
+
# include <expected>
|
48
|
+
# endif
|
49
|
+
#endif // FMT_MODULE
|
50
|
+
|
51
|
+
#if FMT_HAS_INCLUDE(<version>)
|
52
|
+
# include <version>
|
53
|
+
#endif
|
54
|
+
|
55
|
+
// GCC 4 does not support FMT_HAS_INCLUDE.
|
56
|
+
#if FMT_HAS_INCLUDE(<cxxabi.h>) || defined(__GLIBCXX__)
|
57
|
+
# include <cxxabi.h>
|
58
|
+
// Android NDK with gabi++ library on some architectures does not implement
|
59
|
+
// abi::__cxa_demangle().
|
60
|
+
# ifndef __GABIXX_CXXABI_H__
|
61
|
+
# define FMT_HAS_ABI_CXA_DEMANGLE
|
62
|
+
# endif
|
63
|
+
#endif
|
64
|
+
|
65
|
+
// For older Xcode versions, __cpp_lib_xxx flags are inaccurately defined.
|
66
|
+
#ifndef FMT_CPP_LIB_FILESYSTEM
|
67
|
+
# ifdef __cpp_lib_filesystem
|
68
|
+
# define FMT_CPP_LIB_FILESYSTEM __cpp_lib_filesystem
|
69
|
+
# else
|
70
|
+
# define FMT_CPP_LIB_FILESYSTEM 0
|
71
|
+
# endif
|
72
|
+
#endif
|
73
|
+
|
74
|
+
#ifndef FMT_CPP_LIB_VARIANT
|
75
|
+
# ifdef __cpp_lib_variant
|
76
|
+
# define FMT_CPP_LIB_VARIANT __cpp_lib_variant
|
77
|
+
# else
|
78
|
+
# define FMT_CPP_LIB_VARIANT 0
|
79
|
+
# endif
|
80
|
+
#endif
|
81
|
+
|
82
|
+
#if FMT_CPP_LIB_FILESYSTEM
|
83
|
+
FMT_BEGIN_NAMESPACE
|
84
|
+
|
85
|
+
namespace detail {
|
86
|
+
|
87
|
+
template <typename Char, typename PathChar>
|
88
|
+
auto get_path_string(const std::filesystem::path& p,
|
89
|
+
const std::basic_string<PathChar>& native) {
|
90
|
+
if constexpr (std::is_same_v<Char, char> && std::is_same_v<PathChar, wchar_t>)
|
91
|
+
return to_utf8<wchar_t>(native, to_utf8_error_policy::replace);
|
92
|
+
else
|
93
|
+
return p.string<Char>();
|
94
|
+
}
|
95
|
+
|
96
|
+
template <typename Char, typename PathChar>
|
97
|
+
void write_escaped_path(basic_memory_buffer<Char>& quoted,
|
98
|
+
const std::filesystem::path& p,
|
99
|
+
const std::basic_string<PathChar>& native) {
|
100
|
+
if constexpr (std::is_same_v<Char, char> &&
|
101
|
+
std::is_same_v<PathChar, wchar_t>) {
|
102
|
+
auto buf = basic_memory_buffer<wchar_t>();
|
103
|
+
write_escaped_string<wchar_t>(std::back_inserter(buf), native);
|
104
|
+
bool valid = to_utf8<wchar_t>::convert(quoted, {buf.data(), buf.size()});
|
105
|
+
FMT_ASSERT(valid, "invalid utf16");
|
106
|
+
} else if constexpr (std::is_same_v<Char, PathChar>) {
|
107
|
+
write_escaped_string<std::filesystem::path::value_type>(
|
108
|
+
std::back_inserter(quoted), native);
|
109
|
+
} else {
|
110
|
+
write_escaped_string<Char>(std::back_inserter(quoted), p.string<Char>());
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
} // namespace detail
|
115
|
+
|
116
|
+
FMT_EXPORT
|
117
|
+
template <typename Char> struct formatter<std::filesystem::path, Char> {
|
118
|
+
private:
|
119
|
+
format_specs specs_;
|
120
|
+
detail::arg_ref<Char> width_ref_;
|
121
|
+
bool debug_ = false;
|
122
|
+
char path_type_ = 0;
|
123
|
+
|
124
|
+
public:
|
125
|
+
FMT_CONSTEXPR void set_debug_format(bool set = true) { debug_ = set; }
|
126
|
+
|
127
|
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) {
|
128
|
+
auto it = ctx.begin(), end = ctx.end();
|
129
|
+
if (it == end) return it;
|
130
|
+
|
131
|
+
it = detail::parse_align(it, end, specs_);
|
132
|
+
if (it == end) return it;
|
133
|
+
|
134
|
+
Char c = *it;
|
135
|
+
if ((c >= '0' && c <= '9') || c == '{')
|
136
|
+
it = detail::parse_width(it, end, specs_, width_ref_, ctx);
|
137
|
+
if (it != end && *it == '?') {
|
138
|
+
debug_ = true;
|
139
|
+
++it;
|
140
|
+
}
|
141
|
+
if (it != end && (*it == 'g')) path_type_ = detail::to_ascii(*it++);
|
142
|
+
return it;
|
143
|
+
}
|
144
|
+
|
145
|
+
template <typename FormatContext>
|
146
|
+
auto format(const std::filesystem::path& p, FormatContext& ctx) const {
|
147
|
+
auto specs = specs_;
|
148
|
+
auto path_string =
|
149
|
+
!path_type_ ? p.native()
|
150
|
+
: p.generic_string<std::filesystem::path::value_type>();
|
151
|
+
|
152
|
+
detail::handle_dynamic_spec(specs.dynamic_width(), specs.width, width_ref_,
|
153
|
+
ctx);
|
154
|
+
if (!debug_) {
|
155
|
+
auto s = detail::get_path_string<Char>(p, path_string);
|
156
|
+
return detail::write(ctx.out(), basic_string_view<Char>(s), specs);
|
157
|
+
}
|
158
|
+
auto quoted = basic_memory_buffer<Char>();
|
159
|
+
detail::write_escaped_path(quoted, p, path_string);
|
160
|
+
return detail::write(ctx.out(),
|
161
|
+
basic_string_view<Char>(quoted.data(), quoted.size()),
|
162
|
+
specs);
|
163
|
+
}
|
164
|
+
};
|
165
|
+
|
166
|
+
class path : public std::filesystem::path {
|
167
|
+
public:
|
168
|
+
auto display_string() const -> std::string {
|
169
|
+
const std::filesystem::path& base = *this;
|
170
|
+
return fmt::format(FMT_STRING("{}"), base);
|
171
|
+
}
|
172
|
+
auto system_string() const -> std::string { return string(); }
|
173
|
+
|
174
|
+
auto generic_display_string() const -> std::string {
|
175
|
+
const std::filesystem::path& base = *this;
|
176
|
+
return fmt::format(FMT_STRING("{:g}"), base);
|
177
|
+
}
|
178
|
+
auto generic_system_string() const -> std::string { return generic_string(); }
|
179
|
+
};
|
180
|
+
|
181
|
+
FMT_END_NAMESPACE
|
182
|
+
#endif // FMT_CPP_LIB_FILESYSTEM
|
183
|
+
|
184
|
+
FMT_BEGIN_NAMESPACE
|
185
|
+
FMT_EXPORT
|
186
|
+
template <std::size_t N, typename Char>
|
187
|
+
struct formatter<std::bitset<N>, Char>
|
188
|
+
: nested_formatter<basic_string_view<Char>, Char> {
|
189
|
+
private:
|
190
|
+
// Functor because C++11 doesn't support generic lambdas.
|
191
|
+
struct writer {
|
192
|
+
const std::bitset<N>& bs;
|
193
|
+
|
194
|
+
template <typename OutputIt>
|
195
|
+
FMT_CONSTEXPR auto operator()(OutputIt out) -> OutputIt {
|
196
|
+
for (auto pos = N; pos > 0; --pos) {
|
197
|
+
out = detail::write<Char>(out, bs[pos - 1] ? Char('1') : Char('0'));
|
198
|
+
}
|
199
|
+
|
200
|
+
return out;
|
201
|
+
}
|
202
|
+
};
|
203
|
+
|
204
|
+
public:
|
205
|
+
template <typename FormatContext>
|
206
|
+
auto format(const std::bitset<N>& bs, FormatContext& ctx) const
|
207
|
+
-> decltype(ctx.out()) {
|
208
|
+
return this->write_padded(ctx, writer{bs});
|
209
|
+
}
|
210
|
+
};
|
211
|
+
|
212
|
+
FMT_EXPORT
|
213
|
+
template <typename Char>
|
214
|
+
struct formatter<std::thread::id, Char> : basic_ostream_formatter<Char> {};
|
215
|
+
FMT_END_NAMESPACE
|
216
|
+
|
217
|
+
#ifdef __cpp_lib_optional
|
218
|
+
FMT_BEGIN_NAMESPACE
|
219
|
+
FMT_EXPORT
|
220
|
+
template <typename T, typename Char>
|
221
|
+
struct formatter<std::optional<T>, Char,
|
222
|
+
std::enable_if_t<is_formattable<T, Char>::value>> {
|
223
|
+
private:
|
224
|
+
formatter<T, Char> underlying_;
|
225
|
+
static constexpr basic_string_view<Char> optional =
|
226
|
+
detail::string_literal<Char, 'o', 'p', 't', 'i', 'o', 'n', 'a', 'l',
|
227
|
+
'('>{};
|
228
|
+
static constexpr basic_string_view<Char> none =
|
229
|
+
detail::string_literal<Char, 'n', 'o', 'n', 'e'>{};
|
230
|
+
|
231
|
+
template <class U>
|
232
|
+
FMT_CONSTEXPR static auto maybe_set_debug_format(U& u, bool set)
|
233
|
+
-> decltype(u.set_debug_format(set)) {
|
234
|
+
u.set_debug_format(set);
|
235
|
+
}
|
236
|
+
|
237
|
+
template <class U>
|
238
|
+
FMT_CONSTEXPR static void maybe_set_debug_format(U&, ...) {}
|
239
|
+
|
240
|
+
public:
|
241
|
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) {
|
242
|
+
maybe_set_debug_format(underlying_, true);
|
243
|
+
return underlying_.parse(ctx);
|
244
|
+
}
|
245
|
+
|
246
|
+
template <typename FormatContext>
|
247
|
+
auto format(const std::optional<T>& opt, FormatContext& ctx) const
|
248
|
+
-> decltype(ctx.out()) {
|
249
|
+
if (!opt) return detail::write<Char>(ctx.out(), none);
|
250
|
+
|
251
|
+
auto out = ctx.out();
|
252
|
+
out = detail::write<Char>(out, optional);
|
253
|
+
ctx.advance_to(out);
|
254
|
+
out = underlying_.format(*opt, ctx);
|
255
|
+
return detail::write(out, ')');
|
256
|
+
}
|
257
|
+
};
|
258
|
+
FMT_END_NAMESPACE
|
259
|
+
#endif // __cpp_lib_optional
|
260
|
+
|
261
|
+
#if defined(__cpp_lib_expected) || FMT_CPP_LIB_VARIANT
|
262
|
+
|
263
|
+
FMT_BEGIN_NAMESPACE
|
264
|
+
namespace detail {
|
265
|
+
|
266
|
+
template <typename Char, typename OutputIt, typename T>
|
267
|
+
auto write_escaped_alternative(OutputIt out, const T& v) -> OutputIt {
|
268
|
+
if constexpr (has_to_string_view<T>::value)
|
269
|
+
return write_escaped_string<Char>(out, detail::to_string_view(v));
|
270
|
+
if constexpr (std::is_same_v<T, Char>) return write_escaped_char(out, v);
|
271
|
+
return write<Char>(out, v);
|
272
|
+
}
|
273
|
+
|
274
|
+
} // namespace detail
|
275
|
+
|
276
|
+
FMT_END_NAMESPACE
|
277
|
+
#endif
|
278
|
+
|
279
|
+
#ifdef __cpp_lib_expected
|
280
|
+
FMT_BEGIN_NAMESPACE
|
281
|
+
|
282
|
+
FMT_EXPORT
|
283
|
+
template <typename T, typename E, typename Char>
|
284
|
+
struct formatter<std::expected<T, E>, Char,
|
285
|
+
std::enable_if_t<(std::is_void<T>::value ||
|
286
|
+
is_formattable<T, Char>::value) &&
|
287
|
+
is_formattable<E, Char>::value>> {
|
288
|
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
289
|
+
return ctx.begin();
|
290
|
+
}
|
291
|
+
|
292
|
+
template <typename FormatContext>
|
293
|
+
auto format(const std::expected<T, E>& value, FormatContext& ctx) const
|
294
|
+
-> decltype(ctx.out()) {
|
295
|
+
auto out = ctx.out();
|
296
|
+
|
297
|
+
if (value.has_value()) {
|
298
|
+
out = detail::write<Char>(out, "expected(");
|
299
|
+
if constexpr (!std::is_void<T>::value)
|
300
|
+
out = detail::write_escaped_alternative<Char>(out, *value);
|
301
|
+
} else {
|
302
|
+
out = detail::write<Char>(out, "unexpected(");
|
303
|
+
out = detail::write_escaped_alternative<Char>(out, value.error());
|
304
|
+
}
|
305
|
+
*out++ = ')';
|
306
|
+
return out;
|
307
|
+
}
|
308
|
+
};
|
309
|
+
FMT_END_NAMESPACE
|
310
|
+
#endif // __cpp_lib_expected
|
311
|
+
|
312
|
+
#ifdef __cpp_lib_source_location
|
313
|
+
FMT_BEGIN_NAMESPACE
|
314
|
+
FMT_EXPORT
|
315
|
+
template <> struct formatter<std::source_location> {
|
316
|
+
FMT_CONSTEXPR auto parse(parse_context<>& ctx) { return ctx.begin(); }
|
317
|
+
|
318
|
+
template <typename FormatContext>
|
319
|
+
auto format(const std::source_location& loc, FormatContext& ctx) const
|
320
|
+
-> decltype(ctx.out()) {
|
321
|
+
auto out = ctx.out();
|
322
|
+
out = detail::write(out, loc.file_name());
|
323
|
+
out = detail::write(out, ':');
|
324
|
+
out = detail::write<char>(out, loc.line());
|
325
|
+
out = detail::write(out, ':');
|
326
|
+
out = detail::write<char>(out, loc.column());
|
327
|
+
out = detail::write(out, ": ");
|
328
|
+
out = detail::write(out, loc.function_name());
|
329
|
+
return out;
|
330
|
+
}
|
331
|
+
};
|
332
|
+
FMT_END_NAMESPACE
|
333
|
+
#endif
|
334
|
+
|
335
|
+
#if FMT_CPP_LIB_VARIANT
|
336
|
+
FMT_BEGIN_NAMESPACE
|
337
|
+
namespace detail {
|
338
|
+
|
339
|
+
template <typename T>
|
340
|
+
using variant_index_sequence =
|
341
|
+
std::make_index_sequence<std::variant_size<T>::value>;
|
342
|
+
|
343
|
+
template <typename> struct is_variant_like_ : std::false_type {};
|
344
|
+
template <typename... Types>
|
345
|
+
struct is_variant_like_<std::variant<Types...>> : std::true_type {};
|
346
|
+
|
347
|
+
// formattable element check.
|
348
|
+
template <typename T, typename C> class is_variant_formattable_ {
|
349
|
+
template <std::size_t... Is>
|
350
|
+
static std::conjunction<
|
351
|
+
is_formattable<std::variant_alternative_t<Is, T>, C>...>
|
352
|
+
check(std::index_sequence<Is...>);
|
353
|
+
|
354
|
+
public:
|
355
|
+
static constexpr const bool value =
|
356
|
+
decltype(check(variant_index_sequence<T>{}))::value;
|
357
|
+
};
|
358
|
+
|
359
|
+
} // namespace detail
|
360
|
+
|
361
|
+
template <typename T> struct is_variant_like {
|
362
|
+
static constexpr const bool value = detail::is_variant_like_<T>::value;
|
363
|
+
};
|
364
|
+
|
365
|
+
template <typename T, typename C> struct is_variant_formattable {
|
366
|
+
static constexpr const bool value =
|
367
|
+
detail::is_variant_formattable_<T, C>::value;
|
368
|
+
};
|
369
|
+
|
370
|
+
FMT_EXPORT
|
371
|
+
template <typename Char> struct formatter<std::monostate, Char> {
|
372
|
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
373
|
+
return ctx.begin();
|
374
|
+
}
|
375
|
+
|
376
|
+
template <typename FormatContext>
|
377
|
+
auto format(const std::monostate&, FormatContext& ctx) const
|
378
|
+
-> decltype(ctx.out()) {
|
379
|
+
return detail::write<Char>(ctx.out(), "monostate");
|
380
|
+
}
|
381
|
+
};
|
382
|
+
|
383
|
+
FMT_EXPORT
|
384
|
+
template <typename Variant, typename Char>
|
385
|
+
struct formatter<
|
386
|
+
Variant, Char,
|
387
|
+
std::enable_if_t<std::conjunction_v<
|
388
|
+
is_variant_like<Variant>, is_variant_formattable<Variant, Char>>>> {
|
389
|
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
390
|
+
return ctx.begin();
|
391
|
+
}
|
392
|
+
|
393
|
+
template <typename FormatContext>
|
394
|
+
auto format(const Variant& value, FormatContext& ctx) const
|
395
|
+
-> decltype(ctx.out()) {
|
396
|
+
auto out = ctx.out();
|
397
|
+
|
398
|
+
out = detail::write<Char>(out, "variant(");
|
399
|
+
FMT_TRY {
|
400
|
+
std::visit(
|
401
|
+
[&](const auto& v) {
|
402
|
+
out = detail::write_escaped_alternative<Char>(out, v);
|
403
|
+
},
|
404
|
+
value);
|
405
|
+
}
|
406
|
+
FMT_CATCH(const std::bad_variant_access&) {
|
407
|
+
detail::write<Char>(out, "valueless by exception");
|
408
|
+
}
|
409
|
+
*out++ = ')';
|
410
|
+
return out;
|
411
|
+
}
|
412
|
+
};
|
413
|
+
FMT_END_NAMESPACE
|
414
|
+
#endif // FMT_CPP_LIB_VARIANT
|
415
|
+
|
416
|
+
FMT_BEGIN_NAMESPACE
|
417
|
+
FMT_EXPORT
|
418
|
+
template <> struct formatter<std::error_code> {
|
419
|
+
private:
|
420
|
+
format_specs specs_;
|
421
|
+
detail::arg_ref<char> width_ref_;
|
422
|
+
|
423
|
+
public:
|
424
|
+
FMT_CONSTEXPR auto parse(parse_context<>& ctx) -> const char* {
|
425
|
+
auto it = ctx.begin(), end = ctx.end();
|
426
|
+
if (it == end) return it;
|
427
|
+
|
428
|
+
it = detail::parse_align(it, end, specs_);
|
429
|
+
if (it == end) return it;
|
430
|
+
|
431
|
+
char c = *it;
|
432
|
+
if ((c >= '0' && c <= '9') || c == '{')
|
433
|
+
it = detail::parse_width(it, end, specs_, width_ref_, ctx);
|
434
|
+
return it;
|
435
|
+
}
|
436
|
+
|
437
|
+
template <typename FormatContext>
|
438
|
+
FMT_CONSTEXPR20 auto format(const std::error_code& ec,
|
439
|
+
FormatContext& ctx) const -> decltype(ctx.out()) {
|
440
|
+
auto specs = specs_;
|
441
|
+
detail::handle_dynamic_spec(specs.dynamic_width(), specs.width, width_ref_,
|
442
|
+
ctx);
|
443
|
+
memory_buffer buf;
|
444
|
+
buf.append(string_view(ec.category().name()));
|
445
|
+
buf.push_back(':');
|
446
|
+
detail::write<char>(appender(buf), ec.value());
|
447
|
+
return detail::write<char>(ctx.out(), string_view(buf.data(), buf.size()),
|
448
|
+
specs);
|
449
|
+
}
|
450
|
+
};
|
451
|
+
|
452
|
+
#if FMT_USE_RTTI
|
453
|
+
namespace detail {
|
454
|
+
|
455
|
+
template <typename Char, typename OutputIt>
|
456
|
+
auto write_demangled_name(OutputIt out, const std::type_info& ti) -> OutputIt {
|
457
|
+
# ifdef FMT_HAS_ABI_CXA_DEMANGLE
|
458
|
+
int status = 0;
|
459
|
+
std::size_t size = 0;
|
460
|
+
std::unique_ptr<char, void (*)(void*)> demangled_name_ptr(
|
461
|
+
abi::__cxa_demangle(ti.name(), nullptr, &size, &status), &std::free);
|
462
|
+
|
463
|
+
string_view demangled_name_view;
|
464
|
+
if (demangled_name_ptr) {
|
465
|
+
demangled_name_view = demangled_name_ptr.get();
|
466
|
+
|
467
|
+
// Normalization of stdlib inline namespace names.
|
468
|
+
// libc++ inline namespaces.
|
469
|
+
// std::__1::* -> std::*
|
470
|
+
// std::__1::__fs::* -> std::*
|
471
|
+
// libstdc++ inline namespaces.
|
472
|
+
// std::__cxx11::* -> std::*
|
473
|
+
// std::filesystem::__cxx11::* -> std::filesystem::*
|
474
|
+
if (demangled_name_view.starts_with("std::")) {
|
475
|
+
char* begin = demangled_name_ptr.get();
|
476
|
+
char* to = begin + 5; // std::
|
477
|
+
for (char *from = to, *end = begin + demangled_name_view.size();
|
478
|
+
from < end;) {
|
479
|
+
// This is safe, because demangled_name is NUL-terminated.
|
480
|
+
if (from[0] == '_' && from[1] == '_') {
|
481
|
+
char* next = from + 1;
|
482
|
+
while (next < end && *next != ':') next++;
|
483
|
+
if (next[0] == ':' && next[1] == ':') {
|
484
|
+
from = next + 2;
|
485
|
+
continue;
|
486
|
+
}
|
487
|
+
}
|
488
|
+
*to++ = *from++;
|
489
|
+
}
|
490
|
+
demangled_name_view = {begin, detail::to_unsigned(to - begin)};
|
491
|
+
}
|
492
|
+
} else {
|
493
|
+
demangled_name_view = string_view(ti.name());
|
494
|
+
}
|
495
|
+
return detail::write_bytes<Char>(out, demangled_name_view);
|
496
|
+
# elif FMT_MSC_VERSION
|
497
|
+
const string_view demangled_name(ti.name());
|
498
|
+
for (std::size_t i = 0; i < demangled_name.size(); ++i) {
|
499
|
+
auto sub = demangled_name;
|
500
|
+
sub.remove_prefix(i);
|
501
|
+
if (sub.starts_with("enum ")) {
|
502
|
+
i += 4;
|
503
|
+
continue;
|
504
|
+
}
|
505
|
+
if (sub.starts_with("class ") || sub.starts_with("union ")) {
|
506
|
+
i += 5;
|
507
|
+
continue;
|
508
|
+
}
|
509
|
+
if (sub.starts_with("struct ")) {
|
510
|
+
i += 6;
|
511
|
+
continue;
|
512
|
+
}
|
513
|
+
if (*sub.begin() != ' ') *out++ = *sub.begin();
|
514
|
+
}
|
515
|
+
return out;
|
516
|
+
# else
|
517
|
+
return detail::write_bytes<Char>(out, string_view(ti.name()));
|
518
|
+
# endif
|
519
|
+
}
|
520
|
+
|
521
|
+
} // namespace detail
|
522
|
+
|
523
|
+
FMT_EXPORT
|
524
|
+
template <typename Char>
|
525
|
+
struct formatter<std::type_info, Char // DEPRECATED! Mixing code unit types.
|
526
|
+
> {
|
527
|
+
public:
|
528
|
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
529
|
+
return ctx.begin();
|
530
|
+
}
|
531
|
+
|
532
|
+
template <typename Context>
|
533
|
+
auto format(const std::type_info& ti, Context& ctx) const
|
534
|
+
-> decltype(ctx.out()) {
|
535
|
+
return detail::write_demangled_name<Char>(ctx.out(), ti);
|
536
|
+
}
|
537
|
+
};
|
538
|
+
#endif
|
539
|
+
|
540
|
+
FMT_EXPORT
|
541
|
+
template <typename T, typename Char>
|
542
|
+
struct formatter<
|
543
|
+
T, Char, // DEPRECATED! Mixing code unit types.
|
544
|
+
typename std::enable_if<std::is_base_of<std::exception, T>::value>::type> {
|
545
|
+
private:
|
546
|
+
bool with_typename_ = false;
|
547
|
+
|
548
|
+
public:
|
549
|
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
550
|
+
auto it = ctx.begin();
|
551
|
+
auto end = ctx.end();
|
552
|
+
if (it == end || *it == '}') return it;
|
553
|
+
if (*it == 't') {
|
554
|
+
++it;
|
555
|
+
with_typename_ = FMT_USE_RTTI != 0;
|
556
|
+
}
|
557
|
+
return it;
|
558
|
+
}
|
559
|
+
|
560
|
+
template <typename Context>
|
561
|
+
auto format(const std::exception& ex, Context& ctx) const
|
562
|
+
-> decltype(ctx.out()) {
|
563
|
+
auto out = ctx.out();
|
564
|
+
#if FMT_USE_RTTI
|
565
|
+
if (with_typename_) {
|
566
|
+
out = detail::write_demangled_name<Char>(out, typeid(ex));
|
567
|
+
*out++ = ':';
|
568
|
+
*out++ = ' ';
|
569
|
+
}
|
570
|
+
#endif
|
571
|
+
return detail::write_bytes<Char>(out, string_view(ex.what()));
|
572
|
+
}
|
573
|
+
};
|
574
|
+
|
575
|
+
namespace detail {
|
576
|
+
|
577
|
+
template <typename T, typename Enable = void>
|
578
|
+
struct has_flip : std::false_type {};
|
579
|
+
|
580
|
+
template <typename T>
|
581
|
+
struct has_flip<T, void_t<decltype(std::declval<T>().flip())>>
|
582
|
+
: std::true_type {};
|
583
|
+
|
584
|
+
template <typename T> struct is_bit_reference_like {
|
585
|
+
static constexpr const bool value =
|
586
|
+
std::is_convertible<T, bool>::value &&
|
587
|
+
std::is_nothrow_assignable<T, bool>::value && has_flip<T>::value;
|
588
|
+
};
|
589
|
+
|
590
|
+
#ifdef _LIBCPP_VERSION
|
591
|
+
|
592
|
+
// Workaround for libc++ incompatibility with C++ standard.
|
593
|
+
// According to the Standard, `bitset::operator[] const` returns bool.
|
594
|
+
template <typename C>
|
595
|
+
struct is_bit_reference_like<std::__bit_const_reference<C>> {
|
596
|
+
static constexpr const bool value = true;
|
597
|
+
};
|
598
|
+
|
599
|
+
#endif
|
600
|
+
|
601
|
+
} // namespace detail
|
602
|
+
|
603
|
+
// We can't use std::vector<bool, Allocator>::reference and
|
604
|
+
// std::bitset<N>::reference because the compiler can't deduce Allocator and N
|
605
|
+
// in partial specialization.
|
606
|
+
FMT_EXPORT
|
607
|
+
template <typename BitRef, typename Char>
|
608
|
+
struct formatter<BitRef, Char,
|
609
|
+
enable_if_t<detail::is_bit_reference_like<BitRef>::value>>
|
610
|
+
: formatter<bool, Char> {
|
611
|
+
template <typename FormatContext>
|
612
|
+
FMT_CONSTEXPR auto format(const BitRef& v, FormatContext& ctx) const
|
613
|
+
-> decltype(ctx.out()) {
|
614
|
+
return formatter<bool, Char>::format(v, ctx);
|
615
|
+
}
|
616
|
+
};
|
617
|
+
|
618
|
+
template <typename T, typename Deleter>
|
619
|
+
auto ptr(const std::unique_ptr<T, Deleter>& p) -> const void* {
|
620
|
+
return p.get();
|
621
|
+
}
|
622
|
+
template <typename T> auto ptr(const std::shared_ptr<T>& p) -> const void* {
|
623
|
+
return p.get();
|
624
|
+
}
|
625
|
+
|
626
|
+
FMT_EXPORT
|
627
|
+
template <typename T, typename Char>
|
628
|
+
struct formatter<std::atomic<T>, Char,
|
629
|
+
enable_if_t<is_formattable<T, Char>::value>>
|
630
|
+
: formatter<T, Char> {
|
631
|
+
template <typename FormatContext>
|
632
|
+
auto format(const std::atomic<T>& v, FormatContext& ctx) const
|
633
|
+
-> decltype(ctx.out()) {
|
634
|
+
return formatter<T, Char>::format(v.load(), ctx);
|
635
|
+
}
|
636
|
+
};
|
637
|
+
|
638
|
+
#ifdef __cpp_lib_atomic_flag_test
|
639
|
+
FMT_EXPORT
|
640
|
+
template <typename Char>
|
641
|
+
struct formatter<std::atomic_flag, Char> : formatter<bool, Char> {
|
642
|
+
template <typename FormatContext>
|
643
|
+
auto format(const std::atomic_flag& v, FormatContext& ctx) const
|
644
|
+
-> decltype(ctx.out()) {
|
645
|
+
return formatter<bool, Char>::format(v.test(), ctx);
|
646
|
+
}
|
647
|
+
};
|
648
|
+
#endif // __cpp_lib_atomic_flag_test
|
649
|
+
|
650
|
+
FMT_EXPORT
|
651
|
+
template <typename T, typename Char> struct formatter<std::complex<T>, Char> {
|
652
|
+
private:
|
653
|
+
detail::dynamic_format_specs<Char> specs_;
|
654
|
+
|
655
|
+
template <typename FormatContext, typename OutputIt>
|
656
|
+
FMT_CONSTEXPR auto do_format(const std::complex<T>& c,
|
657
|
+
detail::dynamic_format_specs<Char>& specs,
|
658
|
+
FormatContext& ctx, OutputIt out) const
|
659
|
+
-> OutputIt {
|
660
|
+
if (c.real() != 0) {
|
661
|
+
*out++ = Char('(');
|
662
|
+
out = detail::write<Char>(out, c.real(), specs, ctx.locale());
|
663
|
+
specs.set_sign(sign::plus);
|
664
|
+
out = detail::write<Char>(out, c.imag(), specs, ctx.locale());
|
665
|
+
if (!detail::isfinite(c.imag())) *out++ = Char(' ');
|
666
|
+
*out++ = Char('i');
|
667
|
+
*out++ = Char(')');
|
668
|
+
return out;
|
669
|
+
}
|
670
|
+
out = detail::write<Char>(out, c.imag(), specs, ctx.locale());
|
671
|
+
if (!detail::isfinite(c.imag())) *out++ = Char(' ');
|
672
|
+
*out++ = Char('i');
|
673
|
+
return out;
|
674
|
+
}
|
675
|
+
|
676
|
+
public:
|
677
|
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
678
|
+
if (ctx.begin() == ctx.end() || *ctx.begin() == '}') return ctx.begin();
|
679
|
+
return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx,
|
680
|
+
detail::type_constant<T, Char>::value);
|
681
|
+
}
|
682
|
+
|
683
|
+
template <typename FormatContext>
|
684
|
+
auto format(const std::complex<T>& c, FormatContext& ctx) const
|
685
|
+
-> decltype(ctx.out()) {
|
686
|
+
auto specs = specs_;
|
687
|
+
if (specs.dynamic()) {
|
688
|
+
detail::handle_dynamic_spec(specs.dynamic_width(), specs.width,
|
689
|
+
specs.width_ref, ctx);
|
690
|
+
detail::handle_dynamic_spec(specs.dynamic_precision(), specs.precision,
|
691
|
+
specs.precision_ref, ctx);
|
692
|
+
}
|
693
|
+
|
694
|
+
if (specs.width == 0) return do_format(c, specs, ctx, ctx.out());
|
695
|
+
auto buf = basic_memory_buffer<Char>();
|
696
|
+
|
697
|
+
auto outer_specs = format_specs();
|
698
|
+
outer_specs.width = specs.width;
|
699
|
+
outer_specs.copy_fill_from(specs);
|
700
|
+
outer_specs.set_align(specs.align());
|
701
|
+
|
702
|
+
specs.width = 0;
|
703
|
+
specs.set_fill({});
|
704
|
+
specs.set_align(align::none);
|
705
|
+
|
706
|
+
do_format(c, specs, ctx, basic_appender<Char>(buf));
|
707
|
+
return detail::write<Char>(ctx.out(),
|
708
|
+
basic_string_view<Char>(buf.data(), buf.size()),
|
709
|
+
outer_specs);
|
710
|
+
}
|
711
|
+
};
|
712
|
+
|
713
|
+
FMT_EXPORT
|
714
|
+
template <typename T, typename Char>
|
715
|
+
struct formatter<std::reference_wrapper<T>, Char,
|
716
|
+
enable_if_t<is_formattable<remove_cvref_t<T>, Char>::value>>
|
717
|
+
: formatter<remove_cvref_t<T>, Char> {
|
718
|
+
template <typename FormatContext>
|
719
|
+
auto format(std::reference_wrapper<T> ref, FormatContext& ctx) const
|
720
|
+
-> decltype(ctx.out()) {
|
721
|
+
return formatter<remove_cvref_t<T>, Char>::format(ref.get(), ctx);
|
722
|
+
}
|
723
|
+
};
|
724
|
+
|
725
|
+
FMT_END_NAMESPACE
|
726
|
+
#endif // FMT_STD_H_
|