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