1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- G N A T . C R C 3 2 --
9 -- Copyright (C) 2001-2010, AdaCore --
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 with Ada
.Unchecked_Conversion
;
34 package body GNAT
.CRC32
is
40 procedure Update
(C
: in out CRC32
; Value
: String) is
42 for K
in Value
'Range loop
43 Update
(C
, Value
(K
));
47 procedure Update
(C
: in out CRC32
; Value
: Ada
.Streams
.Stream_Element
) is
48 function To_Char
is new Ada
.Unchecked_Conversion
49 (Ada
.Streams
.Stream_Element
, Character);
50 V
: constant Character := To_Char
(Value
);
57 Value
: Ada
.Streams
.Stream_Element_Array
)
60 for K
in Value
'Range loop
61 Update
(C
, Value
(K
));
69 procedure Wide_Update
(C
: in out CRC32
; Value
: Wide_Character) is
70 subtype S2
is String (1 .. 2);
71 function To_S2
is new Ada
.Unchecked_Conversion
(Wide_Character, S2
);
72 VS
: constant S2
:= To_S2
(Value
);
78 procedure Wide_Update
(C
: in out CRC32
; Value
: Wide_String) is
80 for K
in Value
'Range loop
81 Wide_Update
(C
, Value
(K
));