1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . S T R I N G S . S T R E A M _ O P S --
9 -- Copyright (C) 2009-2023, 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 -- This package provides subprogram implementations of stream attributes for
33 -- the following types using a "block IO" approach in which the entire data
34 -- item is written in one operation, instead of writing individual characters.
36 -- Ada.Stream_Element_Array
39 -- Ada.Wide_Wide_String
40 -- System.Storage_Array
42 -- Note: this routine is in Ada.Strings because historically it handled only
43 -- the string types. It is not worth moving it at this stage.
45 -- The compiler will generate references to the subprograms in this package
46 -- when expanding stream attributes for the above mentioned types. Example:
48 -- String'Output (Some_Stream, Some_String);
50 -- will be expanded into:
52 -- String_Output (Some_Stream, Some_String);
54 -- String_Output_Blk_IO (Some_Stream, Some_String);
56 -- String_Output form is used if pragma Restrictions (No_String_Optimizations)
57 -- is active, which requires element by element operations. The BLK_IO form
58 -- is used if this restriction is not set, allowing block optimization.
60 -- Note that if System.Stream_Attributes.Block_IO_OK is False, then the BLK_IO
61 -- form is treated as equivalent to the normal case, so that the optimization
62 -- is inhibited anyway, regardless of the setting of the restriction. This
63 -- handles the XDR implementation of System.Stream_Attributes in particular
64 -- which does not permit block io optimization.
68 with System
.Storage_Elements
;
70 package System
.Strings
.Stream_Ops
is
72 -------------------------------------
73 -- Storage_Array stream operations --
74 -------------------------------------
76 function Storage_Array_Input
77 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
78 return System
.Storage_Elements
.Storage_Array
;
80 function Storage_Array_Input_Blk_IO
81 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
82 return System
.Storage_Elements
.Storage_Array
;
84 procedure Storage_Array_Output
85 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
86 Item
: System
.Storage_Elements
.Storage_Array
);
88 procedure Storage_Array_Output_Blk_IO
89 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
90 Item
: System
.Storage_Elements
.Storage_Array
);
92 procedure Storage_Array_Read
93 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
94 Item
: out System
.Storage_Elements
.Storage_Array
);
96 procedure Storage_Array_Read_Blk_IO
97 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
98 Item
: out System
.Storage_Elements
.Storage_Array
);
100 procedure Storage_Array_Write
101 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
102 Item
: System
.Storage_Elements
.Storage_Array
);
104 procedure Storage_Array_Write_Blk_IO
105 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
106 Item
: System
.Storage_Elements
.Storage_Array
);
108 --------------------------------------------
109 -- Stream_Element_Array stream operations --
110 --------------------------------------------
112 function Stream_Element_Array_Input
113 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
114 return Ada
.Streams
.Stream_Element_Array
;
116 function Stream_Element_Array_Input_Blk_IO
117 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
118 return Ada
.Streams
.Stream_Element_Array
;
120 procedure Stream_Element_Array_Output
121 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
122 Item
: Ada
.Streams
.Stream_Element_Array
);
124 procedure Stream_Element_Array_Output_Blk_IO
125 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
126 Item
: Ada
.Streams
.Stream_Element_Array
);
128 procedure Stream_Element_Array_Read
129 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
130 Item
: out Ada
.Streams
.Stream_Element_Array
);
132 procedure Stream_Element_Array_Read_Blk_IO
133 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
134 Item
: out Ada
.Streams
.Stream_Element_Array
);
136 procedure Stream_Element_Array_Write
137 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
138 Item
: Ada
.Streams
.Stream_Element_Array
);
140 procedure Stream_Element_Array_Write_Blk_IO
141 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
142 Item
: Ada
.Streams
.Stream_Element_Array
);
144 ------------------------------
145 -- String stream operations --
146 ------------------------------
148 function String_Input
149 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
152 function String_Input_Blk_IO
153 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
156 function String_Input_Tag
157 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
159 -- Same as String_Input_Blk_IO, except raises an exception for overly long
160 -- Strings. See expansion of Attribute_Input in Exp_Attr for details.
162 procedure String_Output
163 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
166 procedure String_Output_Blk_IO
167 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
170 procedure String_Read
171 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
174 procedure String_Read_Blk_IO
175 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
178 procedure String_Write
179 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
182 procedure String_Write_Blk_IO
183 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
186 -----------------------------------
187 -- Wide_String stream operations --
188 -----------------------------------
190 function Wide_String_Input
191 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
194 function Wide_String_Input_Blk_IO
195 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
198 procedure Wide_String_Output
199 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
202 procedure Wide_String_Output_Blk_IO
203 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
206 procedure Wide_String_Read
207 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
208 Item
: out Wide_String);
210 procedure Wide_String_Read_Blk_IO
211 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
212 Item
: out Wide_String);
214 procedure Wide_String_Write
215 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
218 procedure Wide_String_Write_Blk_IO
219 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
222 ----------------------------------------
223 -- Wide_Wide_String stream operations --
224 ----------------------------------------
226 function Wide_Wide_String_Input
227 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
228 return Wide_Wide_String
;
230 function Wide_Wide_String_Input_Blk_IO
231 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
232 return Wide_Wide_String
;
234 procedure Wide_Wide_String_Output
235 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
236 Item
: Wide_Wide_String
);
238 procedure Wide_Wide_String_Output_Blk_IO
239 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
240 Item
: Wide_Wide_String
);
242 procedure Wide_Wide_String_Read
243 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
244 Item
: out Wide_Wide_String
);
246 procedure Wide_Wide_String_Read_Blk_IO
247 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
248 Item
: out Wide_Wide_String
);
250 procedure Wide_Wide_String_Write
251 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
252 Item
: Wide_Wide_String
);
254 procedure Wide_Wide_String_Write_Blk_IO
255 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
256 Item
: Wide_Wide_String
);
258 end System
.Strings
.Stream_Ops
;