-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings_edit-utf8-integer_edit.ads
More file actions
167 lines (166 loc) · 6.85 KB
/
strings_edit-utf8-integer_edit.ads
File metadata and controls
167 lines (166 loc) · 6.85 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
-- --
-- package Copyright (c) Dmitry A. Kazakov --
-- Strings_Edit.UTF8. Luebeck --
-- Integer_Edit Spring, 2005 --
-- Interface --
-- Last revision : 21:03 21 Apr 2009 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
--
-- This generic package is the parent for integer I/O packages (the
-- generic parameter Number).
--
generic
type Number is range <>;
with procedure Get_Digit
( Source : String;
Pointer : in out Integer;
Digit : out Natural
) is <>;
with procedure Get_Sign
( Source : String;
Pointer : in out Integer;
Sign_Of : out Sign
) is <>;
with procedure Put_Digit
( Destination : in out String;
Pointer : in out Integer;
Digit : Script_Digit
) is <>;
with procedure Put_Sign
( Destination : in out String;
Pointer : in out Integer;
Sign_Of : Sign
) is <>;
package Strings_Edit.UTF8.Integer_Edit is
--
-- Get -- Get an integer number from UTF-8 string
--
-- Source - The string to be processed
-- Pointer - The current position in the string
-- Value - The result
-- Base - The base of the expected number
-- First - The lowest allowed value
-- Last - The highest allowed value
-- ToFirst - Force value to First instead of exception
-- ToLast - Force value to Last instead of exception
--
-- This procedure gets a decimal integer number from the string Source.
-- The process starts from Source (Pointer).
--
-- Exceptions:
--
-- Constraint_Error - The number is not in First..Last
-- Data_Error - Syntax error in the number
-- End_Error - There is no any number
-- Layout_Error - Pointer not in Source'First..Source'Last + 1
--
procedure Get
( Source : in String;
Pointer : in out Integer;
Value : out Number'Base;
Base : Script_Base := 10;
First : Number'Base := Number'First;
Last : Number'Base := Number'Last;
ToFirst : Boolean := False;
ToLast : Boolean := False
);
--
-- Value -- String to an integer conversion
--
-- Source - The string to be processed
-- Base - The base of the expected number
-- First - The lowest allowed value
-- Last - The highest allowed value
-- ToFirst - Force value to First instead of exception
-- ToLast - Force value to Last instead of exception
--
-- This function gets a decimal integer number from the string Source.
-- The number can be surrounded by spaces and tabs. The whole string
-- Source should be matched. Otherwise the exception Data_Error is
-- propagated.
--
-- Returns :
--
-- The value
--
-- Exceptions:
--
-- Constraint_Error - The number is not in First..Last
-- Data_Error - Syntax error in the number
-- End_Error - There is no any number
--
function Value
( Source : in String;
Base : Script_Base := 10;
First : in Number'Base := Number'First;
Last : Number'Base := Number'Last;
ToFirst : Boolean := False;
ToLast : Boolean := False
) return Number'Base;
--
-- Put -- Put an integer into a string
--
-- Destination - The string that accepts the output
-- Pointer - The current position in the string
-- Value - The value to be put
-- Base - The base of the number
-- PutPlus - The plus should placed for positive numbers
--
-- This procedure places the number specified by the parameter Value
-- into the output string Destination. UTF-8 characters are used for the
-- output. The string is written starting from Destination (Pointer).
-- The parameter PutPlus indicates whether the plus sign should be
-- placed if the number is positive.
--
-- Exceptions:
--
-- Layout_Error - Pointer is not in Destination'Range or there is no
-- room for the output.
--
procedure Put
( Destination : in out String;
Pointer : in out Integer;
Value : Number'Base;
Base : Script_Base := 10;
PutPlus : Boolean := False
);
--
-- Image -- Integer to string conversion
--
-- Value - The value to be converted
-- Base - The base of the number
-- PutPlus - The plus should placed for positive numbers
--
-- This function converts Value to string. The parameter PutPlus
-- indicates whether the plus sign should be placed if the number is
-- positive.
--
-- Returns :
--
-- The result string
--
function Image
( Value : Number'Base;
Base : Script_Base := 10;
PutPlus : Boolean := False
) return String;
end Strings_Edit.UTF8.Integer_Edit ;