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

Enrico Zini enrico at costa.debian.org
Fri May 5 09:48:09 UTC 2006


Author: enrico
Date: Fri May  5 09:48:07 2006
New Revision: 1703

Modified:
   tagcoll/2.0/   (props changed)
   tagcoll/2.0/tagcoll/Consumer.h
   tagcoll/2.0/tagcoll/Expression.h
   tagcoll/2.0/tagcoll/Patches.h
   tagcoll/2.0/tagcoll/Sink.h
   tagcoll/2.0/tagcoll/TextFormat.h
   tagcoll/2.0/tagcoll/TextFormat.tcc
   tagcoll/2.0/tagcoll/filters.h
Log:
 r2586 at viaza:  enrico | 2006-05-05 11:46:21 +0200
 Consumer can now accept Singletons and Empty without ambiguities
 Use *out= for output iterators
 Use wibble::mixin::OutputIterator to implement output iterators


Modified: tagcoll/2.0/tagcoll/Consumer.h
==============================================================================
--- tagcoll/2.0/tagcoll/Consumer.h	(original)
+++ tagcoll/2.0/tagcoll/Consumer.h	Fri May  5 09:48:07 2006
@@ -77,12 +77,21 @@
 	/// Process an untagged item
 	void consume(const ITEM& item) { consumeItemUntagged(item); }
 
+	/// Process an untagged item
+	void consume(const wibble::Singleton<ITEM>& item, const wibble::Empty<TAG>&) { consumeItemUntagged(*item.begin()); }
+
 	/// Process a tagged item, with its tags
 	void consume(const ITEM& item, const std::set<TAG>& tags) { consumeItem(item, tags); }
 
+	/// Process a tagged item, with its tags
+	void consume(const wibble::Singleton<ITEM>& item, const std::set<TAG>& tags) { consumeItem(*item.begin(), tags); }
+
 	/// Process a set of items, all with no tags
 	void consume(const std::set<ITEM>& items) { consumeItemsUntagged(items); }
 
+	/// Process a set of items, all with no tags
+	void consume(const std::set<ITEM>& items, const wibble::Empty<TAG>&) { consumeItemsUntagged(items); }
+
 	/// Process a set of items identically tagged, with their tags
 	void consume(const std::set<ITEM>& items, const std::set<TAG>& tags) { consumeItems(items, tags); }
 };
@@ -95,27 +104,6 @@
 public:
 	ConsumerAdaptor(Consumer<ITEM, TAG>& target) : target(target) {}
 
-	template<typename Item, typename Tags>
-	ConsumerAdaptor<ITEM, TAG>& operator=(const std::pair<wibble::Singleton<Item>, wibble::Empty<TAG> >& data)
-	{
-		target.consume(*data.first.begin());
-		return *this;
-	}
-
-	template<typename Items, typename Tag>
-	ConsumerAdaptor<ITEM, TAG>& operator=(const std::pair<Items, wibble::Empty<Tag> >& data)
-	{
-		target.consume(data.first);
-		return *this;
-	}
-
-	template<typename Item, typename Tags>
-	ConsumerAdaptor<ITEM, TAG>& operator=(const std::pair<wibble::Singleton<Item>, Tags>& data)
-	{
-		target.consume(*data.first.begin(), data.second);
-		return *this;
-	}
-
 	template<typename Items, typename Tags>
 	ConsumerAdaptor<ITEM, TAG>& operator=(const std::pair<Items, Tags>& data)
 	{

Modified: tagcoll/2.0/tagcoll/Expression.h
==============================================================================
--- tagcoll/2.0/tagcoll/Expression.h	(original)
+++ tagcoll/2.0/tagcoll/Expression.h	Fri May  5 09:48:07 2006
@@ -25,6 +25,7 @@
 #include <set>
 #include <map>
 #include <wibble/singleton.h>
+#include <wibble/mixin.h>
 
 namespace tagcoll
 {
@@ -235,7 +236,7 @@
  * Remove the items that do not match a tag expression.
  */
 template<class OUT>
-class FilterItemsByExpression : public ExpressionFilter
+class FilterItemsByExpression : public ExpressionFilter, public wibble::mixin::OutputIterator< FilterItemsByExpression<OUT> >
 {
 protected:
 	OUT out;
@@ -248,14 +249,12 @@
 	
 	// output iterator interface
 
-	FilterItemsByExpression& operator++() { return *this; }
-
 	template<typename Items, typename Tags>
 	FilterItemsByExpression& operator=(const std::pair<Items, Tags>& data)
 	{
 		if (match(data.second))
 		{
-			out = data;
+			*out = data;
 			++out;
 		}
 		return *this;
@@ -276,7 +275,8 @@
  * "!(use::gaming || game::*)".
  */
 template<class OUT>
-class FilterTagsByExpression : public ExpressionFilter
+class FilterTagsByExpression : public ExpressionFilter, public wibble::mixin::OutputIterator< FilterTagsByExpression<OUT> >
+
 {
 protected:
 	OUT out;
@@ -289,8 +289,6 @@
 
 	// output iterator interface
 
-	FilterTagsByExpression& operator++() { return *this; }
-
 	template<typename Items, typename Tags>
 	FilterTagsByExpression& operator=(const std::pair<Items, Tags>& data)
 	{
@@ -309,9 +307,9 @@
 				changed = true;
 		}
 		if (!changed)
-			out = data;
+			*out = data;
 		else
-			out = std::make_pair(data.first, filtered);
+			*out = std::make_pair(data.first, filtered);
 		++out;
 		return *this;
 	}

Modified: tagcoll/2.0/tagcoll/Patches.h
==============================================================================
--- tagcoll/2.0/tagcoll/Patches.h	(original)
+++ tagcoll/2.0/tagcoll/Patches.h	Fri May  5 09:48:07 2006
@@ -27,6 +27,7 @@
 
 #include <wibble/operators.h>
 #include <wibble/singleton.h>
+#include <wibble/mixin.h>
 #include <map>
 #include <string>
 
@@ -159,7 +160,7 @@
 };
 
 template<typename ITEM, typename TAG, typename OUT>
-class Patcher
+class Patcher : public wibble::mixin::OutputIterator< Patcher<ITEM, TAG, OUT> >
 {
 	OUT out;
 	const PatchList<ITEM, TAG>& patches;
@@ -167,9 +168,6 @@
 	Patcher(const PatchList<ITEM, TAG>& patches, const OUT& out)
 		: out(out), patches(patches) {}
 
-	Patcher<ITEM, TAG, OUT>& operator++() { return *this; }
-	Patcher<ITEM, TAG, OUT>& operator*() { return *this; }
-
 	template<typename Items, typename Tags>
 	Patcher<ITEM, TAG, OUT>& operator=(const std::pair<Items, Tags>& data)
 	{
@@ -180,9 +178,9 @@
 			typename PatchList<ITEM, TAG>::const_iterator p = patches.find(*i);
 			if (p == patches.end())
 				// If there are no patches, return the tagset unchanged
-				out = data;
+				*out = data;
 			else
-				out = make_pair(wibble::singleton(*i), p->second.apply(data.second));
+				*out = make_pair(wibble::singleton(*i), p->second.apply(data.second));
 			++out;
 		}
 		return *this;

Modified: tagcoll/2.0/tagcoll/Sink.h
==============================================================================
--- tagcoll/2.0/tagcoll/Sink.h	(original)
+++ tagcoll/2.0/tagcoll/Sink.h	Fri May  5 09:48:07 2006
@@ -23,17 +23,17 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
 
+#include <wibble/mixin.h>
+
 namespace tagcoll
 {
 
 /**
  * Consumer that discards its input
  */
-class Sink
+class Sink : public wibble::mixin::OutputIterator<Sink>
 {
 public:
-	Sink& operator++() const { return *this; }
-	
 	template<typename Data>
 	Sink& operator=(const Data&) const { return *this; }
 };

Modified: tagcoll/2.0/tagcoll/TextFormat.h
==============================================================================
--- tagcoll/2.0/tagcoll/TextFormat.h	(original)
+++ tagcoll/2.0/tagcoll/TextFormat.h	Fri May  5 09:48:07 2006
@@ -54,7 +54,7 @@
  *   ITEM1, ITEM2, ITEM3:
  *   ITEM1, ITEM2, ITEM3: TAG1, TAG2, TAG3
  */
-class StdioWriter
+class StdioWriter : public wibble::mixin::OutputIterator<StdioWriter>
 {
 protected:
 	FILE* out;
@@ -62,8 +62,6 @@
 public:
 	StdioWriter(FILE* out) : out(out) {}
 
-	StdioWriter& operator++() { return *this; }
-
 	template<typename Items, typename Tags>
 	StdioWriter& operator=(const std::pair<Items, Tags>& data);
 };

Modified: tagcoll/2.0/tagcoll/TextFormat.tcc
==============================================================================
--- tagcoll/2.0/tagcoll/TextFormat.tcc	(original)
+++ tagcoll/2.0/tagcoll/TextFormat.tcc	Fri May  5 09:48:07 2006
@@ -120,9 +120,9 @@
 					if (itemset.empty())
 						throw tagcoll::exception::Parser(line, "no elements before `:' separator");
 					if (tagset.empty())
-						out = make_pair(itemset, wibble::Empty<std::string>());
+						*out = make_pair(itemset, wibble::Empty<std::string>());
 					else
-						out = make_pair(itemset, tagset);
+						*out = make_pair(itemset, tagset);
 					++out;
 				}
 				itemset.clear();

Modified: tagcoll/2.0/tagcoll/filters.h
==============================================================================
--- tagcoll/2.0/tagcoll/filters.h	(original)
+++ tagcoll/2.0/tagcoll/filters.h	Fri May  5 09:48:07 2006
@@ -23,6 +23,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
 
+#include <wibble/mixin.h>
 #include <set>
 #include <map>
 #include <string>
@@ -45,14 +46,13 @@
 
 public:
 	template<typename IT>
-	class SubstitutionsInserter
+	class SubstitutionsInserter : public wibble::mixin::OutputIterator< SubstitutionsInserter<IT> >
 	{
 		Substitutions<IT>& out;
 
 	public:
 		SubstitutionsInserter(Substitutions<IT>& out)
 			: out(out) {}
-		SubstitutionsInserter& operator++() { return *this; }
 
 		template<typename NewItems, typename OldItems>
 		SubstitutionsInserter& operator=(const std::pair<NewItems, OldItems>& data)
@@ -114,7 +114,7 @@
  * \endcode
  */
 template<typename T, typename OUT>
-class Substitute
+class Substitute : public wibble::mixin::OutputIterator< Substitute<T, OUT> >
 {
 protected:
 	Substitutions<T> changes;
@@ -134,12 +134,10 @@
 	 */
 	const Substitutions<T>& substitutions() const { return changes; }
 
-	Substitute<T, OUT>& operator++() { return *this; }
-
 	template<typename Items, typename Tags>
 	Substitute<T, OUT>& operator=(const std::pair<Items, Tags>& data)
 	{
-		out = make_pair(data.first, changes.change(data.second));
+		*out = make_pair(data.first, changes.change(data.second));
 		++out;
 		return *this;
 	}
@@ -158,7 +156,7 @@
  * have tags and keeps the packages that have none.
  */
 template <typename OUT>
-class UntaggedRemover
+class UntaggedRemover : public wibble::mixin::OutputIterator< UntaggedRemover<OUT> >
 {
 protected:
 	OUT out;
@@ -167,8 +165,6 @@
 public:
 	UntaggedRemover(const OUT& out, bool inverse = false) : out(out), inverse(inverse) {}
 
-	UntaggedRemover<OUT>& operator++() { return *this; }
-
 	template<typename Items, typename Tags>
 	UntaggedRemover<OUT>& operator=(const std::pair<Items, Tags>& data)
 	{
@@ -176,13 +172,13 @@
 		{
 			if (inverse)
 			{
-				out = data;
+				*out = data;
 				++out;
 			}
 		} else {
 			if (!inverse)
 			{
-				out = data;
+				*out = data;
 				++out;
 			}
 		}
@@ -201,7 +197,7 @@
  * Removes tags which are not inside a facet
  */
 template<typename OUT>
-class UnfacetedRemover
+class UnfacetedRemover : public wibble::mixin::OutputIterator< UnfacetedRemover<OUT> >
 {
 protected:
 	OUT out;
@@ -211,8 +207,6 @@
 	UnfacetedRemover(const OUT& out, const std::string& separator = std::string("::"))
 		: out(out), separator(separator) {}
 
-	UnfacetedRemover<OUT>& operator++() { return *this; }
-
 	template<typename Items, typename Tags>
 	UnfacetedRemover<OUT>& operator=(const std::pair<Items, Tags>& data)
 	{
@@ -227,9 +221,9 @@
 				changed = true;
 
 		if (changed)
-			out = make_pair(data.first, patched);
+			*out = make_pair(data.first, patched);
 		else
-			out = data;
+			*out = data;
 		++out;
 
 		return *this;



More information about the Debtags-commits mailing list