Index: src/natools-s_expressions-atom_buffers.adb ================================================================== --- src/natools-s_expressions-atom_buffers.adb +++ src/natools-s_expressions-atom_buffers.adb @@ -72,10 +72,26 @@ Preallocate (Buffer, 1); Buffer.Ref.Update.Data.all (Buffer.Used + 1) := Data; Buffer.Used := Buffer.Used + 1; end Append; + + procedure Append_Reverse (Buffer : in out Atom_Buffer; Data : in Atom) is + procedure Process (Target : in out Atom); + + procedure Process (Target : in out Atom) is + begin + for I in reverse Data'Range loop + Buffer.Used := Buffer.Used + 1; + Target (Buffer.Used) := Data (I); + end loop; + end Process; + begin + Preallocate (Buffer, Data'Length); + Buffer.Ref.Update (Process'Access); + end Append_Reverse; + function Length (Buffer : Atom_Buffer) return Count is begin return Buffer.Used; end Length; @@ -142,10 +158,17 @@ function Element (Buffer : Atom_Buffer; Position : Count) return Octet is begin return Buffer.Ref.Query.Data.all (Position); end Element; + + procedure Pop (Buffer : in out Atom_Buffer; Data : out Octet) is + begin + Data := Buffer.Ref.Query.Data.all (Buffer.Used); + Buffer.Used := Buffer.Used - 1; + end Pop; + procedure Hard_Reset (Buffer : in out Atom_Buffer) is begin Buffer.Ref.Reset; Buffer.Available := 0; Index: src/natools-s_expressions-atom_buffers.ads ================================================================== --- src/natools-s_expressions-atom_buffers.ads +++ src/natools-s_expressions-atom_buffers.ads @@ -40,10 +40,13 @@ -- any further allocation. procedure Append (Buffer : in out Atom_Buffer; Data : in Atom); procedure Append (Buffer : in out Atom_Buffer; Data : in Octet); -- Append Data after the end of Buffer + + procedure Append_Reverse (Buffer : in out Atom_Buffer; Data : in Atom); + -- Append bytes from Atom from last to first function Length (Buffer : Atom_Buffer) return Count; function Data (Buffer : Atom_Buffer) return Atom; procedure Query (Buffer : in Atom_Buffer; @@ -52,10 +55,13 @@ (Buffer : in Atom_Buffer; Data : out Atom; Length : out Count); function Element (Buffer : Atom_Buffer; Position : Count) return Octet; -- Accessors to the whole buffer as an Atom + + procedure Pop (Buffer : in out Atom_Buffer; Data : out Octet); + -- Remove last octet from Buffer and store it in Data function Raw_Query (Buffer : Atom_Buffer) return Atom_Refs.Accessor; -- Accessor to the whole allocated memory procedure Hard_Reset (Buffer : in out Atom_Buffer);