/[eiffelstudio]/branches/eth/eve/eweasel/tests/melt096/es_string.e
ViewVC logotype

Contents of /branches/eth/eve/eweasel/tests/melt096/es_string.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 83441 - (show annotations)
Sat Jun 5 13:52:53 2010 UTC (9 years, 7 months ago) by jasonw
File size: 1915 byte(s)
Renamed branch eve3 to eve. The eve branch serves as the new branch for the EVE project.
1 indexing
2 description: "";
3 date: "$Date$";
4 revision: "$Revision$"
5
6 class
7 ES_STRING
8
9 inherit
10 STRING
11 rename
12 plus as string_plus
13 redefine
14 mirrored
15 end
16
17 creation
18 make, make_from_string, clone_from_string,
19 make_from_c
20
21 feature -- Creation
22
23 clone_from_string (s: STRING) is
24 -- Initialize from the characters of `s'.
25 require
26 string_exists: s /= void
27 do
28 area := s.area.twin
29 count := s.count
30 ensure
31 unique_identity: area /= s.area
32 identical_data: equal (area, s.area)
33 end
34
35 feature -- Basic operations
36
37 appended (other: detachable ANY): ES_STRING is
38 do
39 Result := twin
40 if other /= Void then
41 Result.append (other.out)
42 end
43 ensure
44 constant: equal (Current, old twin)
45 end
46
47 plus alias "+" (other: detachable ANY): ES_STRING is
48 do
49 Result := twin
50 if other /= Void then
51 Result.append (other.out)
52 end
53 ensure
54 constant: equal (Current, old twin)
55 end
56
57
58 feature -- Status report
59
60 is_left_adjusted: BOOLEAN is
61 do
62 Result := item (lower) /= ' '
63 ensure
64 no_initial_blank: item (1) /= ' '
65 end
66
67 is_right_adjusted: BOOLEAN is
68 do
69 Result := item (upper) /= ' '
70 ensure
71 no_final_blank: item (count) /= ' '
72 end
73
74 lower: INTEGER is 1
75 -- Index of lowest character
76
77 upper: INTEGER is
78 -- Synonym of count
79 do
80 Result := count
81 end
82
83 feature -- Element change
84
85 shorten_to (i: INTEGER) is
86 require
87 great_enough: i >= 1
88 small_enough: i <= count
89 do
90 from
91 variant
92 count
93 until
94 i = count
95 loop
96 remove (count)
97 end
98 ensure
99 correct_length: count = i
100 end
101
102 feature -- Conversion
103
104 mirrored: like Current is
105 -- Mirror image of string;
106 -- result for "Hello world" is "dlrow olleH".
107 do
108 --| Why re-implement it? Simplicity.
109 Result := twin
110 Result.mirror
111 end
112
113 feature -- Access
114
115 -- new_iterator: ES_STRING_ITERATOR is
116 -- do
117 -- !! Result.make (Current)
118 -- end
119
120 end -- class ES_STRING

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23