1.1 --- a/src/work/deba/graph_writer.h Tue Feb 01 15:51:22 2005 +0000
1.2 +++ b/src/work/deba/graph_writer.h Tue Feb 01 15:56:37 2005 +0000
1.3 @@ -54,11 +54,10 @@
1.4 QuotedStringWriter(bool _escaped = true) : escaped(_escaped) {}
1.5
1.6 void write(std::ostream& os, const std::string& value) {
1.7 - char c;
1.8 os << "\"";
1.9 if (escaped) {
1.10 ostringstream ls;
1.11 - for (int i = 0; i < value.size(); ++i) {
1.12 + for (int i = 0; i < (int)value.size(); ++i) {
1.13 writeEscape(ls, value[i]);
1.14 }
1.15 os << ls.str();
1.16 @@ -136,12 +135,13 @@
1.17
1.18
1.19 ~GraphWriter() {
1.20 -
1.21 - for (typename NodeMapWriters::iterator it = node_map_writers.begin(); it != node_map_writers.end(); ++it) {
1.22 + for (typename NodeMapWriters::iterator it = node_map_writers.begin();
1.23 + it != node_map_writers.end(); ++it) {
1.24 delete it->second;
1.25 }
1.26
1.27 - for (typename EdgeMapWriters::iterator it = edge_map_writers.begin(); it != edge_map_writers.end(); ++it) {
1.28 + for (typename EdgeMapWriters::iterator it = edge_map_writers.begin();
1.29 + it != edge_map_writers.end(); ++it) {
1.30 delete it->second;
1.31 }
1.32
1.33 @@ -150,29 +150,33 @@
1.34 // Node map rules
1.35
1.36 template <typename Map>
1.37 - GraphWriter& writeNodeMap(std::string name, const Map& map) {
1.38 - return writeNodeMap<typename WriterTraits::template Writer<typename Map::Value>, Map>(name, map);
1.39 + GraphWriter& addNodeMap(std::string name, const Map& map) {
1.40 + return addNodeMap<typename WriterTraits::template Writer<
1.41 + typename Map::Value>, Map>(name, map);
1.42 }
1.43
1.44 template <typename Writer, typename Map>
1.45 - GraphWriter& writeNodeMap(std::string name, const Map& map, const Writer& writer = Writer()) {
1.46 + GraphWriter& addNodeMap(std::string name, const Map& map,
1.47 + const Writer& writer = Writer()) {
1.48 // if (node_map_writers.find(name) != node_map_writers.end()) {
1.49 - // throw Exception() << "Multiple write rule for node map: " << name;
1.50 + // throw Exception() << "Multiple write rule for node map: "
1.51 + // << name;
1.52 // }
1.53 - node_map_writers.push_back(make_pair(name, new MapWriter<Node, Map, Writer>(map, writer)));
1.54 + node_map_writers.push_back(
1.55 + make_pair(name, new MapWriter<Node, Map, Writer>(map, writer)));
1.56 return *this;
1.57 }
1.58
1.59 // Edge map rules
1.60
1.61 template <typename Map>
1.62 - GraphWriter& writeEdgeMap(std::string name, const Map& map) {
1.63 - return writeEdgeMap<typename WriterTraits::template Writer<typename Map::Value>, Map>(name, map);
1.64 + GraphWriter& addEdgeMap(std::string name, const Map& map) {
1.65 + return addEdgeMap<typename WriterTraits::template Writer<typename Map::Value>, Map>(name, map);
1.66 }
1.67
1.68
1.69 template <typename Writer, typename Map>
1.70 - GraphWriter& writeEdgeMap(std::string name, const Map& map, const Writer& writer = Writer()) {
1.71 + GraphWriter& addEdgeMap(std::string name, const Map& map, const Writer& writer = Writer()) {
1.72 // if (edge_map_writers.find(name) != edge_map_writers.end()) {
1.73 // throw Exception() << "Multiple write rule for edge map: " << name;
1.74 // }
1.75 @@ -181,20 +185,22 @@
1.76 }
1.77
1.78 // Node rules
1.79 - GraphWriter& writeNode(std::string name, const Node& node) {
1.80 + GraphWriter& addNode(std::string name, const Node& node) {
1.81 // if (node_writers.find(name) != node_writers.end()) {
1.82 // throw Exception() << "Multiple write rule for node";
1.83 // }
1.84 node_writers.push_back(make_pair(name, node));
1.85 + return *this;
1.86 }
1.87
1.88 // Edge rules
1.89
1.90 - GraphWriter& writeEdge(std::string name, const Edge& edge) {
1.91 + GraphWriter& addEdge(std::string name, const Edge& edge) {
1.92 // if (edge_writers.find(name) != edge_writers.end()) {
1.93 // throw Exception() << "Multiple write rule for edge";
1.94 // }
1.95 edge_writers.push_back(make_pair(name, edge));
1.96 + return *this;
1.97 }
1.98
1.99 void write() {
1.100 @@ -210,12 +216,12 @@
1.101 void writeNodeSet() {
1.102 if (node_map_writers.size() == 0) return;
1.103 os << "@nodeset" << std::endl;
1.104 - for (int i = 0; i < node_map_writers.size(); ++i) {
1.105 + for (int i = 0; i < (int)node_map_writers.size(); ++i) {
1.106 os << node_map_writers[i].first << '\t';
1.107 }
1.108 os << std::endl;
1.109 for (NodeIt it(graph); it != INVALID; ++it) {
1.110 - for (int i = 0; i < node_map_writers.size(); ++i) {
1.111 + for (int i = 0; i < (int)node_map_writers.size(); ++i) {
1.112 node_map_writers[i].second->write(os, it);
1.113 }
1.114 os << std::endl;
1.115 @@ -230,14 +236,14 @@
1.116 }
1.117 os << "@edgeset" << std::endl;
1.118 os << "\t\t";
1.119 - for (int i = 0; i < edge_map_writers.size(); ++i) {
1.120 + for (int i = 0; i < (int)edge_map_writers.size(); ++i) {
1.121 os << edge_map_writers[i].first << '\t';
1.122 }
1.123 os << std::endl;
1.124 for (EdgeIt it(graph); it != INVALID; ++it) {
1.125 node_map_writers[0].second->write(os, graph.source(it));
1.126 node_map_writers[0].second->write(os, graph.target(it));
1.127 - for (int i = 0; i < edge_map_writers.size(); ++i) {
1.128 + for (int i = 0; i < (int)edge_map_writers.size(); ++i) {
1.129 edge_map_writers[i].second->write(os, it);
1.130 }
1.131 os << std::endl;
1.132 @@ -250,7 +256,7 @@
1.133 throw Exception() << "Missing node id map";
1.134 }
1.135 os << "@nodes" << std::endl;
1.136 - for (int i = 0; i < node_writers.size(); ++i) {
1.137 + for (int i = 0; i < (int)node_writers.size(); ++i) {
1.138 os << node_writers[i].first << '\t';
1.139 node_map_writers[0].second->write(os, node_writers[i].second);
1.140 os << std::endl;
1.141 @@ -263,7 +269,7 @@
1.142 throw Exception() << "Missing edge id map";
1.143 }
1.144 os << "@edges" << std::endl;
1.145 - for (int i = 0; i < edge_writers.size(); ++i) {
1.146 + for (int i = 0; i < (int)edge_writers.size(); ++i) {
1.147 os << edge_writers[i].first << '\t';
1.148 edge_map_writers[0].second->write(os, edge_writers[i].second);
1.149 os << std::endl;
1.150 @@ -295,7 +301,6 @@
1.151
1.152
1.153 virtual void write(std::ostream& os, const Item& item) {
1.154 - Value value;
1.155 writer.write(os, map[item]);
1.156 }
1.157
1.158 @@ -303,10 +308,12 @@
1.159
1.160
1.161
1.162 - typedef std::vector< std::pair<std::string, WriterBase<Node>*> > NodeMapWriters;
1.163 + typedef std::vector< std::pair<std::string, WriterBase<Node>*> >
1.164 + NodeMapWriters;
1.165 NodeMapWriters node_map_writers;
1.166
1.167 - typedef std::vector< std::pair<std::string, WriterBase<Edge>*> > EdgeMapWriters;
1.168 + typedef std::vector< std::pair<std::string, WriterBase<Edge>*> >
1.169 + EdgeMapWriters;
1.170 EdgeMapWriters edge_map_writers;
1.171
1.172 typedef std::vector<std::pair<std::string, Node> > NodeWriters;