DEVELOPMENT EDITION · 769442725406
Library Reference
On this page

Package Verada.Strings.Unbounded

Verada.Strings.Unbounded: strings of any length, stored on the heap and freed where the object dies (a reclaimed type). Unlike Ada.Strings.Unbounded, the type is limited: there are no copies, and a value is given or changed by the procedures here. The model of an object is its String value, To_String. Only memory limits the length (Verada.Storage): Append raises Storage_Error when memory cannot hold the result.

Unbounded_String

type Unbounded_String is limited private
  with Default_Initial_Condition => Length (Unbounded_String) = 0,
       Finalizable => (Finalize => Free, Relaxed_Finalization => True);

Length

function Length (Source : Unbounded_String) return Natural
  with Global => null,
       Post => Length'Result < Verada.Storage.Length_Bound;

To_String

function To_String (Source : Unbounded_String) return String
  with Global => null,
       Post => To_String'Result'Length = Length (Source)
               and then (To_String'Result'Length = 0 or else To_String'Result'First = 1);

Element

function Element (Source : Unbounded_String; Index : Positive) return Character
  with Global => null,
       Pre => Index <= Length (Source),
       Post => Element'Result = To_String (Source) (Index);

Set

procedure Set (Target : in out Unbounded_String; Source : String)
  with Global => null,
       Post => To_String (Target) = Source;

Append

procedure Append (Source : in out Unbounded_String; New_Item : String)
  with Global => null,
       Post => To_String (Source) = To_String (Source)'Old & New_Item;

Append

procedure Append (Source : in out Unbounded_String; New_Item : Character)
  with Global => null,
       Post => To_String (Source) = To_String (Source)'Old & New_Item;

Move

procedure Move (From : in out Unbounded_String; To : in out Unbounded_String)
  with Global => null,
       Post => To_String (To) = To_String (From)'Old and then Length (From) = 0;

Move (From, To): To takes From's value, From becomes empty

Free

procedure Free (Source : in out Unbounded_String)
  with Global => null,
       Post => Length (Source) = 0;