class_packedbytearray.rst 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/PackedByteArray.xml.
  6. .. _class_PackedByteArray:
  7. PackedByteArray
  8. ===============
  9. A packed array of bytes.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. An array specifically designed to hold bytes. Packs data tightly, so it saves memory for large array sizes.
  14. \ **PackedByteArray** also provides methods to encode/decode various types to/from bytes. The way values are encoded is an implementation detail and shouldn't be relied upon when interacting with external apps.
  15. \ **Note:** Packed arrays are always passed by reference. To get a copy of an array that can be modified independently of the original array, use :ref:`duplicate<class_PackedByteArray_method_duplicate>`. This is *not* the case for built-in properties and methods. The returned packed array of these are a copies, and changing it will *not* affect the original value. To update a built-in property you need to modify the returned array, and then assign it to the property again.
  16. .. note::
  17. There are notable differences when using this API with C#. See :ref:`doc_c_sharp_differences` for more information.
  18. .. rst-class:: classref-reftable-group
  19. Constructors
  20. ------------
  21. .. table::
  22. :widths: auto
  23. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>`\ (\ ) |
  25. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>`\ (\ from\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  27. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>`\ (\ from\: :ref:`Array<class_Array>`\ ) |
  29. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
  30. .. rst-class:: classref-reftable-group
  31. Methods
  32. -------
  33. .. table::
  34. :widths: auto
  35. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`append<class_PackedByteArray_method_append>`\ (\ value\: :ref:`int<class_int>`\ ) |
  37. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | |void| | :ref:`append_array<class_PackedByteArray_method_append_array>`\ (\ array\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  39. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`int<class_int>` | :ref:`bsearch<class_PackedByteArray_method_bsearch>`\ (\ value\: :ref:`int<class_int>`, before\: :ref:`bool<class_bool>` = true\ ) |
  41. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | |void| | :ref:`clear<class_PackedByteArray_method_clear>`\ (\ ) |
  43. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`compress<class_PackedByteArray_method_compress>`\ (\ compression_mode\: :ref:`int<class_int>` = 0\ ) |const| |
  45. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`count<class_PackedByteArray_method_count>`\ (\ value\: :ref:`int<class_int>`\ ) |const| |
  47. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`float<class_float>` | :ref:`decode_double<class_PackedByteArray_method_decode_double>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  49. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`float<class_float>` | :ref:`decode_float<class_PackedByteArray_method_decode_float>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  51. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`float<class_float>` | :ref:`decode_half<class_PackedByteArray_method_decode_half>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  53. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`int<class_int>` | :ref:`decode_s8<class_PackedByteArray_method_decode_s8>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  55. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`int<class_int>` | :ref:`decode_s16<class_PackedByteArray_method_decode_s16>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  57. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`int<class_int>` | :ref:`decode_s32<class_PackedByteArray_method_decode_s32>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  59. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`int<class_int>` | :ref:`decode_s64<class_PackedByteArray_method_decode_s64>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  61. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`int<class_int>` | :ref:`decode_u8<class_PackedByteArray_method_decode_u8>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  63. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`int<class_int>` | :ref:`decode_u16<class_PackedByteArray_method_decode_u16>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  65. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`int<class_int>` | :ref:`decode_u32<class_PackedByteArray_method_decode_u32>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  67. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`int<class_int>` | :ref:`decode_u64<class_PackedByteArray_method_decode_u64>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  69. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`Variant<class_Variant>` | :ref:`decode_var<class_PackedByteArray_method_decode_var>`\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| |
  71. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`int<class_int>` | :ref:`decode_var_size<class_PackedByteArray_method_decode_var_size>`\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| |
  73. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`decompress<class_PackedByteArray_method_decompress>`\ (\ buffer_size\: :ref:`int<class_int>`, compression_mode\: :ref:`int<class_int>` = 0\ ) |const| |
  75. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`decompress_dynamic<class_PackedByteArray_method_decompress_dynamic>`\ (\ max_output_size\: :ref:`int<class_int>`, compression_mode\: :ref:`int<class_int>` = 0\ ) |const| |
  77. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`duplicate<class_PackedByteArray_method_duplicate>`\ (\ ) |
  79. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | |void| | :ref:`encode_double<class_PackedByteArray_method_encode_double>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) |
  81. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | |void| | :ref:`encode_float<class_PackedByteArray_method_encode_float>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) |
  83. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | |void| | :ref:`encode_half<class_PackedByteArray_method_encode_half>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) |
  85. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | |void| | :ref:`encode_s8<class_PackedByteArray_method_encode_s8>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  87. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | |void| | :ref:`encode_s16<class_PackedByteArray_method_encode_s16>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  89. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | |void| | :ref:`encode_s32<class_PackedByteArray_method_encode_s32>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  91. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | |void| | :ref:`encode_s64<class_PackedByteArray_method_encode_s64>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  93. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | |void| | :ref:`encode_u8<class_PackedByteArray_method_encode_u8>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  95. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | |void| | :ref:`encode_u16<class_PackedByteArray_method_encode_u16>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  97. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | |void| | :ref:`encode_u32<class_PackedByteArray_method_encode_u32>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  99. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | |void| | :ref:`encode_u64<class_PackedByteArray_method_encode_u64>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  101. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`int<class_int>` | :ref:`encode_var<class_PackedByteArray_method_encode_var>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`Variant<class_Variant>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |
  103. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | |void| | :ref:`fill<class_PackedByteArray_method_fill>`\ (\ value\: :ref:`int<class_int>`\ ) |
  105. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`int<class_int>` | :ref:`find<class_PackedByteArray_method_find>`\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = 0\ ) |const| |
  107. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`int<class_int>` | :ref:`get<class_PackedByteArray_method_get>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
  109. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`String<class_String>` | :ref:`get_string_from_ascii<class_PackedByteArray_method_get_string_from_ascii>`\ (\ ) |const| |
  111. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`String<class_String>` | :ref:`get_string_from_utf8<class_PackedByteArray_method_get_string_from_utf8>`\ (\ ) |const| |
  113. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`String<class_String>` | :ref:`get_string_from_utf16<class_PackedByteArray_method_get_string_from_utf16>`\ (\ ) |const| |
  115. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`String<class_String>` | :ref:`get_string_from_utf32<class_PackedByteArray_method_get_string_from_utf32>`\ (\ ) |const| |
  117. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`String<class_String>` | :ref:`get_string_from_wchar<class_PackedByteArray_method_get_string_from_wchar>`\ (\ ) |const| |
  119. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`bool<class_bool>` | :ref:`has<class_PackedByteArray_method_has>`\ (\ value\: :ref:`int<class_int>`\ ) |const| |
  121. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`bool<class_bool>` | :ref:`has_encoded_var<class_PackedByteArray_method_has_encoded_var>`\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| |
  123. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`String<class_String>` | :ref:`hex_encode<class_PackedByteArray_method_hex_encode>`\ (\ ) |const| |
  125. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`int<class_int>` | :ref:`insert<class_PackedByteArray_method_insert>`\ (\ at_index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  127. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`bool<class_bool>` | :ref:`is_empty<class_PackedByteArray_method_is_empty>`\ (\ ) |const| |
  129. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | :ref:`bool<class_bool>` | :ref:`push_back<class_PackedByteArray_method_push_back>`\ (\ value\: :ref:`int<class_int>`\ ) |
  131. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | |void| | :ref:`remove_at<class_PackedByteArray_method_remove_at>`\ (\ index\: :ref:`int<class_int>`\ ) |
  133. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | :ref:`int<class_int>` | :ref:`resize<class_PackedByteArray_method_resize>`\ (\ new_size\: :ref:`int<class_int>`\ ) |
  135. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | |void| | :ref:`reverse<class_PackedByteArray_method_reverse>`\ (\ ) |
  137. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | :ref:`int<class_int>` | :ref:`rfind<class_PackedByteArray_method_rfind>`\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = -1\ ) |const| |
  139. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | |void| | :ref:`set<class_PackedByteArray_method_set>`\ (\ index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  141. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | :ref:`int<class_int>` | :ref:`size<class_PackedByteArray_method_size>`\ (\ ) |const| |
  143. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`slice<class_PackedByteArray_method_slice>`\ (\ begin\: :ref:`int<class_int>`, end\: :ref:`int<class_int>` = 2147483647\ ) |const| |
  145. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | |void| | :ref:`sort<class_PackedByteArray_method_sort>`\ (\ ) |
  147. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | :ref:`PackedFloat32Array<class_PackedFloat32Array>` | :ref:`to_float32_array<class_PackedByteArray_method_to_float32_array>`\ (\ ) |const| |
  149. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | :ref:`PackedFloat64Array<class_PackedFloat64Array>` | :ref:`to_float64_array<class_PackedByteArray_method_to_float64_array>`\ (\ ) |const| |
  151. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`to_int32_array<class_PackedByteArray_method_to_int32_array>`\ (\ ) |const| |
  153. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  154. | :ref:`PackedInt64Array<class_PackedInt64Array>` | :ref:`to_int64_array<class_PackedByteArray_method_to_int64_array>`\ (\ ) |const| |
  155. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  156. .. rst-class:: classref-reftable-group
  157. Operators
  158. ---------
  159. .. table::
  160. :widths: auto
  161. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  162. | :ref:`bool<class_bool>` | :ref:`operator !=<class_PackedByteArray_operator_neq_PackedByteArray>`\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  163. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  164. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`operator +<class_PackedByteArray_operator_sum_PackedByteArray>`\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  165. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  166. | :ref:`bool<class_bool>` | :ref:`operator ==<class_PackedByteArray_operator_eq_PackedByteArray>`\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  167. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  168. | :ref:`int<class_int>` | :ref:`operator []<class_PackedByteArray_operator_idx_int>`\ (\ index\: :ref:`int<class_int>`\ ) |
  169. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  170. .. rst-class:: classref-section-separator
  171. ----
  172. .. rst-class:: classref-descriptions-group
  173. Constructor Descriptions
  174. ------------------------
  175. .. _class_PackedByteArray_constructor_PackedByteArray:
  176. .. rst-class:: classref-constructor
  177. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray**\ (\ ) :ref:`🔗<class_PackedByteArray_constructor_PackedByteArray>`
  178. Constructs an empty **PackedByteArray**.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. rst-class:: classref-constructor
  182. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray**\ (\ from\: :ref:`PackedByteArray<class_PackedByteArray>`\ )
  183. Constructs a **PackedByteArray** as a copy of the given **PackedByteArray**.
  184. .. rst-class:: classref-item-separator
  185. ----
  186. .. rst-class:: classref-constructor
  187. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray**\ (\ from\: :ref:`Array<class_Array>`\ )
  188. Constructs a new **PackedByteArray**. Optionally, you can pass in a generic :ref:`Array<class_Array>` that will be converted.
  189. .. rst-class:: classref-section-separator
  190. ----
  191. .. rst-class:: classref-descriptions-group
  192. Method Descriptions
  193. -------------------
  194. .. _class_PackedByteArray_method_append:
  195. .. rst-class:: classref-method
  196. :ref:`bool<class_bool>` **append**\ (\ value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_append>`
  197. Appends an element at the end of the array (alias of :ref:`push_back<class_PackedByteArray_method_push_back>`).
  198. .. rst-class:: classref-item-separator
  199. ----
  200. .. _class_PackedByteArray_method_append_array:
  201. .. rst-class:: classref-method
  202. |void| **append_array**\ (\ array\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_PackedByteArray_method_append_array>`
  203. Appends a **PackedByteArray** at the end of this array.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_PackedByteArray_method_bsearch:
  207. .. rst-class:: classref-method
  208. :ref:`int<class_int>` **bsearch**\ (\ value\: :ref:`int<class_int>`, before\: :ref:`bool<class_bool>` = true\ ) :ref:`🔗<class_PackedByteArray_method_bsearch>`
  209. Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search. Optionally, a ``before`` specifier can be passed. If ``false``, the returned index comes after all existing entries of the value in the array.
  210. \ **Note:** Calling :ref:`bsearch<class_PackedByteArray_method_bsearch>` on an unsorted array results in unexpected behavior.
  211. .. rst-class:: classref-item-separator
  212. ----
  213. .. _class_PackedByteArray_method_clear:
  214. .. rst-class:: classref-method
  215. |void| **clear**\ (\ ) :ref:`🔗<class_PackedByteArray_method_clear>`
  216. Clears the array. This is equivalent to using :ref:`resize<class_PackedByteArray_method_resize>` with a size of ``0``.
  217. .. rst-class:: classref-item-separator
  218. ----
  219. .. _class_PackedByteArray_method_compress:
  220. .. rst-class:: classref-method
  221. :ref:`PackedByteArray<class_PackedByteArray>` **compress**\ (\ compression_mode\: :ref:`int<class_int>` = 0\ ) |const| :ref:`🔗<class_PackedByteArray_method_compress>`
  222. Returns a new **PackedByteArray** with the data compressed. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants.
  223. .. rst-class:: classref-item-separator
  224. ----
  225. .. _class_PackedByteArray_method_count:
  226. .. rst-class:: classref-method
  227. :ref:`int<class_int>` **count**\ (\ value\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_count>`
  228. Returns the number of times an element is in the array.
  229. .. rst-class:: classref-item-separator
  230. ----
  231. .. _class_PackedByteArray_method_decode_double:
  232. .. rst-class:: classref-method
  233. :ref:`float<class_float>` **decode_double**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_double>`
  234. Decodes a 64-bit floating-point number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0.0`` if a valid number can't be decoded.
  235. .. rst-class:: classref-item-separator
  236. ----
  237. .. _class_PackedByteArray_method_decode_float:
  238. .. rst-class:: classref-method
  239. :ref:`float<class_float>` **decode_float**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_float>`
  240. Decodes a 32-bit floating-point number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0.0`` if a valid number can't be decoded.
  241. .. rst-class:: classref-item-separator
  242. ----
  243. .. _class_PackedByteArray_method_decode_half:
  244. .. rst-class:: classref-method
  245. :ref:`float<class_float>` **decode_half**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_half>`
  246. Decodes a 16-bit floating-point number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0.0`` if a valid number can't be decoded.
  247. .. rst-class:: classref-item-separator
  248. ----
  249. .. _class_PackedByteArray_method_decode_s8:
  250. .. rst-class:: classref-method
  251. :ref:`int<class_int>` **decode_s8**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_s8>`
  252. Decodes a 8-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  253. .. rst-class:: classref-item-separator
  254. ----
  255. .. _class_PackedByteArray_method_decode_s16:
  256. .. rst-class:: classref-method
  257. :ref:`int<class_int>` **decode_s16**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_s16>`
  258. Decodes a 16-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  259. .. rst-class:: classref-item-separator
  260. ----
  261. .. _class_PackedByteArray_method_decode_s32:
  262. .. rst-class:: classref-method
  263. :ref:`int<class_int>` **decode_s32**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_s32>`
  264. Decodes a 32-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  265. .. rst-class:: classref-item-separator
  266. ----
  267. .. _class_PackedByteArray_method_decode_s64:
  268. .. rst-class:: classref-method
  269. :ref:`int<class_int>` **decode_s64**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_s64>`
  270. Decodes a 64-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  271. .. rst-class:: classref-item-separator
  272. ----
  273. .. _class_PackedByteArray_method_decode_u8:
  274. .. rst-class:: classref-method
  275. :ref:`int<class_int>` **decode_u8**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_u8>`
  276. Decodes a 8-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  277. .. rst-class:: classref-item-separator
  278. ----
  279. .. _class_PackedByteArray_method_decode_u16:
  280. .. rst-class:: classref-method
  281. :ref:`int<class_int>` **decode_u16**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_u16>`
  282. Decodes a 16-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  283. .. rst-class:: classref-item-separator
  284. ----
  285. .. _class_PackedByteArray_method_decode_u32:
  286. .. rst-class:: classref-method
  287. :ref:`int<class_int>` **decode_u32**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_u32>`
  288. Decodes a 32-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  289. .. rst-class:: classref-item-separator
  290. ----
  291. .. _class_PackedByteArray_method_decode_u64:
  292. .. rst-class:: classref-method
  293. :ref:`int<class_int>` **decode_u64**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_u64>`
  294. Decodes a 64-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  295. .. rst-class:: classref-item-separator
  296. ----
  297. .. _class_PackedByteArray_method_decode_var:
  298. .. rst-class:: classref-method
  299. :ref:`Variant<class_Variant>` **decode_var**\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_var>`
  300. Decodes a :ref:`Variant<class_Variant>` from the bytes starting at ``byte_offset``. Returns ``null`` if a valid variant can't be decoded or the value is :ref:`Object<class_Object>`-derived and ``allow_objects`` is ``false``.
  301. .. rst-class:: classref-item-separator
  302. ----
  303. .. _class_PackedByteArray_method_decode_var_size:
  304. .. rst-class:: classref-method
  305. :ref:`int<class_int>` **decode_var_size**\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_var_size>`
  306. Decodes a size of a :ref:`Variant<class_Variant>` from the bytes starting at ``byte_offset``. Requires at least 4 bytes of data starting at the offset, otherwise fails.
  307. .. rst-class:: classref-item-separator
  308. ----
  309. .. _class_PackedByteArray_method_decompress:
  310. .. rst-class:: classref-method
  311. :ref:`PackedByteArray<class_PackedByteArray>` **decompress**\ (\ buffer_size\: :ref:`int<class_int>`, compression_mode\: :ref:`int<class_int>` = 0\ ) |const| :ref:`🔗<class_PackedByteArray_method_decompress>`
  312. Returns a new **PackedByteArray** with the data decompressed. Set ``buffer_size`` to the size of the uncompressed data. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants.
  313. \ **Note:** Decompression is not guaranteed to work with data not compressed by Godot, for example if data compressed with the deflate compression mode lacks a checksum or header.
  314. .. rst-class:: classref-item-separator
  315. ----
  316. .. _class_PackedByteArray_method_decompress_dynamic:
  317. .. rst-class:: classref-method
  318. :ref:`PackedByteArray<class_PackedByteArray>` **decompress_dynamic**\ (\ max_output_size\: :ref:`int<class_int>`, compression_mode\: :ref:`int<class_int>` = 0\ ) |const| :ref:`🔗<class_PackedByteArray_method_decompress_dynamic>`
  319. Returns a new **PackedByteArray** with the data decompressed. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants. **This method only accepts brotli, gzip, and deflate compression modes.**\
  320. This method is potentially slower than :ref:`decompress<class_PackedByteArray_method_decompress>`, as it may have to re-allocate its output buffer multiple times while decompressing, whereas :ref:`decompress<class_PackedByteArray_method_decompress>` knows it's output buffer size from the beginning.
  321. GZIP has a maximal compression ratio of 1032:1, meaning it's very possible for a small compressed payload to decompress to a potentially very large output. To guard against this, you may provide a maximum size this function is allowed to allocate in bytes via ``max_output_size``. Passing -1 will allow for unbounded output. If any positive value is passed, and the decompression exceeds that amount in bytes, then an error will be returned.
  322. \ **Note:** Decompression is not guaranteed to work with data not compressed by Godot, for example if data compressed with the deflate compression mode lacks a checksum or header.
  323. .. rst-class:: classref-item-separator
  324. ----
  325. .. _class_PackedByteArray_method_duplicate:
  326. .. rst-class:: classref-method
  327. :ref:`PackedByteArray<class_PackedByteArray>` **duplicate**\ (\ ) :ref:`🔗<class_PackedByteArray_method_duplicate>`
  328. Creates a copy of the array, and returns it.
  329. .. rst-class:: classref-item-separator
  330. ----
  331. .. _class_PackedByteArray_method_encode_double:
  332. .. rst-class:: classref-method
  333. |void| **encode_double**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_double>`
  334. Encodes a 64-bit floating-point number as bytes at the index of ``byte_offset`` bytes. The array must have at least 8 bytes of allocated space, starting at the offset.
  335. .. rst-class:: classref-item-separator
  336. ----
  337. .. _class_PackedByteArray_method_encode_float:
  338. .. rst-class:: classref-method
  339. |void| **encode_float**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_float>`
  340. Encodes a 32-bit floating-point number as bytes at the index of ``byte_offset`` bytes. The array must have at least 4 bytes of space, starting at the offset.
  341. .. rst-class:: classref-item-separator
  342. ----
  343. .. _class_PackedByteArray_method_encode_half:
  344. .. rst-class:: classref-method
  345. |void| **encode_half**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_half>`
  346. Encodes a 16-bit floating-point number as bytes at the index of ``byte_offset`` bytes. The array must have at least 2 bytes of space, starting at the offset.
  347. .. rst-class:: classref-item-separator
  348. ----
  349. .. _class_PackedByteArray_method_encode_s8:
  350. .. rst-class:: classref-method
  351. |void| **encode_s8**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_s8>`
  352. Encodes a 8-bit signed integer number (signed byte) at the index of ``byte_offset`` bytes. The array must have at least 1 byte of space, starting at the offset.
  353. .. rst-class:: classref-item-separator
  354. ----
  355. .. _class_PackedByteArray_method_encode_s16:
  356. .. rst-class:: classref-method
  357. |void| **encode_s16**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_s16>`
  358. Encodes a 16-bit signed integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 2 bytes of space, starting at the offset.
  359. .. rst-class:: classref-item-separator
  360. ----
  361. .. _class_PackedByteArray_method_encode_s32:
  362. .. rst-class:: classref-method
  363. |void| **encode_s32**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_s32>`
  364. Encodes a 32-bit signed integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 4 bytes of space, starting at the offset.
  365. .. rst-class:: classref-item-separator
  366. ----
  367. .. _class_PackedByteArray_method_encode_s64:
  368. .. rst-class:: classref-method
  369. |void| **encode_s64**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_s64>`
  370. Encodes a 64-bit signed integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 8 bytes of space, starting at the offset.
  371. .. rst-class:: classref-item-separator
  372. ----
  373. .. _class_PackedByteArray_method_encode_u8:
  374. .. rst-class:: classref-method
  375. |void| **encode_u8**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_u8>`
  376. Encodes a 8-bit unsigned integer number (byte) at the index of ``byte_offset`` bytes. The array must have at least 1 byte of space, starting at the offset.
  377. .. rst-class:: classref-item-separator
  378. ----
  379. .. _class_PackedByteArray_method_encode_u16:
  380. .. rst-class:: classref-method
  381. |void| **encode_u16**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_u16>`
  382. Encodes a 16-bit unsigned integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 2 bytes of space, starting at the offset.
  383. .. rst-class:: classref-item-separator
  384. ----
  385. .. _class_PackedByteArray_method_encode_u32:
  386. .. rst-class:: classref-method
  387. |void| **encode_u32**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_u32>`
  388. Encodes a 32-bit unsigned integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 4 bytes of space, starting at the offset.
  389. .. rst-class:: classref-item-separator
  390. ----
  391. .. _class_PackedByteArray_method_encode_u64:
  392. .. rst-class:: classref-method
  393. |void| **encode_u64**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_u64>`
  394. Encodes a 64-bit unsigned integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 8 bytes of space, starting at the offset.
  395. .. rst-class:: classref-item-separator
  396. ----
  397. .. _class_PackedByteArray_method_encode_var:
  398. .. rst-class:: classref-method
  399. :ref:`int<class_int>` **encode_var**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`Variant<class_Variant>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_PackedByteArray_method_encode_var>`
  400. Encodes a :ref:`Variant<class_Variant>` at the index of ``byte_offset`` bytes. A sufficient space must be allocated, depending on the encoded variant's size. If ``allow_objects`` is ``false``, :ref:`Object<class_Object>`-derived values are not permitted and will instead be serialized as ID-only.
  401. .. rst-class:: classref-item-separator
  402. ----
  403. .. _class_PackedByteArray_method_fill:
  404. .. rst-class:: classref-method
  405. |void| **fill**\ (\ value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_fill>`
  406. Assigns the given value to all elements in the array. This can typically be used together with :ref:`resize<class_PackedByteArray_method_resize>` to create an array with a given size and initialized elements.
  407. .. rst-class:: classref-item-separator
  408. ----
  409. .. _class_PackedByteArray_method_find:
  410. .. rst-class:: classref-method
  411. :ref:`int<class_int>` **find**\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = 0\ ) |const| :ref:`🔗<class_PackedByteArray_method_find>`
  412. Searches the array for a value and returns its index or ``-1`` if not found. Optionally, the initial search index can be passed.
  413. .. rst-class:: classref-item-separator
  414. ----
  415. .. _class_PackedByteArray_method_get:
  416. .. rst-class:: classref-method
  417. :ref:`int<class_int>` **get**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_get>`
  418. Returns the byte at the given ``index`` in the array. This is the same as using the ``[]`` operator (``array[index]``).
  419. .. rst-class:: classref-item-separator
  420. ----
  421. .. _class_PackedByteArray_method_get_string_from_ascii:
  422. .. rst-class:: classref-method
  423. :ref:`String<class_String>` **get_string_from_ascii**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_get_string_from_ascii>`
  424. Converts ASCII/Latin-1 encoded array to :ref:`String<class_String>`. Fast alternative to :ref:`get_string_from_utf8<class_PackedByteArray_method_get_string_from_utf8>` if the content is ASCII/Latin-1 only. Unlike the UTF-8 function this function maps every byte to a character in the array. Multibyte sequences will not be interpreted correctly. For parsing user input always use :ref:`get_string_from_utf8<class_PackedByteArray_method_get_string_from_utf8>`. This is the inverse of :ref:`String.to_ascii_buffer<class_String_method_to_ascii_buffer>`.
  425. .. rst-class:: classref-item-separator
  426. ----
  427. .. _class_PackedByteArray_method_get_string_from_utf8:
  428. .. rst-class:: classref-method
  429. :ref:`String<class_String>` **get_string_from_utf8**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_get_string_from_utf8>`
  430. Converts UTF-8 encoded array to :ref:`String<class_String>`. Slower than :ref:`get_string_from_ascii<class_PackedByteArray_method_get_string_from_ascii>` but supports UTF-8 encoded data. Use this function if you are unsure about the source of the data. For user input this function should always be preferred. Returns empty string if source array is not valid UTF-8 string. This is the inverse of :ref:`String.to_utf8_buffer<class_String_method_to_utf8_buffer>`.
  431. .. rst-class:: classref-item-separator
  432. ----
  433. .. _class_PackedByteArray_method_get_string_from_utf16:
  434. .. rst-class:: classref-method
  435. :ref:`String<class_String>` **get_string_from_utf16**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_get_string_from_utf16>`
  436. Converts UTF-16 encoded array to :ref:`String<class_String>`. If the BOM is missing, system endianness is assumed. Returns empty string if source array is not valid UTF-16 string. This is the inverse of :ref:`String.to_utf16_buffer<class_String_method_to_utf16_buffer>`.
  437. .. rst-class:: classref-item-separator
  438. ----
  439. .. _class_PackedByteArray_method_get_string_from_utf32:
  440. .. rst-class:: classref-method
  441. :ref:`String<class_String>` **get_string_from_utf32**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_get_string_from_utf32>`
  442. Converts UTF-32 encoded array to :ref:`String<class_String>`. System endianness is assumed. Returns empty string if source array is not valid UTF-32 string. This is the inverse of :ref:`String.to_utf32_buffer<class_String_method_to_utf32_buffer>`.
  443. .. rst-class:: classref-item-separator
  444. ----
  445. .. _class_PackedByteArray_method_get_string_from_wchar:
  446. .. rst-class:: classref-method
  447. :ref:`String<class_String>` **get_string_from_wchar**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_get_string_from_wchar>`
  448. Converts wide character (``wchar_t``, UTF-16 on Windows, UTF-32 on other platforms) encoded array to :ref:`String<class_String>`. Returns empty string if source array is not valid wide string. This is the inverse of :ref:`String.to_wchar_buffer<class_String_method_to_wchar_buffer>`.
  449. .. rst-class:: classref-item-separator
  450. ----
  451. .. _class_PackedByteArray_method_has:
  452. .. rst-class:: classref-method
  453. :ref:`bool<class_bool>` **has**\ (\ value\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_has>`
  454. Returns ``true`` if the array contains ``value``.
  455. .. rst-class:: classref-item-separator
  456. ----
  457. .. _class_PackedByteArray_method_has_encoded_var:
  458. .. rst-class:: classref-method
  459. :ref:`bool<class_bool>` **has_encoded_var**\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_PackedByteArray_method_has_encoded_var>`
  460. Returns ``true`` if a valid :ref:`Variant<class_Variant>` value can be decoded at the ``byte_offset``. Returns ``false`` otherwise or when the value is :ref:`Object<class_Object>`-derived and ``allow_objects`` is ``false``.
  461. .. rst-class:: classref-item-separator
  462. ----
  463. .. _class_PackedByteArray_method_hex_encode:
  464. .. rst-class:: classref-method
  465. :ref:`String<class_String>` **hex_encode**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_hex_encode>`
  466. Returns a hexadecimal representation of this array as a :ref:`String<class_String>`.
  467. .. tabs::
  468. .. code-tab:: gdscript
  469. var array = PackedByteArray([11, 46, 255])
  470. print(array.hex_encode()) # Prints: 0b2eff
  471. .. code-tab:: csharp
  472. var array = new byte[] {11, 46, 255};
  473. GD.Print(array.HexEncode()); // Prints: 0b2eff
  474. .. rst-class:: classref-item-separator
  475. ----
  476. .. _class_PackedByteArray_method_insert:
  477. .. rst-class:: classref-method
  478. :ref:`int<class_int>` **insert**\ (\ at_index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_insert>`
  479. Inserts a new element at a given position in the array. The position must be valid, or at the end of the array (``idx == size()``).
  480. .. rst-class:: classref-item-separator
  481. ----
  482. .. _class_PackedByteArray_method_is_empty:
  483. .. rst-class:: classref-method
  484. :ref:`bool<class_bool>` **is_empty**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_is_empty>`
  485. Returns ``true`` if the array is empty.
  486. .. rst-class:: classref-item-separator
  487. ----
  488. .. _class_PackedByteArray_method_push_back:
  489. .. rst-class:: classref-method
  490. :ref:`bool<class_bool>` **push_back**\ (\ value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_push_back>`
  491. Appends an element at the end of the array.
  492. .. rst-class:: classref-item-separator
  493. ----
  494. .. _class_PackedByteArray_method_remove_at:
  495. .. rst-class:: classref-method
  496. |void| **remove_at**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_remove_at>`
  497. Removes an element from the array by index.
  498. .. rst-class:: classref-item-separator
  499. ----
  500. .. _class_PackedByteArray_method_resize:
  501. .. rst-class:: classref-method
  502. :ref:`int<class_int>` **resize**\ (\ new_size\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_resize>`
  503. Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling :ref:`resize<class_PackedByteArray_method_resize>` once and assigning the new values is faster than adding new elements one by one.
  504. .. rst-class:: classref-item-separator
  505. ----
  506. .. _class_PackedByteArray_method_reverse:
  507. .. rst-class:: classref-method
  508. |void| **reverse**\ (\ ) :ref:`🔗<class_PackedByteArray_method_reverse>`
  509. Reverses the order of the elements in the array.
  510. .. rst-class:: classref-item-separator
  511. ----
  512. .. _class_PackedByteArray_method_rfind:
  513. .. rst-class:: classref-method
  514. :ref:`int<class_int>` **rfind**\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = -1\ ) |const| :ref:`🔗<class_PackedByteArray_method_rfind>`
  515. Searches the array in reverse order. Optionally, a start search index can be passed. If negative, the start index is considered relative to the end of the array.
  516. .. rst-class:: classref-item-separator
  517. ----
  518. .. _class_PackedByteArray_method_set:
  519. .. rst-class:: classref-method
  520. |void| **set**\ (\ index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_set>`
  521. Changes the byte at the given index.
  522. .. rst-class:: classref-item-separator
  523. ----
  524. .. _class_PackedByteArray_method_size:
  525. .. rst-class:: classref-method
  526. :ref:`int<class_int>` **size**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_size>`
  527. Returns the number of elements in the array.
  528. .. rst-class:: classref-item-separator
  529. ----
  530. .. _class_PackedByteArray_method_slice:
  531. .. rst-class:: classref-method
  532. :ref:`PackedByteArray<class_PackedByteArray>` **slice**\ (\ begin\: :ref:`int<class_int>`, end\: :ref:`int<class_int>` = 2147483647\ ) |const| :ref:`🔗<class_PackedByteArray_method_slice>`
  533. Returns the slice of the **PackedByteArray**, from ``begin`` (inclusive) to ``end`` (exclusive), as a new **PackedByteArray**.
  534. The absolute value of ``begin`` and ``end`` will be clamped to the array size, so the default value for ``end`` makes it slice to the size of the array by default (i.e. ``arr.slice(1)`` is a shorthand for ``arr.slice(1, arr.size())``).
  535. If either ``begin`` or ``end`` are negative, they will be relative to the end of the array (i.e. ``arr.slice(0, -2)`` is a shorthand for ``arr.slice(0, arr.size() - 2)``).
  536. .. rst-class:: classref-item-separator
  537. ----
  538. .. _class_PackedByteArray_method_sort:
  539. .. rst-class:: classref-method
  540. |void| **sort**\ (\ ) :ref:`🔗<class_PackedByteArray_method_sort>`
  541. Sorts the elements of the array in ascending order.
  542. .. rst-class:: classref-item-separator
  543. ----
  544. .. _class_PackedByteArray_method_to_float32_array:
  545. .. rst-class:: classref-method
  546. :ref:`PackedFloat32Array<class_PackedFloat32Array>` **to_float32_array**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_to_float32_array>`
  547. Returns a copy of the data converted to a :ref:`PackedFloat32Array<class_PackedFloat32Array>`, where each block of 4 bytes has been converted to a 32-bit float (C++ ``float``).
  548. The size of the input array must be a multiple of 4 (size of 32-bit float). The size of the new array will be ``byte_array.size() / 4``.
  549. If the original data can't be converted to 32-bit floats, the resulting data is undefined.
  550. .. rst-class:: classref-item-separator
  551. ----
  552. .. _class_PackedByteArray_method_to_float64_array:
  553. .. rst-class:: classref-method
  554. :ref:`PackedFloat64Array<class_PackedFloat64Array>` **to_float64_array**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_to_float64_array>`
  555. Returns a copy of the data converted to a :ref:`PackedFloat64Array<class_PackedFloat64Array>`, where each block of 8 bytes has been converted to a 64-bit float (C++ ``double``, Godot :ref:`float<class_float>`).
  556. The size of the input array must be a multiple of 8 (size of 64-bit double). The size of the new array will be ``byte_array.size() / 8``.
  557. If the original data can't be converted to 64-bit floats, the resulting data is undefined.
  558. .. rst-class:: classref-item-separator
  559. ----
  560. .. _class_PackedByteArray_method_to_int32_array:
  561. .. rst-class:: classref-method
  562. :ref:`PackedInt32Array<class_PackedInt32Array>` **to_int32_array**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_to_int32_array>`
  563. Returns a copy of the data converted to a :ref:`PackedInt32Array<class_PackedInt32Array>`, where each block of 4 bytes has been converted to a signed 32-bit integer (C++ ``int32_t``).
  564. The size of the input array must be a multiple of 4 (size of 32-bit integer). The size of the new array will be ``byte_array.size() / 4``.
  565. If the original data can't be converted to signed 32-bit integers, the resulting data is undefined.
  566. .. rst-class:: classref-item-separator
  567. ----
  568. .. _class_PackedByteArray_method_to_int64_array:
  569. .. rst-class:: classref-method
  570. :ref:`PackedInt64Array<class_PackedInt64Array>` **to_int64_array**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_to_int64_array>`
  571. Returns a copy of the data converted to a :ref:`PackedInt64Array<class_PackedInt64Array>`, where each block of 8 bytes has been converted to a signed 64-bit integer (C++ ``int64_t``, Godot :ref:`int<class_int>`).
  572. The size of the input array must be a multiple of 8 (size of 64-bit integer). The size of the new array will be ``byte_array.size() / 8``.
  573. If the original data can't be converted to signed 64-bit integers, the resulting data is undefined.
  574. .. rst-class:: classref-section-separator
  575. ----
  576. .. rst-class:: classref-descriptions-group
  577. Operator Descriptions
  578. ---------------------
  579. .. _class_PackedByteArray_operator_neq_PackedByteArray:
  580. .. rst-class:: classref-operator
  581. :ref:`bool<class_bool>` **operator !=**\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_PackedByteArray_operator_neq_PackedByteArray>`
  582. Returns ``true`` if contents of the arrays differ.
  583. .. rst-class:: classref-item-separator
  584. ----
  585. .. _class_PackedByteArray_operator_sum_PackedByteArray:
  586. .. rst-class:: classref-operator
  587. :ref:`PackedByteArray<class_PackedByteArray>` **operator +**\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_PackedByteArray_operator_sum_PackedByteArray>`
  588. Returns a new **PackedByteArray** with contents of ``right`` added at the end of this array. For better performance, consider using :ref:`append_array<class_PackedByteArray_method_append_array>` instead.
  589. .. rst-class:: classref-item-separator
  590. ----
  591. .. _class_PackedByteArray_operator_eq_PackedByteArray:
  592. .. rst-class:: classref-operator
  593. :ref:`bool<class_bool>` **operator ==**\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_PackedByteArray_operator_eq_PackedByteArray>`
  594. Returns ``true`` if contents of both arrays are the same, i.e. they have all equal bytes at the corresponding indices.
  595. .. rst-class:: classref-item-separator
  596. ----
  597. .. _class_PackedByteArray_operator_idx_int:
  598. .. rst-class:: classref-operator
  599. :ref:`int<class_int>` **operator []**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_operator_idx_int>`
  600. Returns the byte at index ``index``. Negative indices can be used to access the elements starting from the end. Using index out of array's bounds will result in an error.
  601. Note that the byte is returned as a 64-bit :ref:`int<class_int>`.
  602. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  603. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  604. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  605. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  606. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  607. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  608. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  609. .. |void| replace:: :abbr:`void (No return value.)`