ctpbee-opt-api 0.1.0__cp312-cp312-win_amd64.whl

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 (414) hide show
  1. ctpbee_api/__init__.py +17 -0
  2. ctpbee_api/ctp/__init__.py +3 -0
  3. ctpbee_api/ctp/ctp_constant.py +1253 -0
  4. ctpbee_api/ctp/generator/concat.py +93 -0
  5. ctpbee_api/ctp/generator/const.py +325 -0
  6. ctpbee_api/ctp/generator/ctp_constant.py +1274 -0
  7. ctpbee_api/ctp/generator/ctp_md_header_define.h +13 -0
  8. ctpbee_api/ctp/generator/ctp_md_header_function.h +6 -0
  9. ctpbee_api/ctp/generator/ctp_md_header_on.h +26 -0
  10. ctpbee_api/ctp/generator/ctp_md_header_process.h +26 -0
  11. ctpbee_api/ctp/generator/ctp_md_source_function.cpp +42 -0
  12. ctpbee_api/ctp/generator/ctp_md_source_module.cpp +18 -0
  13. ctpbee_api/ctp/generator/ctp_md_source_on.cpp +156 -0
  14. ctpbee_api/ctp/generator/ctp_md_source_process.cpp +282 -0
  15. ctpbee_api/ctp/generator/ctp_md_source_switch.cpp +78 -0
  16. ctpbee_api/ctp/generator/ctp_md_source_task.cpp +211 -0
  17. ctpbee_api/ctp/generator/ctp_struct.py +5640 -0
  18. ctpbee_api/ctp/generator/ctp_td_header_define.h +130 -0
  19. ctpbee_api/ctp/generator/ctp_td_header_function.h +174 -0
  20. ctpbee_api/ctp/generator/ctp_td_header_on.h +260 -0
  21. ctpbee_api/ctp/generator/ctp_td_header_process.h +260 -0
  22. ctpbee_api/ctp/generator/ctp_td_source_function.cpp +1456 -0
  23. ctpbee_api/ctp/generator/ctp_td_source_module.cpp +222 -0
  24. ctpbee_api/ctp/generator/ctp_td_source_on.cpp +1572 -0
  25. ctpbee_api/ctp/generator/ctp_td_source_process.cpp +5472 -0
  26. ctpbee_api/ctp/generator/ctp_td_source_switch.cpp +780 -0
  27. ctpbee_api/ctp/generator/ctp_td_source_task.cpp +2444 -0
  28. ctpbee_api/ctp/generator/ctp_typedef.py +800 -0
  29. ctpbee_api/ctp/generator/generate_api_functions.py +345 -0
  30. ctpbee_api/ctp/generator/generate_data_type.py +76 -0
  31. ctpbee_api/ctp/generator/generate_struct.py +84 -0
  32. ctpbee_api/ctp/include/mac/ctp/ThostFtdcMdApi.h +168 -0
  33. ctpbee_api/ctp/include/mac/ctp/ThostFtdcTraderApi.h +770 -0
  34. ctpbee_api/ctp/include/mac/ctp/ThostFtdcUserApiDataType.h +6878 -0
  35. ctpbee_api/ctp/include/mac/ctp/ThostFtdcUserApiStruct.h +10915 -0
  36. ctpbee_api/ctp/include/mac/pybind11/attr.h +690 -0
  37. ctpbee_api/ctp/include/mac/pybind11/buffer_info.h +208 -0
  38. ctpbee_api/ctp/include/mac/pybind11/cast.h +1704 -0
  39. ctpbee_api/ctp/include/mac/pybind11/chrono.h +225 -0
  40. ctpbee_api/ctp/include/mac/pybind11/common.h +2 -0
  41. ctpbee_api/ctp/include/mac/pybind11/complex.h +74 -0
  42. ctpbee_api/ctp/include/mac/pybind11/detail/class.h +743 -0
  43. ctpbee_api/ctp/include/mac/pybind11/detail/common.h +1255 -0
  44. ctpbee_api/ctp/include/mac/pybind11/detail/descr.h +171 -0
  45. ctpbee_api/ctp/include/mac/pybind11/detail/init.h +434 -0
  46. ctpbee_api/ctp/include/mac/pybind11/detail/internals.h +656 -0
  47. ctpbee_api/ctp/include/mac/pybind11/detail/type_caster_base.h +1177 -0
  48. ctpbee_api/ctp/include/mac/pybind11/detail/typeid.h +65 -0
  49. ctpbee_api/ctp/include/mac/pybind11/eigen/common.h +9 -0
  50. ctpbee_api/ctp/include/mac/pybind11/eigen/matrix.h +714 -0
  51. ctpbee_api/ctp/include/mac/pybind11/eigen/tensor.h +516 -0
  52. ctpbee_api/ctp/include/mac/pybind11/eigen.h +12 -0
  53. ctpbee_api/ctp/include/mac/pybind11/embed.h +316 -0
  54. ctpbee_api/ctp/include/mac/pybind11/eval.h +156 -0
  55. ctpbee_api/ctp/include/mac/pybind11/functional.h +137 -0
  56. ctpbee_api/ctp/include/mac/pybind11/gil.h +239 -0
  57. ctpbee_api/ctp/include/mac/pybind11/iostream.h +265 -0
  58. ctpbee_api/ctp/include/mac/pybind11/numpy.h +1998 -0
  59. ctpbee_api/ctp/include/mac/pybind11/operators.h +202 -0
  60. ctpbee_api/ctp/include/mac/pybind11/options.h +92 -0
  61. ctpbee_api/ctp/include/mac/pybind11/pybind11.h +2890 -0
  62. ctpbee_api/ctp/include/mac/pybind11/pytypes.h +2557 -0
  63. ctpbee_api/ctp/include/mac/pybind11/stl/filesystem.h +116 -0
  64. ctpbee_api/ctp/include/mac/pybind11/stl.h +447 -0
  65. ctpbee_api/ctp/include/mac/pybind11/stl_bind.h +851 -0
  66. ctpbee_api/ctp/include/mac/pybind11/type_caster_pyobject_ptr.h +61 -0
  67. ctpbee_api/ctp/include/new/ctp/ThostFtdcMdApi.h +168 -0
  68. ctpbee_api/ctp/include/new/ctp/ThostFtdcTraderApi.h +770 -0
  69. ctpbee_api/ctp/include/new/ctp/ThostFtdcUserApiDataType.h +6878 -0
  70. ctpbee_api/ctp/include/new/ctp/ThostFtdcUserApiStruct.h +10915 -0
  71. ctpbee_api/ctp/include/new/pybind11/attr.h +690 -0
  72. ctpbee_api/ctp/include/new/pybind11/buffer_info.h +208 -0
  73. ctpbee_api/ctp/include/new/pybind11/cast.h +1704 -0
  74. ctpbee_api/ctp/include/new/pybind11/chrono.h +225 -0
  75. ctpbee_api/ctp/include/new/pybind11/common.h +2 -0
  76. ctpbee_api/ctp/include/new/pybind11/complex.h +74 -0
  77. ctpbee_api/ctp/include/new/pybind11/detail/class.h +743 -0
  78. ctpbee_api/ctp/include/new/pybind11/detail/common.h +1255 -0
  79. ctpbee_api/ctp/include/new/pybind11/detail/descr.h +171 -0
  80. ctpbee_api/ctp/include/new/pybind11/detail/init.h +434 -0
  81. ctpbee_api/ctp/include/new/pybind11/detail/internals.h +656 -0
  82. ctpbee_api/ctp/include/new/pybind11/detail/type_caster_base.h +1177 -0
  83. ctpbee_api/ctp/include/new/pybind11/detail/typeid.h +65 -0
  84. ctpbee_api/ctp/include/new/pybind11/eigen/common.h +9 -0
  85. ctpbee_api/ctp/include/new/pybind11/eigen/matrix.h +714 -0
  86. ctpbee_api/ctp/include/new/pybind11/eigen/tensor.h +516 -0
  87. ctpbee_api/ctp/include/new/pybind11/eigen.h +12 -0
  88. ctpbee_api/ctp/include/new/pybind11/embed.h +316 -0
  89. ctpbee_api/ctp/include/new/pybind11/eval.h +156 -0
  90. ctpbee_api/ctp/include/new/pybind11/functional.h +137 -0
  91. ctpbee_api/ctp/include/new/pybind11/gil.h +239 -0
  92. ctpbee_api/ctp/include/new/pybind11/iostream.h +265 -0
  93. ctpbee_api/ctp/include/new/pybind11/numpy.h +1998 -0
  94. ctpbee_api/ctp/include/new/pybind11/operators.h +202 -0
  95. ctpbee_api/ctp/include/new/pybind11/options.h +92 -0
  96. ctpbee_api/ctp/include/new/pybind11/pybind11.h +2890 -0
  97. ctpbee_api/ctp/include/new/pybind11/pytypes.h +2557 -0
  98. ctpbee_api/ctp/include/new/pybind11/stl/filesystem.h +116 -0
  99. ctpbee_api/ctp/include/new/pybind11/stl.h +447 -0
  100. ctpbee_api/ctp/include/new/pybind11/stl_bind.h +851 -0
  101. ctpbee_api/ctp/include/new/pybind11/type_caster_pyobject_ptr.h +61 -0
  102. ctpbee_api/ctp/include/previous/ctp/ThostFtdcMdApi.h +168 -0
  103. ctpbee_api/ctp/include/previous/ctp/ThostFtdcTraderApi.h +770 -0
  104. ctpbee_api/ctp/include/previous/ctp/ThostFtdcUserApiDataType.h +6878 -0
  105. ctpbee_api/ctp/include/previous/ctp/ThostFtdcUserApiStruct.h +10915 -0
  106. ctpbee_api/ctp/include/previous/pybind11/attr.h +489 -0
  107. ctpbee_api/ctp/include/previous/pybind11/buffer_info.h +108 -0
  108. ctpbee_api/ctp/include/previous/pybind11/cast.h +2067 -0
  109. ctpbee_api/ctp/include/previous/pybind11/chrono.h +162 -0
  110. ctpbee_api/ctp/include/previous/pybind11/common.h +2 -0
  111. ctpbee_api/ctp/include/previous/pybind11/complex.h +61 -0
  112. ctpbee_api/ctp/include/previous/pybind11/detail/class.h +626 -0
  113. ctpbee_api/ctp/include/previous/pybind11/detail/common.h +803 -0
  114. ctpbee_api/ctp/include/previous/pybind11/detail/descr.h +185 -0
  115. ctpbee_api/ctp/include/previous/pybind11/detail/init.h +335 -0
  116. ctpbee_api/ctp/include/previous/pybind11/detail/internals.h +285 -0
  117. ctpbee_api/ctp/include/previous/pybind11/detail/typeid.h +53 -0
  118. ctpbee_api/ctp/include/previous/pybind11/eigen.h +604 -0
  119. ctpbee_api/ctp/include/previous/pybind11/embed.h +194 -0
  120. ctpbee_api/ctp/include/previous/pybind11/eval.h +117 -0
  121. ctpbee_api/ctp/include/previous/pybind11/functional.h +85 -0
  122. ctpbee_api/ctp/include/previous/pybind11/iostream.h +200 -0
  123. ctpbee_api/ctp/include/previous/pybind11/numpy.h +1601 -0
  124. ctpbee_api/ctp/include/previous/pybind11/operators.h +168 -0
  125. ctpbee_api/ctp/include/previous/pybind11/options.h +65 -0
  126. ctpbee_api/ctp/include/previous/pybind11/pybind11.h +1965 -0
  127. ctpbee_api/ctp/include/previous/pybind11/pytypes.h +1332 -0
  128. ctpbee_api/ctp/include/previous/pybind11/stl.h +376 -0
  129. ctpbee_api/ctp/include/previous/pybind11/stl_bind.h +599 -0
  130. ctpbee_api/ctp/libs/libcomunicationkey.a +0 -0
  131. ctpbee_api/ctp/libs/libcrypto.a +0 -0
  132. ctpbee_api/ctp/libs/libssl.a +0 -0
  133. ctpbee_api/ctp/libs/thostmduserapi_se.lib +0 -0
  134. ctpbee_api/ctp/libs/thosttraderapi_se.lib +0 -0
  135. ctpbee_api/ctp/libthostmduserapi_se.so +0 -0
  136. ctpbee_api/ctp/libthosttraderapi_se.so +0 -0
  137. ctpbee_api/ctp/thostmduserapi_se.dll +0 -0
  138. ctpbee_api/ctp/thosttraderapi_se.dll +0 -0
  139. ctpbee_api/ctp/vnctp/vnctp.h +189 -0
  140. ctpbee_api/ctp/vnctp/vnctp.sln +41 -0
  141. ctpbee_api/ctp/vnctp/vnctpmd/dllmain.cpp +19 -0
  142. ctpbee_api/ctp/vnctp/vnctpmd/stdafx.cpp +1 -0
  143. ctpbee_api/ctp/vnctp/vnctpmd/stdafx.h +17 -0
  144. ctpbee_api/ctp/vnctp/vnctpmd/targetver.h +8 -0
  145. ctpbee_api/ctp/vnctp/vnctpmd/vnctpmd.cpp +953 -0
  146. ctpbee_api/ctp/vnctp/vnctpmd/vnctpmd.h +209 -0
  147. ctpbee_api/ctp/vnctp/vnctpmd/vnctpmd.vcxproj +200 -0
  148. ctpbee_api/ctp/vnctp/vnctpmd/vnctpmd.vcxproj.filters +54 -0
  149. ctpbee_api/ctp/vnctp/vnctpmd/vnctpmd.vcxproj.user +4 -0
  150. ctpbee_api/ctp/vnctp/vnctptd/dllmain.cpp +19 -0
  151. ctpbee_api/ctp/vnctp/vnctptd/stdafx.cpp +1 -0
  152. ctpbee_api/ctp/vnctp/vnctptd/stdafx.h +16 -0
  153. ctpbee_api/ctp/vnctp/vnctptd/targetver.h +8 -0
  154. ctpbee_api/ctp/vnctp/vnctptd/vnctptd.cpp +12148 -0
  155. ctpbee_api/ctp/vnctp/vnctptd/vnctptd.h +1329 -0
  156. ctpbee_api/ctp/vnctp/vnctptd/vnctptd.vcxproj +198 -0
  157. ctpbee_api/ctp/vnctp/vnctptd/vnctptd.vcxproj.filters +54 -0
  158. ctpbee_api/ctp/vnctp/vnctptd/vnctptd.vcxproj.user +4 -0
  159. ctpbee_api/ctp/vnctpmd.cp312-win_amd64.pyd +0 -0
  160. ctpbee_api/ctp/vnctptd.cp312-win_amd64.pyd +0 -0
  161. ctpbee_api/ctp_mini/__init__.py +3 -0
  162. ctpbee_api/ctp_mini/generator/generate_api_functions.py +343 -0
  163. ctpbee_api/ctp_mini/generator/generate_data_type.py +76 -0
  164. ctpbee_api/ctp_mini/generator/generate_struct.py +85 -0
  165. ctpbee_api/ctp_mini/generator/mini_constant.py +1186 -0
  166. ctpbee_api/ctp_mini/generator/mini_md_header_define.h +13 -0
  167. ctpbee_api/ctp_mini/generator/mini_md_header_function.h +4 -0
  168. ctpbee_api/ctp_mini/generator/mini_md_header_on.h +26 -0
  169. ctpbee_api/ctp_mini/generator/mini_md_header_process.h +26 -0
  170. ctpbee_api/ctp_mini/generator/mini_md_source_function.cpp +29 -0
  171. ctpbee_api/ctp_mini/generator/mini_md_source_module.cpp +17 -0
  172. ctpbee_api/ctp_mini/generator/mini_md_source_on.cpp +156 -0
  173. ctpbee_api/ctp_mini/generator/mini_md_source_process.cpp +264 -0
  174. ctpbee_api/ctp_mini/generator/mini_md_source_switch.cpp +78 -0
  175. ctpbee_api/ctp_mini/generator/mini_md_source_task.cpp +203 -0
  176. ctpbee_api/ctp_mini/generator/mini_struct.py +4599 -0
  177. ctpbee_api/ctp_mini/generator/mini_td_header_define.h +63 -0
  178. ctpbee_api/ctp_mini/generator/mini_td_header_function.h +84 -0
  179. ctpbee_api/ctp_mini/generator/mini_td_header_on.h +126 -0
  180. ctpbee_api/ctp_mini/generator/mini_td_header_process.h +126 -0
  181. ctpbee_api/ctp_mini/generator/mini_td_source_function.cpp +663 -0
  182. ctpbee_api/ctp_mini/generator/mini_td_source_module.cpp +107 -0
  183. ctpbee_api/ctp_mini/generator/mini_td_source_on.cpp +756 -0
  184. ctpbee_api/ctp_mini/generator/mini_td_source_process.cpp +2492 -0
  185. ctpbee_api/ctp_mini/generator/mini_td_source_switch.cpp +378 -0
  186. ctpbee_api/ctp_mini/generator/mini_td_source_task.cpp +1193 -0
  187. ctpbee_api/ctp_mini/generator/mini_typedef.py +755 -0
  188. ctpbee_api/ctp_mini/generator/package/vnminimd.cpp +886 -0
  189. ctpbee_api/ctp_mini/generator/package/vnminimd.h +205 -0
  190. ctpbee_api/ctp_mini/include/new/mini/ThostFtdcMdApi.h +148 -0
  191. ctpbee_api/ctp_mini/include/new/mini/ThostFtdcTraderApi.h +419 -0
  192. ctpbee_api/ctp_mini/include/new/mini/ThostFtdcUserApiDataType.h +6458 -0
  193. ctpbee_api/ctp_mini/include/new/mini/ThostFtdcUserApiStruct.h +8890 -0
  194. ctpbee_api/ctp_mini/include/new/pybind11/attr.h +690 -0
  195. ctpbee_api/ctp_mini/include/new/pybind11/buffer_info.h +208 -0
  196. ctpbee_api/ctp_mini/include/new/pybind11/cast.h +1704 -0
  197. ctpbee_api/ctp_mini/include/new/pybind11/chrono.h +225 -0
  198. ctpbee_api/ctp_mini/include/new/pybind11/common.h +2 -0
  199. ctpbee_api/ctp_mini/include/new/pybind11/complex.h +74 -0
  200. ctpbee_api/ctp_mini/include/new/pybind11/detail/class.h +743 -0
  201. ctpbee_api/ctp_mini/include/new/pybind11/detail/common.h +1255 -0
  202. ctpbee_api/ctp_mini/include/new/pybind11/detail/descr.h +171 -0
  203. ctpbee_api/ctp_mini/include/new/pybind11/detail/init.h +434 -0
  204. ctpbee_api/ctp_mini/include/new/pybind11/detail/internals.h +656 -0
  205. ctpbee_api/ctp_mini/include/new/pybind11/detail/type_caster_base.h +1177 -0
  206. ctpbee_api/ctp_mini/include/new/pybind11/detail/typeid.h +65 -0
  207. ctpbee_api/ctp_mini/include/new/pybind11/eigen/common.h +9 -0
  208. ctpbee_api/ctp_mini/include/new/pybind11/eigen/matrix.h +714 -0
  209. ctpbee_api/ctp_mini/include/new/pybind11/eigen/tensor.h +516 -0
  210. ctpbee_api/ctp_mini/include/new/pybind11/eigen.h +12 -0
  211. ctpbee_api/ctp_mini/include/new/pybind11/embed.h +316 -0
  212. ctpbee_api/ctp_mini/include/new/pybind11/eval.h +156 -0
  213. ctpbee_api/ctp_mini/include/new/pybind11/functional.h +137 -0
  214. ctpbee_api/ctp_mini/include/new/pybind11/gil.h +239 -0
  215. ctpbee_api/ctp_mini/include/new/pybind11/iostream.h +265 -0
  216. ctpbee_api/ctp_mini/include/new/pybind11/numpy.h +1998 -0
  217. ctpbee_api/ctp_mini/include/new/pybind11/operators.h +202 -0
  218. ctpbee_api/ctp_mini/include/new/pybind11/options.h +92 -0
  219. ctpbee_api/ctp_mini/include/new/pybind11/pybind11.h +2890 -0
  220. ctpbee_api/ctp_mini/include/new/pybind11/pytypes.h +2557 -0
  221. ctpbee_api/ctp_mini/include/new/pybind11/stl/filesystem.h +116 -0
  222. ctpbee_api/ctp_mini/include/new/pybind11/stl.h +447 -0
  223. ctpbee_api/ctp_mini/include/new/pybind11/stl_bind.h +851 -0
  224. ctpbee_api/ctp_mini/include/new/pybind11/type_caster_pyobject_ptr.h +61 -0
  225. ctpbee_api/ctp_mini/include/previous/mini/ThostFtdcMdApi.h +148 -0
  226. ctpbee_api/ctp_mini/include/previous/mini/ThostFtdcTraderApi.h +419 -0
  227. ctpbee_api/ctp_mini/include/previous/mini/ThostFtdcUserApiDataType.h +6458 -0
  228. ctpbee_api/ctp_mini/include/previous/mini/ThostFtdcUserApiStruct.h +8890 -0
  229. ctpbee_api/ctp_mini/include/previous/pybind11/attr.h +489 -0
  230. ctpbee_api/ctp_mini/include/previous/pybind11/buffer_info.h +108 -0
  231. ctpbee_api/ctp_mini/include/previous/pybind11/cast.h +2067 -0
  232. ctpbee_api/ctp_mini/include/previous/pybind11/chrono.h +162 -0
  233. ctpbee_api/ctp_mini/include/previous/pybind11/common.h +2 -0
  234. ctpbee_api/ctp_mini/include/previous/pybind11/complex.h +61 -0
  235. ctpbee_api/ctp_mini/include/previous/pybind11/detail/class.h +626 -0
  236. ctpbee_api/ctp_mini/include/previous/pybind11/detail/common.h +803 -0
  237. ctpbee_api/ctp_mini/include/previous/pybind11/detail/descr.h +185 -0
  238. ctpbee_api/ctp_mini/include/previous/pybind11/detail/init.h +335 -0
  239. ctpbee_api/ctp_mini/include/previous/pybind11/detail/internals.h +285 -0
  240. ctpbee_api/ctp_mini/include/previous/pybind11/detail/typeid.h +53 -0
  241. ctpbee_api/ctp_mini/include/previous/pybind11/eigen.h +604 -0
  242. ctpbee_api/ctp_mini/include/previous/pybind11/embed.h +194 -0
  243. ctpbee_api/ctp_mini/include/previous/pybind11/eval.h +117 -0
  244. ctpbee_api/ctp_mini/include/previous/pybind11/functional.h +85 -0
  245. ctpbee_api/ctp_mini/include/previous/pybind11/iostream.h +200 -0
  246. ctpbee_api/ctp_mini/include/previous/pybind11/numpy.h +1601 -0
  247. ctpbee_api/ctp_mini/include/previous/pybind11/operators.h +168 -0
  248. ctpbee_api/ctp_mini/include/previous/pybind11/options.h +65 -0
  249. ctpbee_api/ctp_mini/include/previous/pybind11/pybind11.h +1965 -0
  250. ctpbee_api/ctp_mini/include/previous/pybind11/pytypes.h +1332 -0
  251. ctpbee_api/ctp_mini/include/previous/pybind11/stl.h +376 -0
  252. ctpbee_api/ctp_mini/include/previous/pybind11/stl_bind.h +599 -0
  253. ctpbee_api/ctp_mini/libs/thostmduserapi.lib +0 -0
  254. ctpbee_api/ctp_mini/libs/thosttraderapi.lib +0 -0
  255. ctpbee_api/ctp_mini/libthostmduserapi.so +0 -0
  256. ctpbee_api/ctp_mini/libthosttraderapi.so +0 -0
  257. ctpbee_api/ctp_mini/mini_constant.py +1186 -0
  258. ctpbee_api/ctp_mini/thostmduserapi.dll +0 -0
  259. ctpbee_api/ctp_mini/thosttraderapi.dll +0 -0
  260. ctpbee_api/ctp_mini/vnctp_mini/vnctp_mini.h +146 -0
  261. ctpbee_api/ctp_mini/vnctp_mini/vnctp_mini.sln +41 -0
  262. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/dllmain.cpp +0 -0
  263. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/stdafx.cpp +0 -0
  264. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/stdafx.h +0 -0
  265. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/targetver.h +0 -0
  266. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/vnctp_minimd.cpp +886 -0
  267. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/vnctp_minimd.h +203 -0
  268. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/vnctp_minimd.vcxproj +183 -0
  269. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/vnctp_minimd.vcxproj.filters +54 -0
  270. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/vnctp_minimd.vcxproj.user +4 -0
  271. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/dllmain.cpp +0 -0
  272. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/stdafx.cpp +0 -0
  273. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/stdafx.h +0 -0
  274. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/targetver.h +0 -0
  275. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/vnctp_minitd.cpp +5716 -0
  276. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/vnctp_minitd.h +680 -0
  277. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/vnctp_minitd.vcxproj +180 -0
  278. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/vnctp_minitd.vcxproj.filters +54 -0
  279. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/vnctp_minitd.vcxproj.user +4 -0
  280. ctpbee_api/ctp_mini/vnctp_minimd.cp312-win_amd64.pyd +0 -0
  281. ctpbee_api/ctp_mini/vnctp_minitd.cp312-win_amd64.pyd +0 -0
  282. ctpbee_api/ctp_mini/vnctp_minitd.lib +0 -0
  283. ctpbee_api/rohon/RohonBaseV64.dll +0 -0
  284. ctpbee_api/rohon/WinDataCollect.dll +0 -0
  285. ctpbee_api/rohon/__init__.py +3 -0
  286. ctpbee_api/rohon/generator/generate_api_functions.py +348 -0
  287. ctpbee_api/rohon/generator/generate_data_type.py +76 -0
  288. ctpbee_api/rohon/generator/generate_struct.py +84 -0
  289. ctpbee_api/rohon/generator/rohon_constant.py +1242 -0
  290. ctpbee_api/rohon/generator/rohon_md_header_define.h +13 -0
  291. ctpbee_api/rohon/generator/rohon_md_header_function.h +6 -0
  292. ctpbee_api/rohon/generator/rohon_md_header_on.h +26 -0
  293. ctpbee_api/rohon/generator/rohon_md_header_process.h +26 -0
  294. ctpbee_api/rohon/generator/rohon_md_source_function.cpp +40 -0
  295. ctpbee_api/rohon/generator/rohon_md_source_module.cpp +18 -0
  296. ctpbee_api/rohon/generator/rohon_md_source_on.cpp +156 -0
  297. ctpbee_api/rohon/generator/rohon_md_source_process.cpp +271 -0
  298. ctpbee_api/rohon/generator/rohon_md_source_switch.cpp +78 -0
  299. ctpbee_api/rohon/generator/rohon_md_source_task.cpp +211 -0
  300. ctpbee_api/rohon/generator/rohon_struct.py +4958 -0
  301. ctpbee_api/rohon/generator/rohon_td_header_define.h +125 -0
  302. ctpbee_api/rohon/generator/rohon_td_header_function.h +164 -0
  303. ctpbee_api/rohon/generator/rohon_td_header_on.h +250 -0
  304. ctpbee_api/rohon/generator/rohon_td_header_process.h +250 -0
  305. ctpbee_api/rohon/generator/rohon_td_source_function.cpp +1338 -0
  306. ctpbee_api/rohon/generator/rohon_td_source_module.cpp +209 -0
  307. ctpbee_api/rohon/generator/rohon_td_source_on.cpp +1500 -0
  308. ctpbee_api/rohon/generator/rohon_td_source_process.cpp +5125 -0
  309. ctpbee_api/rohon/generator/rohon_td_source_switch.cpp +750 -0
  310. ctpbee_api/rohon/generator/rohon_td_source_task.cpp +2339 -0
  311. ctpbee_api/rohon/generator/rohon_typedef.py +781 -0
  312. ctpbee_api/rohon/include/new/pybind11/attr.h +690 -0
  313. ctpbee_api/rohon/include/new/pybind11/buffer_info.h +208 -0
  314. ctpbee_api/rohon/include/new/pybind11/cast.h +1704 -0
  315. ctpbee_api/rohon/include/new/pybind11/chrono.h +225 -0
  316. ctpbee_api/rohon/include/new/pybind11/common.h +2 -0
  317. ctpbee_api/rohon/include/new/pybind11/complex.h +74 -0
  318. ctpbee_api/rohon/include/new/pybind11/detail/class.h +743 -0
  319. ctpbee_api/rohon/include/new/pybind11/detail/common.h +1255 -0
  320. ctpbee_api/rohon/include/new/pybind11/detail/descr.h +171 -0
  321. ctpbee_api/rohon/include/new/pybind11/detail/init.h +434 -0
  322. ctpbee_api/rohon/include/new/pybind11/detail/internals.h +656 -0
  323. ctpbee_api/rohon/include/new/pybind11/detail/type_caster_base.h +1177 -0
  324. ctpbee_api/rohon/include/new/pybind11/detail/typeid.h +65 -0
  325. ctpbee_api/rohon/include/new/pybind11/eigen/common.h +9 -0
  326. ctpbee_api/rohon/include/new/pybind11/eigen/matrix.h +714 -0
  327. ctpbee_api/rohon/include/new/pybind11/eigen/tensor.h +516 -0
  328. ctpbee_api/rohon/include/new/pybind11/eigen.h +12 -0
  329. ctpbee_api/rohon/include/new/pybind11/embed.h +316 -0
  330. ctpbee_api/rohon/include/new/pybind11/eval.h +156 -0
  331. ctpbee_api/rohon/include/new/pybind11/functional.h +137 -0
  332. ctpbee_api/rohon/include/new/pybind11/gil.h +239 -0
  333. ctpbee_api/rohon/include/new/pybind11/iostream.h +265 -0
  334. ctpbee_api/rohon/include/new/pybind11/numpy.h +1998 -0
  335. ctpbee_api/rohon/include/new/pybind11/operators.h +202 -0
  336. ctpbee_api/rohon/include/new/pybind11/options.h +92 -0
  337. ctpbee_api/rohon/include/new/pybind11/pybind11.h +2890 -0
  338. ctpbee_api/rohon/include/new/pybind11/pytypes.h +2557 -0
  339. ctpbee_api/rohon/include/new/pybind11/stl/filesystem.h +116 -0
  340. ctpbee_api/rohon/include/new/pybind11/stl.h +447 -0
  341. ctpbee_api/rohon/include/new/pybind11/stl_bind.h +851 -0
  342. ctpbee_api/rohon/include/new/pybind11/type_caster_pyobject_ptr.h +61 -0
  343. ctpbee_api/rohon/include/new/rohon/ThostFtdcMdApi.h +168 -0
  344. ctpbee_api/rohon/include/new/rohon/ThostFtdcTraderApi.h +739 -0
  345. ctpbee_api/rohon/include/new/rohon/ThostFtdcUserApiDataType.h +6708 -0
  346. ctpbee_api/rohon/include/new/rohon/ThostFtdcUserApiStruct.h +9580 -0
  347. ctpbee_api/rohon/include/previous/pybind11/attr.h +489 -0
  348. ctpbee_api/rohon/include/previous/pybind11/buffer_info.h +108 -0
  349. ctpbee_api/rohon/include/previous/pybind11/cast.h +2067 -0
  350. ctpbee_api/rohon/include/previous/pybind11/chrono.h +162 -0
  351. ctpbee_api/rohon/include/previous/pybind11/common.h +2 -0
  352. ctpbee_api/rohon/include/previous/pybind11/complex.h +61 -0
  353. ctpbee_api/rohon/include/previous/pybind11/detail/class.h +626 -0
  354. ctpbee_api/rohon/include/previous/pybind11/detail/common.h +803 -0
  355. ctpbee_api/rohon/include/previous/pybind11/detail/descr.h +185 -0
  356. ctpbee_api/rohon/include/previous/pybind11/detail/init.h +335 -0
  357. ctpbee_api/rohon/include/previous/pybind11/detail/internals.h +285 -0
  358. ctpbee_api/rohon/include/previous/pybind11/detail/typeid.h +53 -0
  359. ctpbee_api/rohon/include/previous/pybind11/eigen.h +604 -0
  360. ctpbee_api/rohon/include/previous/pybind11/embed.h +194 -0
  361. ctpbee_api/rohon/include/previous/pybind11/eval.h +117 -0
  362. ctpbee_api/rohon/include/previous/pybind11/functional.h +85 -0
  363. ctpbee_api/rohon/include/previous/pybind11/iostream.h +200 -0
  364. ctpbee_api/rohon/include/previous/pybind11/numpy.h +1601 -0
  365. ctpbee_api/rohon/include/previous/pybind11/operators.h +168 -0
  366. ctpbee_api/rohon/include/previous/pybind11/options.h +65 -0
  367. ctpbee_api/rohon/include/previous/pybind11/pybind11.h +1965 -0
  368. ctpbee_api/rohon/include/previous/pybind11/pytypes.h +1332 -0
  369. ctpbee_api/rohon/include/previous/pybind11/stl.h +376 -0
  370. ctpbee_api/rohon/include/previous/pybind11/stl_bind.h +599 -0
  371. ctpbee_api/rohon/include/previous/rohon/ThostFtdcMdApi.h +168 -0
  372. ctpbee_api/rohon/include/previous/rohon/ThostFtdcTraderApi.h +739 -0
  373. ctpbee_api/rohon/include/previous/rohon/ThostFtdcUserApiDataType.h +6708 -0
  374. ctpbee_api/rohon/include/previous/rohon/ThostFtdcUserApiStruct.h +9580 -0
  375. ctpbee_api/rohon/libLinuxDataCollect.so +0 -0
  376. ctpbee_api/rohon/librohonbase.so +0 -0
  377. ctpbee_api/rohon/librohonbase.so.1.1 +0 -0
  378. ctpbee_api/rohon/librohonbase.so.1.1.0.1 +0 -0
  379. ctpbee_api/rohon/libs/thostmduserapi_se.lib +0 -0
  380. ctpbee_api/rohon/libs/thosttraderapi_se.lib +0 -0
  381. ctpbee_api/rohon/libthostmduserapi_se.so +0 -0
  382. ctpbee_api/rohon/libthosttraderapi_se.so +0 -0
  383. ctpbee_api/rohon/rohon_constant.py +1242 -0
  384. ctpbee_api/rohon/thostmduserapi_se.dll +0 -0
  385. ctpbee_api/rohon/thosttraderapi_se.dll +0 -0
  386. ctpbee_api/rohon/vnrohon/.vs/vnrohon/v15/.suo +0 -0
  387. ctpbee_api/rohon/vnrohon/.vs/vnrohon/v15/Browse.VC.db +0 -0
  388. ctpbee_api/rohon/vnrohon/.vs/vnrohon/v15/Solution.VC.db +0 -0
  389. ctpbee_api/rohon/vnrohon/vnrohon.h +147 -0
  390. ctpbee_api/rohon/vnrohon/vnrohon.sln +41 -0
  391. ctpbee_api/rohon/vnrohon/vnrohonmd/dllmain.cpp +19 -0
  392. ctpbee_api/rohon/vnrohon/vnrohonmd/framework.h +5 -0
  393. ctpbee_api/rohon/vnrohon/vnrohonmd/pch.cpp +5 -0
  394. ctpbee_api/rohon/vnrohon/vnrohonmd/pch.h +13 -0
  395. ctpbee_api/rohon/vnrohon/vnrohonmd/vnrohonmd.cpp +931 -0
  396. ctpbee_api/rohon/vnrohon/vnrohonmd/vnrohonmd.h +207 -0
  397. ctpbee_api/rohon/vnrohon/vnrohonmd/vnrohonmd.vcxproj +188 -0
  398. ctpbee_api/rohon/vnrohon/vnrohonmd/vnrohonmd.vcxproj.filters +54 -0
  399. ctpbee_api/rohon/vnrohon/vnrohonmd/vnrohonmd.vcxproj.user +4 -0
  400. ctpbee_api/rohon/vnrohon/vnrohontd/dllmain.cpp +19 -0
  401. ctpbee_api/rohon/vnrohon/vnrohontd/framework.h +5 -0
  402. ctpbee_api/rohon/vnrohon/vnrohontd/pch.cpp +5 -0
  403. ctpbee_api/rohon/vnrohon/vnrohontd/pch.h +13 -0
  404. ctpbee_api/rohon/vnrohon/vnrohontd/vnrohontd.cpp +11395 -0
  405. ctpbee_api/rohon/vnrohon/vnrohontd/vnrohontd.h +1259 -0
  406. ctpbee_api/rohon/vnrohon/vnrohontd/vnrohontd.vcxproj +188 -0
  407. ctpbee_api/rohon/vnrohon/vnrohontd/vnrohontd.vcxproj.filters +54 -0
  408. ctpbee_api/rohon/vnrohon/vnrohontd/vnrohontd.vcxproj.user +4 -0
  409. ctpbee_api/rohon/vnrohonmd.cp312-win_amd64.pyd +0 -0
  410. ctpbee_api/rohon/vnrohontd.cp312-win_amd64.pyd +0 -0
  411. ctpbee_opt_api-0.1.0.dist-info/METADATA +46 -0
  412. ctpbee_opt_api-0.1.0.dist-info/RECORD +414 -0
  413. ctpbee_opt_api-0.1.0.dist-info/WHEEL +5 -0
  414. ctpbee_opt_api-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,599 @@
1
+ /*
2
+ pybind11/std_bind.h: Binding generators for STL data types
3
+
4
+ Copyright (c) 2016 Sergey Lyskov and Wenzel Jakob
5
+
6
+ All rights reserved. Use of this source code is governed by a
7
+ BSD-style license that can be found in the LICENSE file.
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include "detail/common.h"
13
+ #include "operators.h"
14
+
15
+ #include <algorithm>
16
+ #include <sstream>
17
+
18
+ NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
19
+ NAMESPACE_BEGIN(detail)
20
+
21
+ /* SFINAE helper class used by 'is_comparable */
22
+ template <typename T> struct container_traits {
23
+ template <typename T2> static std::true_type test_comparable(decltype(std::declval<const T2 &>() == std::declval<const T2 &>())*);
24
+ template <typename T2> static std::false_type test_comparable(...);
25
+ template <typename T2> static std::true_type test_value(typename T2::value_type *);
26
+ template <typename T2> static std::false_type test_value(...);
27
+ template <typename T2> static std::true_type test_pair(typename T2::first_type *, typename T2::second_type *);
28
+ template <typename T2> static std::false_type test_pair(...);
29
+
30
+ static constexpr const bool is_comparable = std::is_same<std::true_type, decltype(test_comparable<T>(nullptr))>::value;
31
+ static constexpr const bool is_pair = std::is_same<std::true_type, decltype(test_pair<T>(nullptr, nullptr))>::value;
32
+ static constexpr const bool is_vector = std::is_same<std::true_type, decltype(test_value<T>(nullptr))>::value;
33
+ static constexpr const bool is_element = !is_pair && !is_vector;
34
+ };
35
+
36
+ /* Default: is_comparable -> std::false_type */
37
+ template <typename T, typename SFINAE = void>
38
+ struct is_comparable : std::false_type { };
39
+
40
+ /* For non-map data structures, check whether operator== can be instantiated */
41
+ template <typename T>
42
+ struct is_comparable<
43
+ T, enable_if_t<container_traits<T>::is_element &&
44
+ container_traits<T>::is_comparable>>
45
+ : std::true_type { };
46
+
47
+ /* For a vector/map data structure, recursively check the value type (which is std::pair for maps) */
48
+ template <typename T>
49
+ struct is_comparable<T, enable_if_t<container_traits<T>::is_vector>> {
50
+ static constexpr const bool value =
51
+ is_comparable<typename T::value_type>::value;
52
+ };
53
+
54
+ /* For pairs, recursively check the two data types */
55
+ template <typename T>
56
+ struct is_comparable<T, enable_if_t<container_traits<T>::is_pair>> {
57
+ static constexpr const bool value =
58
+ is_comparable<typename T::first_type>::value &&
59
+ is_comparable<typename T::second_type>::value;
60
+ };
61
+
62
+ /* Fallback functions */
63
+ template <typename, typename, typename... Args> void vector_if_copy_constructible(const Args &...) { }
64
+ template <typename, typename, typename... Args> void vector_if_equal_operator(const Args &...) { }
65
+ template <typename, typename, typename... Args> void vector_if_insertion_operator(const Args &...) { }
66
+ template <typename, typename, typename... Args> void vector_modifiers(const Args &...) { }
67
+
68
+ template<typename Vector, typename Class_>
69
+ void vector_if_copy_constructible(enable_if_t<is_copy_constructible<Vector>::value, Class_> &cl) {
70
+ cl.def(init<const Vector &>(), "Copy constructor");
71
+ }
72
+
73
+ template<typename Vector, typename Class_>
74
+ void vector_if_equal_operator(enable_if_t<is_comparable<Vector>::value, Class_> &cl) {
75
+ using T = typename Vector::value_type;
76
+
77
+ cl.def(self == self);
78
+ cl.def(self != self);
79
+
80
+ cl.def("count",
81
+ [](const Vector &v, const T &x) {
82
+ return std::count(v.begin(), v.end(), x);
83
+ },
84
+ arg("x"),
85
+ "Return the number of times ``x`` appears in the list"
86
+ );
87
+
88
+ cl.def("remove", [](Vector &v, const T &x) {
89
+ auto p = std::find(v.begin(), v.end(), x);
90
+ if (p != v.end())
91
+ v.erase(p);
92
+ else
93
+ throw value_error();
94
+ },
95
+ arg("x"),
96
+ "Remove the first item from the list whose value is x. "
97
+ "It is an error if there is no such item."
98
+ );
99
+
100
+ cl.def("__contains__",
101
+ [](const Vector &v, const T &x) {
102
+ return std::find(v.begin(), v.end(), x) != v.end();
103
+ },
104
+ arg("x"),
105
+ "Return true the container contains ``x``"
106
+ );
107
+ }
108
+
109
+ // Vector modifiers -- requires a copyable vector_type:
110
+ // (Technically, some of these (pop and __delitem__) don't actually require copyability, but it seems
111
+ // silly to allow deletion but not insertion, so include them here too.)
112
+ template <typename Vector, typename Class_>
113
+ void vector_modifiers(enable_if_t<is_copy_constructible<typename Vector::value_type>::value, Class_> &cl) {
114
+ using T = typename Vector::value_type;
115
+ using SizeType = typename Vector::size_type;
116
+ using DiffType = typename Vector::difference_type;
117
+
118
+ cl.def("append",
119
+ [](Vector &v, const T &value) { v.push_back(value); },
120
+ arg("x"),
121
+ "Add an item to the end of the list");
122
+
123
+ cl.def(init([](iterable it) {
124
+ auto v = std::unique_ptr<Vector>(new Vector());
125
+ v->reserve(len(it));
126
+ for (handle h : it)
127
+ v->push_back(h.cast<T>());
128
+ return v.release();
129
+ }));
130
+
131
+ cl.def("extend",
132
+ [](Vector &v, const Vector &src) {
133
+ v.insert(v.end(), src.begin(), src.end());
134
+ },
135
+ arg("L"),
136
+ "Extend the list by appending all the items in the given list"
137
+ );
138
+
139
+ cl.def("insert",
140
+ [](Vector &v, SizeType i, const T &x) {
141
+ if (i > v.size())
142
+ throw index_error();
143
+ v.insert(v.begin() + (DiffType) i, x);
144
+ },
145
+ arg("i") , arg("x"),
146
+ "Insert an item at a given position."
147
+ );
148
+
149
+ cl.def("pop",
150
+ [](Vector &v) {
151
+ if (v.empty())
152
+ throw index_error();
153
+ T t = v.back();
154
+ v.pop_back();
155
+ return t;
156
+ },
157
+ "Remove and return the last item"
158
+ );
159
+
160
+ cl.def("pop",
161
+ [](Vector &v, SizeType i) {
162
+ if (i >= v.size())
163
+ throw index_error();
164
+ T t = v[i];
165
+ v.erase(v.begin() + (DiffType) i);
166
+ return t;
167
+ },
168
+ arg("i"),
169
+ "Remove and return the item at index ``i``"
170
+ );
171
+
172
+ cl.def("__setitem__",
173
+ [](Vector &v, SizeType i, const T &t) {
174
+ if (i >= v.size())
175
+ throw index_error();
176
+ v[i] = t;
177
+ }
178
+ );
179
+
180
+ /// Slicing protocol
181
+ cl.def("__getitem__",
182
+ [](const Vector &v, slice slice) -> Vector * {
183
+ size_t start, stop, step, slicelength;
184
+
185
+ if (!slice.compute(v.size(), &start, &stop, &step, &slicelength))
186
+ throw error_already_set();
187
+
188
+ Vector *seq = new Vector();
189
+ seq->reserve((size_t) slicelength);
190
+
191
+ for (size_t i=0; i<slicelength; ++i) {
192
+ seq->push_back(v[start]);
193
+ start += step;
194
+ }
195
+ return seq;
196
+ },
197
+ arg("s"),
198
+ "Retrieve list elements using a slice object"
199
+ );
200
+
201
+ cl.def("__setitem__",
202
+ [](Vector &v, slice slice, const Vector &value) {
203
+ size_t start, stop, step, slicelength;
204
+ if (!slice.compute(v.size(), &start, &stop, &step, &slicelength))
205
+ throw error_already_set();
206
+
207
+ if (slicelength != value.size())
208
+ throw std::runtime_error("Left and right hand size of slice assignment have different sizes!");
209
+
210
+ for (size_t i=0; i<slicelength; ++i) {
211
+ v[start] = value[i];
212
+ start += step;
213
+ }
214
+ },
215
+ "Assign list elements using a slice object"
216
+ );
217
+
218
+ cl.def("__delitem__",
219
+ [](Vector &v, SizeType i) {
220
+ if (i >= v.size())
221
+ throw index_error();
222
+ v.erase(v.begin() + DiffType(i));
223
+ },
224
+ "Delete the list elements at index ``i``"
225
+ );
226
+
227
+ cl.def("__delitem__",
228
+ [](Vector &v, slice slice) {
229
+ size_t start, stop, step, slicelength;
230
+
231
+ if (!slice.compute(v.size(), &start, &stop, &step, &slicelength))
232
+ throw error_already_set();
233
+
234
+ if (step == 1 && false) {
235
+ v.erase(v.begin() + (DiffType) start, v.begin() + DiffType(start + slicelength));
236
+ } else {
237
+ for (size_t i = 0; i < slicelength; ++i) {
238
+ v.erase(v.begin() + DiffType(start));
239
+ start += step - 1;
240
+ }
241
+ }
242
+ },
243
+ "Delete list elements using a slice object"
244
+ );
245
+
246
+ }
247
+
248
+ // If the type has an operator[] that doesn't return a reference (most notably std::vector<bool>),
249
+ // we have to access by copying; otherwise we return by reference.
250
+ template <typename Vector> using vector_needs_copy = negation<
251
+ std::is_same<decltype(std::declval<Vector>()[typename Vector::size_type()]), typename Vector::value_type &>>;
252
+
253
+ // The usual case: access and iterate by reference
254
+ template <typename Vector, typename Class_>
255
+ void vector_accessor(enable_if_t<!vector_needs_copy<Vector>::value, Class_> &cl) {
256
+ using T = typename Vector::value_type;
257
+ using SizeType = typename Vector::size_type;
258
+ using ItType = typename Vector::iterator;
259
+
260
+ cl.def("__getitem__",
261
+ [](Vector &v, SizeType i) -> T & {
262
+ if (i >= v.size())
263
+ throw index_error();
264
+ return v[i];
265
+ },
266
+ return_value_policy::reference_internal // ref + keepalive
267
+ );
268
+
269
+ cl.def("__iter__",
270
+ [](Vector &v) {
271
+ return make_iterator<
272
+ return_value_policy::reference_internal, ItType, ItType, T&>(
273
+ v.begin(), v.end());
274
+ },
275
+ keep_alive<0, 1>() /* Essential: keep list alive while iterator exists */
276
+ );
277
+ }
278
+
279
+ // The case for special objects, like std::vector<bool>, that have to be returned-by-copy:
280
+ template <typename Vector, typename Class_>
281
+ void vector_accessor(enable_if_t<vector_needs_copy<Vector>::value, Class_> &cl) {
282
+ using T = typename Vector::value_type;
283
+ using SizeType = typename Vector::size_type;
284
+ using ItType = typename Vector::iterator;
285
+ cl.def("__getitem__",
286
+ [](const Vector &v, SizeType i) -> T {
287
+ if (i >= v.size())
288
+ throw index_error();
289
+ return v[i];
290
+ }
291
+ );
292
+
293
+ cl.def("__iter__",
294
+ [](Vector &v) {
295
+ return make_iterator<
296
+ return_value_policy::copy, ItType, ItType, T>(
297
+ v.begin(), v.end());
298
+ },
299
+ keep_alive<0, 1>() /* Essential: keep list alive while iterator exists */
300
+ );
301
+ }
302
+
303
+ template <typename Vector, typename Class_> auto vector_if_insertion_operator(Class_ &cl, std::string const &name)
304
+ -> decltype(std::declval<std::ostream&>() << std::declval<typename Vector::value_type>(), void()) {
305
+ using size_type = typename Vector::size_type;
306
+
307
+ cl.def("__repr__",
308
+ [name](Vector &v) {
309
+ std::ostringstream s;
310
+ s << name << '[';
311
+ for (size_type i=0; i < v.size(); ++i) {
312
+ s << v[i];
313
+ if (i != v.size() - 1)
314
+ s << ", ";
315
+ }
316
+ s << ']';
317
+ return s.str();
318
+ },
319
+ "Return the canonical string representation of this list."
320
+ );
321
+ }
322
+
323
+ // Provide the buffer interface for vectors if we have data() and we have a format for it
324
+ // GCC seems to have "void std::vector<bool>::data()" - doing SFINAE on the existence of data() is insufficient, we need to check it returns an appropriate pointer
325
+ template <typename Vector, typename = void>
326
+ struct vector_has_data_and_format : std::false_type {};
327
+ template <typename Vector>
328
+ struct vector_has_data_and_format<Vector, enable_if_t<std::is_same<decltype(format_descriptor<typename Vector::value_type>::format(), std::declval<Vector>().data()), typename Vector::value_type*>::value>> : std::true_type {};
329
+
330
+ // Add the buffer interface to a vector
331
+ template <typename Vector, typename Class_, typename... Args>
332
+ enable_if_t<detail::any_of<std::is_same<Args, buffer_protocol>...>::value>
333
+ vector_buffer(Class_& cl) {
334
+ using T = typename Vector::value_type;
335
+
336
+ static_assert(vector_has_data_and_format<Vector>::value, "There is not an appropriate format descriptor for this vector");
337
+
338
+ // numpy.h declares this for arbitrary types, but it may raise an exception and crash hard at runtime if PYBIND11_NUMPY_DTYPE hasn't been called, so check here
339
+ format_descriptor<T>::format();
340
+
341
+ cl.def_buffer([](Vector& v) -> buffer_info {
342
+ return buffer_info(v.data(), static_cast<ssize_t>(sizeof(T)), format_descriptor<T>::format(), 1, {v.size()}, {sizeof(T)});
343
+ });
344
+
345
+ cl.def(init([](buffer buf) {
346
+ auto info = buf.request();
347
+ if (info.ndim != 1 || info.strides[0] % static_cast<ssize_t>(sizeof(T)))
348
+ throw type_error("Only valid 1D buffers can be copied to a vector");
349
+ if (!detail::compare_buffer_info<T>::compare(info) || (ssize_t) sizeof(T) != info.itemsize)
350
+ throw type_error("Format mismatch (Python: " + info.format + " C++: " + format_descriptor<T>::format() + ")");
351
+
352
+ auto vec = std::unique_ptr<Vector>(new Vector());
353
+ vec->reserve((size_t) info.shape[0]);
354
+ T *p = static_cast<T*>(info.ptr);
355
+ ssize_t step = info.strides[0] / static_cast<ssize_t>(sizeof(T));
356
+ T *end = p + info.shape[0] * step;
357
+ for (; p != end; p += step)
358
+ vec->push_back(*p);
359
+ return vec.release();
360
+ }));
361
+
362
+ return;
363
+ }
364
+
365
+ template <typename Vector, typename Class_, typename... Args>
366
+ enable_if_t<!detail::any_of<std::is_same<Args, buffer_protocol>...>::value> vector_buffer(Class_&) {}
367
+
368
+ NAMESPACE_END(detail)
369
+
370
+ //
371
+ // std::vector
372
+ //
373
+ template <typename Vector, typename holder_type = std::unique_ptr<Vector>, typename... Args>
374
+ class_<Vector, holder_type> bind_vector(handle scope, std::string const &name, Args&&... args) {
375
+ using Class_ = class_<Vector, holder_type>;
376
+
377
+ // If the value_type is unregistered (e.g. a converting type) or is itself registered
378
+ // module-local then make the vector binding module-local as well:
379
+ using vtype = typename Vector::value_type;
380
+ auto vtype_info = detail::get_type_info(typeid(vtype));
381
+ bool local = !vtype_info || vtype_info->module_local;
382
+
383
+ Class_ cl(scope, name.c_str(), pybind11::module_local(local), std::forward<Args>(args)...);
384
+
385
+ // Declare the buffer interface if a buffer_protocol() is passed in
386
+ detail::vector_buffer<Vector, Class_, Args...>(cl);
387
+
388
+ cl.def(init<>());
389
+
390
+ // Register copy constructor (if possible)
391
+ detail::vector_if_copy_constructible<Vector, Class_>(cl);
392
+
393
+ // Register comparison-related operators and functions (if possible)
394
+ detail::vector_if_equal_operator<Vector, Class_>(cl);
395
+
396
+ // Register stream insertion operator (if possible)
397
+ detail::vector_if_insertion_operator<Vector, Class_>(cl, name);
398
+
399
+ // Modifiers require copyable vector value type
400
+ detail::vector_modifiers<Vector, Class_>(cl);
401
+
402
+ // Accessor and iterator; return by value if copyable, otherwise we return by ref + keep-alive
403
+ detail::vector_accessor<Vector, Class_>(cl);
404
+
405
+ cl.def("__bool__",
406
+ [](const Vector &v) -> bool {
407
+ return !v.empty();
408
+ },
409
+ "Check whether the list is nonempty"
410
+ );
411
+
412
+ cl.def("__len__", &Vector::size);
413
+
414
+
415
+
416
+
417
+ #if 0
418
+ // C++ style functions deprecated, leaving it here as an example
419
+ cl.def(init<size_type>());
420
+
421
+ cl.def("resize",
422
+ (void (Vector::*) (size_type count)) & Vector::resize,
423
+ "changes the number of elements stored");
424
+
425
+ cl.def("erase",
426
+ [](Vector &v, SizeType i) {
427
+ if (i >= v.size())
428
+ throw index_error();
429
+ v.erase(v.begin() + i);
430
+ }, "erases element at index ``i``");
431
+
432
+ cl.def("empty", &Vector::empty, "checks whether the container is empty");
433
+ cl.def("size", &Vector::size, "returns the number of elements");
434
+ cl.def("push_back", (void (Vector::*)(const T&)) &Vector::push_back, "adds an element to the end");
435
+ cl.def("pop_back", &Vector::pop_back, "removes the last element");
436
+
437
+ cl.def("max_size", &Vector::max_size, "returns the maximum possible number of elements");
438
+ cl.def("reserve", &Vector::reserve, "reserves storage");
439
+ cl.def("capacity", &Vector::capacity, "returns the number of elements that can be held in currently allocated storage");
440
+ cl.def("shrink_to_fit", &Vector::shrink_to_fit, "reduces memory usage by freeing unused memory");
441
+
442
+ cl.def("clear", &Vector::clear, "clears the contents");
443
+ cl.def("swap", &Vector::swap, "swaps the contents");
444
+
445
+ cl.def("front", [](Vector &v) {
446
+ if (v.size()) return v.front();
447
+ else throw index_error();
448
+ }, "access the first element");
449
+
450
+ cl.def("back", [](Vector &v) {
451
+ if (v.size()) return v.back();
452
+ else throw index_error();
453
+ }, "access the last element ");
454
+
455
+ #endif
456
+
457
+ return cl;
458
+ }
459
+
460
+
461
+
462
+ //
463
+ // std::map, std::unordered_map
464
+ //
465
+
466
+ NAMESPACE_BEGIN(detail)
467
+
468
+ /* Fallback functions */
469
+ template <typename, typename, typename... Args> void map_if_insertion_operator(const Args &...) { }
470
+ template <typename, typename, typename... Args> void map_assignment(const Args &...) { }
471
+
472
+ // Map assignment when copy-assignable: just copy the value
473
+ template <typename Map, typename Class_>
474
+ void map_assignment(enable_if_t<std::is_copy_assignable<typename Map::mapped_type>::value, Class_> &cl) {
475
+ using KeyType = typename Map::key_type;
476
+ using MappedType = typename Map::mapped_type;
477
+
478
+ cl.def("__setitem__",
479
+ [](Map &m, const KeyType &k, const MappedType &v) {
480
+ auto it = m.find(k);
481
+ if (it != m.end()) it->second = v;
482
+ else m.emplace(k, v);
483
+ }
484
+ );
485
+ }
486
+
487
+ // Not copy-assignable, but still copy-constructible: we can update the value by erasing and reinserting
488
+ template<typename Map, typename Class_>
489
+ void map_assignment(enable_if_t<
490
+ !std::is_copy_assignable<typename Map::mapped_type>::value &&
491
+ is_copy_constructible<typename Map::mapped_type>::value,
492
+ Class_> &cl) {
493
+ using KeyType = typename Map::key_type;
494
+ using MappedType = typename Map::mapped_type;
495
+
496
+ cl.def("__setitem__",
497
+ [](Map &m, const KeyType &k, const MappedType &v) {
498
+ // We can't use m[k] = v; because value type might not be default constructable
499
+ auto r = m.emplace(k, v);
500
+ if (!r.second) {
501
+ // value type is not copy assignable so the only way to insert it is to erase it first...
502
+ m.erase(r.first);
503
+ m.emplace(k, v);
504
+ }
505
+ }
506
+ );
507
+ }
508
+
509
+
510
+ template <typename Map, typename Class_> auto map_if_insertion_operator(Class_ &cl, std::string const &name)
511
+ -> decltype(std::declval<std::ostream&>() << std::declval<typename Map::key_type>() << std::declval<typename Map::mapped_type>(), void()) {
512
+
513
+ cl.def("__repr__",
514
+ [name](Map &m) {
515
+ std::ostringstream s;
516
+ s << name << '{';
517
+ bool f = false;
518
+ for (auto const &kv : m) {
519
+ if (f)
520
+ s << ", ";
521
+ s << kv.first << ": " << kv.second;
522
+ f = true;
523
+ }
524
+ s << '}';
525
+ return s.str();
526
+ },
527
+ "Return the canonical string representation of this map."
528
+ );
529
+ }
530
+
531
+
532
+ NAMESPACE_END(detail)
533
+
534
+ template <typename Map, typename holder_type = std::unique_ptr<Map>, typename... Args>
535
+ class_<Map, holder_type> bind_map(handle scope, const std::string &name, Args&&... args) {
536
+ using KeyType = typename Map::key_type;
537
+ using MappedType = typename Map::mapped_type;
538
+ using Class_ = class_<Map, holder_type>;
539
+
540
+ // If either type is a non-module-local bound type then make the map binding non-local as well;
541
+ // otherwise (e.g. both types are either module-local or converting) the map will be
542
+ // module-local.
543
+ auto tinfo = detail::get_type_info(typeid(MappedType));
544
+ bool local = !tinfo || tinfo->module_local;
545
+ if (local) {
546
+ tinfo = detail::get_type_info(typeid(KeyType));
547
+ local = !tinfo || tinfo->module_local;
548
+ }
549
+
550
+ Class_ cl(scope, name.c_str(), pybind11::module_local(local), std::forward<Args>(args)...);
551
+
552
+ cl.def(init<>());
553
+
554
+ // Register stream insertion operator (if possible)
555
+ detail::map_if_insertion_operator<Map, Class_>(cl, name);
556
+
557
+ cl.def("__bool__",
558
+ [](const Map &m) -> bool { return !m.empty(); },
559
+ "Check whether the map is nonempty"
560
+ );
561
+
562
+ cl.def("__iter__",
563
+ [](Map &m) { return make_key_iterator(m.begin(), m.end()); },
564
+ keep_alive<0, 1>() /* Essential: keep list alive while iterator exists */
565
+ );
566
+
567
+ cl.def("items",
568
+ [](Map &m) { return make_iterator(m.begin(), m.end()); },
569
+ keep_alive<0, 1>() /* Essential: keep list alive while iterator exists */
570
+ );
571
+
572
+ cl.def("__getitem__",
573
+ [](Map &m, const KeyType &k) -> MappedType & {
574
+ auto it = m.find(k);
575
+ if (it == m.end())
576
+ throw key_error();
577
+ return it->second;
578
+ },
579
+ return_value_policy::reference_internal // ref + keepalive
580
+ );
581
+
582
+ // Assignment provided only if the type is copyable
583
+ detail::map_assignment<Map, Class_>(cl);
584
+
585
+ cl.def("__delitem__",
586
+ [](Map &m, const KeyType &k) {
587
+ auto it = m.find(k);
588
+ if (it == m.end())
589
+ throw key_error();
590
+ m.erase(it);
591
+ }
592
+ );
593
+
594
+ cl.def("__len__", &Map::size);
595
+
596
+ return cl;
597
+ }
598
+
599
+ NAMESPACE_END(PYBIND11_NAMESPACE)
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file