Index: lemon/lemon_writer.h
===================================================================
--- lemon/lemon_writer.h	(revision 1705)
+++ lemon/lemon_writer.h	(revision 1845)
@@ -165,4 +165,93 @@
     };
 
+
+    template <typename _Item>    
+    class MapWriterBase {
+    public:
+      typedef _Item Item;
+
+      virtual ~MapWriterBase() {}
+
+      virtual void write(std::ostream& os, const Item& item) = 0;
+    };
+
+
+    template <typename _Item, typename _Map, typename _Writer>
+    class MapWriter : public MapWriterBase<_Item> {
+    public:
+      typedef _Map Map;
+      typedef _Writer Writer;
+      typedef typename Writer::Value Value;
+      typedef _Item Item;
+      
+      typename _writer_bits::Ref<Map>::Type map;
+      Writer writer;
+
+      MapWriter(const Map& _map, const Writer& _writer) 
+	: map(_map), writer(_writer) {}
+
+      virtual ~MapWriter() {}
+
+      virtual void write(std::ostream& os, const Item& item) {
+	Value value = map[item];
+	writer.write(os, value);
+      }
+
+    };
+
+
+    class ValueWriterBase {
+    public:
+      virtual ~ValueWriterBase() {}
+      virtual void write(std::ostream&) = 0;
+    };
+
+    template <typename _Value, typename _Writer>
+    class ValueWriter : public ValueWriterBase {
+    public:
+      typedef _Value Value;
+      typedef _Writer Writer;
+
+      ValueWriter(const Value& _value, const Writer& _writer)
+ 	: value(_value), writer(_writer) {}
+
+      virtual void write(std::ostream& os) {
+	writer.write(os, value);
+      }
+    private:
+      const Value& value;
+      Writer writer;
+    };
+    
+
+    template <typename _Item>
+    class IdWriterBase {
+    public:
+      typedef _Item Item;
+      virtual ~IdWriterBase() {}
+      virtual void write(std::ostream&, const Item&) const = 0;
+      virtual bool isIdWriter() const = 0;
+    };
+
+    template <typename _Item, typename _BoxedIdWriter>
+    class IdWriter : public IdWriterBase<_Item> {
+    public:
+      typedef _Item Item;
+      typedef _BoxedIdWriter BoxedIdWriter;
+
+      const BoxedIdWriter& idWriter;
+
+      IdWriter(const BoxedIdWriter& _idWriter) 
+	: idWriter(_idWriter) {}
+
+      virtual void write(std::ostream& os, const Item& item) const {
+	idWriter.writeId(os, item);
+      }
+
+      virtual bool isIdWriter() const {
+	return idWriter.isIdWriter();
+      }
+    };
+
   }
 
@@ -282,107 +371,4 @@
   };
 
-  /// \brief Helper class for implementing the common SectionWriters.
-  ///
-  /// Helper class for implementing the common SectionWriters.
-  class CommonSectionWriterBase : public LemonWriter::SectionWriter {
-    typedef LemonWriter::SectionWriter Parent;
-  protected:
-    
-    /// \brief Constructor for CommonSectionWriterBase.
-    ///
-    /// Constructor for CommonSectionWriterBase. It attach this writer to
-    /// the given LemonWriter.
-    CommonSectionWriterBase(LemonWriter& _writer) 
-      : Parent(_writer) {}
-
-    template <typename _Item>    
-    class WriterBase {
-    public:
-      typedef _Item Item;
-
-      virtual ~WriterBase() {}
-
-      virtual void write(std::ostream& os, const Item& item) = 0;
-    };
-
-
-    template <typename _Item, typename _Map, typename _Writer>
-    class MapWriter : public WriterBase<_Item> {
-    public:
-      typedef _Map Map;
-      typedef _Writer Writer;
-      typedef typename Writer::Value Value;
-      typedef _Item Item;
-      
-      typename _writer_bits::Ref<Map>::Type map;
-      Writer writer;
-
-      MapWriter(const Map& _map, const Writer& _writer) 
-	: map(_map), writer(_writer) {}
-
-      virtual ~MapWriter() {}
-
-      virtual void write(std::ostream& os, const Item& item) {
-	Value value = map[item];
-	writer.write(os, value);
-      }
-
-    };
-
-
-    class ValueWriterBase {
-    public:
-      virtual ~ValueWriterBase() {}
-      virtual void write(std::ostream&) = 0;
-    };
-
-    template <typename _Value, typename _Writer>
-    class ValueWriter : public ValueWriterBase {
-    public:
-      typedef _Value Value;
-      typedef _Writer Writer;
-
-      ValueWriter(const Value& _value, const Writer& _writer)
- 	: value(_value), writer(_writer) {}
-
-      virtual void write(std::ostream& os) {
-	writer.write(os, value);
-      }
-    private:
-      const Value& value;
-      Writer writer;
-    };
-    
-
-    template <typename _Item>
-    class IdWriterBase {
-    public:
-      typedef _Item Item;
-      virtual ~IdWriterBase() {}
-      virtual void write(std::ostream&, const Item&) const = 0;
-      virtual bool isIdWriter() const = 0;
-    };
-
-    template <typename _Item, typename _BoxedIdWriter>
-    class IdWriter : public IdWriterBase<_Item> {
-    public:
-      typedef _Item Item;
-      typedef _BoxedIdWriter BoxedIdWriter;
-
-      const BoxedIdWriter& idWriter;
-
-      IdWriter(const BoxedIdWriter& _idWriter) 
-	: idWriter(_idWriter) {}
-
-      virtual void write(std::ostream& os, const Item& item) const {
-	idWriter.writeId(os, item);
-      }
-
-      virtual bool isIdWriter() const {
-	return idWriter.isIdWriter();
-      }
-    };
-  };
-
   /// \ingroup io_group
   /// \brief SectionWriter for writing a graph's nodeset.
@@ -404,6 +390,6 @@
   /// \relates LemonWriter
   template <typename _Graph, typename _Traits = DefaultWriterTraits>
-  class NodeSetWriter : public CommonSectionWriterBase {
-    typedef CommonSectionWriterBase Parent;
+  class NodeSetWriter : public LemonWriter::SectionWriter {
+    typedef LemonWriter::SectionWriter Parent;
   public:
 
@@ -458,5 +444,6 @@
       checkConcept<_writer_bits::ItemWriter<typename Map::Value>, Writer>();
       writers.push_back(
-	make_pair(name, new MapWriter<Node, Map, Writer>(map, writer)));
+	make_pair(name, new _writer_bits::
+		  MapWriter<Node, Map, Writer>(map, writer)));
       return *this;
     }
@@ -528,8 +515,9 @@
   private:
 
-    typedef std::vector<std::pair<std::string, WriterBase<Node>*> > MapWriters;
+    typedef std::vector<std::pair<std::string, _writer_bits::
+				  MapWriterBase<Node>*> > MapWriters;
     MapWriters writers;
 
-    WriterBase<Node>* idMap;
+    _writer_bits::MapWriterBase<Node>* idMap;
     bool forceIdMap;
    
@@ -563,6 +551,6 @@
   /// \relates LemonWriter
   template <typename _Graph, typename _Traits = DefaultWriterTraits>
-  class EdgeSetWriter : public CommonSectionWriterBase {
-    typedef CommonSectionWriterBase Parent;
+  class EdgeSetWriter : public LemonWriter::SectionWriter {
+    typedef LemonWriter::SectionWriter Parent;
   public:
 
@@ -587,5 +575,6 @@
 	graph(_graph), id(_id) {
       checkConcept<_writer_bits::ItemIdWriter<Node>, NodeIdWriter>();
-      nodeIdWriter.reset(new IdWriter<Node, NodeIdWriter>(_nodeIdWriter));
+      nodeIdWriter.reset(new _writer_bits::
+			 IdWriter<Node, NodeIdWriter>(_nodeIdWriter));
     } 
 
@@ -624,5 +613,6 @@
       checkConcept<_writer_bits::ItemWriter<typename Map::Value>, Writer>();
       writers.push_back(
-	make_pair(name, new MapWriter<Edge, Map, Writer>(map, writer)));
+	make_pair(name, new _writer_bits::
+		  MapWriter<Edge, Map, Writer>(map, writer)));
       return *this;
     }
@@ -702,8 +692,9 @@
   private:
 
-    typedef std::vector<std::pair<std::string, WriterBase<Edge>*> > MapWriters;
+    typedef std::vector<std::pair<std::string, _writer_bits::
+				  MapWriterBase<Edge>*> > MapWriters;
     MapWriters writers;
 
-    WriterBase<Edge>* idMap;
+    _writer_bits::MapWriterBase<Edge>* idMap;
     bool forceIdMap;
    
@@ -711,5 +702,5 @@
     std::string id;
 
-    std::auto_ptr<IdWriterBase<Node> > nodeIdWriter;
+    std::auto_ptr<_writer_bits::IdWriterBase<Node> > nodeIdWriter;
   };
 
@@ -744,6 +735,6 @@
   /// \relates LemonWriter
   template <typename _Graph, typename _Traits = DefaultWriterTraits>
-  class UndirEdgeSetWriter : public CommonSectionWriterBase {
-    typedef CommonSectionWriterBase Parent;
+  class UndirEdgeSetWriter : public LemonWriter::SectionWriter {
+    typedef LemonWriter::SectionWriter Parent;
   public:
 
@@ -769,5 +760,6 @@
 	graph(_graph), id(_id) {
       checkConcept<_writer_bits::ItemIdWriter<Node>, NodeIdWriter>();
-      nodeIdWriter.reset(new IdWriter<Node, NodeIdWriter>(_nodeIdWriter));
+      nodeIdWriter.reset(new _writer_bits::
+			 IdWriter<Node, NodeIdWriter>(_nodeIdWriter));
     } 
 
@@ -806,5 +798,6 @@
       checkConcept<_writer_bits::ItemWriter<typename Map::Value>, Writer>();
       writers.push_back(
-	make_pair(name, new MapWriter<UndirEdge, Map, Writer>(map, writer)));
+	make_pair(name, new _writer_bits::
+		  MapWriter<UndirEdge, Map, Writer>(map, writer)));
       return *this;
     }
@@ -929,9 +922,9 @@
   private:
 
-    typedef std::vector<std::pair<std::string, 
-				  WriterBase<UndirEdge>*> > MapWriters;
+    typedef std::vector<std::pair<std::string, _writer_bits::
+				  MapWriterBase<UndirEdge>*> > MapWriters;
     MapWriters writers;
 
-    WriterBase<UndirEdge>* idMap;
+    _writer_bits::MapWriterBase<UndirEdge>* idMap;
     bool forceIdMap;
    
@@ -939,5 +932,5 @@
     std::string id;
 
-    std::auto_ptr<IdWriterBase<Node> > nodeIdWriter;
+    std::auto_ptr<_writer_bits::IdWriterBase<Node> > nodeIdWriter;
   };
 
@@ -953,6 +946,6 @@
   /// \relates LemonWriter
   template <typename _Graph>
-  class NodeWriter : public CommonSectionWriterBase {
-    typedef CommonSectionWriterBase Parent;
+  class NodeWriter : public LemonWriter::SectionWriter {
+    typedef LemonWriter::SectionWriter Parent;
     typedef _Graph Graph;
     typedef typename Graph::Node Node;
@@ -969,5 +962,5 @@
       : Parent(_writer), id(_id) {
       checkConcept<_writer_bits::ItemIdWriter<Node>, _IdWriter>();
-      idWriter.reset(new IdWriter<Node, _IdWriter>(_idWriter));
+      idWriter.reset(new _writer_bits::IdWriter<Node, _IdWriter>(_idWriter));
     }
 
@@ -1021,5 +1014,5 @@
     typedef std::vector<std::pair<std::string, const Node*> > NodeWriters;
     NodeWriters writers;
-    std::auto_ptr<IdWriterBase<Node> > idWriter;
+    std::auto_ptr<_writer_bits::IdWriterBase<Node> > idWriter;
   };
 
@@ -1035,6 +1028,6 @@
   /// \relates LemonWriter
   template <typename _Graph>
-  class EdgeWriter : public CommonSectionWriterBase {
-    typedef CommonSectionWriterBase Parent;
+  class EdgeWriter : public LemonWriter::SectionWriter {
+    typedef LemonWriter::SectionWriter Parent;
     typedef _Graph Graph;
     typedef typename Graph::Edge Edge;
@@ -1051,5 +1044,5 @@
       : Parent(_writer), id(_id) {
       checkConcept<_writer_bits::ItemIdWriter<Edge>, _IdWriter>();
-      idWriter.reset(new IdWriter<Edge, _IdWriter>(_idWriter));
+      idWriter.reset(new _writer_bits::IdWriter<Edge, _IdWriter>(_idWriter));
     }
 
@@ -1102,5 +1095,5 @@
     EdgeWriters writers;
 
-    std::auto_ptr<IdWriterBase<Edge> > idWriter;
+    std::auto_ptr<_writer_bits::IdWriterBase<Edge> > idWriter;
   };
 
@@ -1116,6 +1109,6 @@
   /// \relates LemonWriter
   template <typename _Graph>
-  class UndirEdgeWriter : public CommonSectionWriterBase {
-    typedef CommonSectionWriterBase Parent;
+  class UndirEdgeWriter : public LemonWriter::SectionWriter {
+    typedef LemonWriter::SectionWriter Parent;
     typedef _Graph Graph;
     typedef typename Graph::Node Node;
@@ -1136,6 +1129,8 @@
       checkConcept<_writer_bits::ItemIdWriter<Edge>, _IdWriter>();
       checkConcept<_writer_bits::ItemIdWriter<UndirEdge>, _IdWriter>();
-      undirEdgeIdWriter.reset(new IdWriter<UndirEdge, _IdWriter>(_idWriter));
-      edgeIdWriter.reset(new IdWriter<Edge, _IdWriter>(_idWriter));
+      undirEdgeIdWriter.reset(new _writer_bits::
+			      IdWriter<UndirEdge, _IdWriter>(_idWriter));
+      edgeIdWriter.reset(new _writer_bits::
+			 IdWriter<Edge, _IdWriter>(_idWriter));
     }
 
@@ -1203,9 +1198,9 @@
 				  const UndirEdge*> > UndirEdgeWriters;
     UndirEdgeWriters undirEdgeWriters;
-    std::auto_ptr<IdWriterBase<UndirEdge> > undirEdgeIdWriter;
+    std::auto_ptr<_writer_bits::IdWriterBase<UndirEdge> > undirEdgeIdWriter;
 
     typedef std::vector<std::pair<std::string, const Edge*> > EdgeWriters;
     EdgeWriters edgeWriters;
-    std::auto_ptr<IdWriterBase<Edge> > edgeIdWriter;
+    std::auto_ptr<_writer_bits::IdWriterBase<Edge> > edgeIdWriter;
 
   };
@@ -1223,6 +1218,6 @@
   /// \relates LemonWriter
   template <typename _Traits = DefaultWriterTraits>
-  class AttributeWriter : public CommonSectionWriterBase {
-    typedef CommonSectionWriterBase Parent;
+  class AttributeWriter : public LemonWriter::SectionWriter {
+    typedef LemonWriter::SectionWriter Parent;
     typedef _Traits Traits; 
   public:
@@ -1268,6 +1263,6 @@
 				    const Writer& writer = Writer()) {
       checkConcept<_writer_bits::ItemWriter<Value>, Writer>();
-      writers.push_back(make_pair(name, new ValueWriter<Value, Writer>
-      			       (value, writer)));
+      writers.push_back(make_pair(name, new _writer_bits::
+				  ValueWriter<Value, Writer>(value, writer)));
       return *this;
     }
@@ -1297,5 +1292,6 @@
     std::string id;
 
-    typedef std::vector<std::pair<std::string, ValueWriterBase*> > Writers;
+    typedef std::vector<std::pair<std::string, 
+				  _writer_bits::ValueWriterBase*> > Writers;
     Writers writers;  
   };
