/[eiffelstudio]/FreeELKS/trunk/library/kernel/string_to_numeric_convertor.e
ViewVC logotype

Contents of /FreeELKS/trunk/library/kernel/string_to_numeric_convertor.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91477 - (show annotations)
Sun Jan 14 09:47:13 2007 UTC (13 years ago) by ericb
File size: 4107 byte(s)
Synchronized with ISE 6.0.65740
1 indexing
2 description: "Abstract convertor for string to number conversion"
3 library: "Free implementation of ELKS library"
4 copyright: "Copyright (c) 1986-2006, Eiffel Software and others"
5 license: "Eiffel Forum License v2 (see forum.txt)"
6 date: "$Date$"
7 revision: "$Revision$"
8
9 deferred class
10 STRING_TO_NUMERIC_CONVERTOR
11
12 inherit
13 NUMERIC_INFORMATION
14
15 feature -- Status reporting
16
17 trailing_separators_acceptable: BOOLEAN
18 -- Are trailing separators acceptable?
19
20 leading_separators_acceptable: BOOLEAN
21 -- Are leading separators acceptable?
22
23 leading_separators: STRING
24 -- Leading separators
25
26 trailing_separators: STRING
27 -- Trailing separators
28
29 separators_valid (separators: STRING): BOOLEAN is
30 -- Are `separators' valid?
31 require
32 separators_not_void: separators /= Void
33 deferred
34 end
35
36 conversion_type_valid (type: INTEGER): BOOLEAN is
37 -- Is `type' to which string will be converted valid?
38 -- See `NUMBER_INFORMATION' for more information.
39 deferred
40 end
41
42 overflowed: BOOLEAN is
43 -- Is number overflowed (too large)?
44 deferred
45 end
46
47 underflowed: BOOLEAN is
48 -- Is number underflowed (too small)?
49 deferred
50 end
51
52 parse_successful: BOOLEAN is
53 -- Is parse so far successful?
54 deferred
55 end
56
57 conversion_type: INTEGER
58 -- Type to which a string will be converted
59 -- See `NUMBER_INFORMATION' for more information.
60
61 feature -- Reset
62
63 reset (type: INTEGER) is
64 -- Reset this convertor to start a new parse session
65 -- and get ready for parsing integer of `type'.
66 -- Always call this feature before every new parse session.
67 -- See `NUMBER_INFORMATION' for more information about `type'.
68 require
69 type_valid: conversion_type_valid (type)
70 deferred
71 ensure
72 last_state_set: last_state = 0
73 sign_set: sign = 0
74 conversion_type_set: conversion_type = type
75 not_overflowed: not overflowed
76 not_underflowed: not underflowed
77 parse_successful: parse_successful
78 end
79
80 feature -- Status setting
81
82 set_trailing_separators_acceptable (b: BOOLEAN) is
83 -- Set `trailing_separators_acceptable' to `b'.
84 do
85 trailing_separators_acceptable := b
86 ensure
87 trailing_separators_acceptable_set:
88 trailing_separators_acceptable = b
89 end
90
91 set_leading_separators_acceptable (b: BOOLEAN) is
92 -- Set `leading_separators_acceptable' to `b'.
93 do
94 leading_separators_acceptable := b
95 ensure
96 leading_separators_acceptable_set:
97 leading_separators_acceptable = b
98 end
99
100 set_leading_separators (separators: STRING) is
101 -- Set `leading_separators' with `separators'.
102 require
103 separators_not_void: separators /= Void
104 separators_valid: separators_valid (separators)
105 do
106 create leading_separators.make_from_string (separators)
107 ensure
108 leading_separators_set: leading_separators.is_equal (separators)
109 end
110
111 set_trailing_separators (separators: STRING) is
112 -- Set `trailing_separators' with `separators'.
113 require
114 separators_not_void: separators /= Void
115 separators_valid: separators_valid (separators)
116 do
117 create trailing_separators.make_from_string (separators)
118 ensure
119 trailing_separators_set: trailing_separators.is_equal (separators)
120 end
121
122 feature -- Parse
123
124 parse_string_with_type (s: STRING_GENERAL; type: INTEGER) is
125 -- `Reset' convertor to start a new parse session and
126 -- parse `s' to see if it is a number of `type'.
127 -- Make result available in `overflowed', `underflowed' and `parse_successful'.
128 -- See `NUMBER_INFORMATION' for more information about `type'.
129 require
130 s_not_void: s /= Void
131 s_is_valid_as_string_8: s.is_valid_as_string_8
132 type_valid: conversion_type_valid (type)
133 deferred
134 end
135
136 parse_character (c: CHARACTER) is
137 -- Parse `c' in current parse session.
138 -- Make result available in `overflowed', `underflowed' and `parse_successful'.
139 deferred
140 end
141
142 feature{NONE} -- Implementation
143
144 last_state: INTEGER
145 -- Last state of this state machine
146
147 sign: INTEGER
148 -- Sign of this integer, 0: positive; 1: negative.
149
150 invariant
151 leading_separators_not_void: leading_separators /= Void
152 trailing_separators_not_void: trailing_separators /= Void
153 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23