1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . T E X T _ I O . B O U N D E D _ I O --
9 -- Copyright (C) 1997-2005, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 with Ada.Text_IO; use Ada.Text_IO;
35 with Ada.Unchecked_Deallocation;
37 package body Ada.Text_IO.Bounded_IO is
39 type String_Access is access all String;
41 procedure Free (SA : in out String_Access);
42 -- Perform an unchecked deallocation of a non-null string
48 procedure Free (SA : in out String_Access) is
49 Null_String : constant String := "";
51 procedure Deallocate is
52 new Ada.Unchecked_Deallocation (String, String_Access);
55 -- Do not try to free statically allocated null string
57 if SA.all /= Null_String then
66 function Get_Line return Bounded.Bounded_String is
68 return Bounded.To_Bounded_String (Get_Line);
76 (File : File_Type) return Bounded.Bounded_String
79 return Bounded.To_Bounded_String (Get_Line (File));
87 (Item : out Bounded.Bounded_String)
89 Buffer : String (1 .. 1000);
95 Get_Line (Buffer, Last);
96 Str1 := new String'(Buffer (1 .. Last));
98 while Last = Buffer'Last loop
99 Get_Line (Buffer, Last);
100 Str2 := new String'(Str1.all & Buffer (1 .. Last));
105 Item := Bounded.To_Bounded_String (Str1.all);
114 Item : out Bounded.Bounded_String)
116 Buffer : String (1 .. 1000);
118 Str1 : String_Access;
119 Str2 : String_Access;
122 Get_Line (File, Buffer, Last);
123 Str1 := new String'(Buffer (1 .. Last));
125 while Last = Buffer'Last loop
126 Get_Line (File, Buffer, Last);
127 Str2 := new String'(Str1.all & Buffer (1 .. Last));
132 Item := Bounded.To_Bounded_String (Str1.all);
140 (Item : Bounded.Bounded_String)
143 Put (Bounded.To_String (Item));
152 Item : Bounded.Bounded_String)
155 Put (File, Bounded.To_String (Item));
163 (Item : Bounded.Bounded_String)
166 Put_Line (Bounded.To_String (Item));
175 Item : Bounded.Bounded_String)
178 Put_Line (File, Bounded.To_String (Item));
181 end Ada.Text_IO.Bounded_IO;