TextFormat.h

Go to the documentation of this file.
00001 #ifndef TAGCOLL_TEXTFORMAT_H
00002 #define TAGCOLL_TEXTFORMAT_H
00003 
00008 /*
00009  * Copyright (C) 2003,2004,2005  Enrico Zini <enrico@debian.org>
00010  *
00011  * This library is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Lesser General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 2.1 of the License, or (at your option) any later version.
00015  *
00016  * This library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this library; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00024  */
00025 
00026 #include <tagcoll/Consumer.h>
00027 #include <tagcoll/Serializer.h>
00028 #include <tagcoll/Exception.h>
00029 #include <tagcoll/ParserBase.h>
00030 
00031 #include <stdio.h>
00032 
00033 //#define TRACE_PARSE
00034 
00035 namespace Tagcoll
00036 {
00037 template<class ITEM, class TAG>
00038 class PatchList;
00039 
00053 template<class ITEM, class TAG>
00054 class TextFormat : public Consumer<ITEM, TAG>
00055 {
00056 protected:
00057     const Converter<ITEM, std::string>& itemconv;
00058     const Converter<TAG, std::string>& tagconv;
00059     FILE* out;
00060 
00061     virtual void consumeItemUntagged(const ITEM& item);
00062     virtual void consumeItem(const ITEM& item, const OpSet<TAG>& tags);
00063     virtual void consumeItemsUntagged(const OpSet<ITEM>& items);
00064     virtual void consumeItems(const OpSet<ITEM>& items, const OpSet<TAG>& tags);
00065 
00066 public:
00067     TextFormat(
00068             const Converter<ITEM, std::string>& itemconv,
00069             const Converter<TAG, std::string>& tagconv,
00070             FILE* out) : itemconv(itemconv), tagconv(tagconv), out(out) {}
00071     virtual ~TextFormat() {}
00072 
00073 
00077     static void outputPatch(
00078             Converter<ITEM, std::string>& itemconv,
00079             Converter<TAG, std::string>& tagconv,
00080             const PatchList<ITEM, TAG>& patch,
00081             FILE* out);
00082 
00086     static void parse(
00087             Converter<std::string, ITEM>& itemconv,
00088             Converter<std::string, TAG>& tagconv,
00089             ParserInput& in,
00090             Consumer<ITEM, TAG>& consumer);
00091 
00095     static PatchList<ITEM, TAG> parsePatch(
00096             Converter<std::string, ITEM>& itemconv,
00097             Converter<std::string, TAG>& tagconv,
00098             ParserInput& in);
00099 };
00100 
00101 };
00102 
00103 // vim:set ts=4 sw=4:
00104 #endif

Generated on Sat Jan 17 03:28:50 2009 for libtagcoll by  doxygen 1.5.1