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--                                 B o d y                                  --
8--                                                                          --
9--          Copyright (C) 2008-2018, 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
32pragma Compiler_Unit_Warning;
33
34with Ada.Streams;              use Ada.Streams;
35with Ada.Streams.Stream_IO;    use Ada.Streams.Stream_IO;
36with Ada.Unchecked_Conversion;
37
38with System;                   use System;
39with System.Storage_Elements;  use System.Storage_Elements;
40with System.Stream_Attributes;
41
42package body System.Strings.Stream_Ops is
43
44   --  The following type describes the low-level IO mechanism used in package
45   --  Stream_Ops_Internal.
46
47   type IO_Kind is (Byte_IO, Block_IO);
48
49   --  The following package provides an IO framework for strings. Depending
50   --  on the version of System.Stream_Attributes as well as the size of
51   --  formal parameter Element_Type, the package will either utilize block
52   --  IO or element-by-element IO.
53
54   generic
55      type Element_Type is private;
56      type Index_Type is range <>;
57      type Array_Type is array (Index_Type range <>) of Element_Type;
58
59   package Stream_Ops_Internal is
60      function Input
61        (Strm       : access Root_Stream_Type'Class;
62         IO         : IO_Kind;
63         Max_Length : Long_Integer := Long_Integer'Last) return Array_Type;
64      --  Raises an exception if you try to read a String that is longer than
65      --  Max_Length. See expansion of Attribute_Input in Exp_Attr for details.
66
67      procedure Output
68        (Strm : access Root_Stream_Type'Class;
69         Item : Array_Type;
70         IO   : IO_Kind);
71
72      procedure Read
73        (Strm : access Root_Stream_Type'Class;
74         Item : out Array_Type;
75         IO   : IO_Kind);
76
77      procedure Write
78        (Strm : access Root_Stream_Type'Class;
79         Item : Array_Type;
80         IO   : IO_Kind);
81   end Stream_Ops_Internal;
82
83   -------------------------
84   -- Stream_Ops_Internal --
85   -------------------------
86
87   package body Stream_Ops_Internal is
88
89      --  The following value represents the number of BITS allocated for the
90      --  default block used in string IO. The sizes of all other types are
91      --  calculated relative to this value.
92
93      Default_Block_Size : constant := 512 * 8;
94
95      --  Shorthand notation for stream element and element type sizes
96
97      ET_Size : constant Integer := Element_Type'Size;
98      SE_Size : constant Integer := Stream_Element'Size;
99
100      --  The following constants describe the number of array elements or
101      --  stream elements that can fit into a default block.
102
103      AE_In_Default_Block : constant Index_Type :=
104                              Index_Type (Default_Block_Size / ET_Size);
105      --  Number of array elements in a default block
106
107      SE_In_Default_Block : constant Integer := Default_Block_Size / SE_Size;
108      --  Number of storage elements in a default block
109
110      --  Buffer types
111
112      subtype Default_Block is Stream_Element_Array
113        (1 .. Stream_Element_Offset (SE_In_Default_Block));
114
115      subtype Array_Block is
116        Array_Type (Index_Type range 1 .. AE_In_Default_Block);
117
118      --  Conversions to and from Default_Block
119
120      function To_Default_Block is
121        new Ada.Unchecked_Conversion (Array_Block, Default_Block);
122
123      function To_Array_Block is
124        new Ada.Unchecked_Conversion (Default_Block, Array_Block);
125
126      -----------
127      -- Input --
128      -----------
129
130      function Input
131        (Strm       : access Root_Stream_Type'Class;
132         IO         : IO_Kind;
133         Max_Length : Long_Integer := Long_Integer'Last) return Array_Type
134      is
135         pragma Unsuppress (All_Checks);
136         --  The above makes T'Class'Input robust in the case of bad data. The
137         --  declaration of Item below could raise Storage_Error if the length
138         --  is too big.
139
140      begin
141         if Strm = null then
142            raise Constraint_Error;
143         end if;
144
145         declare
146            Low, High : Index_Type'Base;
147         begin
148            --  Read the bounds of the string. Note that they could be out of
149            --  range of Index_Type in the case of empty arrays.
150
151            Index_Type'Read (Strm, Low);
152            Index_Type'Read (Strm, High);
153
154            if Long_Integer (High) - Long_Integer (Low) > Max_Length then
155               raise Constraint_Error;
156            end if;
157
158            --  Read the character content of the string
159
160            declare
161               Item : Array_Type (Low .. High);
162            begin
163               Read (Strm, Item, IO);
164               return Item;
165            end;
166         end;
167      end Input;
168
169      ------------
170      -- Output --
171      ------------
172
173      procedure Output
174        (Strm : access Root_Stream_Type'Class;
175         Item : Array_Type;
176         IO   : IO_Kind)
177      is
178      begin
179         if Strm = null then
180            raise Constraint_Error;
181         end if;
182
183         --  Write the bounds of the string
184
185         Index_Type'Write (Strm, Item'First);
186         Index_Type'Write (Strm, Item'Last);
187
188         --  Write the character content of the string
189
190         Write (Strm, Item, IO);
191      end Output;
192
193      ----------
194      -- Read --
195      ----------
196
197      procedure Read
198        (Strm : access Root_Stream_Type'Class;
199         Item : out Array_Type;
200         IO   : IO_Kind)
201      is
202      begin
203         if Strm = null then
204            raise Constraint_Error;
205         end if;
206
207         --  Nothing to do if the desired string is empty
208
209         if Item'Length = 0 then
210            return;
211         end if;
212
213         --  Block IO
214
215         if IO = Block_IO and then Stream_Attributes.Block_IO_OK then
216            declare
217               --  Determine the size in BITS of the block necessary to contain
218               --  the whole string.
219
220               Block_Size : constant Natural :=
221                              Integer (Item'Last - Item'First + 1) * ET_Size;
222
223               --  Item can be larger than what the default block can store,
224               --  determine the number of whole reads necessary to read the
225               --  string.
226
227               Blocks : constant Natural := Block_Size / Default_Block_Size;
228
229               --  The size of Item may not be a multiple of the default block
230               --  size, determine the size of the remaining chunk in BITS.
231
232               Rem_Size : constant Natural :=
233                            Block_Size mod Default_Block_Size;
234
235               --  String indexes
236
237               Low  : Index_Type := Item'First;
238               High : Index_Type := Low + AE_In_Default_Block - 1;
239
240               --  End of stream error detection
241
242               Last : Stream_Element_Offset := 0;
243               Sum  : Stream_Element_Offset := 0;
244
245            begin
246               --  Step 1: If the string is too large, read in individual
247               --  chunks the size of the default block.
248
249               if Blocks > 0 then
250                  declare
251                     Block : Default_Block;
252
253                  begin
254                     for Counter in 1 .. Blocks loop
255                        Read (Strm.all, Block, Last);
256                        Item (Low .. High) := To_Array_Block (Block);
257
258                        Low  := High + 1;
259                        High := Low + AE_In_Default_Block - 1;
260                        Sum  := Sum + Last;
261                        Last := 0;
262                     end loop;
263                  end;
264               end if;
265
266               --  Step 2: Read in any remaining elements
267
268               if Rem_Size > 0 then
269                  declare
270                     subtype Rem_Block is Stream_Element_Array
271                       (1 .. Stream_Element_Offset (Rem_Size / SE_Size));
272
273                     subtype Rem_Array_Block is
274                       Array_Type (Index_Type range
275                                    1 .. Index_Type (Rem_Size / ET_Size));
276
277                     function To_Rem_Array_Block is new
278                       Ada.Unchecked_Conversion (Rem_Block, Rem_Array_Block);
279
280                     Block : Rem_Block;
281
282                  begin
283                     Read (Strm.all, Block, Last);
284                     Item (Low .. Item'Last) := To_Rem_Array_Block (Block);
285
286                     Sum := Sum + Last;
287                  end;
288               end if;
289
290               --  Step 3: Potential error detection. The sum of all the
291               --  chunks is less than we initially wanted to read. In other
292               --  words, the stream does not contain enough elements to fully
293               --  populate Item.
294
295               if (Integer (Sum) * SE_Size) / ET_Size < Item'Length then
296                  raise End_Error;
297               end if;
298            end;
299
300         --  Byte IO
301
302         else
303            declare
304               E : Element_Type;
305            begin
306               for Index in Item'First .. Item'Last loop
307                  Element_Type'Read (Strm, E);
308                  Item (Index) := E;
309               end loop;
310            end;
311         end if;
312      end Read;
313
314      -----------
315      -- Write --
316      -----------
317
318      procedure Write
319        (Strm : access Root_Stream_Type'Class;
320         Item : Array_Type;
321         IO   : IO_Kind)
322      is
323      begin
324         if Strm = null then
325            raise Constraint_Error;
326         end if;
327
328         --  Nothing to do if the input string is empty
329
330         if Item'Length = 0 then
331            return;
332         end if;
333
334         --  Block IO
335
336         if IO = Block_IO and then Stream_Attributes.Block_IO_OK then
337            declare
338               --  Determine the size in BITS of the block necessary to contain
339               --  the whole string.
340
341               Block_Size : constant Natural := Item'Length * ET_Size;
342
343               --  Item can be larger than what the default block can store,
344               --  determine the number of whole writes necessary to output the
345               --  string.
346
347               Blocks : constant Natural := Block_Size / Default_Block_Size;
348
349               --  The size of Item may not be a multiple of the default block
350               --  size, determine the size of the remaining chunk.
351
352               Rem_Size : constant Natural :=
353                            Block_Size mod Default_Block_Size;
354
355               --  String indexes
356
357               Low  : Index_Type := Item'First;
358               High : Index_Type := Low + AE_In_Default_Block - 1;
359
360            begin
361               --  Step 1: If the string is too large, write out individual
362               --  chunks the size of the default block.
363
364               for Counter in 1 .. Blocks loop
365                  Write (Strm.all, To_Default_Block (Item (Low .. High)));
366                  Low  := High + 1;
367                  High := Low + AE_In_Default_Block - 1;
368               end loop;
369
370               --  Step 2: Write out any remaining elements
371
372               if Rem_Size > 0 then
373                  declare
374                     subtype Rem_Block is Stream_Element_Array
375                       (1 .. Stream_Element_Offset (Rem_Size / SE_Size));
376
377                     subtype Rem_Array_Block is
378                       Array_Type (Index_Type range
379                                     1 .. Index_Type (Rem_Size / ET_Size));
380
381                     function To_Rem_Block is new
382                       Ada.Unchecked_Conversion (Rem_Array_Block, Rem_Block);
383
384                  begin
385                     Write (Strm.all, To_Rem_Block (Item (Low .. Item'Last)));
386                  end;
387               end if;
388            end;
389
390         --  Byte IO
391
392         else
393            for Index in Item'First .. Item'Last loop
394               Element_Type'Write (Strm, Item (Index));
395            end loop;
396         end if;
397      end Write;
398   end Stream_Ops_Internal;
399
400   --  Specific instantiations for all Ada array types handled
401
402   package Storage_Array_Ops is
403     new Stream_Ops_Internal
404       (Element_Type => Storage_Element,
405        Index_Type   => Storage_Offset,
406        Array_Type   => Storage_Array);
407
408   package Stream_Element_Array_Ops is
409     new Stream_Ops_Internal
410       (Element_Type => Stream_Element,
411        Index_Type   => Stream_Element_Offset,
412        Array_Type   => Stream_Element_Array);
413
414   package String_Ops is
415     new Stream_Ops_Internal
416       (Element_Type => Character,
417        Index_Type   => Positive,
418        Array_Type   => String);
419
420   package Wide_String_Ops is
421     new Stream_Ops_Internal
422       (Element_Type => Wide_Character,
423        Index_Type   => Positive,
424        Array_Type   => Wide_String);
425
426   package Wide_Wide_String_Ops is
427     new Stream_Ops_Internal
428       (Element_Type => Wide_Wide_Character,
429        Index_Type   => Positive,
430        Array_Type   => Wide_Wide_String);
431
432   -------------------------
433   -- Storage_Array_Input --
434   -------------------------
435
436   function Storage_Array_Input
437     (Strm : access Ada.Streams.Root_Stream_Type'Class) return Storage_Array
438   is
439   begin
440      return Storage_Array_Ops.Input (Strm, Byte_IO);
441   end Storage_Array_Input;
442
443   --------------------------------
444   -- Storage_Array_Input_Blk_IO --
445   --------------------------------
446
447   function Storage_Array_Input_Blk_IO
448     (Strm : access Ada.Streams.Root_Stream_Type'Class) return Storage_Array
449   is
450   begin
451      return Storage_Array_Ops.Input (Strm, Block_IO);
452   end Storage_Array_Input_Blk_IO;
453
454   --------------------------
455   -- Storage_Array_Output --
456   --------------------------
457
458   procedure Storage_Array_Output
459     (Strm : access Ada.Streams.Root_Stream_Type'Class;
460      Item : Storage_Array)
461   is
462   begin
463      Storage_Array_Ops.Output (Strm, Item, Byte_IO);
464   end Storage_Array_Output;
465
466   ---------------------------------
467   -- Storage_Array_Output_Blk_IO --
468   ---------------------------------
469
470   procedure Storage_Array_Output_Blk_IO
471     (Strm : access Ada.Streams.Root_Stream_Type'Class;
472      Item : Storage_Array)
473   is
474   begin
475      Storage_Array_Ops.Output (Strm, Item, Block_IO);
476   end Storage_Array_Output_Blk_IO;
477
478   ------------------------
479   -- Storage_Array_Read --
480   ------------------------
481
482   procedure Storage_Array_Read
483     (Strm : access Ada.Streams.Root_Stream_Type'Class;
484      Item : out Storage_Array)
485   is
486   begin
487      Storage_Array_Ops.Read (Strm, Item, Byte_IO);
488   end Storage_Array_Read;
489
490   -------------------------------
491   -- Storage_Array_Read_Blk_IO --
492   -------------------------------
493
494   procedure Storage_Array_Read_Blk_IO
495     (Strm : access Ada.Streams.Root_Stream_Type'Class;
496      Item : out Storage_Array)
497   is
498   begin
499      Storage_Array_Ops.Read (Strm, Item, Block_IO);
500   end Storage_Array_Read_Blk_IO;
501
502   -------------------------
503   -- Storage_Array_Write --
504   -------------------------
505
506   procedure Storage_Array_Write
507     (Strm : access Ada.Streams.Root_Stream_Type'Class;
508      Item : Storage_Array)
509   is
510   begin
511      Storage_Array_Ops.Write (Strm, Item, Byte_IO);
512   end Storage_Array_Write;
513
514   --------------------------------
515   -- Storage_Array_Write_Blk_IO --
516   --------------------------------
517
518   procedure Storage_Array_Write_Blk_IO
519     (Strm : access Ada.Streams.Root_Stream_Type'Class;
520      Item : Storage_Array)
521   is
522   begin
523      Storage_Array_Ops.Write (Strm, Item, Block_IO);
524   end Storage_Array_Write_Blk_IO;
525
526   --------------------------------
527   -- Stream_Element_Array_Input --
528   --------------------------------
529
530   function Stream_Element_Array_Input
531     (Strm : access Ada.Streams.Root_Stream_Type'Class)
532      return Stream_Element_Array
533   is
534   begin
535      return Stream_Element_Array_Ops.Input (Strm, Byte_IO);
536   end Stream_Element_Array_Input;
537
538   ---------------------------------------
539   -- Stream_Element_Array_Input_Blk_IO --
540   ---------------------------------------
541
542   function Stream_Element_Array_Input_Blk_IO
543     (Strm : access Ada.Streams.Root_Stream_Type'Class)
544      return Stream_Element_Array
545   is
546   begin
547      return Stream_Element_Array_Ops.Input (Strm, Block_IO);
548   end Stream_Element_Array_Input_Blk_IO;
549
550   ---------------------------------
551   -- Stream_Element_Array_Output --
552   ---------------------------------
553
554   procedure Stream_Element_Array_Output
555     (Strm : access Ada.Streams.Root_Stream_Type'Class;
556      Item : Stream_Element_Array)
557   is
558   begin
559      Stream_Element_Array_Ops.Output (Strm, Item, Byte_IO);
560   end Stream_Element_Array_Output;
561
562   ----------------------------------------
563   -- Stream_Element_Array_Output_Blk_IO --
564   ----------------------------------------
565
566   procedure Stream_Element_Array_Output_Blk_IO
567     (Strm : access Ada.Streams.Root_Stream_Type'Class;
568      Item : Stream_Element_Array)
569   is
570   begin
571      Stream_Element_Array_Ops.Output (Strm, Item, Block_IO);
572   end Stream_Element_Array_Output_Blk_IO;
573
574   -------------------------------
575   -- Stream_Element_Array_Read --
576   -------------------------------
577
578   procedure Stream_Element_Array_Read
579     (Strm : access Ada.Streams.Root_Stream_Type'Class;
580      Item : out Stream_Element_Array)
581   is
582   begin
583      Stream_Element_Array_Ops.Read (Strm, Item, Byte_IO);
584   end Stream_Element_Array_Read;
585
586   --------------------------------------
587   -- Stream_Element_Array_Read_Blk_IO --
588   --------------------------------------
589
590   procedure Stream_Element_Array_Read_Blk_IO
591     (Strm : access Ada.Streams.Root_Stream_Type'Class;
592      Item : out Stream_Element_Array)
593   is
594   begin
595      Stream_Element_Array_Ops.Read (Strm, Item, Block_IO);
596   end Stream_Element_Array_Read_Blk_IO;
597
598   --------------------------------
599   -- Stream_Element_Array_Write --
600   --------------------------------
601
602   procedure Stream_Element_Array_Write
603     (Strm : access Ada.Streams.Root_Stream_Type'Class;
604      Item : Stream_Element_Array)
605   is
606   begin
607      Stream_Element_Array_Ops.Write (Strm, Item, Byte_IO);
608   end Stream_Element_Array_Write;
609
610   ---------------------------------------
611   -- Stream_Element_Array_Write_Blk_IO --
612   ---------------------------------------
613
614   procedure Stream_Element_Array_Write_Blk_IO
615     (Strm : access Ada.Streams.Root_Stream_Type'Class;
616      Item : Stream_Element_Array)
617   is
618   begin
619      Stream_Element_Array_Ops.Write (Strm, Item, Block_IO);
620   end Stream_Element_Array_Write_Blk_IO;
621
622   ------------------
623   -- String_Input --
624   ------------------
625
626   function String_Input
627     (Strm : access Ada.Streams.Root_Stream_Type'Class) return String
628   is
629   begin
630      return String_Ops.Input (Strm, Byte_IO);
631   end String_Input;
632
633   -------------------------
634   -- String_Input_Blk_IO --
635   -------------------------
636
637   function String_Input_Blk_IO
638     (Strm : access Ada.Streams.Root_Stream_Type'Class) return String
639   is
640   begin
641      return String_Ops.Input (Strm, Block_IO);
642   end String_Input_Blk_IO;
643
644   -------------------------
645   -- String_Input_Tag --
646   -------------------------
647
648   function String_Input_Tag
649     (Strm : access Ada.Streams.Root_Stream_Type'Class) return String
650   is
651   begin
652      return String_Ops.Input (Strm, Block_IO, Max_Length => 10_000);
653   end String_Input_Tag;
654
655   -------------------
656   -- String_Output --
657   -------------------
658
659   procedure String_Output
660     (Strm : access Ada.Streams.Root_Stream_Type'Class;
661      Item : String)
662   is
663   begin
664      String_Ops.Output (Strm, Item, Byte_IO);
665   end String_Output;
666
667   --------------------------
668   -- String_Output_Blk_IO --
669   --------------------------
670
671   procedure String_Output_Blk_IO
672     (Strm : access Ada.Streams.Root_Stream_Type'Class;
673      Item : String)
674   is
675   begin
676      String_Ops.Output (Strm, Item, Block_IO);
677   end String_Output_Blk_IO;
678
679   -----------------
680   -- String_Read --
681   -----------------
682
683   procedure String_Read
684     (Strm : access Ada.Streams.Root_Stream_Type'Class;
685      Item : out String)
686   is
687   begin
688      String_Ops.Read (Strm, Item, Byte_IO);
689   end String_Read;
690
691   ------------------------
692   -- String_Read_Blk_IO --
693   ------------------------
694
695   procedure String_Read_Blk_IO
696     (Strm : access Ada.Streams.Root_Stream_Type'Class;
697      Item : out String)
698   is
699   begin
700      String_Ops.Read (Strm, Item, Block_IO);
701   end String_Read_Blk_IO;
702
703   ------------------
704   -- String_Write --
705   ------------------
706
707   procedure String_Write
708     (Strm : access Ada.Streams.Root_Stream_Type'Class;
709      Item : String)
710   is
711   begin
712      String_Ops.Write (Strm, Item, Byte_IO);
713   end String_Write;
714
715   -------------------------
716   -- String_Write_Blk_IO --
717   -------------------------
718
719   procedure String_Write_Blk_IO
720     (Strm : access Ada.Streams.Root_Stream_Type'Class;
721      Item : String)
722   is
723   begin
724      String_Ops.Write (Strm, Item, Block_IO);
725   end String_Write_Blk_IO;
726
727   -----------------------
728   -- Wide_String_Input --
729   -----------------------
730
731   function Wide_String_Input
732     (Strm : access Ada.Streams.Root_Stream_Type'Class) return Wide_String
733   is
734   begin
735      return Wide_String_Ops.Input (Strm, Byte_IO);
736   end Wide_String_Input;
737
738   ------------------------------
739   -- Wide_String_Input_Blk_IO --
740   ------------------------------
741
742   function Wide_String_Input_Blk_IO
743     (Strm : access Ada.Streams.Root_Stream_Type'Class) return Wide_String
744   is
745   begin
746      return Wide_String_Ops.Input (Strm, Block_IO);
747   end Wide_String_Input_Blk_IO;
748
749   ------------------------
750   -- Wide_String_Output --
751   ------------------------
752
753   procedure Wide_String_Output
754     (Strm : access Ada.Streams.Root_Stream_Type'Class;
755      Item : Wide_String)
756   is
757   begin
758      Wide_String_Ops.Output (Strm, Item, Byte_IO);
759   end Wide_String_Output;
760
761   -------------------------------
762   -- Wide_String_Output_Blk_IO --
763   -------------------------------
764
765   procedure Wide_String_Output_Blk_IO
766     (Strm : access Ada.Streams.Root_Stream_Type'Class;
767      Item : Wide_String)
768   is
769   begin
770      Wide_String_Ops.Output (Strm, Item, Block_IO);
771   end Wide_String_Output_Blk_IO;
772
773   ----------------------
774   -- Wide_String_Read --
775   ----------------------
776
777   procedure Wide_String_Read
778     (Strm : access Ada.Streams.Root_Stream_Type'Class;
779      Item : out Wide_String)
780   is
781   begin
782      Wide_String_Ops.Read (Strm, Item, Byte_IO);
783   end Wide_String_Read;
784
785   -----------------------------
786   -- Wide_String_Read_Blk_IO --
787   -----------------------------
788
789   procedure Wide_String_Read_Blk_IO
790     (Strm : access Ada.Streams.Root_Stream_Type'Class;
791      Item : out Wide_String)
792   is
793   begin
794      Wide_String_Ops.Read (Strm, Item, Block_IO);
795   end Wide_String_Read_Blk_IO;
796
797   -----------------------
798   -- Wide_String_Write --
799   -----------------------
800
801   procedure Wide_String_Write
802     (Strm : access Ada.Streams.Root_Stream_Type'Class;
803      Item : Wide_String)
804   is
805   begin
806      Wide_String_Ops.Write (Strm, Item, Byte_IO);
807   end Wide_String_Write;
808
809   ------------------------------
810   -- Wide_String_Write_Blk_IO --
811   ------------------------------
812
813   procedure Wide_String_Write_Blk_IO
814     (Strm : access Ada.Streams.Root_Stream_Type'Class;
815      Item : Wide_String)
816   is
817   begin
818      Wide_String_Ops.Write (Strm, Item, Block_IO);
819   end Wide_String_Write_Blk_IO;
820
821   ----------------------------
822   -- Wide_Wide_String_Input --
823   ----------------------------
824
825   function Wide_Wide_String_Input
826     (Strm : access Ada.Streams.Root_Stream_Type'Class) return Wide_Wide_String
827   is
828   begin
829      return Wide_Wide_String_Ops.Input (Strm, Byte_IO);
830   end Wide_Wide_String_Input;
831
832   -----------------------------------
833   -- Wide_Wide_String_Input_Blk_IO --
834   -----------------------------------
835
836   function Wide_Wide_String_Input_Blk_IO
837     (Strm : access Ada.Streams.Root_Stream_Type'Class) return Wide_Wide_String
838   is
839   begin
840      return Wide_Wide_String_Ops.Input (Strm, Block_IO);
841   end Wide_Wide_String_Input_Blk_IO;
842
843   -----------------------------
844   -- Wide_Wide_String_Output --
845   -----------------------------
846
847   procedure Wide_Wide_String_Output
848     (Strm : access Ada.Streams.Root_Stream_Type'Class;
849      Item : Wide_Wide_String)
850   is
851   begin
852      Wide_Wide_String_Ops.Output (Strm, Item, Byte_IO);
853   end Wide_Wide_String_Output;
854
855   ------------------------------------
856   -- Wide_Wide_String_Output_Blk_IO --
857   ------------------------------------
858
859   procedure Wide_Wide_String_Output_Blk_IO
860     (Strm : access Ada.Streams.Root_Stream_Type'Class;
861      Item : Wide_Wide_String)
862   is
863   begin
864      Wide_Wide_String_Ops.Output (Strm, Item, Block_IO);
865   end Wide_Wide_String_Output_Blk_IO;
866
867   ---------------------------
868   -- Wide_Wide_String_Read --
869   ---------------------------
870
871   procedure Wide_Wide_String_Read
872     (Strm : access Ada.Streams.Root_Stream_Type'Class;
873      Item : out Wide_Wide_String)
874   is
875   begin
876      Wide_Wide_String_Ops.Read (Strm, Item, Byte_IO);
877   end Wide_Wide_String_Read;
878
879   ----------------------------------
880   -- Wide_Wide_String_Read_Blk_IO --
881   ----------------------------------
882
883   procedure Wide_Wide_String_Read_Blk_IO
884     (Strm : access Ada.Streams.Root_Stream_Type'Class;
885      Item : out Wide_Wide_String)
886   is
887   begin
888      Wide_Wide_String_Ops.Read (Strm, Item, Block_IO);
889   end Wide_Wide_String_Read_Blk_IO;
890
891   ----------------------------
892   -- Wide_Wide_String_Write --
893   ----------------------------
894
895   procedure Wide_Wide_String_Write
896     (Strm : access Ada.Streams.Root_Stream_Type'Class;
897      Item : Wide_Wide_String)
898   is
899   begin
900      Wide_Wide_String_Ops.Write (Strm, Item, Byte_IO);
901   end Wide_Wide_String_Write;
902
903   -----------------------------------
904   -- Wide_Wide_String_Write_Blk_IO --
905   -----------------------------------
906
907   procedure Wide_Wide_String_Write_Blk_IO
908     (Strm : access Ada.Streams.Root_Stream_Type'Class;
909      Item : Wide_Wide_String)
910   is
911   begin
912      Wide_Wide_String_Ops.Write (Strm, Item, Block_IO);
913   end Wide_Wide_String_Write_Blk_IO;
914
915end System.Strings.Stream_Ops;
916