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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
use type Ada.Streams.Stream_Element_Offset;
-----------------------
-- Bit Manipulations --
-----------------------
function Low_6 (Byte : in Character) return Base_64_Digit
is (Character'Pos (Byte) mod 64);
is (Base_64_Digit (Natural (Character'Pos (Byte)) mod 64));
function Low_4 (Byte : in Character) return Single_Byte_Padding
is (Character'Pos (Byte) mod 16);
is (Single_Byte_Padding (Natural (Character'Pos (Byte)) mod 16));
function Low_2 (Byte : in Character) return Double_Byte_Padding
is (Character'Pos (Byte) mod 4);
is (Double_Byte_Padding (Natural (Character'Pos (Byte)) mod 4));
-- Least significant bits of a byte
function High_6 (Byte : in Character) return Base_64_Digit
is (Character'Pos (Byte) / 4);
is (Base_64_Digit (Natural (Character'Pos (Byte)) / 4));
function High_4 (Byte : in Character) return Single_Byte_Padding
is (Character'Pos (Byte) / 16);
is (Single_Byte_Padding (Natural (Character'Pos (Byte)) / 16));
function High_2 (Byte : in Character) return Double_Byte_Padding
is (Character'Pos (Byte) / 64);
is (Double_Byte_Padding (Natural (Character'Pos (Byte)) / 64));
-- Most significant bits of a byte
function Image_2_4 (Low : Double_Byte_Padding; High : Single_Byte_Padding)
return Base_64_Symbol
is (Image (Low + High * 4));
function Image_4_2 (Low : Single_Byte_Padding; High : Double_Byte_Padding)
return Base_64_Symbol
|