PoolArrays.hpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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. _read_access = nullptr;
  21. }
  22. inline Read(const Read & p_other) {
  23. _read_access = godot::api->godot_pool_byte_array_read_access_copy(p_other._read_access);
  24. }
  25. inline ~Read() {
  26. godot::api->godot_pool_byte_array_read_access_destroy(_read_access);
  27. }
  28. inline const uint8_t *ptr() const {
  29. return godot::api->godot_pool_byte_array_read_access_ptr(_read_access);
  30. }
  31. inline const uint8_t &operator[](int p_idx) const {
  32. return ptr()[p_idx];
  33. }
  34. inline void operator=(const Read& p_other) {
  35. godot::api->godot_pool_byte_array_read_access_operator_assign(_read_access, p_other._read_access);
  36. }
  37. };
  38. class Write {
  39. friend class PoolByteArray;
  40. godot_pool_byte_array_write_access *_write_access;
  41. public:
  42. inline Write() {
  43. _write_access = nullptr;
  44. }
  45. inline Write(const Write & p_other) {
  46. _write_access = godot::api->godot_pool_byte_array_write_access_copy(p_other._write_access);
  47. }
  48. inline ~Write() {
  49. godot::api->godot_pool_byte_array_write_access_destroy(_write_access);
  50. }
  51. inline uint8_t *ptr() const {
  52. return godot::api->godot_pool_byte_array_write_access_ptr(_write_access);
  53. }
  54. inline uint8_t &operator[](int p_idx) const {
  55. return ptr()[p_idx];
  56. }
  57. inline void operator=(const Write& p_other) {
  58. godot::api->godot_pool_byte_array_write_access_operator_assign(_write_access, p_other._write_access);
  59. }
  60. };
  61. PoolByteArray();
  62. PoolByteArray(const PoolByteArray &p_other);
  63. PoolByteArray &operator=(const PoolByteArray & p_other);
  64. PoolByteArray(const Array& array);
  65. Read read() const;
  66. Write write();
  67. void append(const uint8_t data);
  68. void append_array(const PoolByteArray& array);
  69. int insert(const int idx, const uint8_t data);
  70. void invert();
  71. void push_back(const uint8_t data);
  72. void remove(const int idx);
  73. void resize(const int size);
  74. void set(const int idx, const uint8_t data);
  75. const uint8_t operator [](const int idx);
  76. int size() const;
  77. ~PoolByteArray();
  78. };
  79. class PoolIntArray {
  80. godot_pool_int_array _godot_array;
  81. public:
  82. class Read {
  83. friend class PoolIntArray;
  84. godot_pool_int_array_read_access *_read_access;
  85. public:
  86. inline Read() {
  87. _read_access = nullptr;
  88. }
  89. inline Read(const Read & p_other) {
  90. _read_access = godot::api->godot_pool_int_array_read_access_copy(p_other._read_access);
  91. }
  92. inline ~Read() {
  93. godot::api->godot_pool_int_array_read_access_destroy(_read_access);
  94. }
  95. inline const int *ptr() const {
  96. return godot::api->godot_pool_int_array_read_access_ptr(_read_access);
  97. }
  98. inline const int &operator[](int p_idx) const {
  99. return ptr()[p_idx];
  100. }
  101. inline void operator=(const Read& p_other) {
  102. godot::api->godot_pool_int_array_read_access_operator_assign(_read_access, p_other._read_access);
  103. }
  104. };
  105. class Write {
  106. friend class PoolIntArray;
  107. godot_pool_int_array_write_access *_write_access;
  108. public:
  109. inline Write() {
  110. _write_access = nullptr;
  111. }
  112. inline Write(const Write & p_other) {
  113. _write_access = godot::api->godot_pool_int_array_write_access_copy(p_other._write_access);
  114. }
  115. inline ~Write() {
  116. godot::api->godot_pool_int_array_write_access_destroy(_write_access);
  117. }
  118. inline int *ptr() const {
  119. return godot::api->godot_pool_int_array_write_access_ptr(_write_access);
  120. }
  121. inline int &operator[](int p_idx) const {
  122. return ptr()[p_idx];
  123. }
  124. inline void operator=(const Write& p_other) {
  125. godot::api->godot_pool_int_array_write_access_operator_assign(_write_access, p_other._write_access);
  126. }
  127. };
  128. PoolIntArray();
  129. PoolIntArray(const PoolIntArray &p_other);
  130. PoolIntArray &operator=(const PoolIntArray &p_other);
  131. PoolIntArray(const Array& array);
  132. Read read() const;
  133. Write write();
  134. void append(const int data);
  135. void append_array(const PoolIntArray& array);
  136. int insert(const int idx, const int data);
  137. void invert();
  138. void push_back(const int data);
  139. void remove(const int idx);
  140. void resize(const int size);
  141. void set(const int idx, const int data);
  142. const int operator [](const int idx);
  143. int size() const;
  144. ~PoolIntArray();
  145. };
  146. class PoolRealArray {
  147. godot_pool_real_array _godot_array;
  148. public:
  149. class Read {
  150. friend class PoolRealArray;
  151. godot_pool_real_array_read_access *_read_access;
  152. public:
  153. inline Read() {
  154. _read_access = nullptr;
  155. }
  156. inline Read(const Read & p_other) {
  157. _read_access = godot::api->godot_pool_real_array_read_access_copy(p_other._read_access);
  158. }
  159. inline ~Read() {
  160. godot::api->godot_pool_real_array_read_access_destroy(_read_access);
  161. }
  162. inline const real_t *ptr() const {
  163. return godot::api->godot_pool_real_array_read_access_ptr(_read_access);
  164. }
  165. inline const real_t &operator[](int p_idx) const {
  166. return ptr()[p_idx];
  167. }
  168. inline void operator=(const Read& p_other) {
  169. godot::api->godot_pool_real_array_read_access_operator_assign(_read_access, p_other._read_access);
  170. }
  171. };
  172. class Write {
  173. friend class PoolRealArray;
  174. godot_pool_real_array_write_access *_write_access;
  175. public:
  176. inline Write() {
  177. _write_access = nullptr;
  178. }
  179. inline Write(const Write & p_other) {
  180. _write_access = godot::api->godot_pool_real_array_write_access_copy(p_other._write_access);
  181. }
  182. inline ~Write() {
  183. godot::api->godot_pool_real_array_write_access_destroy(_write_access);
  184. }
  185. inline real_t *ptr() const {
  186. return godot::api->godot_pool_real_array_write_access_ptr(_write_access);
  187. }
  188. inline real_t &operator[](int p_idx) const {
  189. return ptr()[p_idx];
  190. }
  191. inline void operator=(const Write& p_other) {
  192. godot::api->godot_pool_real_array_write_access_operator_assign(_write_access, p_other._write_access);
  193. }
  194. };
  195. PoolRealArray();
  196. PoolRealArray(const PoolRealArray &p_other);
  197. PoolRealArray &operator=(const PoolRealArray &p_other);
  198. PoolRealArray(const Array& array);
  199. Read read() const;
  200. Write write();
  201. void append(const real_t data);
  202. void append_array(const PoolRealArray& array);
  203. int insert(const int idx, const real_t data);
  204. void invert();
  205. void push_back(const real_t data);
  206. void remove(const int idx);
  207. void resize(const int size);
  208. void set(const int idx, const real_t data);
  209. const real_t operator [](const int idx);
  210. int size() const;
  211. ~PoolRealArray();
  212. };
  213. class PoolStringArray {
  214. godot_pool_string_array _godot_array;
  215. public:
  216. class Read {
  217. friend class PoolStringArray;
  218. godot_pool_string_array_read_access *_read_access;
  219. public:
  220. inline Read() {
  221. _read_access = nullptr;
  222. }
  223. inline Read(const Read & p_other) {
  224. _read_access = godot::api->godot_pool_string_array_read_access_copy(p_other._read_access);
  225. }
  226. inline ~Read() {
  227. godot::api->godot_pool_string_array_read_access_destroy(_read_access);
  228. }
  229. inline const String *ptr() const {
  230. return (const String *) godot::api->godot_pool_string_array_read_access_ptr(_read_access);
  231. }
  232. inline const String &operator[](int p_idx) const {
  233. return ptr()[p_idx];
  234. }
  235. inline void operator=(const Read& p_other) {
  236. godot::api->godot_pool_string_array_read_access_operator_assign(_read_access, p_other._read_access);
  237. }
  238. };
  239. class Write {
  240. friend class PoolStringArray;
  241. godot_pool_string_array_write_access *_write_access;
  242. public:
  243. inline Write() {
  244. _write_access = nullptr;
  245. }
  246. inline Write(const Write & p_other) {
  247. _write_access = godot::api->godot_pool_string_array_write_access_copy(p_other._write_access);
  248. }
  249. inline ~Write() {
  250. godot::api->godot_pool_string_array_write_access_destroy(_write_access);
  251. }
  252. inline String *ptr() const {
  253. return (String *) godot::api->godot_pool_string_array_write_access_ptr(_write_access);
  254. }
  255. inline String &operator[](int p_idx) const {
  256. return ptr()[p_idx];
  257. }
  258. inline void operator=(const Write& p_other) {
  259. godot::api->godot_pool_string_array_write_access_operator_assign(_write_access, p_other._write_access);
  260. }
  261. };
  262. PoolStringArray();
  263. PoolStringArray(const PoolStringArray &p_other);
  264. PoolStringArray &operator=(const PoolStringArray &p_other);
  265. PoolStringArray(const Array& array);
  266. Read read() const;
  267. Write write();
  268. void append(const String& data);
  269. void append_array(const PoolStringArray& array);
  270. int insert(const int idx, const String& data);
  271. void invert();
  272. void push_back(const String& data);
  273. void remove(const int idx);
  274. void resize(const int size);
  275. void set(const int idx, const String& data);
  276. const String operator [](const int idx);
  277. int size() const;
  278. ~PoolStringArray();
  279. };
  280. class PoolVector2Array {
  281. godot_pool_vector2_array _godot_array;
  282. public:
  283. class Read {
  284. friend class PoolVector2Array;
  285. godot_pool_vector2_array_read_access *_read_access;
  286. public:
  287. inline Read() {
  288. _read_access = nullptr;
  289. }
  290. inline Read(const Read & p_other) {
  291. _read_access = godot::api->godot_pool_vector2_array_read_access_copy(p_other._read_access);
  292. }
  293. inline ~Read() {
  294. godot::api->godot_pool_vector2_array_read_access_destroy(_read_access);
  295. }
  296. inline const Vector2 *ptr() const {
  297. return (const Vector2 *) godot::api->godot_pool_vector2_array_read_access_ptr(_read_access);
  298. }
  299. inline const Vector2 &operator[](int p_idx) const {
  300. return ptr()[p_idx];
  301. }
  302. inline void operator=(const Read& p_other) {
  303. godot::api->godot_pool_vector2_array_read_access_operator_assign(_read_access, p_other._read_access);
  304. }
  305. };
  306. class Write {
  307. friend class PoolVector2Array;
  308. godot_pool_vector2_array_write_access *_write_access;
  309. public:
  310. inline Write() {
  311. _write_access = nullptr;
  312. }
  313. inline Write(const Write & p_other) {
  314. _write_access = godot::api->godot_pool_vector2_array_write_access_copy(p_other._write_access);
  315. }
  316. inline ~Write() {
  317. godot::api->godot_pool_vector2_array_write_access_destroy(_write_access);
  318. }
  319. inline Vector2 *ptr() const {
  320. return (Vector2 *) godot::api->godot_pool_vector2_array_write_access_ptr(_write_access);
  321. }
  322. inline Vector2 &operator[](int p_idx) const {
  323. return ptr()[p_idx];
  324. }
  325. inline void operator=(const Write& p_other) {
  326. godot::api->godot_pool_vector2_array_write_access_operator_assign(_write_access, p_other._write_access);
  327. }
  328. };
  329. PoolVector2Array();
  330. PoolVector2Array(const PoolVector2Array &p_other);
  331. PoolVector2Array &operator=(const PoolVector2Array &p_other);
  332. PoolVector2Array(const Array& array);
  333. Read read() const;
  334. Write write();
  335. void append(const Vector2& data);
  336. void append_array(const PoolVector2Array& array);
  337. int insert(const int idx, const Vector2& data);
  338. void invert();
  339. void push_back(const Vector2& data);
  340. void remove(const int idx);
  341. void resize(const int size);
  342. void set(const int idx, const Vector2& data);
  343. const Vector2 operator [](const int idx);
  344. int size() const;
  345. ~PoolVector2Array();
  346. };
  347. class PoolVector3Array {
  348. godot_pool_vector3_array _godot_array;
  349. public:
  350. class Read {
  351. friend class PoolVector3Array;
  352. godot_pool_vector3_array_read_access *_read_access;
  353. public:
  354. inline Read() {
  355. _read_access = nullptr;
  356. }
  357. inline Read(const Read & p_other) {
  358. _read_access = godot::api->godot_pool_vector3_array_read_access_copy(p_other._read_access);
  359. }
  360. inline ~Read() {
  361. godot::api->godot_pool_vector3_array_read_access_destroy(_read_access);
  362. }
  363. inline const Vector3 *ptr() const {
  364. return (const Vector3 *) godot::api->godot_pool_vector3_array_read_access_ptr(_read_access);
  365. }
  366. inline const Vector3 &operator[](int p_idx) const {
  367. return ptr()[p_idx];
  368. }
  369. inline void operator=(const Read& p_other) {
  370. godot::api->godot_pool_vector3_array_read_access_operator_assign(_read_access, p_other._read_access);
  371. }
  372. };
  373. class Write {
  374. friend class PoolVector3Array;
  375. godot_pool_vector3_array_write_access *_write_access;
  376. public:
  377. inline Write() {
  378. _write_access = nullptr;
  379. }
  380. inline Write(const Write & p_other) {
  381. _write_access = godot::api->godot_pool_vector3_array_write_access_copy(p_other._write_access);
  382. }
  383. inline ~Write() {
  384. godot::api->godot_pool_vector3_array_write_access_destroy(_write_access);
  385. }
  386. inline Vector3 *ptr() const {
  387. return (Vector3 *) godot::api->godot_pool_vector3_array_write_access_ptr(_write_access);
  388. }
  389. inline Vector3 &operator[](int p_idx) const {
  390. return ptr()[p_idx];
  391. }
  392. inline void operator=(const Write& p_other) {
  393. godot::api->godot_pool_vector3_array_write_access_operator_assign(_write_access, p_other._write_access);
  394. }
  395. };
  396. PoolVector3Array();
  397. PoolVector3Array(const PoolVector3Array &p_other);
  398. PoolVector3Array &operator=(const PoolVector3Array &p_other);
  399. PoolVector3Array(const Array& array);
  400. Read read() const;
  401. Write write();
  402. void append(const Vector3& data);
  403. void append_array(const PoolVector3Array& array);
  404. int insert(const int idx, const Vector3& data);
  405. void invert();
  406. void push_back(const Vector3& data);
  407. void remove(const int idx);
  408. void resize(const int size);
  409. void set(const int idx, const Vector3& data);
  410. const Vector3 operator [](const int idx);
  411. int size() const;
  412. ~PoolVector3Array();
  413. };
  414. class PoolColorArray {
  415. godot_pool_color_array _godot_array;
  416. public:
  417. class Read {
  418. friend class PoolColorArray;
  419. godot_pool_color_array_read_access *_read_access;
  420. public:
  421. inline Read() {
  422. _read_access = nullptr;
  423. }
  424. inline Read(const Read & p_other) {
  425. _read_access = godot::api->godot_pool_color_array_read_access_copy(p_other._read_access);
  426. }
  427. inline ~Read() {
  428. godot::api->godot_pool_color_array_read_access_destroy(_read_access);
  429. }
  430. inline const Color *ptr() const {
  431. return (const Color *) godot::api->godot_pool_color_array_read_access_ptr(_read_access);
  432. }
  433. inline const Color &operator[](int p_idx) const {
  434. return ptr()[p_idx];
  435. }
  436. inline void operator=(const Read& p_other) {
  437. godot::api->godot_pool_color_array_read_access_operator_assign(_read_access, p_other._read_access);
  438. }
  439. };
  440. class Write {
  441. friend class PoolColorArray;
  442. godot_pool_color_array_write_access *_write_access;
  443. public:
  444. inline Write() {
  445. _write_access = nullptr;
  446. }
  447. inline Write(const Write & p_other) {
  448. _write_access = godot::api->godot_pool_color_array_write_access_copy(p_other._write_access);
  449. }
  450. inline ~Write() {
  451. godot::api->godot_pool_color_array_write_access_destroy(_write_access);
  452. }
  453. inline Color *ptr() const {
  454. return (Color *) godot::api->godot_pool_color_array_write_access_ptr(_write_access);
  455. }
  456. inline Color &operator[](int p_idx) const {
  457. return ptr()[p_idx];
  458. }
  459. inline void operator=(const Write& p_other) {
  460. godot::api->godot_pool_color_array_write_access_operator_assign(_write_access, p_other._write_access);
  461. }
  462. };
  463. PoolColorArray();
  464. PoolColorArray(const PoolColorArray &p_other);
  465. PoolColorArray &operator=(const PoolColorArray &p_other);
  466. PoolColorArray(const Array& array);
  467. Read read() const;
  468. Write write();
  469. void append(const Color& data);
  470. void append_array(const PoolColorArray& array);
  471. int insert(const int idx, const Color& data);
  472. void invert();
  473. void push_back(const Color& data);
  474. void remove(const int idx);
  475. void resize(const int size);
  476. void set(const int idx, const Color& data);
  477. const Color operator [](const int idx);
  478. int size() const;
  479. ~PoolColorArray();
  480. };
  481. }
  482. #endif // POOLARRAYS_H