PoolArrays.hpp 16 KB

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