/[eiffelstudio]/branches/eth/eve/Src/library/abel/libraries/ethz/src/abel/criteriontree/ps_predefined_operators.e
ViewVC logotype

Contents of /branches/eth/eve/Src/library/abel/libraries/ethz/src/abel/criteriontree/ps_predefined_operators.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88483 - (show annotations)
Thu Mar 29 21:30:22 2012 UTC (7 years, 6 months ago) by romanschmocker
File size: 2729 byte(s)
finished implementation if PS_PREDEFINED_CRITERION, added some unit tests for new functionality
1 note
2 description: "Defines the allowed predefined operators for each basic type"
3 author: "Roman Schmocker"
4 date: "$Date$"
5 revision: "$Revision$"
6
7 class
8 PS_PREDEFINED_OPERATORS
9
10
11 feature -- Predefined operators
12
13 equals: STRING = "="
14
15 greater: STRING = ">"
16
17 greater_equal: STRING = ">="
18
19 less: STRING = "<"
20
21 less_equal: STRING = "<="
22
23 like_string: STRING = "like"
24
25
26 feature -- Status
27
28 is_valid_combination (operator: STRING; value: ANY) : BOOLEAN
29 -- Is `operator' a valid string that can be used with the runtime type of `value'?
30 local
31 valid_operators: ARRAY[STRING]
32 do
33 Result := True
34
35 -- Strings
36 if attached {READABLE_STRING_8} value or attached {READABLE_STRING_32} value then
37 valid_operators := << equals, like_string>>
38
39 -- Booleans
40 elseif attached {BOOLEAN} value then
41 valid_operators := <<equals>>
42
43 -- Integers
44 elseif attached {INTEGER_64} value or attached {INTEGER_32} value
45 or attached {INTEGER_16} value or attached {INTEGER_8} value then
46 valid_operators := <<equals, greater, greater_equal, less, less_equal>>
47
48 -- Reals
49 elseif attached {REAL_64} value or attached {REAL_32} value then
50 valid_operators := <<equals, greater, greater_equal, less, less_equal>>
51
52 -- Naturals
53 elseif attached {NATURAL_64} value or attached {NATURAL_32} value
54 or attached {NATURAL_16} value or attached {NATURAL_8} value then
55 valid_operators := <<equals, greater, greater_equal, less, less_equal>>
56
57 -- Value is not a valid base type - return false
58 else
59 Result:= False
60 valid_operators := <<"">>
61 end
62
63 Result := Result and across valid_operators as cursor some cursor.item.is_case_insensitive_equal (operator) end
64 end
65
66
67 feature -- Utilities
68
69 is_boolean_type (object:ANY):BOOLEAN
70 -- Is `object' of a boolean type?
71 do
72 Result:= attached{BOOLEAN} object
73 end
74
75 is_string_8_type (object:ANY):BOOLEAN
76 -- Is `object' of a string type?
77 do
78 Result:= attached {READABLE_STRING_8} object
79 end
80
81 is_string_32_type (object:ANY):BOOLEAN
82 -- Is `object' of a string type?
83 do
84 Result:= attached {READABLE_STRING_32} object
85 end
86
87 is_integer_type (object:ANY):BOOLEAN
88 -- Is `object' of an integer type?
89 do
90 Result:=attached {INTEGER_64} object or attached {INTEGER_32} object
91 or attached {INTEGER_16} object or attached {INTEGER_8} object
92 end
93
94 is_real_type (object:ANY):BOOLEAN
95 -- Is `object' of a real type?
96 do
97 Result:= attached {REAL_64} object or attached {REAL_32} object
98 end
99
100 is_natural_type (object:ANY):BOOLEAN
101 -- Is `object' of a natural type?
102 do
103 Result:= attached {NATURAL_64} object or attached {NATURAL_32} object
104 or attached {NATURAL_16} object or attached {NATURAL_8} object
105 end
106
107 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23