Safer interface for WSF_VALUE, when related to STRING value
This commit is contained in:
@@ -52,8 +52,8 @@ feature -- Execution
|
|||||||
s: STRING
|
s: STRING
|
||||||
uri: STRING
|
uri: STRING
|
||||||
do
|
do
|
||||||
if attached ctx.path_parameter ("path") as l_path then
|
if attached {WSF_STRING} ctx.path_parameter ("path") as l_path then
|
||||||
uri := l_path.as_string
|
uri := l_path.string
|
||||||
process_uri (uri, ctx, req, res)
|
process_uri (uri, ctx, req, res)
|
||||||
else
|
else
|
||||||
create h.make
|
create h.make
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_VALUE
|
WSF_VALUE
|
||||||
|
redefine
|
||||||
|
as_string
|
||||||
|
end
|
||||||
|
|
||||||
ITERABLE [WSF_STRING]
|
ITERABLE [WSF_STRING]
|
||||||
|
|
||||||
@@ -62,6 +65,25 @@ feature -- Access
|
|||||||
Result := string_values.first
|
Result := string_values.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Status report
|
||||||
|
|
||||||
|
is_string: BOOLEAN
|
||||||
|
-- Is Current as a WSF_STRING representation?
|
||||||
|
do
|
||||||
|
Result := string_values.count = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Conversion
|
||||||
|
|
||||||
|
as_string: WSF_STRING
|
||||||
|
do
|
||||||
|
if string_values.count = 1 then
|
||||||
|
Result := first_string_value
|
||||||
|
else
|
||||||
|
Result := Precursor
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Traversing
|
feature -- Traversing
|
||||||
|
|
||||||
new_cursor: ITERATION_CURSOR [WSF_STRING]
|
new_cursor: ITERATION_CURSOR [WSF_STRING]
|
||||||
@@ -71,23 +93,7 @@ feature -- Traversing
|
|||||||
|
|
||||||
feature -- Helper
|
feature -- Helper
|
||||||
|
|
||||||
same_string (a_other: READABLE_STRING_GENERAL): BOOLEAN
|
string_representation: STRING_32
|
||||||
-- Does `a_other' represent the same string as `Current'?
|
|
||||||
do
|
|
||||||
if string_values.count = 1 then
|
|
||||||
Result := first_string_value.same_string (a_other)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
is_case_insensitive_equal (a_other: READABLE_STRING_8): BOOLEAN
|
|
||||||
-- Does `a_other' represent the same case insensitive string as `Current'?
|
|
||||||
do
|
|
||||||
if string_values.count = 1 then
|
|
||||||
Result := first_string_value.is_case_insensitive_equal (a_other)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
as_string: STRING_32
|
|
||||||
do
|
do
|
||||||
if string_values.count = 1 then
|
if string_values.count = 1 then
|
||||||
create Result.make_from_string (first_string_value)
|
create Result.make_from_string (first_string_value)
|
||||||
|
|||||||
@@ -9,12 +9,16 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_VALUE
|
WSF_VALUE
|
||||||
|
redefine
|
||||||
|
same_string,
|
||||||
|
is_case_insensitive_equal
|
||||||
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
convert
|
convert
|
||||||
as_string: {READABLE_STRING_32, STRING_32}
|
string_representation: {READABLE_STRING_32, STRING_32}
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
@@ -37,6 +41,11 @@ feature -- Access
|
|||||||
|
|
||||||
url_encoded_string: READABLE_STRING_32
|
url_encoded_string: READABLE_STRING_32
|
||||||
|
|
||||||
|
feature -- Status report
|
||||||
|
|
||||||
|
is_string: BOOLEAN = True
|
||||||
|
-- Is Current as a WSF_STRING representation?
|
||||||
|
|
||||||
feature -- Helper
|
feature -- Helper
|
||||||
|
|
||||||
same_string (a_other: READABLE_STRING_GENERAL): BOOLEAN
|
same_string (a_other: READABLE_STRING_GENERAL): BOOLEAN
|
||||||
@@ -60,7 +69,7 @@ feature -- Helper
|
|||||||
|
|
||||||
feature -- Conversion
|
feature -- Conversion
|
||||||
|
|
||||||
as_string: STRING_32
|
string_representation: STRING_32
|
||||||
do
|
do
|
||||||
create Result.make_from_string (string)
|
create Result.make_from_string (string)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_VALUE
|
WSF_VALUE
|
||||||
|
redefine
|
||||||
|
as_string
|
||||||
|
end
|
||||||
|
|
||||||
ITERABLE [WSF_VALUE]
|
ITERABLE [WSF_VALUE]
|
||||||
|
|
||||||
@@ -27,6 +30,7 @@ feature {NONE} -- Initialization
|
|||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
name: READABLE_STRING_32
|
name: READABLE_STRING_32
|
||||||
|
-- Parameter name
|
||||||
|
|
||||||
first_value: detachable WSF_VALUE
|
first_value: detachable WSF_VALUE
|
||||||
-- First value if any.
|
-- First value if any.
|
||||||
@@ -63,6 +67,27 @@ feature -- Access
|
|||||||
Result := values.count
|
Result := values.count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Status report
|
||||||
|
|
||||||
|
is_string: BOOLEAN
|
||||||
|
-- Is Current as a WSF_STRING representation?
|
||||||
|
do
|
||||||
|
if values.count = 1 and then attached first_value as fv then
|
||||||
|
Result := fv.is_string
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Conversion
|
||||||
|
|
||||||
|
as_string: WSF_STRING
|
||||||
|
do
|
||||||
|
if values.count = 1 and then attached first_value as fv then
|
||||||
|
Result := fv.as_string
|
||||||
|
else
|
||||||
|
Result := Precursor
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Element change
|
feature -- Element change
|
||||||
|
|
||||||
add_value (a_value: WSF_VALUE; k: READABLE_STRING_32)
|
add_value (a_value: WSF_VALUE; k: READABLE_STRING_32)
|
||||||
@@ -81,29 +106,13 @@ feature -- Traversing
|
|||||||
|
|
||||||
feature -- Helper
|
feature -- Helper
|
||||||
|
|
||||||
same_string (a_other: READABLE_STRING_GENERAL): BOOLEAN
|
string_representation: STRING_32
|
||||||
-- Does `a_other' represent the same string as `Current'?
|
|
||||||
do
|
|
||||||
if values.count = 1 and then attached first_value as f then
|
|
||||||
Result := f.same_string (a_other)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
is_case_insensitive_equal (a_other: READABLE_STRING_8): BOOLEAN
|
|
||||||
-- Does `a_other' represent the same case insensitive string as `Current'?
|
|
||||||
do
|
|
||||||
if values.count = 1 and then attached first_value as f then
|
|
||||||
Result := f.is_case_insensitive_equal (a_other)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
as_string: STRING_32
|
|
||||||
do
|
do
|
||||||
create Result.make_from_string ("{")
|
create Result.make_from_string ("{")
|
||||||
if values.count = 1 and then attached first_key as fk then
|
if values.count = 1 and then attached first_key as fk then
|
||||||
Result.append (fk + ": ")
|
Result.append (fk + ": ")
|
||||||
if attached value (fk) as fv then
|
if attached value (fk) as fv then
|
||||||
Result.append (fv.as_string)
|
Result.append (fv.string_representation)
|
||||||
else
|
else
|
||||||
Result.append ("???")
|
Result.append ("???")
|
||||||
end
|
end
|
||||||
@@ -115,7 +124,7 @@ feature -- Helper
|
|||||||
Result.append_character (',')
|
Result.append_character (',')
|
||||||
end
|
end
|
||||||
Result.append (c.key + ": ")
|
Result.append (c.key + ": ")
|
||||||
Result.append (c.item.as_string)
|
Result.append (c.item.string_representation)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Result.append_character ('}')
|
Result.append_character ('}')
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ deferred class
|
|||||||
inherit
|
inherit
|
||||||
DEBUG_OUTPUT
|
DEBUG_OUTPUT
|
||||||
|
|
||||||
convert
|
|
||||||
as_string: {READABLE_STRING_32, STRING_32}
|
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
name: READABLE_STRING_32
|
name: READABLE_STRING_32
|
||||||
@@ -19,16 +16,54 @@ feature -- Access
|
|||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Status report
|
||||||
|
|
||||||
|
is_string: BOOLEAN
|
||||||
|
-- Is Current as a WSF_STRING representation?
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Query
|
||||||
|
|
||||||
|
as_string: WSF_STRING
|
||||||
|
-- String value
|
||||||
|
require
|
||||||
|
is_string: is_string
|
||||||
|
do
|
||||||
|
if attached {WSF_STRING} Current as str then
|
||||||
|
Result := str
|
||||||
|
else
|
||||||
|
check is_string: is_string end
|
||||||
|
create Result.make (name, string_representation)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
string_representation: STRING_32
|
||||||
|
-- String representation of Current
|
||||||
|
-- if possible
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Helper
|
feature -- Helper
|
||||||
|
|
||||||
same_string (a_other: READABLE_STRING_GENERAL): BOOLEAN
|
same_string (a_other: READABLE_STRING_GENERAL): BOOLEAN
|
||||||
-- Does `a_other' represent the same string as `Current'?
|
-- Does `a_other' represent the same string as `Current'?
|
||||||
deferred
|
do
|
||||||
|
if is_string then
|
||||||
|
Result:= as_string.same_string (a_other)
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
result_true_only_for_string: Result implies is_string
|
||||||
end
|
end
|
||||||
|
|
||||||
is_case_insensitive_equal (a_other: READABLE_STRING_8): BOOLEAN
|
is_case_insensitive_equal (a_other: READABLE_STRING_8): BOOLEAN
|
||||||
-- Does `a_other' represent the same case insensitive string as `Current'?
|
-- Does `a_other' represent the same case insensitive string as `Current'?
|
||||||
deferred
|
do
|
||||||
|
if is_string then
|
||||||
|
Result:= as_string.is_case_insensitive_equal (a_other)
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
result_true_only_for_string: Result implies is_string
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Status report
|
feature -- Status report
|
||||||
@@ -36,13 +71,7 @@ feature -- Status report
|
|||||||
debug_output: STRING
|
debug_output: STRING
|
||||||
-- String that should be displayed in debugger to represent `Current'.
|
-- String that should be displayed in debugger to represent `Current'.
|
||||||
do
|
do
|
||||||
create Result.make_from_string (name.as_string_8 + "=" + as_string.as_string_8)
|
create Result.make_from_string (name.as_string_8 + "=" + string_representation.as_string_8)
|
||||||
end
|
|
||||||
|
|
||||||
feature -- Query
|
|
||||||
|
|
||||||
as_string: STRING_32
|
|
||||||
deferred
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|||||||
Reference in New Issue
Block a user