File: uconv.adb

package info (click to toggle)
libaws 2.2dfsg-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 7,624 kB
  • ctags: 1,173
  • sloc: ada: 61,829; ansic: 6,483; makefile: 1,282; xml: 196; sh: 119; java: 112; python: 66; sed: 40
file content (47 lines) | stat: -rw-r--r-- 1,389 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

--  Test availability of the Unchecked_Conversion between
--  Stream_Element_Array and String

with Ada.Unchecked_Conversion;
with Ada.Streams; use Ada.Streams;
with Ada.Text_IO;
with Ada.Command_Line;

procedure Uconv is

   Sample : constant String :=
      "$Author: obry $" & ASCII.LF &
      "$Date: 2005/12/17 16:39:46 $" & ASCII.LF &
      "$Name: release_2_2 $" & ASCII.LF &
      "$Locker:  $" & ASCII.LF &
      "$RCSfile: uconv.adb,v $" & ASCII.LF &
      "$Revision: 1.6 $" & ASCII.LF &
      "$Source: /anoncvs/AWS/workspace/uconv.adb,v $" & ASCII.LF &
      "$State: Exp $" & ASCII.LF;

   subtype Fixed_String is String (Sample'First .. Sample'Last);

   subtype Fixed_Array is Stream_Element_Array
     (Stream_Element_Offset (Sample'First)
      .. Stream_Element_Offset (Sample'Last));

   function To_Stream_Elements is
     new Ada.Unchecked_Conversion (Fixed_String, Fixed_Array);

   function To_String is
     new Ada.Unchecked_Conversion (Fixed_Array, Fixed_String);

begin
   if Fixed_Array'Size = Fixed_String'Size
   and then Fixed_Array'Alignment = Fixed_String'Alignment
   and then Sample = To_String (To_Stream_Elements (Sample)) then
      Ada.Text_IO.Put_Line ("Use fast.");
   else
      Ada.Text_IO.Put_Line ("Use portable.");
      declare
         use Ada.Command_Line;
      begin
         Set_Exit_Status (Failure);
      end;
   end if;
end Uconv;