PoolArrays.hpp 18 KB

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