Added `WSF_TABLE.is_empty: BOOLEAN'
Added `WSF_TABLE.as_array_of_string: detachable ARRAY [READABLE_STRING_32]'
This commit is contained in:
@@ -65,6 +65,11 @@ feature -- Access
|
||||
Result := values.item (k)
|
||||
end
|
||||
|
||||
is_empty: BOOLEAN
|
||||
do
|
||||
Result := count = 0
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
do
|
||||
Result := values.count
|
||||
@@ -108,6 +113,59 @@ feature -- Conversion
|
||||
end
|
||||
end
|
||||
|
||||
as_array_of_string: detachable ARRAY [READABLE_STRING_32]
|
||||
-- Return an array of STRING if possible., otherwise Void
|
||||
local
|
||||
i,n: INTEGER
|
||||
nb: INTEGER
|
||||
do
|
||||
from
|
||||
i := 1
|
||||
n := count
|
||||
create Result.make_filled ("", 1, n)
|
||||
until
|
||||
i > n or Result = Void
|
||||
loop
|
||||
if attached {WSF_STRING} value (i.out) as s then
|
||||
Result.put (s.value, i)
|
||||
nb := nb + 1
|
||||
else
|
||||
Result := Void
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
if Result /= Void and then nb /= n then
|
||||
Result := Void
|
||||
end
|
||||
ensure
|
||||
is_array_of_string implies Result /= Void and then Result.count = count and then Result.lower = 1
|
||||
end
|
||||
|
||||
is_array_of_string: BOOLEAN
|
||||
-- Is Current representable as an array of string?
|
||||
local
|
||||
i,n, nb: INTEGER
|
||||
do
|
||||
from
|
||||
i := 1
|
||||
n := count
|
||||
nb := 0
|
||||
Result := True
|
||||
until
|
||||
i > n or not Result
|
||||
loop
|
||||
if attached {WSF_STRING} value (i.out) then
|
||||
nb := nb + 1
|
||||
else
|
||||
Result := False
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
if nb /= n then
|
||||
Result := False
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
add_value (a_value: WSF_VALUE; k: READABLE_STRING_32)
|
||||
|
||||
Reference in New Issue
Block a user