From cea0fbbbf90e0d7f2ff3fceb6c0f99c3ee97a06b Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Thu, 7 Nov 2024 14:14:08 +0300 Subject: [PATCH] Virtual_String_Vector.Join with string separator. --- .../implementation/vss-string_vectors.adb | 26 +++++++++++++++++++ source/text/vss-string_vectors.ads | 4 +++ 2 files changed, 30 insertions(+) diff --git a/source/text/implementation/vss-string_vectors.adb b/source/text/implementation/vss-string_vectors.adb index ea7c3231..f1777828 100644 --- a/source/text/implementation/vss-string_vectors.adb +++ b/source/text/implementation/vss-string_vectors.adb @@ -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 -- ---------------- diff --git a/source/text/vss-string_vectors.ads b/source/text/vss-string_vectors.ads index ecd798f3..57beb39d 100644 --- a/source/text/vss-string_vectors.ads +++ b/source/text/vss-string_vectors.ads @@ -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.