1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . W I D E _ T E X T _ I O . W I D E _ B O U N D E D _ I O --
9 -- Copyright (C) 1997-2024, 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 3, 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. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with Ada
.Unchecked_Deallocation
;
34 package body Ada
.Wide_Text_IO
.Wide_Bounded_IO
is
36 type Wide_String_Access
is access all Wide_String;
38 procedure Free
(WSA
: in out Wide_String_Access
);
39 -- Perform an unchecked deallocation of a non-null string
45 procedure Free
(WSA
: in out Wide_String_Access
) is
46 Null_Wide_String
: constant Wide_String := "";
48 procedure Deallocate
is
49 new Ada
.Unchecked_Deallocation
(Wide_String, Wide_String_Access
);
52 -- Do not try to free statically allocated null string
54 if WSA
.all /= Null_Wide_String
then
63 function Get_Line
return Wide_Bounded
.Bounded_Wide_String
is
65 return Wide_Bounded
.To_Bounded_Wide_String
(Get_Line
);
73 (File
: File_Type
) return Wide_Bounded
.Bounded_Wide_String
76 return Wide_Bounded
.To_Bounded_Wide_String
(Get_Line
(File
));
84 (Item
: out Wide_Bounded
.Bounded_Wide_String
)
86 Buffer
: Wide_String (1 .. 1000);
88 Str1
: Wide_String_Access
;
89 Str2
: Wide_String_Access
;
92 Get_Line
(Buffer
, Last
);
93 Str1
:= new Wide_String'(Buffer (1 .. Last));
95 while Last = Buffer'Last loop
96 Get_Line (Buffer, Last);
97 Str2 := new Wide_String'(Str1
.all & Buffer
(1 .. Last
));
102 Item
:= Wide_Bounded
.To_Bounded_Wide_String
(Str1
.all);
111 Item
: out Wide_Bounded
.Bounded_Wide_String
)
113 Buffer
: Wide_String (1 .. 1000);
115 Str1
: Wide_String_Access
;
116 Str2
: Wide_String_Access
;
119 Get_Line
(File
, Buffer
, Last
);
120 Str1
:= new Wide_String'(Buffer (1 .. Last));
122 while Last = Buffer'Last loop
123 Get_Line (File, Buffer, Last);
124 Str2 := new Wide_String'(Str1
.all & Buffer
(1 .. Last
));
129 Item
:= Wide_Bounded
.To_Bounded_Wide_String
(Str1
.all);
137 (Item
: Wide_Bounded
.Bounded_Wide_String
)
140 Put
(Wide_Bounded
.To_Wide_String
(Item
));
149 Item
: Wide_Bounded
.Bounded_Wide_String
)
152 Put
(File
, Wide_Bounded
.To_Wide_String
(Item
));
160 (Item
: Wide_Bounded
.Bounded_Wide_String
)
163 Put_Line
(Wide_Bounded
.To_Wide_String
(Item
));
172 Item
: Wide_Bounded
.Bounded_Wide_String
)
175 Put_Line
(File
, Wide_Bounded
.To_Wide_String
(Item
));
178 end Ada
.Wide_Text_IO
.Wide_Bounded_IO
;