improved CMS_CSS_STYLE and WITH_CSS_STYLE

This commit is contained in:
Jocelyn Fiat
2013-02-28 19:36:09 +01:00
parent 9d8e8eb25a
commit e7b8f398f7
2 changed files with 75 additions and 8 deletions

View File

@@ -7,26 +7,81 @@ note
class class
CMS_CSS_STYLE CMS_CSS_STYLE
inherit
ITERABLE [READABLE_STRING_8]
create create
make, make,
make_from_string make_with_string,
make_with_items
convert convert
make_from_string ({READABLE_STRING_8, STRING_8}) make_with_string ({READABLE_STRING_8, STRING_8})
feature {NONE} -- Initialization feature {NONE} -- Initialization
make make
do do
create {ARRAYED_LIST [READABLE_STRING_8]} items.make (3) make_with_items (create {like items}.make (3))
end end
make_from_string (s: READABLE_STRING_8) make_with_string (s: READABLE_STRING_8)
do do
items := s.split (';') make_with_items (s.split (';'))
end end
items: LIST [READABLE_STRING_8] make_with_items (lst: ITERABLE [READABLE_STRING_8])
do
create items.make (5)
across
lst as c
loop
if attached {IMMUTABLE_STRING_8} c.item as imm then
items.force (imm)
else
items.force (create {IMMUTABLE_STRING_8}.make_from_string (c.item))
end
end
end
items: ARRAYED_LIST [IMMUTABLE_STRING_8]
feature -- Access
count: INTEGER
-- Count of style entities.
new_cursor: ITERATION_CURSOR [READABLE_STRING_8]
do
Result := items.new_cursor
end
feature -- Element change
plus alias "+" (a_other: CMS_CSS_STYLE): like Current
-- <Precursor>
local
lst: ARRAYED_LIST [READABLE_STRING_8]
do
create lst.make (count + a_other.count)
lst.append (items)
across
a_other as c
loop
lst.force (c.item)
end
create Result.make_with_items (lst)
end
append (a_other: CMS_CSS_STYLE)
-- Append style from `a_other' into Current
do
across
a_other as c
loop
items.force (c.item)
end
end
feature -- Change feature -- Change

View File

@@ -12,9 +12,21 @@ feature -- Status report
feature -- Change feature -- Change
set_css_style (a_style: like css_style) reset_css_style
do do
css_style := Void
end
add_css_style (a_style: like css_style)
local
s: like css_style
do
s := css_style
if s = Void then
css_style := a_style css_style := a_style
elseif a_style /= Void then
css_style := s + a_style
end
end end
feature -- Conversion feature -- Conversion