asis_2019.0.0_3ca32fa2/tools/gnat2xml/test/strings_edit.adb

  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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
--                                                                    --
--  package Strings_Edit            Copyright (c)  Dmitry A. Kazakov  --
--  Implementation                                 Luebeck            --
--                                                 Spring, 2000       --
--                                                                    --
--                                Last revision :  10:11 25 Jun 2005  --
--                                                                    --
--  This  library  is  free software; you can redistribute it and/or  --
--  modify it under the terms of the GNU General Public  License  as  --
--  published by the Free Software Foundation; either version  2  of  --
--  the License, or (at your option) any later version. This library  --
--  is distributed in the hope that it will be useful,  but  WITHOUT  --
--  ANY   WARRANTY;   without   even   the   implied   warranty   of  --
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  --
--  General  Public  License  for  more  details.  You  should  have  --
--  received  a  copy  of  the GNU General Public License along with  --
--  this library; if not, write to  the  Free  Software  Foundation,  --
--  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.    --
--                                                                    --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--____________________________________________________________________--

with Ada.IO_Exceptions;  use Ada.IO_Exceptions;

package body Strings_Edit is
   function GetDigit (Symbol : Character) return Natural is
   begin
      case Symbol is
         when '0' => return 0;
         when '1' => return 1;
         when '2' => return 2;
         when '3' => return 3;
         when '4' => return 4;
         when '5' => return 5;
         when '6' => return 6;
         when '7' => return 7;
         when '8' => return 8;
         when '9' => return 9;
         when 'A' | 'a' => return 10;
         when 'B' | 'b' => return 11;
         when 'C' | 'c' => return 12;
         when 'D' | 'd' => return 13;
         when 'E' | 'e' => return 14;
         when 'F' | 'f' => return 15;
         when others => return 16;
      end case;
   end GetDigit;
--
-- Text_Edit
--
-- This is an internal package containing  implementation  of  all  text
-- editing subprograms. 
--
   package Text_Edit is
      function TrimCharacter
               (  Source : in String;
                  Blank  : in Character := ' '
               )  return String; 
      function TrimSet
               (  Source : in String;
                  Blanks : in Ada.Strings.Maps.Character_Set
               )  return String;
      procedure GetCharacter
                (  Source  : in String;
                   Pointer : in out Integer;
                   Blank   : in Character := ' '
                );
      procedure GetSet
                (  Source  : in String;
                   Pointer : in out Integer;
                   Blanks  : in Ada.Strings.Maps. Character_Set
                );
      procedure PutString
                (  Destination : in out String;
                   Pointer     : in out Integer;
                   Value       : in String;
                   Field       : in Natural := 0;
                   Justify     : in Alignment := Left;
                   Fill        : in Character := ' '
                );
      procedure PutCharacter
                (  Destination : in out String;
                   Pointer     : in out Integer;
                   Value       : in Character;
                   Field       : in Natural := 0;
                   Justify     : in Alignment := Left;
                   Fill        : in Character := ' '
                );
   end Text_Edit;
   package body Text_Edit is separate;

   function Trim
            (  Source : in String;
               Blank  : in Character := ' '
            )  return String renames Text_Edit.TrimCharacter;
   function Trim
            (  Source : in String;
               Blanks : in Ada.Strings.Maps.Character_Set
            )  return String renames Text_Edit.TrimSet;
   procedure Get
             (  Source  : in String;
                Pointer : in out Integer;
                Blank   : in Character := ' '
             )  renames Text_Edit.GetCharacter;
   procedure Get
             (  Source  : in String;
                Pointer : in out Integer;
                Blanks  : in Ada.Strings.Maps. Character_Set
             )  renames Text_Edit.GetSet;
   procedure Put
             (  Destination : in out String;
                Pointer     : in out Integer;
                Value       : in String;
                Field       : in Natural   := 0;
                Justify     : in Alignment := Left;
                Fill        : in Character := ' '
             )  renames Text_Edit.PutString;
   procedure Put
             (  Destination : in out String;
                Pointer     : in out Integer;
                Value       : in Character;
                Field       : in Natural   := 0;
                Justify     : in Alignment := Left;
                Fill        : in Character := ' '
             )  renames Text_Edit.PutCharacter;

end Strings_Edit;