/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

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