Skip to content

Commit

Permalink
JSON string invalidate
Browse files Browse the repository at this point in the history
This function is useful to invalidate a string that is about to be cleaned - changing the string otherwise would break the class contract
  • Loading branch information
cadrian committed Dec 2, 2015
1 parent 1f2193c commit d386e99
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lib/json/value/json_string.e
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,26 @@ feature {ANY}
feature {JSON_HANDLER}
string: UNICODE_STRING

invalidate
-- Allows to modify the string, e.g. to clean it. Note: an invalidated string cannot be revalidated.
do
is_valid := False
end

is_valid: BOOLEAN

feature {}
make (a_string: like string)
require
a_string /= Void
do
is_valid := True
string := a_string
hash_code := a_string.hash_code
ensure
string = a_string
set_string_invariant(a_string)
is_valid
end

from_string (a_string: ABSTRACT_STRING)
Expand Down Expand Up @@ -145,8 +155,8 @@ feature {}

invariant
string_exists: string /= Void
invariant_string: string_invariant.is_equal(string)
invariant_hash_code: hash_code = string.hash_code -- of course, but better said...
invariant_string: is_valid implies string_invariant.is_equal(string)
invariant_hash_code: is_valid implies hash_code = string.hash_code -- of course, but better said...

end -- class JSON_STRING
--
Expand Down

0 comments on commit d386e99

Please sign in to comment.