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-2018, 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_Optimziations)
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 versions of System.Stream_Attributes (in particular the XDR version
64 -- found in s-stratt-xdr) which do not permit block io optimization.
66 pragma Compiler_Unit_Warning
;
70 with System
.Storage_Elements
;
72 package System
.Strings
.Stream_Ops
is
74 -------------------------------------
75 -- Storage_Array stream operations --
76 -------------------------------------
78 function Storage_Array_Input
79 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
80 return System
.Storage_Elements
.Storage_Array
;
82 function Storage_Array_Input_Blk_IO
83 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
84 return System
.Storage_Elements
.Storage_Array
;
86 procedure Storage_Array_Output
87 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
88 Item
: System
.Storage_Elements
.Storage_Array
);
90 procedure Storage_Array_Output_Blk_IO
91 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
92 Item
: System
.Storage_Elements
.Storage_Array
);
94 procedure Storage_Array_Read
95 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
96 Item
: out System
.Storage_Elements
.Storage_Array
);
98 procedure Storage_Array_Read_Blk_IO
99 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
100 Item
: out System
.Storage_Elements
.Storage_Array
);
102 procedure Storage_Array_Write
103 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
104 Item
: System
.Storage_Elements
.Storage_Array
);
106 procedure Storage_Array_Write_Blk_IO
107 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
108 Item
: System
.Storage_Elements
.Storage_Array
);
110 --------------------------------------------
111 -- Stream_Element_Array stream operations --
112 --------------------------------------------
114 function Stream_Element_Array_Input
115 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
116 return Ada
.Streams
.Stream_Element_Array
;
118 function Stream_Element_Array_Input_Blk_IO
119 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
120 return Ada
.Streams
.Stream_Element_Array
;
122 procedure Stream_Element_Array_Output
123 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
124 Item
: Ada
.Streams
.Stream_Element_Array
);
126 procedure Stream_Element_Array_Output_Blk_IO
127 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
128 Item
: Ada
.Streams
.Stream_Element_Array
);
130 procedure Stream_Element_Array_Read
131 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
132 Item
: out Ada
.Streams
.Stream_Element_Array
);
134 procedure Stream_Element_Array_Read_Blk_IO
135 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
136 Item
: out Ada
.Streams
.Stream_Element_Array
);
138 procedure Stream_Element_Array_Write
139 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
140 Item
: Ada
.Streams
.Stream_Element_Array
);
142 procedure Stream_Element_Array_Write_Blk_IO
143 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
144 Item
: Ada
.Streams
.Stream_Element_Array
);
146 ------------------------------
147 -- String stream operations --
148 ------------------------------
150 function String_Input
151 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
154 function String_Input_Blk_IO
155 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
158 function String_Input_Tag
159 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
161 -- Same as String_Input_Blk_IO, except raises an exception for overly long
162 -- Strings. See expansion of Attribute_Input in Exp_Attr for details.
164 procedure String_Output
165 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
168 procedure String_Output_Blk_IO
169 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
172 procedure String_Read
173 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
176 procedure String_Read_Blk_IO
177 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
180 procedure String_Write
181 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
184 procedure String_Write_Blk_IO
185 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
188 -----------------------------------
189 -- Wide_String stream operations --
190 -----------------------------------
192 function Wide_String_Input
193 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
196 function Wide_String_Input_Blk_IO
197 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
200 procedure Wide_String_Output
201 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
204 procedure Wide_String_Output_Blk_IO
205 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
208 procedure Wide_String_Read
209 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
210 Item
: out Wide_String);
212 procedure Wide_String_Read_Blk_IO
213 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
214 Item
: out Wide_String);
216 procedure Wide_String_Write
217 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
220 procedure Wide_String_Write_Blk_IO
221 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
224 ----------------------------------------
225 -- Wide_Wide_String stream operations --
226 ----------------------------------------
228 function Wide_Wide_String_Input
229 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
230 return Wide_Wide_String
;
232 function Wide_Wide_String_Input_Blk_IO
233 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class)
234 return Wide_Wide_String
;
236 procedure Wide_Wide_String_Output
237 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
238 Item
: Wide_Wide_String
);
240 procedure Wide_Wide_String_Output_Blk_IO
241 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
242 Item
: Wide_Wide_String
);
244 procedure Wide_Wide_String_Read
245 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
246 Item
: out Wide_Wide_String
);
248 procedure Wide_Wide_String_Read_Blk_IO
249 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
250 Item
: out Wide_Wide_String
);
252 procedure Wide_Wide_String_Write
253 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
254 Item
: Wide_Wide_String
);
256 procedure Wide_Wide_String_Write_Blk_IO
257 (Strm
: access Ada
.Streams
.Root_Stream_Type
'Class;
258 Item
: Wide_Wide_String
);
260 end System
.Strings
.Stream_Ops
;