libept
|
00001 /* 00002 * Ready-made utility classes for Debtags 00003 * 00004 * Copyright (C) 2003--2007 Enrico Zini <enrico@debian.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 #ifndef EPT_DEBTAGS_UTILS_H 00022 #define EPT_DEBTAGS_UTILS_H 00023 00024 #include <wibble/mixin.h> 00025 #include <ept/debtags/tag.h> 00026 00027 namespace ept { 00028 namespace debtags { 00029 00034 template<typename OUT> 00035 class TagToFacet : public wibble::mixin::OutputIterator< TagToFacet<OUT> > 00036 { 00037 protected: 00038 OUT out; 00039 00040 public: 00041 TagToFacet(const OUT& out) : out(out) {} 00042 00043 template<typename ITEMS, typename TAGS> 00044 TagToFacet<OUT>& operator=(const std::pair<ITEMS, TAGS>& data) 00045 { 00046 std::set< Facet > facets; 00047 for (typename TAGS::const_iterator i = data.second.begin(); 00048 i != data.second.end(); ++i) 00049 facets.insert(i->facet()); 00050 *out = make_pair(data.first, facets); 00051 ++out; 00052 return *this; 00053 } 00054 }; 00055 00056 template<typename OUT> 00057 static TagToFacet<OUT> tagToFacet(const OUT& out) 00058 { 00059 return TagToFacet<OUT>(out); 00060 } 00061 00062 } 00063 } 00064 00065 // vim:set ts=4 sw=4: 00066 #endif