PageRenderTime 27ms CodeModel.GetById 21ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/io/filter_examples.e

http://github.com/tybor/Liberty
Specman e | 44 lines | 31 code | 7 blank | 6 comment | 0 complexity | 486be66715c0c95c0e795fc373c6112c MD5 | raw file
 1class FILTER_EXAMPLES
 2
 3create {ANY}
 4   make
 5
 6feature {}
 7   make
 8      local
 9         file: TEXT_FILE_WRITE; html: HTML_OUTPUT_STREAM
10      do
11         -- first create the terminal stream (the one that can write characters to some device)
12         create file.connect_to("index.html")
13         -- now create the filter, and attach it the previous stream (many filters can be hooked this way)
14         create html.connect_to(file)
15         -- now write the file using the upmost filter (the one that is *not* connected by something else)
16         -- The HTML_OUTPUT_STREAM is a bit peculiar because it exports many helper functions instead of the
17         -- all-purpose put_character. Those functions ensure the integrity of the produced HTML.
18
19         html.header
20         html.open_title
21         html.put_string("My Home Page")
22         html.close_title
23         html.put_stylesheet("styles.css")
24
25         html.body
26         html.with_attribute("class", "section")
27         html.open_section
28         html.put_string("My Home Page")
29         html.close_section
30
31         html.with_attribute("class", "par")
32         html.open_paragraph
33         html.put_string("This is ")
34         html.open_bold
35         html.put_string("my")
36         html.close_bold
37         html.put_string(" home page!")
38         html.close_paragraph
39
40         html.close
41         -- only now can the HTML file be disconnected.
42      end
43
44end -- class FILTER_EXAMPLES