[Debtags-commits] [svn] r876 - libdebtags1/trunk/debtags
Enrico Zini
debtags-commits@lists.alioth.debian.org
Sat, 11 Jun 2005 14:37:00 +0000
Author: enrico
Date: Sat Jun 11 14:36:58 2005
New Revision: 876
Modified:
libdebtags1/trunk/debtags/DebtagsSerializer.cc
libdebtags1/trunk/debtags/DebtagsSerializer.h
libdebtags1/trunk/debtags/TagDB.cc
libdebtags1/trunk/debtags/TagDB.h
libdebtags1/trunk/debtags/instantiations.cc
Log:
Reenabled the string versions of TagDB::output*
Modified: libdebtags1/trunk/debtags/DebtagsSerializer.cc
==============================================================================
--- libdebtags1/trunk/debtags/DebtagsSerializer.cc (original)
+++ libdebtags1/trunk/debtags/DebtagsSerializer.cc Sat Jun 11 14:36:58 2005
@@ -61,4 +61,15 @@
#endif
}
+std::string DebtagsPartialSerializer::tagToString(const Tag& tag) throw ()
+{
+ return ser.tagToString(tag);
+}
+
+
+Debtags::Tag DebtagsPartialSerializer::stringToTag(const std::string& tag) throw ()
+{
+ return ser.stringToTag(tag);
+}
+
// vim:set ts=4 sw=4:
Modified: libdebtags1/trunk/debtags/DebtagsSerializer.h
==============================================================================
--- libdebtags1/trunk/debtags/DebtagsSerializer.h (original)
+++ libdebtags1/trunk/debtags/DebtagsSerializer.h Sat Jun 11 14:36:58 2005
@@ -73,6 +73,49 @@
return Tagcoll::Serializer<Package, Tag>::tagToString(tag);
}
+ friend class DebtagsPartialSerializer;
+};
+
+/**
+ * Serialize only Tags to and from Strings
+ */
+class DebtagsPartialSerializer : public Tagcoll::Serializer<std::string, Tag>
+{
+protected:
+ Tagcoll::Serializer<Debtags::Package, Tag>& ser;
+
+public:
+ DebtagsPartialSerializer(Tagcoll::Serializer<Debtags::Package, Tag>& ser) throw ()
+ : ser(ser) {}
+
+ /**
+ * Convert a TAG to a string
+ */
+ virtual std::string tagToString(const Tag& tag) throw ();
+
+ /**
+ * Convert an ITEM to a string
+ */
+ virtual std::string itemToString(const std::string& item) throw () { return item; }
+
+ /**
+ * Convert a string to a TAG
+ */
+ virtual Tag stringToTag(const std::string& tag) throw ();
+
+ /**
+ * Convert a string to an ITEM
+ */
+ virtual std::string stringToItem(const std::string& item) throw () { return item; }
+
+ /**
+ * Convert TAGs to strings
+ */
+ virtual Tagcoll::OpSet<std::string> tagToString(const Tagcoll::OpSet<Tag>& tag) throw ()
+ {
+ return Tagcoll::Serializer<std::string, Tag>::tagToString(tag);
+ }
+
};
};
Modified: libdebtags1/trunk/debtags/TagDB.cc
==============================================================================
--- libdebtags1/trunk/debtags/TagDB.cc (original)
+++ libdebtags1/trunk/debtags/TagDB.cc Sat Jun 11 14:36:58 2005
@@ -406,9 +406,21 @@
}
#endif
-// Output the current Debian tags database to a TagcollConsumer
+void TagDB::outputSystem(TagcollConsumer<std::string, std::string>& cons)
+{
+ StdioParserInput in(Paths::path_tagdb);
+ TrivialSerializer ser;
+ TextFormat<string, string>::parse(in, ser, cons);
+}
+
+void TagDB::outputSystem(TagcollConsumer<std::string, Tag>& cons)
+{
+ StdioParserInput in(Paths::path_tagdb);
+ DebtagsPartialSerializer ser(serializer);
+ TextFormat<string, Tag>::parse(in, ser, cons);
+}
+
void TagDB::outputSystem(TagcollConsumer<Package, Tag>& cons)
- throw (FileException, ParserException)
{
StdioParserInput in(Paths::path_tagdb);
TextFormat<Package, Tag>::parse(in, serializer, cons);
@@ -487,9 +499,41 @@
}
#endif
-// Output the current Debian tags database, patched with local patch, to a TagcollConsumer
+void TagDB::outputPatched(TagcollConsumer<std::string, std::string>& cons)
+{
+ const string patchFile = rcdir + "/patch";
+ TrivialSerializer ser;
+ if (access(patchFile.c_str(), F_OK) == 0)
+ {
+ StdioParserInput inpatch(patchFile);
+ PatchList<string, string> patch = TextFormat<string, string>::parsePatch(inpatch, ser);
+
+ patch.setConsumer(&cons);
+
+ StdioParserInput in(Paths::path_tagdb);
+ TextFormat<string, string>::parse(in, ser, patch);
+ } else
+ outputSystem(cons);
+}
+
+void TagDB::outputPatched(TagcollConsumer<std::string, Debtags::Tag>& cons)
+{
+ const string patchFile = rcdir + "/patch";
+ DebtagsPartialSerializer ser(serializer);
+ if (access(patchFile.c_str(), F_OK) == 0)
+ {
+ StdioParserInput inpatch(patchFile);
+ PatchList<string, Debtags::Tag> patch = TextFormat<string, Debtags::Tag>::parsePatch(inpatch, ser);
+
+ patch.setConsumer(&cons);
+
+ StdioParserInput in(Paths::path_tagdb);
+ TextFormat<string, Debtags::Tag>::parse(in, ser, patch);
+ } else
+ outputSystem(cons);
+}
+
void TagDB::outputPatched(TagcollConsumer<Debtags::Package, Debtags::Tag>& cons)
- throw (FileException, ParserException)
{
string patchFile = rcdir + "/patch";
if (access(patchFile.c_str(), F_OK) == 0)
Modified: libdebtags1/trunk/debtags/TagDB.h
==============================================================================
--- libdebtags1/trunk/debtags/TagDB.h (original)
+++ libdebtags1/trunk/debtags/TagDB.h Sat Jun 11 14:36:58 2005
@@ -132,40 +132,40 @@
*/
static void outputFile(const std::string& name, TagcollConsumer<Package, Tag>& cons, bool facet_only = true)
throw (FileException, ParserException);
-
+#endif
/** Output the current Debian tags database to a TagcollConsumer
* @note The collection is sent to 'cons' without merging repeated items
*/
- static void outputSystem(TagcollConsumer<std::string, std::string>& cons, bool facet_only = true)
- throw (FileException, ParserException);
+ void outputSystem(TagcollConsumer<std::string, std::string>& cons);
/** Output the current Debian tags database to a TagcollConsumer
* @note The collection is sent to 'cons' without merging repeated items
*/
- static void outputSystem(TagcollConsumer<std::string, Tag>& cons, bool facet_only = true)
- throw (FileException, ParserException);
-#endif
+ void outputSystem(TagcollConsumer<std::string, Tag>& cons);
/** Output the current Debian tags database to a TagcollConsumer
* @note The collection is sent to 'cons' without merging repeated items
*/
- void outputSystem(TagcollConsumer<Package, Tag>& cons)
- throw (FileException, ParserException);
+ void outputSystem(TagcollConsumer<Package, Tag>& cons);
-#if 0
- /// Output the current Debian tags database, patched with local patch, to a TagcollConsumer
- static void outputPatched(TagcollConsumer<std::string, std::string>& cons, bool facet_only = true)
- throw (FileException, ParserException);
+ /**
+ * Output the current Debian tags database, patched with local patch, to a TagcollConsumer
+ * @note The collection is sent to 'cons' without merging repeated items
+ */
+ void outputPatched(TagcollConsumer<std::string, std::string>& cons);
- /// Output the current Debian tags database, patched with local patch, to a TagcollConsumer
- static void outputPatched(TagcollConsumer<std::string, Tag>& cons, bool facet_only = true)
- throw (FileException, ParserException);
-#endif
+ /**
+ * Output the current Debian tags database, patched with local patch, to a TagcollConsumer
+ * @note The collection is sent to 'cons' without merging repeated items
+ */
+ void outputPatched(TagcollConsumer<std::string, Tag>& cons);
- /// Output the current Debian tags database, patched with local patch, to a TagcollConsumer
- void outputPatched(TagcollConsumer<Package, Tag>& cons)
- throw (FileException, ParserException);
+ /**
+ * Output the current Debian tags database, patched with local patch, to a TagcollConsumer
+ * @note The collection is sent to 'cons' without merging repeated items
+ */
+ void outputPatched(TagcollConsumer<Package, Tag>& cons);
//using TDBReadonlyDiskIndex<Package, Tag>::getItems;
//using TDBReadonlyDiskIndex<Package, Tag>::getTags;
Modified: libdebtags1/trunk/debtags/instantiations.cc
==============================================================================
--- libdebtags1/trunk/debtags/instantiations.cc (original)
+++ libdebtags1/trunk/debtags/instantiations.cc Sat Jun 11 14:36:58 2005
@@ -36,9 +36,11 @@
template class TagcollFilter<Debtags::Package, Debtags::Tag>;
template class Patch<Debtags::Package, Debtags::Tag>;
template class PatchList<Debtags::Package, Debtags::Tag>;
+template class Serializer<std::string, Debtags::Tag>;
template class Serializer<Debtags::Package, Debtags::Tag>;
template class ToStrings<Debtags::Package, Debtags::Tag>;
template class FromStrings<Debtags::Package, Debtags::Tag>;
+template class TextFormat<std::string, Debtags::Tag>;
template class TextFormat<Debtags::Package, Debtags::Tag>;
template class DiskIndex<Debtags::Package, Debtags::Tag>;
template class TDBDiskIndex<Debtags::Package, Debtags::Tag>;