Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

Changes.h

Go to the documentation of this file.
00001 #ifndef TAGCOLL_CHANGES_H 00002 #define TAGCOLL_CHANGES_H 00003 00004 /* 00005 * Represent a list of tag substitutions to apply as a TagcollFilter 00006 * 00007 * Copyright (C) 2003 Enrico Zini <enrico@debian.org> 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 00024 #pragma interface 00025 00026 #include <tagcoll/TagcollConsumer.h> 00027 #include <tagcoll/TagcollFilter.h> 00028 00029 #include <map> 00030 #include <string> 00031 00032 namespace Tagcoll 00033 { 00034 00035 // List of changes to apply to tag names with a tagged collection is being 00036 // parsed 00037 class ChangeList : public TagcollConsumer<std::string> 00038 { 00039 protected: 00040 typedef std::map<std::string, std::string> changes_t; 00041 changes_t changes; 00042 00043 public: 00044 virtual ~ChangeList() throw () {} 00045 00046 virtual void consume(const std::string& item) throw () {} 00047 virtual void consume(const std::string& item, const OpSet<std::string>& tags) throw (); 00048 00049 // Change a single tag 00050 std::string change(const std::string& tag) const throw (); 00051 00052 // Change all the tags in a tag set 00053 OpSet<std::string> change(const OpSet<std::string>& tags) const throw (); 00054 }; 00055 00056 class ApplyChanges : public TagcollFilter<std::string> 00057 { 00058 protected: 00059 ChangeList& changes; 00060 00061 public: 00062 ApplyChanges(ChangeList& changes) throw () 00063 : changes(changes) {} 00064 00065 virtual void consume(const std::string& item) throw () 00066 { 00067 consumer->consume(changes.change(item)); 00068 } 00069 00070 virtual void consume(const std::string& item, const OpSet<std::string>& tags) throw () 00071 { 00072 consumer->consume(item, changes.change(tags)); 00073 } 00074 }; 00075 00076 }; 00077 00078 // vim:set ts=4 sw=4: 00079 #endif

Generated on Sun Aug 15 13:57:09 2004 for libtagcoll by doxygen 1.3.8