stream
The specific logic it let to the concrete subclasses
# Do the full rendering and write the final content to a stream
redef fun write_to(stream)
do
assert not is_writing
is_writing = true
force_render
for e in content do
e.write_to(stream)
end
is_writing = false
end
lib/template/template.nit:202,2--212,4
redef fun write_to(stream) do
stream.write "<"
stream.write tag
render_attrs_in(stream)
if is_void and (not isset _children or children.is_empty) then
stream.write "/>"
else
stream.write ">"
if isset _children then for child in children do child.write_to(stream)
stream.write "</"
stream.write tag
stream.write ">"
end
end
lib/html/html.nit:288,2--301,4
# Generate the dot content with the current configuration
redef fun write_to(stream)
do
# Collect interesting nodes
for m in model.mmodules do
# filter out modules outside wanted packages
if m.mgroup == null then continue
if not mpackages.has(m.mgroup.mpackage) then continue
mmodules.add(m)
end
collect_important_importation
# Collect interesting edges
var sub_hierarchy = new POSet[MModule]
for m in mmodules do
sub_hierarchy.add_node(m)
for sm in m.in_importation.greaters do
if sm == m then continue
if not mmodules.has(sm) then continue
sub_hierarchy.add_edge(m, sm)
end
end
stream.write("digraph g \{\n")
stream.write("rankdir=BT;node[shape=box];\n")
# Generate the nodes
for p in model.mpackages do
dot_cluster(stream, p.root.as(not null))
end
# Generate the edges
for m in mmodules do
for sm in sub_hierarchy[m].direct_greaters do
var nm = node_for(m)
var nsm = node_for(sm)
if m.in_importation.direct_greaters.has(sm) then
stream.write("\t{nm} -> {nsm}[style=bold]\n")
else
stream.write("\t{nm} -> {nsm}[style=solid]\n")
end
end
end
stream.write("\}\n")
end
src/model/model_viz.nit:214,2--258,4
# print the full tree on `o`
# Write a ASCII-style tree and use the `display` method to label elements
redef fun write_to(stream: Writer)
do
for r in roots do
write_line(stream, r, "")
sub_write_to(stream, r, "")
end
end
lib/ordered_tree/ordered_tree.nit:145,2--153,4
# Write `self` to a `stream`
#
# Key with `null` values are ignored.
# The empty string can be used to represent an empty value.
#
# ~~~
# var ini = new IniFile
# ini["key"] = "value1"
# ini["key2"] = null
# ini["key3"] = ""
# ini["section1.key"] = "value2"
# ini["section1.key2"] = null
# ini["section2.key"] = "value3"
#
# var stream = new StringWriter
# ini.write_to(stream)
#
# assert stream.to_s == """
# key=value1
# key3=
# [section1]
# key=value2
# [section2]
# key=value3
# """
# ~~~
redef fun write_to(stream) do
for key, value in self do
if value == null then continue
stream.write "{key}={value}\n"
end
for section in sections do
stream.write "[{section.name}]\n"
for key, value in section do
if value == null then continue
stream.write "{key}={value}\n"
end
end
end
lib/ini/ini.nit:300,2--338,4