[Debtags-commits] [svn] r1696 - in tagcoll/2.0: . tagcoll

Enrico Zini enrico at costa.debian.org
Tue May 2 23:22:25 UTC 2006


Author: enrico
Date: Tue May  2 23:22:24 2006
New Revision: 1696

Modified:
   tagcoll/2.0/   (props changed)
   tagcoll/2.0/tagcoll/Patches.h
Log:
 r2560 at viaza:  enrico | 2006-05-03 01:14:47 +0200
 Added a Patcher output iterator filter


Modified: tagcoll/2.0/tagcoll/Patches.h
==============================================================================
--- tagcoll/2.0/tagcoll/Patches.h	(original)
+++ tagcoll/2.0/tagcoll/Patches.h	Tue May  2 23:22:24 2006
@@ -28,6 +28,7 @@
 #include <tagcoll/Collection.h>
 
 #include <wibble/operators.h>
+#include <wibble/singleton.h>
 #include <map>
 #include <string>
 
@@ -160,6 +161,36 @@
 	PatchList<ITEM, TAG> getReverse() const throw ();
 };
 
+template<typename ITEM, typename TAG, typename OUT>
+class Patcher
+{
+	OUT out;
+	const PatchList<ITEM, TAG>& patches;
+public:
+	Patcher(const OUT& out, const PatchList<ITEM, TAG>& patches)
+		: out(out), patches(patches) {}
+
+	Patcher<ITEM, TAG, OUT>& operator++() { return *this; }
+
+	template<typename Items, typename Tags>
+	Patcher<ITEM, TAG, OUT>& operator=(const std::pair<Items, Tags>& data)
+	{
+		for (typename Items::const_iterator i = data.first.begin();
+				i != data.first.end(); ++i)
+		{
+			out = make_pair(wibble::singleton(*i), patches.patch(data.second));
+			++out;
+		}
+		return *this;
+	}
+};
+
+template<typename ITEM, typename TAG, typename OUT>
+Patcher<ITEM, TAG, OUT> patcher(const OUT& out, const PatchList<ITEM, TAG>& patches)
+{
+	return Patcher<ITEM, TAG, OUT>(out, patches);
+}
+
 };
 
 // vim:set ts=4 sw=4:



More information about the Debtags-commits mailing list