vss_24.0.0_b4d0be7c/source/text/vss-strings-conversions.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
--
--  Copyright (C) 2020-2022, AdaCore
--
--  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--

--  Conversion between standard string types and Magic_String.

with Ada.Strings.Unbounded;
with Ada.Strings.UTF_Encoding;
with Ada.Strings.Wide_Wide_Unbounded;

package VSS.Strings.Conversions is

   pragma Preelaborate;

   function To_Virtual_String
     (Item : Ada.Strings.UTF_Encoding.UTF_8_String) return Virtual_String;

   function To_Virtual_String
     (Item : Ada.Strings.Unbounded.Unbounded_String) return Virtual_String;
   --  Convert UTF-8 encoded unbounded string into Virtual_String.

   function To_Virtual_String
     (Item : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String)
      return Virtual_String;
   --  Convert UCS-4 encoded unbounded string into Virtual_String.

   function To_UTF_8_String
     (Item : Virtual_String'Class)
      return Ada.Strings.UTF_Encoding.UTF_8_String;
   --  Convert virtual string into UTF-8 encoded string.

   function To_Unbounded_UTF_8_String
     (Item : Virtual_String'Class)
      return Ada.Strings.Unbounded.Unbounded_String;
   --  Convert virtual string into UTF-8 encoded unbounded string.

   function To_Wide_Wide_String
     (Item : Virtual_String'Class) return Wide_Wide_String;
   --  Convert virtual string into Wide_Wide_String.

   function To_Unbounded_Wide_Wide_String
     (Item : Virtual_String'Class)
      return Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String;
   --  Convert virtual string into Wide_Wide_String.

   procedure Set_UTF_8_String
     (Item : Virtual_String'Class;
      Into : out Ada.Strings.UTF_Encoding.UTF_8_String);
   --  Set given Into string to content of virtual string. Length of the Into
   --  string must be equal to the length in code units of the content of the
   --  virtual string encoded in UTF-8; otherwise Constraint_Error is raised.

   procedure Set_UTF_8_String
     (Item : Virtual_String'Class;
      Last : out Natural;
      Into : out Ada.Strings.UTF_Encoding.UTF_8_String);
   --  Fill given Into string by content of virtual string. Data is written
   --  starting from the first character. Remaining length of the string
   --  must be at least the length in code units of the content of the
   --  virtual string encoded in UTF-8; otherwise Constraint_Error is raised.

   procedure Set_UTF_8_String
     (Item : Virtual_String'Class;
      From : Positive;
      Last : out Natural;
      Into : out Ada.Strings.UTF_Encoding.UTF_8_String);
   --  Fill given Into string by content of virtual string. Data is written
   --  starting From character. Remaining length of the string must be at
   --  least the length in code units of the content of the virtual string
   --  encoded in UTF-8; otherwise Constraint_Error is raised.

   procedure Set_Wide_Wide_String
     (Item : Virtual_String'Class;
      Into : out Wide_Wide_String);
   --  Set given Into string to content of virtual string. Length of the
   --  string must be equal to the length in characters of the virtual
   --  string; otherwise Constraint_Error is raised.

   procedure Set_Wide_Wide_String
     (Item : Virtual_String'Class;
      Last : out Natural;
      Into : out Wide_Wide_String);
   --  Fill given Into string by content of virtual string. Data is written
   --  starting from first character. Length of the string must be at
   --  least the length in characters of the virtual string; otherwise
   --  Constraint_Error is raised.

   procedure Set_Wide_Wide_String
     (Item : Virtual_String'Class;
      From : Positive;
      Last : out Natural;
      Into : out Wide_Wide_String);
   --  Fill given Into string by content of virtual string. Data is written
   --  starting From character. Remaining length of the string must be
   --  at least the length in characters of the virtual string; otherwise
   --  Constraint_Error is raised.

end VSS.Strings.Conversions;