Index: graphviz.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/graph/graphviz.hpp,v retrieving revision 1.14 diff -c -3 -p -r1.14 graphviz.hpp *** graphviz.hpp 2001/11/03 19:13:47 1.14 --- graphviz.hpp 2001/12/06 20:35:04 *************** namespace boost { *** 78,83 **** --- 78,84 ---- private: Name name; }; + template inline label_writer make_label_writer(Name n) { *************** namespace boost { *** 111,116 **** --- 112,138 ---- } } + template + inline void write_all_attributes(Attributes attributes, + const std::string& name, + std::ostream& out) + { + typename Attributes::const_iterator i = attributes.begin(), + end = attributes.end(); + if (i != end) { + out << name << " [\n"; + write_attributes(attributes, out); + out << "];\n"; + } + } + + inline void write_all_attributes(detail::error_property_not_found, + const std::string&, + std::ostream&) + { + // Do nothing - no attributes exist + } + template *************** namespace boost { *** 122,160 **** : g_attributes(gg), n_attributes(gn), e_attributes(ge) { } void operator()(std::ostream& out) const { ! ! typename GraphGraphAttributes::const_iterator ! gi = g_attributes.begin(), ! gend = g_attributes.end(); ! ! if ( gi != gend ) { ! out << "graph ["; ! write_attributes(g_attributes, out); ! out << "];" << std::endl; ! } ! ! //write node [......]; if need ! typename GraphNodeAttributes::const_iterator ! ni = n_attributes.begin(), ! nend = n_attributes.end(); ! ! if ( ni != nend ) { ! out << "node ["; ! write_attributes(n_attributes, out); ! out << "];" << std::endl; ! } ! ! //write edge[....]; if need ! typename GraphEdgeAttributes::const_iterator ! ei = e_attributes.begin(), ! eend = e_attributes.end(); ! ! if ( ei != eend ) { ! out << "edge ["; ! write_attributes(e_attributes, out); ! out << "];" << std::endl; ! } } GraphGraphAttributes g_attributes; GraphNodeAttributes n_attributes; GraphEdgeAttributes e_attributes; --- 144,154 ---- : g_attributes(gg), n_attributes(gn), e_attributes(ge) { } void operator()(std::ostream& out) const { ! write_all_attributes(g_attributes, "graph", out); ! write_all_attributes(n_attributes, "node", out); ! write_all_attributes(e_attributes, "edge", out); } + GraphGraphAttributes g_attributes; GraphNodeAttributes n_attributes; GraphEdgeAttributes e_attributes; *************** namespace boost { *** 196,207 **** template void operator()(std::ostream& out, const VorE& e) const { ! if (!attributes[e].empty()) { out << "["; write_attributes(attributes[e], out); out << "]"; ! } } AttributeMap attributes; }; --- 190,213 ---- template void operator()(std::ostream& out, const VorE& e) const { ! this->write_attribute(out, attributes[e]); ! } ! ! private: ! template ! void write_attribute(std::ostream& out, const AttributeSequence& seq) const ! { ! if (!attributes[e].empty()) { out << "["; write_attributes(attributes[e], out); out << "]"; ! } } + + void write_attribute(std::ostream&, detail::error_property_not_found) const + { + } + AttributeMap attributes; };