lemon/lemon_writer.h
changeset 1855 c72636dcf0bd
parent 1845 f8bbfed86036
child 1875 98698b69a902
equal deleted inserted replaced
6:bd5b02f9e3b1 7:222623d18a12
   170     public:
   170     public:
   171       typedef _Item Item;
   171       typedef _Item Item;
   172 
   172 
   173       virtual ~MapWriterBase() {}
   173       virtual ~MapWriterBase() {}
   174 
   174 
   175       virtual void write(std::ostream& os, const Item& item) = 0;
   175       virtual void write(std::ostream& os, const Item& item) const = 0;
   176     };
   176     };
   177 
   177 
   178 
   178 
   179     template <typename _Item, typename _Map, typename _Writer>
   179     template <typename _Item, typename _Map, typename _Writer>
   180     class MapWriter : public MapWriterBase<_Item> {
   180     class MapWriter : public MapWriterBase<_Item> {
   190       MapWriter(const Map& _map, const Writer& _writer) 
   190       MapWriter(const Map& _map, const Writer& _writer) 
   191 	: map(_map), writer(_writer) {}
   191 	: map(_map), writer(_writer) {}
   192 
   192 
   193       virtual ~MapWriter() {}
   193       virtual ~MapWriter() {}
   194 
   194 
   195       virtual void write(std::ostream& os, const Item& item) {
   195       virtual void write(std::ostream& os, const Item& item) const {
   196 	Value value = map[item];
   196 	Value value = map[item];
   197 	writer.write(os, value);
   197 	writer.write(os, value);
   198       }
   198       }
   199 
   199 
   200     };
   200     };