Renamed JSON_STRING.unescaped_string as unescaped_string_8
+ code cleaning
This commit is contained in:
@@ -27,40 +27,42 @@ create
|
|||||||
make_with_escaped_json
|
make_with_escaped_json
|
||||||
|
|
||||||
convert
|
convert
|
||||||
make_json ({READABLE_STRING_8, STRING_8, IMMUTABLE_STRING_8})
|
make_json ({READABLE_STRING_8, STRING_8, IMMUTABLE_STRING_8}),
|
||||||
|
make_json_from_string_32 ({READABLE_STRING_32, STRING_32, IMMUTABLE_STRING_32})
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_json (an_item: READABLE_STRING_8)
|
make_json (s: READABLE_STRING_8)
|
||||||
-- Initialize.
|
-- Initialize.
|
||||||
require
|
require
|
||||||
item_not_void: an_item /= Void
|
item_not_void: s /= Void
|
||||||
do
|
do
|
||||||
make_with_escaped_json (escaped_json_string (an_item))
|
make_with_escaped_json (escaped_json_string (s))
|
||||||
end
|
end
|
||||||
|
|
||||||
make_json_from_string_32 (an_item: READABLE_STRING_32)
|
make_json_from_string_32 (s: READABLE_STRING_32)
|
||||||
-- Initialize.
|
-- Initialize from STRING_32 `s'.
|
||||||
require
|
require
|
||||||
item_not_void: an_item /= Void
|
item_not_void: s /= Void
|
||||||
do
|
do
|
||||||
make_with_escaped_json (escaped_json_string_32 (an_item))
|
make_with_escaped_json (escaped_json_string_32 (s))
|
||||||
end
|
end
|
||||||
|
|
||||||
make_with_escaped_json (an_item: READABLE_STRING_8)
|
make_with_escaped_json (s: READABLE_STRING_8)
|
||||||
-- Initialize with an_item already escaped
|
-- Initialize with an_item already escaped
|
||||||
require
|
require
|
||||||
item_not_void: an_item /= Void
|
item_not_void: s /= Void
|
||||||
do
|
do
|
||||||
item := an_item
|
item := s
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
item: STRING
|
item: STRING
|
||||||
-- Contents
|
-- Contents with escaped entities if any
|
||||||
|
|
||||||
unescaped_string: STRING_8
|
unescaped_string_8: STRING_8
|
||||||
|
-- Unescaped string from `item'
|
||||||
local
|
local
|
||||||
s: like item
|
s: like item
|
||||||
i, n: INTEGER
|
i, n: INTEGER
|
||||||
@@ -106,6 +108,7 @@ feature -- Access
|
|||||||
end
|
end
|
||||||
|
|
||||||
unescaped_string_32: STRING_32
|
unescaped_string_32: STRING_32
|
||||||
|
-- Unescaped string 32 from `item'
|
||||||
local
|
local
|
||||||
s: like item
|
s: like item
|
||||||
i, n: INTEGER
|
i, n: INTEGER
|
||||||
@@ -154,8 +157,10 @@ feature -- Access
|
|||||||
end
|
end
|
||||||
|
|
||||||
representation: STRING
|
representation: STRING
|
||||||
|
-- String representation of `item' with escaped entities if any
|
||||||
do
|
do
|
||||||
Result := "%""
|
create Result.make (item.count + 2)
|
||||||
|
Result.append_character ('%"')
|
||||||
Result.append (item)
|
Result.append (item)
|
||||||
Result.append_character ('%"')
|
Result.append_character ('%"')
|
||||||
end
|
end
|
||||||
@@ -175,13 +180,13 @@ feature -- Comparison
|
|||||||
-- Is JSON_STRING made of same character sequence as `other'
|
-- Is JSON_STRING made of same character sequence as `other'
|
||||||
-- (possibly with a different capacity)?
|
-- (possibly with a different capacity)?
|
||||||
do
|
do
|
||||||
Result := item.is_equal (other.item)
|
Result := item.same_string (other.item)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Change Element
|
feature -- Change Element
|
||||||
|
|
||||||
append (a_string: STRING)
|
append (a_string: STRING)
|
||||||
-- Add an_item
|
-- Add a_string
|
||||||
require
|
require
|
||||||
a_string_not_void: a_string /= Void
|
a_string_not_void: a_string /= Void
|
||||||
do
|
do
|
||||||
@@ -207,6 +212,7 @@ feature -- Status report
|
|||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
is_hexadecimal (s: READABLE_STRING_8): BOOLEAN
|
is_hexadecimal (s: READABLE_STRING_8): BOOLEAN
|
||||||
|
-- Is `s' an hexadecimal value?
|
||||||
do
|
do
|
||||||
Result := across s as scur all scur.item.is_hexa_digit end
|
Result := across s as scur all scur.item.is_hexa_digit end
|
||||||
end
|
end
|
||||||
@@ -318,6 +324,6 @@ feature {NONE} -- Implementation
|
|||||||
end
|
end
|
||||||
|
|
||||||
invariant
|
invariant
|
||||||
value_not_void: item /= Void
|
item_not_void: item /= Void
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -632,7 +632,7 @@ feature -- Test
|
|||||||
jrep := "%"foo\\bar%""
|
jrep := "%"foo\\bar%""
|
||||||
create parser.make_parser (jrep)
|
create parser.make_parser (jrep)
|
||||||
if attached {JSON_STRING} parser.parse as jstring then
|
if attached {JSON_STRING} parser.parse as jstring then
|
||||||
assert ("unescaped string %"foo\\bar%" to %"foo\bar%"", jstring.unescaped_string.same_string ("foo\bar"))
|
assert ("unescaped string %"foo\\bar%" to %"foo\bar%"", jstring.unescaped_string_8.same_string ("foo\bar"))
|
||||||
end
|
end
|
||||||
|
|
||||||
create js.make_json_from_string_32 ({STRING_32}"%/20320/%/22909/")
|
create js.make_json_from_string_32 ({STRING_32}"%/20320/%/22909/")
|
||||||
|
|||||||
Reference in New Issue
Block a user