PoolArrays.hpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. #ifndef POOLARRAYS_H
  2. #define POOLARRAYS_H
  3. #include "Defs.hpp"
  4. #include "String.hpp"
  5. #include "Color.hpp"
  6. #include "Vector2.hpp"
  7. #include "Vector3.hpp"
  8. #include "GodotGlobal.hpp"
  9. #include <gdnative/pool_arrays.h>
  10. namespace godot {
  11. class Array;
  12. class PoolByteArray {
  13. godot_pool_byte_array _godot_array;
  14. public:
  15. class Read {
  16. friend class PoolByteArray;
  17. godot_pool_byte_array_read_access *_read_access;
  18. public:
  19. inline ~Read() {
  20. godot::api->godot_pool_byte_array_read_access_destroy(_read_access);
  21. }
  22. inline const uint8_t *ptr() const {
  23. return godot::api->godot_pool_byte_array_read_access_ptr(_read_access);
  24. }
  25. inline const uint8_t &operator[](int p_idx) const {
  26. return ptr()[p_idx];
  27. }
  28. inline void operator=(const Read& p_other) {
  29. godot::api->godot_pool_byte_array_read_access_operator_assign(_read_access, p_other._read_access);
  30. }
  31. };
  32. class Write {
  33. friend class PoolByteArray;
  34. godot_pool_byte_array_write_access *_write_access;
  35. public:
  36. inline ~Write() {
  37. godot::api->godot_pool_byte_array_write_access_destroy(_write_access);
  38. }
  39. inline uint8_t *ptr() const {
  40. return godot::api->godot_pool_byte_array_write_access_ptr(_write_access);
  41. }
  42. inline uint8_t &operator[](int p_idx) const {
  43. return ptr()[p_idx];
  44. }
  45. inline void operator=(const Write& p_other) {
  46. godot::api->godot_pool_byte_array_write_access_operator_assign(_write_access, p_other._write_access);
  47. }
  48. };
  49. PoolByteArray();
  50. PoolByteArray(const Array& array);
  51. Read read() const;
  52. Write write();
  53. void append(const uint8_t data);
  54. void append_array(const PoolByteArray& array);
  55. int insert(const int idx, const uint8_t data);
  56. void invert();
  57. void push_back(const uint8_t data);
  58. void remove(const int idx);
  59. void resize(const int size);
  60. void set(const int idx, const uint8_t data);
  61. uint8_t operator [](const int idx);
  62. int size();
  63. ~PoolByteArray();
  64. };
  65. class PoolIntArray {
  66. godot_pool_int_array _godot_array;
  67. public:
  68. class Read {
  69. friend class PoolIntArray;
  70. godot_pool_int_array_read_access *_read_access;
  71. public:
  72. inline ~Read() {
  73. godot::api->godot_pool_int_array_read_access_destroy(_read_access);
  74. }
  75. inline const int *ptr() const {
  76. return godot::api->godot_pool_int_array_read_access_ptr(_read_access);
  77. }
  78. inline const int &operator[](int p_idx) const {
  79. return ptr()[p_idx];
  80. }
  81. inline void operator=(const Read& p_other) {
  82. godot::api->godot_pool_int_array_read_access_operator_assign(_read_access, p_other._read_access);
  83. }
  84. };
  85. class Write {
  86. friend class PoolIntArray;
  87. godot_pool_int_array_write_access *_write_access;
  88. public:
  89. inline ~Write() {
  90. godot::api->godot_pool_int_array_write_access_destroy(_write_access);
  91. }
  92. inline int *ptr() const {
  93. return godot::api->godot_pool_int_array_write_access_ptr(_write_access);
  94. }
  95. inline int &operator[](int p_idx) const {
  96. return ptr()[p_idx];
  97. }
  98. inline void operator=(const Write& p_other) {
  99. godot::api->godot_pool_int_array_write_access_operator_assign(_write_access, p_other._write_access);
  100. }
  101. };
  102. PoolIntArray();
  103. PoolIntArray(const Array& array);
  104. Read read() const;
  105. Write write();
  106. void append(const int data);
  107. void append_array(const PoolIntArray& array);
  108. int insert(const int idx, const int data);
  109. void invert();
  110. void push_back(const int data);
  111. void remove(const int idx);
  112. void resize(const int size);
  113. void set(const int idx, const int data);
  114. int operator [](const int idx);
  115. int size();
  116. ~PoolIntArray();
  117. };
  118. class PoolRealArray {
  119. godot_pool_real_array _godot_array;
  120. public:
  121. class Read {
  122. friend class PoolRealArray;
  123. godot_pool_real_array_read_access *_read_access;
  124. public:
  125. inline ~Read() {
  126. godot::api->godot_pool_real_array_read_access_destroy(_read_access);
  127. }
  128. inline const real_t *ptr() const {
  129. return godot::api->godot_pool_real_array_read_access_ptr(_read_access);
  130. }
  131. inline const real_t &operator[](int p_idx) const {
  132. return ptr()[p_idx];
  133. }
  134. inline void operator=(const Read& p_other) {
  135. godot::api->godot_pool_real_array_read_access_operator_assign(_read_access, p_other._read_access);
  136. }
  137. };
  138. class Write {
  139. friend class PoolRealArray;
  140. godot_pool_real_array_write_access *_write_access;
  141. public:
  142. inline ~Write() {
  143. godot::api->godot_pool_real_array_write_access_destroy(_write_access);
  144. }
  145. inline real_t *ptr() const {
  146. return godot::api->godot_pool_real_array_write_access_ptr(_write_access);
  147. }
  148. inline real_t &operator[](int p_idx) const {
  149. return ptr()[p_idx];
  150. }
  151. inline void operator=(const Write& p_other) {
  152. godot::api->godot_pool_real_array_write_access_operator_assign(_write_access, p_other._write_access);
  153. }
  154. };
  155. PoolRealArray();
  156. PoolRealArray(const Array& array);
  157. Read read() const;
  158. Write write();
  159. void append(const real_t data);
  160. void append_array(const PoolRealArray& array);
  161. int insert(const int idx, const real_t data);
  162. void invert();
  163. void push_back(const real_t data);
  164. void remove(const int idx);
  165. void resize(const int size);
  166. void set(const int idx, const real_t data);
  167. real_t operator [](const int idx);
  168. int size();
  169. ~PoolRealArray();
  170. };
  171. class PoolStringArray {
  172. godot_pool_string_array _godot_array;
  173. public:
  174. class Read {
  175. friend class PoolStringArray;
  176. godot_pool_string_array_read_access *_read_access;
  177. public:
  178. inline ~Read() {
  179. godot::api->godot_pool_string_array_read_access_destroy(_read_access);
  180. }
  181. inline const String *ptr() const {
  182. return (const String *) godot::api->godot_pool_string_array_read_access_ptr(_read_access);
  183. }
  184. inline const String &operator[](int p_idx) const {
  185. return ptr()[p_idx];
  186. }
  187. inline void operator=(const Read& p_other) {
  188. godot::api->godot_pool_string_array_read_access_operator_assign(_read_access, p_other._read_access);
  189. }
  190. };
  191. class Write {
  192. friend class PoolStringArray;
  193. godot_pool_string_array_write_access *_write_access;
  194. public:
  195. inline ~Write() {
  196. godot::api->godot_pool_string_array_write_access_destroy(_write_access);
  197. }
  198. inline String *ptr() const {
  199. return (String *) godot::api->godot_pool_string_array_write_access_ptr(_write_access);
  200. }
  201. inline String &operator[](int p_idx) const {
  202. return ptr()[p_idx];
  203. }
  204. inline void operator=(const Write& p_other) {
  205. godot::api->godot_pool_string_array_write_access_operator_assign(_write_access, p_other._write_access);
  206. }
  207. };
  208. PoolStringArray();
  209. PoolStringArray(const Array& array);
  210. Read read() const;
  211. Write write();
  212. void append(const String& data);
  213. void append_array(const PoolStringArray& array);
  214. int insert(const int idx, const String& data);
  215. void invert();
  216. void push_back(const String& data);
  217. void remove(const int idx);
  218. void resize(const int size);
  219. void set(const int idx, const String& data);
  220. String operator [](const int idx);
  221. int size();
  222. ~PoolStringArray();
  223. };
  224. class PoolVector2Array {
  225. godot_pool_vector2_array _godot_array;
  226. public:
  227. class Read {
  228. friend class PoolVector2Array;
  229. godot_pool_vector2_array_read_access *_read_access;
  230. public:
  231. inline ~Read() {
  232. godot::api->godot_pool_vector2_array_read_access_destroy(_read_access);
  233. }
  234. inline const Vector2 *ptr() const {
  235. return (const Vector2 *) godot::api->godot_pool_vector2_array_read_access_ptr(_read_access);
  236. }
  237. inline const Vector2 &operator[](int p_idx) const {
  238. return ptr()[p_idx];
  239. }
  240. inline void operator=(const Read& p_other) {
  241. godot::api->godot_pool_vector2_array_read_access_operator_assign(_read_access, p_other._read_access);
  242. }
  243. };
  244. class Write {
  245. friend class PoolVector2Array;
  246. godot_pool_vector2_array_write_access *_write_access;
  247. public:
  248. inline ~Write() {
  249. godot::api->godot_pool_vector2_array_write_access_destroy(_write_access);
  250. }
  251. inline Vector2 *ptr() const {
  252. return (Vector2 *) godot::api->godot_pool_vector2_array_write_access_ptr(_write_access);
  253. }
  254. inline Vector2 &operator[](int p_idx) const {
  255. return ptr()[p_idx];
  256. }
  257. inline void operator=(const Write& p_other) {
  258. godot::api->godot_pool_vector2_array_write_access_operator_assign(_write_access, p_other._write_access);
  259. }
  260. };
  261. PoolVector2Array();
  262. PoolVector2Array(const Array& array);
  263. Read read() const;
  264. Write write();
  265. void append(const Vector2& data);
  266. void append_array(const PoolVector2Array& array);
  267. int insert(const int idx, const Vector2& data);
  268. void invert();
  269. void push_back(const Vector2& data);
  270. void remove(const int idx);
  271. void resize(const int size);
  272. void set(const int idx, const Vector2& data);
  273. Vector2 operator [](const int idx);
  274. int size();
  275. ~PoolVector2Array();
  276. };
  277. class PoolVector3Array {
  278. godot_pool_vector3_array _godot_array;
  279. public:
  280. class Read {
  281. friend class PoolVector3Array;
  282. godot_pool_vector3_array_read_access *_read_access;
  283. public:
  284. inline ~Read() {
  285. godot::api->godot_pool_vector3_array_read_access_destroy(_read_access);
  286. }
  287. inline const Vector3 *ptr() const {
  288. return (const Vector3 *) godot::api->godot_pool_vector3_array_read_access_ptr(_read_access);
  289. }
  290. inline const Vector3 &operator[](int p_idx) const {
  291. return ptr()[p_idx];
  292. }
  293. inline void operator=(const Read& p_other) {
  294. godot::api->godot_pool_vector3_array_read_access_operator_assign(_read_access, p_other._read_access);
  295. }
  296. };
  297. class Write {
  298. friend class PoolVector3Array;
  299. godot_pool_vector3_array_write_access *_write_access;
  300. public:
  301. inline ~Write() {
  302. godot::api->godot_pool_vector3_array_write_access_destroy(_write_access);
  303. }
  304. inline Vector3 *ptr() const {
  305. return (Vector3 *) godot::api->godot_pool_vector3_array_write_access_ptr(_write_access);
  306. }
  307. inline Vector3 &operator[](int p_idx) const {
  308. return ptr()[p_idx];
  309. }
  310. inline void operator=(const Write& p_other) {
  311. godot::api->godot_pool_vector3_array_write_access_operator_assign(_write_access, p_other._write_access);
  312. }
  313. };
  314. PoolVector3Array();
  315. PoolVector3Array(const Array& array);
  316. Read read() const;
  317. Write write();
  318. void append(const Vector3& data);
  319. void append_array(const PoolVector3Array& array);
  320. int insert(const int idx, const Vector3& data);
  321. void invert();
  322. void push_back(const Vector3& data);
  323. void remove(const int idx);
  324. void resize(const int size);
  325. void set(const int idx, const Vector3& data);
  326. Vector3 operator [](const int idx);
  327. int size();
  328. ~PoolVector3Array();
  329. };
  330. class PoolColorArray {
  331. godot_pool_color_array _godot_array;
  332. public:
  333. class Read {
  334. friend class PoolColorArray;
  335. godot_pool_color_array_read_access *_read_access;
  336. public:
  337. inline ~Read() {
  338. godot::api->godot_pool_color_array_read_access_destroy(_read_access);
  339. }
  340. inline const Color *ptr() const {
  341. return (const Color *) godot::api->godot_pool_color_array_read_access_ptr(_read_access);
  342. }
  343. inline const Color &operator[](int p_idx) const {
  344. return ptr()[p_idx];
  345. }
  346. inline void operator=(const Read& p_other) {
  347. godot::api->godot_pool_color_array_read_access_operator_assign(_read_access, p_other._read_access);
  348. }
  349. };
  350. class Write {
  351. friend class PoolColorArray;
  352. godot_pool_color_array_write_access *_write_access;
  353. public:
  354. inline ~Write() {
  355. godot::api->godot_pool_color_array_write_access_destroy(_write_access);
  356. }
  357. inline Color *ptr() const {
  358. return (Color *) godot::api->godot_pool_color_array_write_access_ptr(_write_access);
  359. }
  360. inline Color &operator[](int p_idx) const {
  361. return ptr()[p_idx];
  362. }
  363. inline void operator=(const Write& p_other) {
  364. godot::api->godot_pool_color_array_write_access_operator_assign(_write_access, p_other._write_access);
  365. }
  366. };
  367. PoolColorArray();
  368. PoolColorArray(const Array& array);
  369. Read read() const;
  370. Write write();
  371. void append(const Color& data);
  372. void append_array(const PoolColorArray& array);
  373. int insert(const int idx, const Color& data);
  374. void invert();
  375. void push_back(const Color& data);
  376. void remove(const int idx);
  377. void resize(const int size);
  378. void set(const int idx, const Color& data);
  379. Color operator [](const int idx);
  380. int size();
  381. ~PoolColorArray();
  382. };
  383. }
  384. #endif // POOLARRAYS_H