| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- S Y S T E M . S T R I N G S . S T R E A M _ O P S -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 2009-2025, Free Software Foundation, Inc. -- |
| 10 |
-- -- |
| 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. -- |
| 17 |
-- -- |
| 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. -- |
| 21 |
-- -- |
| 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/>. -- |
| 26 |
-- -- |
| 27 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 28 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 29 |
-- -- |
| 30 |
------------------------------------------------------------------------------ |
| 31 |
|
| 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. |
| 35 |
|
| 36 |
-- Ada.Stream_Element_Array |
| 37 |
-- Ada.String |
| 38 |
-- Ada.Wide_String |
| 39 |
-- Ada.Wide_Wide_String |
| 40 |
-- System.Storage_Array |
| 41 |
|
| 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. |
| 44 |
|
| 45 |
-- The compiler will generate references to the subprograms in this package |
| 46 |
-- when expanding stream attributes for the above mentioned types. Example: |
| 47 |
|
| 48 |
-- String'Output (Some_Stream, Some_String); |
| 49 |
|
| 50 |
-- will be expanded into: |
| 51 |
|
| 52 |
-- String_Output (Some_Stream, Some_String); |
| 53 |
-- or |
| 54 |
-- String_Output_Blk_IO (Some_Stream, Some_String); |
| 55 |
|
| 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. |
| 59 |
|
| 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. |
| 65 |
|
| 66 |
with Ada.Streams; |
| 67 |
|
| 68 |
with System.Storage_Elements; |
| 69 |
|
| 70 |
package System.Strings.Stream_Ops is |
| 71 |
|
| 72 |
------------------------------------- |
| 73 |
-- Storage_Array stream operations -- |
| 74 |
------------------------------------- |
| 75 |
|
| 76 |
function Storage_Array_Input |
| 77 |
(Strm : access Ada.Streams.Root_Stream_Type'Class) |
| 78 |
return System.Storage_Elements.Storage_Array; |
| 79 |
|
| 80 |
function Storage_Array_Input_Blk_IO |
| 81 |
(Strm : access Ada.Streams.Root_Stream_Type'Class) |
| 82 |
return System.Storage_Elements.Storage_Array; |
| 83 |
|
| 84 |
procedure Storage_Array_Output |
| 85 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 86 |
Item : System.Storage_Elements.Storage_Array); |
| 87 |
|
| 88 |
procedure Storage_Array_Output_Blk_IO |
| 89 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 90 |
Item : System.Storage_Elements.Storage_Array); |
| 91 |
|
| 92 |
procedure Storage_Array_Read |
| 93 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 94 |
Item : out System.Storage_Elements.Storage_Array); |
| 95 |
|
| 96 |
procedure Storage_Array_Read_Blk_IO |
| 97 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 98 |
Item : out System.Storage_Elements.Storage_Array); |
| 99 |
|
| 100 |
procedure Storage_Array_Write |
| 101 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 102 |
Item : System.Storage_Elements.Storage_Array); |
| 103 |
|
| 104 |
procedure Storage_Array_Write_Blk_IO |
| 105 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 106 |
Item : System.Storage_Elements.Storage_Array); |
| 107 |
|
| 108 |
-------------------------------------------- |
| 109 |
-- Stream_Element_Array stream operations -- |
| 110 |
-------------------------------------------- |
| 111 |
|
| 112 |
function Stream_Element_Array_Input |
| 113 |
(Strm : access Ada.Streams.Root_Stream_Type'Class) |
| 114 |
return Ada.Streams.Stream_Element_Array; |
| 115 |
|
| 116 |
function Stream_Element_Array_Input_Blk_IO |
| 117 |
(Strm : access Ada.Streams.Root_Stream_Type'Class) |
| 118 |
return Ada.Streams.Stream_Element_Array; |
| 119 |
|
| 120 |
procedure Stream_Element_Array_Output |
| 121 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 122 |
Item : Ada.Streams.Stream_Element_Array); |
| 123 |
|
| 124 |
procedure Stream_Element_Array_Output_Blk_IO |
| 125 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 126 |
Item : Ada.Streams.Stream_Element_Array); |
| 127 |
|
| 128 |
procedure Stream_Element_Array_Read |
| 129 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 130 |
Item : out Ada.Streams.Stream_Element_Array); |
| 131 |
|
| 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); |
| 135 |
|
| 136 |
procedure Stream_Element_Array_Write |
| 137 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 138 |
Item : Ada.Streams.Stream_Element_Array); |
| 139 |
|
| 140 |
procedure Stream_Element_Array_Write_Blk_IO |
| 141 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 142 |
Item : Ada.Streams.Stream_Element_Array); |
| 143 |
|
| 144 |
------------------------------ |
| 145 |
-- String stream operations -- |
| 146 |
------------------------------ |
| 147 |
|
| 148 |
function String_Input |
| 149 |
(Strm : access Ada.Streams.Root_Stream_Type'Class) |
| 150 |
return String; |
| 151 |
|
| 152 |
function String_Input_Blk_IO |
| 153 |
(Strm : access Ada.Streams.Root_Stream_Type'Class) |
| 154 |
return String; |
| 155 |
|
| 156 |
function String_Input_Tag |
| 157 |
(Strm : access Ada.Streams.Root_Stream_Type'Class) |
| 158 |
return String; |
| 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. |
| 161 |
|
| 162 |
procedure String_Output |
| 163 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 164 |
Item : String); |
| 165 |
|
| 166 |
procedure String_Output_Blk_IO |
| 167 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 168 |
Item : String); |
| 169 |
|
| 170 |
procedure String_Read |
| 171 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 172 |
Item : out String); |
| 173 |
|
| 174 |
procedure String_Read_Blk_IO |
| 175 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 176 |
Item : out String); |
| 177 |
|
| 178 |
procedure String_Write |
| 179 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 180 |
Item : String); |
| 181 |
|
| 182 |
procedure String_Write_Blk_IO |
| 183 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 184 |
Item : String); |
| 185 |
|
| 186 |
----------------------------------- |
| 187 |
-- Wide_String stream operations -- |
| 188 |
----------------------------------- |
| 189 |
|
| 190 |
function Wide_String_Input |
| 191 |
(Strm : access Ada.Streams.Root_Stream_Type'Class) |
| 192 |
return Wide_String; |
| 193 |
|
| 194 |
function Wide_String_Input_Blk_IO |
| 195 |
(Strm : access Ada.Streams.Root_Stream_Type'Class) |
| 196 |
return Wide_String; |
| 197 |
|
| 198 |
procedure Wide_String_Output |
| 199 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 200 |
Item : Wide_String); |
| 201 |
|
| 202 |
procedure Wide_String_Output_Blk_IO |
| 203 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 204 |
Item : Wide_String); |
| 205 |
|
| 206 |
procedure Wide_String_Read |
| 207 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 208 |
Item : out Wide_String); |
| 209 |
|
| 210 |
procedure Wide_String_Read_Blk_IO |
| 211 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 212 |
Item : out Wide_String); |
| 213 |
|
| 214 |
procedure Wide_String_Write |
| 215 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 216 |
Item : Wide_String); |
| 217 |
|
| 218 |
procedure Wide_String_Write_Blk_IO |
| 219 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 220 |
Item : Wide_String); |
| 221 |
|
| 222 |
---------------------------------------- |
| 223 |
-- Wide_Wide_String stream operations -- |
| 224 |
---------------------------------------- |
| 225 |
|
| 226 |
function Wide_Wide_String_Input |
| 227 |
(Strm : access Ada.Streams.Root_Stream_Type'Class) |
| 228 |
return Wide_Wide_String; |
| 229 |
|
| 230 |
function Wide_Wide_String_Input_Blk_IO |
| 231 |
(Strm : access Ada.Streams.Root_Stream_Type'Class) |
| 232 |
return Wide_Wide_String; |
| 233 |
|
| 234 |
procedure Wide_Wide_String_Output |
| 235 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 236 |
Item : Wide_Wide_String); |
| 237 |
|
| 238 |
procedure Wide_Wide_String_Output_Blk_IO |
| 239 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 240 |
Item : Wide_Wide_String); |
| 241 |
|
| 242 |
procedure Wide_Wide_String_Read |
| 243 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 244 |
Item : out Wide_Wide_String); |
| 245 |
|
| 246 |
procedure Wide_Wide_String_Read_Blk_IO |
| 247 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 248 |
Item : out Wide_Wide_String); |
| 249 |
|
| 250 |
procedure Wide_Wide_String_Write |
| 251 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 252 |
Item : Wide_Wide_String); |
| 253 |
|
| 254 |
procedure Wide_Wide_String_Write_Blk_IO |
| 255 |
(Strm : access Ada.Streams.Root_Stream_Type'Class; |
| 256 |
Item : Wide_Wide_String); |
| 257 |
|
| 258 |
end System.Strings.Stream_Ops; |