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.
Files changed (341) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +88 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +350 -0
  5. data/ext/simpleble/extconf.rb +57 -0
  6. data/ext/simpleble/simpleble_ruby.c +682 -0
  7. data/lib/simpleble/adapter.rb +10 -0
  8. data/lib/simpleble/characteristic.rb +36 -0
  9. data/lib/simpleble/descriptor.rb +8 -0
  10. data/lib/simpleble/exceptions.rb +25 -0
  11. data/lib/simpleble/peripheral.rb +64 -0
  12. data/lib/simpleble/service.rb +16 -0
  13. data/lib/simpleble/version.rb +3 -0
  14. data/lib/simpleble.rb +40 -0
  15. data/vendor/simpleble/build_simplecble/CMakeFiles/4.0.3/CompilerIdCXX/CMakeCXXCompilerId.cpp +920 -0
  16. data/vendor/simpleble/build_simplecble/CMakeFiles/4.0.3/CompilerIdCXX/apple-sdk.cpp +1 -0
  17. data/vendor/simpleble/build_simplecble/CMakeFiles/4.1.0/CompilerIdCXX/CMakeCXXCompilerId.cpp +949 -0
  18. data/vendor/simpleble/build_simplecble/CMakeFiles/4.1.0/CompilerIdCXX/apple-sdk.cpp +1 -0
  19. data/vendor/simpleble/build_simplecble/export/simplecble/export.h +43 -0
  20. data/vendor/simpleble/build_simplecble/simpleble/export/simpleble/export.h +43 -0
  21. data/vendor/simpleble/dependencies/external/kvn/kvn_bytearray.h +222 -0
  22. data/vendor/simpleble/dependencies/external/kvn/kvn_safe_callback.hpp +66 -0
  23. data/vendor/simpleble/dependencies/external/kvn/logfwd.hpp +35 -0
  24. data/vendor/simpleble/dependencies/internal/fmt/args.h +220 -0
  25. data/vendor/simpleble/dependencies/internal/fmt/base.h +2962 -0
  26. data/vendor/simpleble/dependencies/internal/fmt/chrono.h +2338 -0
  27. data/vendor/simpleble/dependencies/internal/fmt/color.h +610 -0
  28. data/vendor/simpleble/dependencies/internal/fmt/compile.h +539 -0
  29. data/vendor/simpleble/dependencies/internal/fmt/core.h +5 -0
  30. data/vendor/simpleble/dependencies/internal/fmt/format-inl.h +1949 -0
  31. data/vendor/simpleble/dependencies/internal/fmt/format.h +4244 -0
  32. data/vendor/simpleble/dependencies/internal/fmt/os.h +427 -0
  33. data/vendor/simpleble/dependencies/internal/fmt/ostream.h +166 -0
  34. data/vendor/simpleble/dependencies/internal/fmt/printf.h +633 -0
  35. data/vendor/simpleble/dependencies/internal/fmt/ranges.h +850 -0
  36. data/vendor/simpleble/dependencies/internal/fmt/std.h +726 -0
  37. data/vendor/simpleble/dependencies/internal/fmt/xchar.h +373 -0
  38. data/vendor/simpleble/dependencies/internal/simplejni/Common.hpp +579 -0
  39. data/vendor/simpleble/dependencies/internal/simplejni/References.hpp +151 -0
  40. data/vendor/simpleble/dependencies/internal/simplejni/Registry.hpp +183 -0
  41. data/vendor/simpleble/dependencies/internal/simplejni/VM.hpp +88 -0
  42. data/vendor/simpleble/examples/simpleble/src/connect.cpp +67 -0
  43. data/vendor/simpleble/examples/simpleble/src/connect_safe.cpp +91 -0
  44. data/vendor/simpleble/examples/simpleble/src/list_adapters.cpp +22 -0
  45. data/vendor/simpleble/examples/simpleble/src/list_adapters_safe.cpp +33 -0
  46. data/vendor/simpleble/examples/simpleble/src/list_paired.cpp +27 -0
  47. data/vendor/simpleble/examples/simpleble/src/multiconnect.cpp +60 -0
  48. data/vendor/simpleble/examples/simpleble/src/notify.cpp +85 -0
  49. data/vendor/simpleble/examples/simpleble/src/notify_multi.cpp +101 -0
  50. data/vendor/simpleble/examples/simpleble/src/power_cycle.cpp +43 -0
  51. data/vendor/simpleble/examples/simpleble/src/read.cpp +82 -0
  52. data/vendor/simpleble/examples/simpleble/src/scan.cpp +62 -0
  53. data/vendor/simpleble/examples/simpleble/src/utils.cpp +59 -0
  54. data/vendor/simpleble/examples/simpleble/src/utils.hpp +27 -0
  55. data/vendor/simpleble/examples/simpleble/src/write.cpp +81 -0
  56. data/vendor/simpleble/examples/simplebluez/ble_nus/ble_nus.cpp +138 -0
  57. data/vendor/simpleble/examples/simplebluez/connect/connect.cpp +119 -0
  58. data/vendor/simpleble/examples/simplebluez/list_adapters/list_adapters.cpp +44 -0
  59. data/vendor/simpleble/examples/simplebluez/list_paired/list_paired.cpp +48 -0
  60. data/vendor/simpleble/examples/simplebluez/notify/notify.cpp +145 -0
  61. data/vendor/simpleble/examples/simplebluez/pair/pair.cpp +181 -0
  62. data/vendor/simpleble/examples/simplebluez/read/read.cpp +141 -0
  63. data/vendor/simpleble/examples/simplebluez/scan/scan.cpp +85 -0
  64. data/vendor/simpleble/examples/simplecble/c/connect.c +163 -0
  65. data/vendor/simpleble/examples/simplecble/c/notify.c +217 -0
  66. data/vendor/simpleble/examples/simplecble/c/scan.c +164 -0
  67. data/vendor/simpleble/examples/simpledbus/notification.cpp +24 -0
  68. data/vendor/simpleble/hitl/src/test_sanity.cpp +48 -0
  69. data/vendor/simpleble/install_simplecble/include/simpleble/Adapter.h +102 -0
  70. data/vendor/simpleble/install_simplecble/include/simpleble/AdapterSafe.h +58 -0
  71. data/vendor/simpleble/install_simplecble/include/simpleble/Advanced.h +50 -0
  72. data/vendor/simpleble/install_simplecble/include/simpleble/Characteristic.h +39 -0
  73. data/vendor/simpleble/install_simplecble/include/simpleble/Config.h +55 -0
  74. data/vendor/simpleble/install_simplecble/include/simpleble/Descriptor.h +30 -0
  75. data/vendor/simpleble/install_simplecble/include/simpleble/Exceptions.h +72 -0
  76. data/vendor/simpleble/install_simplecble/include/simpleble/Logging.h +73 -0
  77. data/vendor/simpleble/install_simplecble/include/simpleble/Peripheral.h +82 -0
  78. data/vendor/simpleble/install_simplecble/include/simpleble/PeripheralSafe.h +64 -0
  79. data/vendor/simpleble/install_simplecble/include/simpleble/Service.h +34 -0
  80. data/vendor/simpleble/install_simplecble/include/simpleble/SimpleBLE.h +8 -0
  81. data/vendor/simpleble/install_simplecble/include/simpleble/Types.h +49 -0
  82. data/vendor/simpleble/install_simplecble/include/simpleble/Utils.h +13 -0
  83. data/vendor/simpleble/install_simplecble/include/simpleble/export.h +43 -0
  84. data/vendor/simpleble/install_simplecble/include/simpleble/kvn/kvn_bytearray.h +222 -0
  85. data/vendor/simpleble/install_simplecble/include/simplecble/adapter.h +188 -0
  86. data/vendor/simpleble/install_simplecble/include/simplecble/logging.h +37 -0
  87. data/vendor/simpleble/install_simplecble/include/simplecble/peripheral.h +304 -0
  88. data/vendor/simpleble/install_simplecble/include/simplecble/simpleble.h +21 -0
  89. data/vendor/simpleble/install_simplecble/include/simplecble/types.h +73 -0
  90. data/vendor/simpleble/install_simplecble/include/simplecble/utils.h +27 -0
  91. data/vendor/simpleble/simpleble/include/simpleble/Adapter.h +102 -0
  92. data/vendor/simpleble/simpleble/include/simpleble/AdapterSafe.h +58 -0
  93. data/vendor/simpleble/simpleble/include/simpleble/Characteristic.h +39 -0
  94. data/vendor/simpleble/simpleble/include/simpleble/Config.h +55 -0
  95. data/vendor/simpleble/simpleble/include/simpleble/Descriptor.h +30 -0
  96. data/vendor/simpleble/simpleble/include/simpleble/Exceptions.h +72 -0
  97. data/vendor/simpleble/simpleble/include/simpleble/Logging.h +73 -0
  98. data/vendor/simpleble/simpleble/include/simpleble/Peripheral.h +82 -0
  99. data/vendor/simpleble/simpleble/include/simpleble/PeripheralSafe.h +64 -0
  100. data/vendor/simpleble/simpleble/include/simpleble/Service.h +34 -0
  101. data/vendor/simpleble/simpleble/include/simpleble/SimpleBLE.h +8 -0
  102. data/vendor/simpleble/simpleble/include/simpleble/Types.h +49 -0
  103. data/vendor/simpleble/simpleble/include/simpleble/Utils.h +13 -0
  104. data/vendor/simpleble/simpleble/include/simpleble_c/adapter.h +188 -0
  105. data/vendor/simpleble/simpleble/include/simpleble_c/logging.h +37 -0
  106. data/vendor/simpleble/simpleble/include/simpleble_c/peripheral.h +304 -0
  107. data/vendor/simpleble/simpleble/include/simpleble_c/simpleble.h +21 -0
  108. data/vendor/simpleble/simpleble/include/simpleble_c/types.h +73 -0
  109. data/vendor/simpleble/simpleble/include/simpleble_c/utils.h +27 -0
  110. data/vendor/simpleble/simpleble/src/CommonUtils.h +63 -0
  111. data/vendor/simpleble/simpleble/src/Exceptions.cpp +31 -0
  112. data/vendor/simpleble/simpleble/src/Logging.cpp +136 -0
  113. data/vendor/simpleble/simpleble/src/LoggingInternal.h +85 -0
  114. data/vendor/simpleble/simpleble/src/Utils.cpp +24 -0
  115. data/vendor/simpleble/simpleble/src/backends/android/AdapterAndroid.cpp +101 -0
  116. data/vendor/simpleble/simpleble/src/backends/android/AdapterAndroid.h +70 -0
  117. data/vendor/simpleble/simpleble/src/backends/android/BackendAndroid.cpp +40 -0
  118. data/vendor/simpleble/simpleble/src/backends/android/BackendAndroid.h +20 -0
  119. data/vendor/simpleble/simpleble/src/backends/android/PeripheralAndroid.cpp +365 -0
  120. data/vendor/simpleble/simpleble/src/backends/android/PeripheralAndroid.h +90 -0
  121. data/vendor/simpleble/simpleble/src/backends/android/bridge/BluetoothGattCallback.cpp +432 -0
  122. data/vendor/simpleble/simpleble/src/backends/android/bridge/BluetoothGattCallback.h +102 -0
  123. data/vendor/simpleble/simpleble/src/backends/android/bridge/ScanCallback.cpp +142 -0
  124. data/vendor/simpleble/simpleble/src/backends/android/bridge/ScanCallback.h +55 -0
  125. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.cpp +107 -0
  126. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothAdapter.h +55 -0
  127. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.cpp +68 -0
  128. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothDevice.h +54 -0
  129. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.cpp +115 -0
  130. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGatt.h +75 -0
  131. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.cpp +142 -0
  132. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattCharacteristic.h +66 -0
  133. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.cpp +67 -0
  134. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattDescriptor.h +46 -0
  135. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.cpp +106 -0
  136. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/BluetoothGattService.h +47 -0
  137. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.cpp +47 -0
  138. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/BluetoothScanner.h +37 -0
  139. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.cpp +69 -0
  140. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanRecord.h +41 -0
  141. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.cpp +63 -0
  142. data/vendor/simpleble/simpleble/src/backends/android/types/android/bluetooth/le/ScanResult.h +42 -0
  143. data/vendor/simpleble/simpleble/src/backends/android/types/android/os/ParcelUUID.cpp +32 -0
  144. data/vendor/simpleble/simpleble/src/backends/android/types/android/os/ParcelUUID.h +30 -0
  145. data/vendor/simpleble/simpleble/src/backends/android/types/android/util/SparseArray.cpp +54 -0
  146. data/vendor/simpleble/simpleble/src/backends/android/types/android/util/SparseArray.h +37 -0
  147. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Iterator.cpp +36 -0
  148. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Iterator.h +28 -0
  149. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/List.cpp +29 -0
  150. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/List.h +27 -0
  151. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Set.cpp +33 -0
  152. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/Set.h +28 -0
  153. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/UUID.cpp +26 -0
  154. data/vendor/simpleble/simpleble/src/backends/android/types/java/util/UUID.h +29 -0
  155. data/vendor/simpleble/simpleble/src/backends/common/AdapterBase.cpp +53 -0
  156. data/vendor/simpleble/simpleble/src/backends/common/AdapterBase.h +81 -0
  157. data/vendor/simpleble/simpleble/src/backends/common/AdapterBaseTypes.h +22 -0
  158. data/vendor/simpleble/simpleble/src/backends/common/BackendBase.h +20 -0
  159. data/vendor/simpleble/simpleble/src/backends/common/BackendUtils.h +33 -0
  160. data/vendor/simpleble/simpleble/src/backends/common/CharacteristicBase.cpp +28 -0
  161. data/vendor/simpleble/simpleble/src/backends/common/CharacteristicBase.h +38 -0
  162. data/vendor/simpleble/simpleble/src/backends/common/DescriptorBase.cpp +7 -0
  163. data/vendor/simpleble/simpleble/src/backends/common/DescriptorBase.h +19 -0
  164. data/vendor/simpleble/simpleble/src/backends/common/PeripheralBase.h +82 -0
  165. data/vendor/simpleble/simpleble/src/backends/common/ServiceBase.cpp +18 -0
  166. data/vendor/simpleble/simpleble/src/backends/common/ServiceBase.h +28 -0
  167. data/vendor/simpleble/simpleble/src/backends/linux/AdapterLinux.cpp +102 -0
  168. data/vendor/simpleble/simpleble/src/backends/linux/AdapterLinux.h +55 -0
  169. data/vendor/simpleble/simpleble/src/backends/linux/BackendBluez.cpp +87 -0
  170. data/vendor/simpleble/simpleble/src/backends/linux/PeripheralLinux.cpp +376 -0
  171. data/vendor/simpleble/simpleble/src/backends/linux/PeripheralLinux.h +90 -0
  172. data/vendor/simpleble/simpleble/src/backends/macos/AdapterBaseMacOS.h +29 -0
  173. data/vendor/simpleble/simpleble/src/backends/macos/AdapterMac.h +78 -0
  174. data/vendor/simpleble/simpleble/src/backends/macos/PeripheralBaseMacOS.h +49 -0
  175. data/vendor/simpleble/simpleble/src/backends/macos/PeripheralMac.h +81 -0
  176. data/vendor/simpleble/simpleble/src/backends/macos/Utils.h +9 -0
  177. data/vendor/simpleble/simpleble/src/backends/plain/AdapterPlain.cpp +65 -0
  178. data/vendor/simpleble/simpleble/src/backends/plain/AdapterPlain.h +49 -0
  179. data/vendor/simpleble/simpleble/src/backends/plain/BackendPlain.cpp +30 -0
  180. data/vendor/simpleble/simpleble/src/backends/plain/PeripheralPlain.cpp +159 -0
  181. data/vendor/simpleble/simpleble/src/backends/plain/PeripheralPlain.h +72 -0
  182. data/vendor/simpleble/simpleble/src/backends/windows/AdapterWindows.cpp +330 -0
  183. data/vendor/simpleble/simpleble/src/backends/windows/AdapterWindows.h +89 -0
  184. data/vendor/simpleble/simpleble/src/backends/windows/BackendWinRT.cpp +67 -0
  185. data/vendor/simpleble/simpleble/src/backends/windows/BackendWinRT.h +18 -0
  186. data/vendor/simpleble/simpleble/src/backends/windows/MtaManager.cpp +49 -0
  187. data/vendor/simpleble/simpleble/src/backends/windows/MtaManager.h +90 -0
  188. data/vendor/simpleble/simpleble/src/backends/windows/PeripheralWindows.cpp +487 -0
  189. data/vendor/simpleble/simpleble/src/backends/windows/PeripheralWindows.h +129 -0
  190. data/vendor/simpleble/simpleble/src/backends/windows/Utils.cpp +146 -0
  191. data/vendor/simpleble/simpleble/src/backends/windows/Utils.h +47 -0
  192. data/vendor/simpleble/simpleble/src/builders/BuildVec.h +32 -0
  193. data/vendor/simpleble/simpleble/src/builders/BuilderBase.h +87 -0
  194. data/vendor/simpleble/simpleble/src/external/TaskRunner.hpp +99 -0
  195. data/vendor/simpleble/simpleble/src/external/ThreadRunner.h +52 -0
  196. data/vendor/simpleble/simpleble/src/external/kvn_safe_callback.hpp +66 -0
  197. data/vendor/simpleble/simpleble/src/external/kvn_safe_map.hpp +94 -0
  198. data/vendor/simpleble/simpleble/src/external/kvn_threadrunner.hpp +70 -0
  199. data/vendor/simpleble/simpleble/src/external/logfwd.hpp +35 -0
  200. data/vendor/simpleble/simpleble/src/frontends/base/Adapter.cpp +111 -0
  201. data/vendor/simpleble/simpleble/src/frontends/base/Backend.cpp +83 -0
  202. data/vendor/simpleble/simpleble/src/frontends/base/Backend.h +76 -0
  203. data/vendor/simpleble/simpleble/src/frontends/base/Characteristic.cpp +56 -0
  204. data/vendor/simpleble/simpleble/src/frontends/base/Descriptor.cpp +21 -0
  205. data/vendor/simpleble/simpleble/src/frontends/base/Peripheral.cpp +113 -0
  206. data/vendor/simpleble/simpleble/src/frontends/base/Service.cpp +26 -0
  207. data/vendor/simpleble/simpleble/src/frontends/safe/AdapterSafe.cpp +158 -0
  208. data/vendor/simpleble/simpleble/src/frontends/safe/PeripheralSafe.cpp +219 -0
  209. data/vendor/simpleble/simpleble/src_c/adapter.cpp +204 -0
  210. data/vendor/simpleble/simpleble/src_c/logging.cpp +19 -0
  211. data/vendor/simpleble/simpleble/src_c/peripheral.cpp +444 -0
  212. data/vendor/simpleble/simpleble/src_c/simpleble.cpp +5 -0
  213. data/vendor/simpleble/simpleble/src_c/utils.cpp +15 -0
  214. data/vendor/simpleble/simpleble/test/src/main.cpp +8 -0
  215. data/vendor/simpleble/simpleble/test/src/test_bytearray.cpp +246 -0
  216. data/vendor/simpleble/simpleble/test/src/test_utils.cpp +24 -0
  217. data/vendor/simpleble/simplebluez/include/simplebluez/Adapter.h +46 -0
  218. data/vendor/simpleble/simplebluez/include/simplebluez/Agent.h +52 -0
  219. data/vendor/simpleble/simplebluez/include/simplebluez/Bluez.h +37 -0
  220. data/vendor/simpleble/simplebluez/include/simplebluez/BluezOrg.h +22 -0
  221. data/vendor/simpleble/simplebluez/include/simplebluez/BluezOrgBluez.h +26 -0
  222. data/vendor/simpleble/simplebluez/include/simplebluez/BluezRoot.h +32 -0
  223. data/vendor/simpleble/simplebluez/include/simplebluez/Characteristic.h +46 -0
  224. data/vendor/simpleble/simplebluez/include/simplebluez/Descriptor.h +33 -0
  225. data/vendor/simpleble/simplebluez/include/simplebluez/Device.h +64 -0
  226. data/vendor/simpleble/simplebluez/include/simplebluez/Exceptions.h +43 -0
  227. data/vendor/simpleble/simplebluez/include/simplebluez/Service.h +27 -0
  228. data/vendor/simpleble/simplebluez/include/simplebluez/Types.h +9 -0
  229. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Adapter1.h +49 -0
  230. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Agent1.h +100 -0
  231. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/AgentManager1.h +24 -0
  232. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Battery1.h +32 -0
  233. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/Device1.h +62 -0
  234. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattCharacteristic1.h +48 -0
  235. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattDescriptor1.h +41 -0
  236. data/vendor/simpleble/simplebluez/include/simplebluez/interfaces/GattService1.h +28 -0
  237. data/vendor/simpleble/simplebluez/src/Adapter.cpp +78 -0
  238. data/vendor/simpleble/simplebluez/src/Agent.cpp +72 -0
  239. data/vendor/simpleble/simplebluez/src/Bluez.cpp +45 -0
  240. data/vendor/simpleble/simplebluez/src/BluezOrg.cpp +20 -0
  241. data/vendor/simpleble/simplebluez/src/BluezOrgBluez.cpp +23 -0
  242. data/vendor/simpleble/simplebluez/src/BluezRoot.cpp +44 -0
  243. data/vendor/simpleble/simplebluez/src/Characteristic.cpp +64 -0
  244. data/vendor/simpleble/simplebluez/src/Descriptor.cpp +27 -0
  245. data/vendor/simpleble/simplebluez/src/Device.cpp +104 -0
  246. data/vendor/simpleble/simplebluez/src/Exceptions.cpp +29 -0
  247. data/vendor/simpleble/simplebluez/src/Logging.cpp +52 -0
  248. data/vendor/simpleble/simplebluez/src/Logging.h +57 -0
  249. data/vendor/simpleble/simplebluez/src/Service.cpp +33 -0
  250. data/vendor/simpleble/simplebluez/src/interfaces/Adapter1.cpp +123 -0
  251. data/vendor/simpleble/simplebluez/src/interfaces/Agent1.cpp +143 -0
  252. data/vendor/simpleble/simplebluez/src/interfaces/AgentManager1.cpp +34 -0
  253. data/vendor/simpleble/simplebluez/src/interfaces/Battery1.cpp +30 -0
  254. data/vendor/simpleble/simplebluez/src/interfaces/Device1.cpp +170 -0
  255. data/vendor/simpleble/simplebluez/src/interfaces/GattCharacteristic1.cpp +118 -0
  256. data/vendor/simpleble/simplebluez/src/interfaces/GattDescriptor1.cpp +78 -0
  257. data/vendor/simpleble/simplebluez/src/interfaces/GattService1.cpp +28 -0
  258. data/vendor/simpleble/simplebluez/test/src/helpers/PythonRunner.cpp +53 -0
  259. data/vendor/simpleble/simplebluez/test/src/helpers/PythonRunner.h +24 -0
  260. data/vendor/simpleble/simplebluez/test/src/main.cpp +16 -0
  261. data/vendor/simpleble/simplecble/include/simplecble/adapter.h +188 -0
  262. data/vendor/simpleble/simplecble/include/simplecble/logging.h +37 -0
  263. data/vendor/simpleble/simplecble/include/simplecble/peripheral.h +304 -0
  264. data/vendor/simpleble/simplecble/include/simplecble/simpleble.h +21 -0
  265. data/vendor/simpleble/simplecble/include/simplecble/types.h +73 -0
  266. data/vendor/simpleble/simplecble/include/simplecble/utils.h +27 -0
  267. data/vendor/simpleble/simplecble/src/adapter.cpp +204 -0
  268. data/vendor/simpleble/simplecble/src/logging.cpp +19 -0
  269. data/vendor/simpleble/simplecble/src/peripheral.cpp +444 -0
  270. data/vendor/simpleble/simplecble/src/simpleble.cpp +5 -0
  271. data/vendor/simpleble/simplecble/src/utils.cpp +15 -0
  272. data/vendor/simpleble/simpledbus/include/simpledbus/advanced/Interface.h +67 -0
  273. data/vendor/simpleble/simpledbus/include/simpledbus/advanced/InterfaceRegistry.h +64 -0
  274. data/vendor/simpleble/simpledbus/include/simpledbus/advanced/Proxy.h +117 -0
  275. data/vendor/simpleble/simpledbus/include/simpledbus/base/Connection.h +50 -0
  276. data/vendor/simpleble/simpledbus/include/simpledbus/base/Exceptions.h +56 -0
  277. data/vendor/simpleble/simpledbus/include/simpledbus/base/Holder.h +147 -0
  278. data/vendor/simpleble/simpledbus/include/simpledbus/base/Logging.h +57 -0
  279. data/vendor/simpleble/simpledbus/include/simpledbus/base/Message.h +89 -0
  280. data/vendor/simpleble/simpledbus/include/simpledbus/base/Path.h +24 -0
  281. data/vendor/simpleble/simpledbus/include/simpledbus/interfaces/ObjectManager.h +26 -0
  282. data/vendor/simpleble/simpledbus/src/advanced/Interface.cpp +155 -0
  283. data/vendor/simpleble/simpledbus/src/advanced/Proxy.cpp +375 -0
  284. data/vendor/simpleble/simpledbus/src/base/Connection.cpp +222 -0
  285. data/vendor/simpleble/simpledbus/src/base/Exceptions.cpp +39 -0
  286. data/vendor/simpleble/simpledbus/src/base/Holder.cpp +739 -0
  287. data/vendor/simpleble/simpledbus/src/base/Logging.cpp +52 -0
  288. data/vendor/simpleble/simpledbus/src/base/Message.cpp +622 -0
  289. data/vendor/simpleble/simpledbus/src/base/Path.cpp +129 -0
  290. data/vendor/simpleble/simpledbus/src/interfaces/ObjectManager.cpp +58 -0
  291. data/vendor/simpleble/simpledbus/test/src/helpers/PythonRunner.cpp +53 -0
  292. data/vendor/simpleble/simpledbus/test/src/helpers/PythonRunner.h +24 -0
  293. data/vendor/simpleble/simpledbus/test/src/main.cpp +16 -0
  294. data/vendor/simpleble/simpledbus/test/src/test_holder.cpp +184 -0
  295. data/vendor/simpleble/simpledbus/test/src/test_message.cpp +397 -0
  296. data/vendor/simpleble/simpledbus/test/src/test_path.cpp +76 -0
  297. data/vendor/simpleble/simpledbus/test/src/test_proxy_children.cpp +109 -0
  298. data/vendor/simpleble/simpledbus/test/src/test_proxy_interfaces.cpp +102 -0
  299. data/vendor/simpleble/simpledbus/test/src/test_proxy_lifetime.cpp +18 -0
  300. data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/ThreadRunner.h +89 -0
  301. data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/android_utils.cpp +55 -0
  302. data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/android_utils.h +18 -0
  303. data/vendor/simpleble/simpledroidble/simpledroidble/src/main/cpp/simpleble_android.cpp +813 -0
  304. data/vendor/simpleble/simplejavable/cpp/src/core/AdapterWrapper.cpp +37 -0
  305. data/vendor/simpleble/simplejavable/cpp/src/core/AdapterWrapper.h +23 -0
  306. data/vendor/simpleble/simplejavable/cpp/src/core/Cache.cpp +58 -0
  307. data/vendor/simpleble/simplejavable/cpp/src/core/Cache.h +34 -0
  308. data/vendor/simpleble/simplejavable/cpp/src/core/PeripheralWrapper.cpp +17 -0
  309. data/vendor/simpleble/simplejavable/cpp/src/core/PeripheralWrapper.h +19 -0
  310. data/vendor/simpleble/simplejavable/cpp/src/java/lang/ArrayList.cpp +257 -0
  311. data/vendor/simpleble/simplejavable/cpp/src/java/lang/ArrayList.h +78 -0
  312. data/vendor/simpleble/simplejavable/cpp/src/java/lang/HashMap.cpp +96 -0
  313. data/vendor/simpleble/simplejavable/cpp/src/java/lang/HashMap.h +54 -0
  314. data/vendor/simpleble/simplejavable/cpp/src/java/lang/Integer.cpp +93 -0
  315. data/vendor/simpleble/simplejavable/cpp/src/java/lang/Integer.h +49 -0
  316. data/vendor/simpleble/simplejavable/cpp/src/java/lang/Iterator.cpp +85 -0
  317. data/vendor/simpleble/simplejavable/cpp/src/java/lang/Iterator.h +48 -0
  318. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/AdapterCallback.cpp +91 -0
  319. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/AdapterCallback.h +90 -0
  320. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Characteristic.cpp +35 -0
  321. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Characteristic.h +60 -0
  322. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/DataCallback.cpp +33 -0
  323. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/DataCallback.h +45 -0
  324. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Descriptor.cpp +30 -0
  325. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Descriptor.h +49 -0
  326. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/PeripheralCallback.cpp +41 -0
  327. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/PeripheralCallback.h +51 -0
  328. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Service.cpp +33 -0
  329. data/vendor/simpleble/simplejavable/cpp/src/org/simplejavable/Service.h +54 -0
  330. data/vendor/simpleble/simplejavable/cpp/src/simplejavable.cpp +361 -0
  331. data/vendor/simpleble/simplepyble/src/main.cpp +55 -0
  332. data/vendor/simpleble/simplepyble/src/wrap_adapter.cpp +106 -0
  333. data/vendor/simpleble/simplepyble/src/wrap_characteristic.cpp +56 -0
  334. data/vendor/simpleble/simplepyble/src/wrap_config.cpp +136 -0
  335. data/vendor/simpleble/simplepyble/src/wrap_descriptor.cpp +21 -0
  336. data/vendor/simpleble/simplepyble/src/wrap_peripheral.cpp +217 -0
  337. data/vendor/simpleble/simplepyble/src/wrap_service.cpp +32 -0
  338. data/vendor/simpleble/simplepyble/src/wrap_types.cpp +21 -0
  339. data/vendor/simpleble/simplersble/src/bindings/Bindings.cpp +338 -0
  340. data/vendor/simpleble/simplersble/src/bindings/Bindings.hpp +178 -0
  341. metadata +430 -0
@@ -0,0 +1,427 @@
1
+ // Formatting library for C++ - optional OS-specific functionality
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_OS_H_
9
+ #define FMT_OS_H_
10
+
11
+ #include "format.h"
12
+
13
+ #ifndef FMT_MODULE
14
+ # include <cerrno>
15
+ # include <cstddef>
16
+ # include <cstdio>
17
+ # include <system_error> // std::system_error
18
+
19
+ # if FMT_HAS_INCLUDE(<xlocale.h>)
20
+ # include <xlocale.h> // LC_NUMERIC_MASK on macOS
21
+ # endif
22
+ #endif // FMT_MODULE
23
+
24
+ #ifndef FMT_USE_FCNTL
25
+ // UWP doesn't provide _pipe.
26
+ # if FMT_HAS_INCLUDE("winapifamily.h")
27
+ # include <winapifamily.h>
28
+ # endif
29
+ # if (FMT_HAS_INCLUDE(<fcntl.h>) || defined(__APPLE__) || \
30
+ defined(__linux__)) && \
31
+ (!defined(WINAPI_FAMILY) || \
32
+ (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
33
+ # include <fcntl.h> // for O_RDONLY
34
+ # define FMT_USE_FCNTL 1
35
+ # else
36
+ # define FMT_USE_FCNTL 0
37
+ # endif
38
+ #endif
39
+
40
+ #ifndef FMT_POSIX
41
+ # if defined(_WIN32) && !defined(__MINGW32__)
42
+ // Fix warnings about deprecated symbols.
43
+ # define FMT_POSIX(call) _##call
44
+ # else
45
+ # define FMT_POSIX(call) call
46
+ # endif
47
+ #endif
48
+
49
+ // Calls to system functions are wrapped in FMT_SYSTEM for testability.
50
+ #ifdef FMT_SYSTEM
51
+ # define FMT_HAS_SYSTEM
52
+ # define FMT_POSIX_CALL(call) FMT_SYSTEM(call)
53
+ #else
54
+ # define FMT_SYSTEM(call) ::call
55
+ # ifdef _WIN32
56
+ // Fix warnings about deprecated symbols.
57
+ # define FMT_POSIX_CALL(call) ::_##call
58
+ # else
59
+ # define FMT_POSIX_CALL(call) ::call
60
+ # endif
61
+ #endif
62
+
63
+ // Retries the expression while it evaluates to error_result and errno
64
+ // equals to EINTR.
65
+ #ifndef _WIN32
66
+ # define FMT_RETRY_VAL(result, expression, error_result) \
67
+ do { \
68
+ (result) = (expression); \
69
+ } while ((result) == (error_result) && errno == EINTR)
70
+ #else
71
+ # define FMT_RETRY_VAL(result, expression, error_result) result = (expression)
72
+ #endif
73
+
74
+ #define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)
75
+
76
+ FMT_BEGIN_NAMESPACE
77
+ FMT_BEGIN_EXPORT
78
+
79
+ /**
80
+ * A reference to a null-terminated string. It can be constructed from a C
81
+ * string or `std::string`.
82
+ *
83
+ * You can use one of the following type aliases for common character types:
84
+ *
85
+ * +---------------+-----------------------------+
86
+ * | Type | Definition |
87
+ * +===============+=============================+
88
+ * | cstring_view | basic_cstring_view<char> |
89
+ * +---------------+-----------------------------+
90
+ * | wcstring_view | basic_cstring_view<wchar_t> |
91
+ * +---------------+-----------------------------+
92
+ *
93
+ * This class is most useful as a parameter type for functions that wrap C APIs.
94
+ */
95
+ template <typename Char> class basic_cstring_view {
96
+ private:
97
+ const Char* data_;
98
+
99
+ public:
100
+ /// Constructs a string reference object from a C string.
101
+ basic_cstring_view(const Char* s) : data_(s) {}
102
+
103
+ /// Constructs a string reference from an `std::string` object.
104
+ basic_cstring_view(const std::basic_string<Char>& s) : data_(s.c_str()) {}
105
+
106
+ /// Returns the pointer to a C string.
107
+ auto c_str() const -> const Char* { return data_; }
108
+ };
109
+
110
+ using cstring_view = basic_cstring_view<char>;
111
+ using wcstring_view = basic_cstring_view<wchar_t>;
112
+
113
+ #ifdef _WIN32
114
+ FMT_API const std::error_category& system_category() noexcept;
115
+
116
+ namespace detail {
117
+ FMT_API void format_windows_error(buffer<char>& out, int error_code,
118
+ const char* message) noexcept;
119
+ }
120
+
121
+ FMT_API std::system_error vwindows_error(int error_code, string_view fmt,
122
+ format_args args);
123
+
124
+ /**
125
+ * Constructs a `std::system_error` object with the description of the form
126
+ *
127
+ * <message>: <system-message>
128
+ *
129
+ * where `<message>` is the formatted message and `<system-message>` is the
130
+ * system message corresponding to the error code.
131
+ * `error_code` is a Windows error code as given by `GetLastError`.
132
+ * If `error_code` is not a valid error code such as -1, the system message
133
+ * will look like "error -1".
134
+ *
135
+ * **Example**:
136
+ *
137
+ * // This throws a system_error with the description
138
+ * // cannot open file 'madeup': The system cannot find the file
139
+ * specified.
140
+ * // or similar (system message may vary).
141
+ * const char *filename = "madeup";
142
+ * LPOFSTRUCT of = LPOFSTRUCT();
143
+ * HFILE file = OpenFile(filename, &of, OF_READ);
144
+ * if (file == HFILE_ERROR) {
145
+ * throw fmt::windows_error(GetLastError(),
146
+ * "cannot open file '{}'", filename);
147
+ * }
148
+ */
149
+ template <typename... T>
150
+ auto windows_error(int error_code, string_view message, const T&... args)
151
+ -> std::system_error {
152
+ return vwindows_error(error_code, message, vargs<T...>{{args...}});
153
+ }
154
+
155
+ // Reports a Windows error without throwing an exception.
156
+ // Can be used to report errors from destructors.
157
+ FMT_API void report_windows_error(int error_code, const char* message) noexcept;
158
+ #else
159
+ inline auto system_category() noexcept -> const std::error_category& {
160
+ return std::system_category();
161
+ }
162
+ #endif // _WIN32
163
+
164
+ // std::system is not available on some platforms such as iOS (#2248).
165
+ #ifdef __OSX__
166
+ template <typename S, typename... Args, typename Char = char_t<S>>
167
+ void say(const S& fmt, Args&&... args) {
168
+ std::system(format("say \"{}\"", format(fmt, args...)).c_str());
169
+ }
170
+ #endif
171
+
172
+ // A buffered file.
173
+ class buffered_file {
174
+ private:
175
+ FILE* file_;
176
+
177
+ friend class file;
178
+
179
+ inline explicit buffered_file(FILE* f) : file_(f) {}
180
+
181
+ public:
182
+ buffered_file(const buffered_file&) = delete;
183
+ void operator=(const buffered_file&) = delete;
184
+
185
+ // Constructs a buffered_file object which doesn't represent any file.
186
+ inline buffered_file() noexcept : file_(nullptr) {}
187
+
188
+ // Destroys the object closing the file it represents if any.
189
+ FMT_API ~buffered_file() noexcept;
190
+
191
+ public:
192
+ inline buffered_file(buffered_file&& other) noexcept : file_(other.file_) {
193
+ other.file_ = nullptr;
194
+ }
195
+
196
+ inline auto operator=(buffered_file&& other) -> buffered_file& {
197
+ close();
198
+ file_ = other.file_;
199
+ other.file_ = nullptr;
200
+ return *this;
201
+ }
202
+
203
+ // Opens a file.
204
+ FMT_API buffered_file(cstring_view filename, cstring_view mode);
205
+
206
+ // Closes the file.
207
+ FMT_API void close();
208
+
209
+ // Returns the pointer to a FILE object representing this file.
210
+ inline auto get() const noexcept -> FILE* { return file_; }
211
+
212
+ FMT_API auto descriptor() const -> int;
213
+
214
+ template <typename... T>
215
+ inline void print(string_view fmt, const T&... args) {
216
+ fmt::vargs<T...> vargs = {{args...}};
217
+ detail::is_locking<T...>() ? fmt::vprint_buffered(file_, fmt, vargs)
218
+ : fmt::vprint(file_, fmt, vargs);
219
+ }
220
+ };
221
+
222
+ #if FMT_USE_FCNTL
223
+
224
+ // A file. Closed file is represented by a file object with descriptor -1.
225
+ // Methods that are not declared with noexcept may throw
226
+ // fmt::system_error in case of failure. Note that some errors such as
227
+ // closing the file multiple times will cause a crash on Windows rather
228
+ // than an exception. You can get standard behavior by overriding the
229
+ // invalid parameter handler with _set_invalid_parameter_handler.
230
+ class FMT_API file {
231
+ private:
232
+ int fd_; // File descriptor.
233
+
234
+ // Constructs a file object with a given descriptor.
235
+ explicit file(int fd) : fd_(fd) {}
236
+
237
+ friend struct pipe;
238
+
239
+ public:
240
+ // Possible values for the oflag argument to the constructor.
241
+ enum {
242
+ RDONLY = FMT_POSIX(O_RDONLY), // Open for reading only.
243
+ WRONLY = FMT_POSIX(O_WRONLY), // Open for writing only.
244
+ RDWR = FMT_POSIX(O_RDWR), // Open for reading and writing.
245
+ CREATE = FMT_POSIX(O_CREAT), // Create if the file doesn't exist.
246
+ APPEND = FMT_POSIX(O_APPEND), // Open in append mode.
247
+ TRUNC = FMT_POSIX(O_TRUNC) // Truncate the content of the file.
248
+ };
249
+
250
+ // Constructs a file object which doesn't represent any file.
251
+ inline file() noexcept : fd_(-1) {}
252
+
253
+ // Opens a file and constructs a file object representing this file.
254
+ file(cstring_view path, int oflag);
255
+
256
+ public:
257
+ file(const file&) = delete;
258
+ void operator=(const file&) = delete;
259
+
260
+ inline file(file&& other) noexcept : fd_(other.fd_) { other.fd_ = -1; }
261
+
262
+ // Move assignment is not noexcept because close may throw.
263
+ inline auto operator=(file&& other) -> file& {
264
+ close();
265
+ fd_ = other.fd_;
266
+ other.fd_ = -1;
267
+ return *this;
268
+ }
269
+
270
+ // Destroys the object closing the file it represents if any.
271
+ ~file() noexcept;
272
+
273
+ // Returns the file descriptor.
274
+ inline auto descriptor() const noexcept -> int { return fd_; }
275
+
276
+ // Closes the file.
277
+ void close();
278
+
279
+ // Returns the file size. The size has signed type for consistency with
280
+ // stat::st_size.
281
+ auto size() const -> long long;
282
+
283
+ // Attempts to read count bytes from the file into the specified buffer.
284
+ auto read(void* buffer, size_t count) -> size_t;
285
+
286
+ // Attempts to write count bytes from the specified buffer to the file.
287
+ auto write(const void* buffer, size_t count) -> size_t;
288
+
289
+ // Duplicates a file descriptor with the dup function and returns
290
+ // the duplicate as a file object.
291
+ static auto dup(int fd) -> file;
292
+
293
+ // Makes fd be the copy of this file descriptor, closing fd first if
294
+ // necessary.
295
+ void dup2(int fd);
296
+
297
+ // Makes fd be the copy of this file descriptor, closing fd first if
298
+ // necessary.
299
+ void dup2(int fd, std::error_code& ec) noexcept;
300
+
301
+ // Creates a buffered_file object associated with this file and detaches
302
+ // this file object from the file.
303
+ auto fdopen(const char* mode) -> buffered_file;
304
+
305
+ # if defined(_WIN32) && !defined(__MINGW32__)
306
+ // Opens a file and constructs a file object representing this file by
307
+ // wcstring_view filename. Windows only.
308
+ static file open_windows_file(wcstring_view path, int oflag);
309
+ # endif
310
+ };
311
+
312
+ struct FMT_API pipe {
313
+ file read_end;
314
+ file write_end;
315
+
316
+ // Creates a pipe setting up read_end and write_end file objects for reading
317
+ // and writing respectively.
318
+ pipe();
319
+ };
320
+
321
+ // Returns the memory page size.
322
+ auto getpagesize() -> long;
323
+
324
+ namespace detail {
325
+
326
+ struct buffer_size {
327
+ constexpr buffer_size() = default;
328
+ size_t value = 0;
329
+ FMT_CONSTEXPR auto operator=(size_t val) const -> buffer_size {
330
+ auto bs = buffer_size();
331
+ bs.value = val;
332
+ return bs;
333
+ }
334
+ };
335
+
336
+ struct ostream_params {
337
+ int oflag = file::WRONLY | file::CREATE | file::TRUNC;
338
+ size_t buffer_size = BUFSIZ > 32768 ? BUFSIZ : 32768;
339
+
340
+ constexpr ostream_params() {}
341
+
342
+ template <typename... T>
343
+ ostream_params(T... params, int new_oflag) : ostream_params(params...) {
344
+ oflag = new_oflag;
345
+ }
346
+
347
+ template <typename... T>
348
+ ostream_params(T... params, detail::buffer_size bs)
349
+ : ostream_params(params...) {
350
+ this->buffer_size = bs.value;
351
+ }
352
+
353
+ // Intel has a bug that results in failure to deduce a constructor
354
+ // for empty parameter packs.
355
+ # if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 2000
356
+ ostream_params(int new_oflag) : oflag(new_oflag) {}
357
+ ostream_params(detail::buffer_size bs) : buffer_size(bs.value) {}
358
+ # endif
359
+ };
360
+
361
+ } // namespace detail
362
+
363
+ FMT_INLINE_VARIABLE constexpr auto buffer_size = detail::buffer_size();
364
+
365
+ /// A fast buffered output stream for writing from a single thread. Writing from
366
+ /// multiple threads without external synchronization may result in a data race.
367
+ class FMT_API ostream : private detail::buffer<char> {
368
+ private:
369
+ file file_;
370
+
371
+ ostream(cstring_view path, const detail::ostream_params& params);
372
+
373
+ static void grow(buffer<char>& buf, size_t);
374
+
375
+ public:
376
+ ostream(ostream&& other) noexcept;
377
+ ~ostream();
378
+
379
+ operator writer() {
380
+ detail::buffer<char>& buf = *this;
381
+ return buf;
382
+ }
383
+
384
+ inline void flush() {
385
+ if (size() == 0) return;
386
+ file_.write(data(), size() * sizeof(data()[0]));
387
+ clear();
388
+ }
389
+
390
+ template <typename... T>
391
+ friend auto output_file(cstring_view path, T... params) -> ostream;
392
+
393
+ inline void close() {
394
+ flush();
395
+ file_.close();
396
+ }
397
+
398
+ /// Formats `args` according to specifications in `fmt` and writes the
399
+ /// output to the file.
400
+ template <typename... T> void print(format_string<T...> fmt, T&&... args) {
401
+ vformat_to(appender(*this), fmt.str, vargs<T...>{{args...}});
402
+ }
403
+ };
404
+
405
+ /**
406
+ * Opens a file for writing. Supported parameters passed in `params`:
407
+ *
408
+ * - `<integer>`: Flags passed to [open](
409
+ * https://pubs.opengroup.org/onlinepubs/007904875/functions/open.html)
410
+ * (`file::WRONLY | file::CREATE | file::TRUNC` by default)
411
+ * - `buffer_size=<integer>`: Output buffer size
412
+ *
413
+ * **Example**:
414
+ *
415
+ * auto out = fmt::output_file("guide.txt");
416
+ * out.print("Don't {}", "Panic");
417
+ */
418
+ template <typename... T>
419
+ inline auto output_file(cstring_view path, T... params) -> ostream {
420
+ return {path, detail::ostream_params(params...)};
421
+ }
422
+ #endif // FMT_USE_FCNTL
423
+
424
+ FMT_END_EXPORT
425
+ FMT_END_NAMESPACE
426
+
427
+ #endif // FMT_OS_H_
@@ -0,0 +1,166 @@
1
+ // Formatting library for C++ - std::ostream support
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_OSTREAM_H_
9
+ #define FMT_OSTREAM_H_
10
+
11
+ #ifndef FMT_MODULE
12
+ # include <fstream> // std::filebuf
13
+ #endif
14
+
15
+ #ifdef _WIN32
16
+ # ifdef __GLIBCXX__
17
+ # include <ext/stdio_filebuf.h>
18
+ # include <ext/stdio_sync_filebuf.h>
19
+ # endif
20
+ # include <io.h>
21
+ #endif
22
+
23
+ #include "chrono.h" // formatbuf
24
+
25
+ #ifdef _MSVC_STL_UPDATE
26
+ # define FMT_MSVC_STL_UPDATE _MSVC_STL_UPDATE
27
+ #elif defined(_MSC_VER) && _MSC_VER < 1912 // VS 15.5
28
+ # define FMT_MSVC_STL_UPDATE _MSVC_LANG
29
+ #else
30
+ # define FMT_MSVC_STL_UPDATE 0
31
+ #endif
32
+
33
+ FMT_BEGIN_NAMESPACE
34
+ namespace detail {
35
+
36
+ // Generate a unique explicit instantion in every translation unit using a tag
37
+ // type in an anonymous namespace.
38
+ namespace {
39
+ struct file_access_tag {};
40
+ } // namespace
41
+ template <typename Tag, typename BufType, FILE* BufType::*FileMemberPtr>
42
+ class file_access {
43
+ friend auto get_file(BufType& obj) -> FILE* { return obj.*FileMemberPtr; }
44
+ };
45
+
46
+ #if FMT_MSVC_STL_UPDATE
47
+ template class file_access<file_access_tag, std::filebuf,
48
+ &std::filebuf::_Myfile>;
49
+ auto get_file(std::filebuf&) -> FILE*;
50
+ #endif
51
+
52
+ // Write the content of buf to os.
53
+ // It is a separate function rather than a part of vprint to simplify testing.
54
+ template <typename Char>
55
+ void write_buffer(std::basic_ostream<Char>& os, buffer<Char>& buf) {
56
+ const Char* buf_data = buf.data();
57
+ using unsigned_streamsize = make_unsigned_t<std::streamsize>;
58
+ unsigned_streamsize size = buf.size();
59
+ unsigned_streamsize max_size = to_unsigned(max_value<std::streamsize>());
60
+ do {
61
+ unsigned_streamsize n = size <= max_size ? size : max_size;
62
+ os.write(buf_data, static_cast<std::streamsize>(n));
63
+ buf_data += n;
64
+ size -= n;
65
+ } while (size != 0);
66
+ }
67
+
68
+ template <typename T> struct streamed_view {
69
+ const T& value;
70
+ };
71
+ } // namespace detail
72
+
73
+ // Formats an object of type T that has an overloaded ostream operator<<.
74
+ template <typename Char>
75
+ struct basic_ostream_formatter : formatter<basic_string_view<Char>, Char> {
76
+ void set_debug_format() = delete;
77
+
78
+ template <typename T, typename Context>
79
+ auto format(const T& value, Context& ctx) const -> decltype(ctx.out()) {
80
+ auto buffer = basic_memory_buffer<Char>();
81
+ auto&& formatbuf = detail::formatbuf<std::basic_streambuf<Char>>(buffer);
82
+ auto&& output = std::basic_ostream<Char>(&formatbuf);
83
+ output.imbue(std::locale::classic()); // The default is always unlocalized.
84
+ output << value;
85
+ output.exceptions(std::ios_base::failbit | std::ios_base::badbit);
86
+ return formatter<basic_string_view<Char>, Char>::format(
87
+ {buffer.data(), buffer.size()}, ctx);
88
+ }
89
+ };
90
+
91
+ using ostream_formatter = basic_ostream_formatter<char>;
92
+
93
+ template <typename T, typename Char>
94
+ struct formatter<detail::streamed_view<T>, Char>
95
+ : basic_ostream_formatter<Char> {
96
+ template <typename Context>
97
+ auto format(detail::streamed_view<T> view, Context& ctx) const
98
+ -> decltype(ctx.out()) {
99
+ return basic_ostream_formatter<Char>::format(view.value, ctx);
100
+ }
101
+ };
102
+
103
+ /**
104
+ * Returns a view that formats `value` via an ostream `operator<<`.
105
+ *
106
+ * **Example**:
107
+ *
108
+ * fmt::print("Current thread id: {}\n",
109
+ * fmt::streamed(std::this_thread::get_id()));
110
+ */
111
+ template <typename T>
112
+ constexpr auto streamed(const T& value) -> detail::streamed_view<T> {
113
+ return {value};
114
+ }
115
+
116
+ inline void vprint(std::ostream& os, string_view fmt, format_args args) {
117
+ auto buffer = memory_buffer();
118
+ detail::vformat_to(buffer, fmt, args);
119
+ FILE* f = nullptr;
120
+ #if FMT_MSVC_STL_UPDATE && FMT_USE_RTTI
121
+ if (auto* buf = dynamic_cast<std::filebuf*>(os.rdbuf()))
122
+ f = detail::get_file(*buf);
123
+ #elif defined(_WIN32) && defined(__GLIBCXX__) && FMT_USE_RTTI
124
+ auto* rdbuf = os.rdbuf();
125
+ if (auto* sfbuf = dynamic_cast<__gnu_cxx::stdio_sync_filebuf<char>*>(rdbuf))
126
+ f = sfbuf->file();
127
+ else if (auto* fbuf = dynamic_cast<__gnu_cxx::stdio_filebuf<char>*>(rdbuf))
128
+ f = fbuf->file();
129
+ #endif
130
+ #ifdef _WIN32
131
+ if (f) {
132
+ int fd = _fileno(f);
133
+ if (_isatty(fd)) {
134
+ os.flush();
135
+ if (detail::write_console(fd, {buffer.data(), buffer.size()})) return;
136
+ }
137
+ }
138
+ #endif
139
+ detail::ignore_unused(f);
140
+ detail::write_buffer(os, buffer);
141
+ }
142
+
143
+ /**
144
+ * Prints formatted data to the stream `os`.
145
+ *
146
+ * **Example**:
147
+ *
148
+ * fmt::print(cerr, "Don't {}!", "panic");
149
+ */
150
+ FMT_EXPORT template <typename... T>
151
+ void print(std::ostream& os, format_string<T...> fmt, T&&... args) {
152
+ fmt::vargs<T...> vargs = {{args...}};
153
+ if (detail::const_check(detail::use_utf8)) return vprint(os, fmt.str, vargs);
154
+ auto buffer = memory_buffer();
155
+ detail::vformat_to(buffer, fmt.str, vargs);
156
+ detail::write_buffer(os, buffer);
157
+ }
158
+
159
+ FMT_EXPORT template <typename... T>
160
+ void println(std::ostream& os, format_string<T...> fmt, T&&... args) {
161
+ fmt::print(os, "{}\n", fmt::format(fmt, std::forward<T>(args)...));
162
+ }
163
+
164
+ FMT_END_NAMESPACE
165
+
166
+ #endif // FMT_OSTREAM_H_