PoolArrays.hpp 12 KB

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