1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT RUN-TIME COMPONENTS                         --
4--                                                                          --
5--              A D A . C H A R A C T E R S . H A N D L I N G               --
6--                                                                          --
7--                                 S p e c                                  --
8--                                                                          --
9--          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
10--                                                                          --
11-- This specification is derived from the Ada Reference Manual for use with --
12-- GNAT. The copyright notice above, and the license provisions that follow --
13-- apply solely to the  contents of the part following the private keyword. --
14--                                                                          --
15-- GNAT is free software;  you can  redistribute it  and/or modify it under --
16-- terms of the  GNU General Public License as published  by the Free Soft- --
17-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
18-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
19-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
20-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
21--                                                                          --
22-- As a special exception under Section 7 of GPL version 3, you are granted --
23-- additional permissions described in the GCC Runtime Library Exception,   --
24-- version 3.1, as published by the Free Software Foundation.               --
25--                                                                          --
26-- You should have received a copy of the GNU General Public License and    --
27-- a copy of the GCC Runtime Library Exception along with this program;     --
28-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
29-- <http://www.gnu.org/licenses/>.                                          --
30--                                                                          --
31-- GNAT was originally developed  by the GNAT team at  New York University. --
32-- Extensive contributions were provided by Ada Core Technologies Inc.      --
33--                                                                          --
34------------------------------------------------------------------------------
35
36package Ada.Characters.Handling is
37   pragma Preelaborate;
38   pragma Pure_05;
39   --  In accordance with Ada 2005 AI-362
40
41   ----------------------------------------
42   -- Character Classification Functions --
43   ----------------------------------------
44
45   function Is_Control               (Item : Character) return Boolean;
46   function Is_Graphic               (Item : Character) return Boolean;
47   function Is_Letter                (Item : Character) return Boolean;
48   function Is_Lower                 (Item : Character) return Boolean;
49   function Is_Upper                 (Item : Character) return Boolean;
50   function Is_Basic                 (Item : Character) return Boolean;
51   function Is_Digit                 (Item : Character) return Boolean;
52   function Is_Decimal_Digit         (Item : Character) return Boolean
53     renames Is_Digit;
54   function Is_Hexadecimal_Digit     (Item : Character) return Boolean;
55   function Is_Alphanumeric          (Item : Character) return Boolean;
56   function Is_Special               (Item : Character) return Boolean;
57   function Is_Line_Terminator       (Item : Character) return Boolean;
58   function Is_Mark                  (Item : Character) return Boolean;
59   function Is_Other_Format          (Item : Character) return Boolean;
60   function Is_Punctuation_Connector (Item : Character) return Boolean;
61   function Is_Space                 (Item : Character) return Boolean;
62
63   ---------------------------------------------------
64   -- Conversion Functions for Character and String --
65   ---------------------------------------------------
66
67   function To_Lower (Item : Character) return Character;
68   function To_Upper (Item : Character) return Character;
69   function To_Basic (Item : Character) return Character;
70
71   function To_Lower (Item : String) return String;
72   function To_Upper (Item : String) return String;
73   function To_Basic (Item : String) return String;
74
75   ----------------------------------------------------------------------
76   -- Classifications of and Conversions Between Character and ISO 646 --
77   ----------------------------------------------------------------------
78
79   subtype ISO_646 is
80     Character range Character'Val (0) .. Character'Val (127);
81
82   function Is_ISO_646 (Item : Character) return Boolean;
83   function Is_ISO_646 (Item : String)    return Boolean;
84
85   function To_ISO_646
86     (Item       : Character;
87      Substitute : ISO_646 := ' ') return ISO_646;
88
89   function To_ISO_646
90     (Item       : String;
91      Substitute : ISO_646 := ' ') return String;
92
93   ------------------------------------------------------
94   -- Classifications of Wide_Character and Characters --
95   ------------------------------------------------------
96
97   --  Ada 2005 AI 395: these functions are moved to Ada.Characters.Conversions
98   --  and are considered obsolete in Ada.Characters.Handling. However we do
99   --  not complain about this obsolescence, since in practice it is necessary
100   --  to use these routines when creating code that is intended to run in
101   --  either Ada 95 or Ada 2005 mode.
102
103   --  We do however have to flag these if the pragma No_Obsolescent_Features
104   --  restriction is active (see Restrict.Check_Obsolescent_2005_Entity).
105
106   function Is_Character (Item : Wide_Character) return Boolean;
107   function Is_String    (Item : Wide_String)    return Boolean;
108
109   ------------------------------------------------------
110   -- Conversions between Wide_Character and Character --
111   ------------------------------------------------------
112
113   --  Ada 2005 AI 395: these functions are moved to Ada.Characters.Conversions
114   --  and are considered obsolete in Ada.Characters.Handling. However we do
115   --  not complain about this obsolescence, since in practice it is necessary
116   --  to use these routines when creating code that is intended to run in
117   --  either Ada 95 or Ada 2005 mode.
118
119   --  We do however have to flag these if the pragma No_Obsolescent_Features
120   --  restriction is active (see Restrict.Check_Obsolescent_2005_Entity).
121
122   function To_Character
123     (Item       : Wide_Character;
124      Substitute : Character := ' ') return Character;
125
126   function To_String
127     (Item       : Wide_String;
128      Substitute : Character := ' ') return String;
129
130   function To_Wide_Character
131     (Item : Character) return Wide_Character;
132
133   function To_Wide_String
134     (Item : String) return Wide_String;
135
136private
137   pragma Inline (Is_Alphanumeric);
138   pragma Inline (Is_Basic);
139   pragma Inline (Is_Character);
140   pragma Inline (Is_Control);
141   pragma Inline (Is_Digit);
142   pragma Inline (Is_Graphic);
143   pragma Inline (Is_Hexadecimal_Digit);
144   pragma Inline (Is_ISO_646);
145   pragma Inline (Is_Letter);
146   pragma Inline (Is_Line_Terminator);
147   pragma Inline (Is_Lower);
148   pragma Inline (Is_Mark);
149   pragma Inline (Is_Other_Format);
150   pragma Inline (Is_Punctuation_Connector);
151   pragma Inline (Is_Space);
152   pragma Inline (Is_Special);
153   pragma Inline (Is_Upper);
154   pragma Inline (To_Basic);
155   pragma Inline (To_Character);
156   pragma Inline (To_Lower);
157   pragma Inline (To_Upper);
158   pragma Inline (To_Wide_Character);
159
160end Ada.Characters.Handling;
161