Index: src/natools-s_expressions-atom_buffers.adb ================================================================== --- src/natools-s_expressions-atom_buffers.adb +++ src/natools-s_expressions-atom_buffers.adb @@ -88,10 +88,33 @@ begin Preallocate (Buffer, Data'Length); Buffer.Ref.Update (Process'Access); end Append_Reverse; + + procedure Invert (Buffer : in out Atom_Buffer) is + procedure Process (Data : in out Atom); + + procedure Process (Data : in out Atom) is + Low : Count := Data'First; + High : Count := Buffer.Used; + Tmp : Octet; + begin + while Low < High loop + Tmp := Data (Low); + Data (Low) := Data (High); + Data (High) := Tmp; + Low := Low + 1; + High := High - 1; + end loop; + end Process; + begin + if not Buffer.Ref.Is_Empty then + Buffer.Ref.Update (Process'Access); + end if; + end Invert; + function Length (Buffer : Atom_Buffer) return Count is begin return Buffer.Used; end Length; Index: src/natools-s_expressions-atom_buffers.ads ================================================================== --- src/natools-s_expressions-atom_buffers.ads +++ src/natools-s_expressions-atom_buffers.ads @@ -44,10 +44,13 @@ -- 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 + procedure Invert (Buffer : in out Atom_Buffer); + -- Invert the order of bytes (first becomes last, etc) + function Length (Buffer : Atom_Buffer) return Count; function Data (Buffer : Atom_Buffer) return Atom; procedure Query (Buffer : in Atom_Buffer; Process : not null access procedure (Data : in Atom));