Skip to content

Commit

Permalink
Virtual_String_Vector.Join with string separator.
Browse files Browse the repository at this point in the history
  • Loading branch information
godunko committed Nov 7, 2024
1 parent 2f9babd commit cea0fbb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions source/text/implementation/vss-string_vectors.adb
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,32 @@ package body VSS.String_Vectors is
end return;
end Join;

----------
-- Join --
----------

function Join
(Self : Virtual_String_Vector'Class;
Separator : VSS.Strings.Virtual_String)
return VSS.Strings.Virtual_String
is
First_Segment : Boolean := True;

begin
return Result : VSS.Strings.Virtual_String do
for Item of Self loop
if First_Segment then
First_Segment := False;

else
Result.Append (Separator);
end if;

Result.Append (Item);
end loop;
end return;
end Join;

----------------
-- Join_Lines --
----------------
Expand Down
4 changes: 4 additions & 0 deletions source/text/vss-string_vectors.ads
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ package VSS.String_Vectors is
(Self : Virtual_String_Vector'Class;
Separator : VSS.Characters.Virtual_Character)
return VSS.Strings.Virtual_String;
function Join
(Self : Virtual_String_Vector'Class;
Separator : VSS.Strings.Virtual_String)
return VSS.Strings.Virtual_String;
-- Join all strings in the string vector into single string with each
-- element separated by the given separator.

Expand Down

0 comments on commit cea0fbb

Please sign in to comment.