Pike v8.0 release 1738

Method Stdio.Buffer()->add_hstring()


Method add_hstring

Buffer add_hstring(string(8bit) data, int size_size)
Buffer add_hstring(Stdio.Buffer data, int size_size)
Buffer add_hstring(System.Memory data, int size_size)
Buffer add_hstring(String.Buffer data, int size_size)
Buffer add_hstring(int(8bit) data, int size_size)
Buffer add_hstring(array data, int size_size)
Buffer add_hstring(int|string(8bit)|Stdio.Buffer|System.Memory|array data, int size_size, int offset)

Description

Adds length of data followed by data to the buffer.

This is identical to sprintf("%"+size_size+"H",(string)Stdio.Buffer(data)) but significantly faster.

size_size is the number of bytes used to represent the length of the data. It must be less than Int.NATIVE_MAX.

offset is added to the length of the data prior to writing out the length. Typical usage involves adding size_size to account for the room used by the size.

The supported data argument types are

int(8bit)

An eight bit character.

string(8bit)

An eight bit string.

System.Memory

A chunk of memory. The whole memory area is added.

Stdio.Buffer

A chunk of memory. The whole memory area is added.

String.Buffer

A chunk of memory. The whole memory area is added.

array

Add all elements in the array individually. Each element may be any one of the types listed here.