← All compilation units

Flyology.Bytes

Description

Owned byte sequence with automatic storage management and value semantics. Its representation and indices are intentionally hidden.

Append

procedure Append (Data : in out Unbounded_Bytes; Value : Ada.Streams.Stream_Element)

Append one byte, growing owned storage as required.

Parameters
Data

Destination sequence

Value

Byte to append

Append

procedure Append (Data : in out Unbounded_Bytes; Value : Ada.Streams.Stream_Element_Array)

Append contiguous bytes, growing owned storage as required.

Parameters
Data

Destination sequence

Value

Bytes to append

Append_Byte_String

procedure Append_Byte_String (Data : in out Unbounded_Bytes; Value : String)

Append a one-to-one byte string. This is not a character encoding.

Parameters
Data

Destination sequence

Value

Byte string to append

Clear

procedure Clear (Data : in out Unbounded_Bytes)

Release all retained elements and backing capacity.

Parameters
Data

Sequence to clear

Element

function Element (Data : Unbounded_Bytes; Index : Positive) return Ada.Streams.Stream_Element

Return one retained byte by its one-based position.

Parameters
Data

Owned byte sequence

Index

One-based byte position

Return value

Byte at Index

Empty

Empty : constant Unbounded_Bytes;

Empty byte sequence.

From_Byte_String

function From_Byte_String (Data : String) return Unbounded_Bytes

Copy a byte string into owned storage using a one-to-one mapping from Character positions 0 .. 255. This is not a character encoding.

Parameters
Data

Source byte string

Return value

Independently owned byte sequence

Length

function Length (Data : Unbounded_Bytes) return Natural

Return the number of retained bytes.

Parameters
Data

Owned byte sequence

Return value

Payload length

Move

procedure Move (Target : in out Unbounded_Bytes; Source : in out Unbounded_Bytes)

Transfer owned storage without copying and leave Source empty.

Parameters
Target

Destination sequence, whose prior storage is released

Source

Sequence whose storage is transferred

Reserve_Capacity

procedure Reserve_Capacity (Data : in out Unbounded_Bytes; Capacity : Natural)

Ensure capacity for at least Capacity bytes without changing Length.

Parameters
Data

Destination sequence

Capacity

Requested retained capacity

To_Array

function To_Array (Data : Unbounded_Bytes) return Ada.Streams.Stream_Element_Array

Return a contiguous copy with lower bound 1, or 1 .. 0 when empty.

Parameters
Data

Owned byte sequence

Return value

Contiguous stream elements

To_Byte_String

function To_Byte_String (Data : Unbounded_Bytes) return String

Convert bytes one-to-one to Character positions 0 .. 255. This helper is intended for byte-oriented protocol parsers and already validated UTF-8 text; it does not decode Unicode.

Parameters
Data

Owned byte sequence

Return value

Byte string with the same octets

To_Unbounded_Bytes

function To_Unbounded_Bytes (Data : Ada.Streams.Stream_Element_Array) return Unbounded_Bytes

Copy a contiguous stream-element array into owned storage.

Parameters
Data

Source bytes

Return value

Independently owned byte sequence

Unbounded_Bytes

type Unbounded_Bytes is private;

Owned byte sequence with automatic storage management and value semantics. Its representation and indices are intentionally hidden.