+vector<int> UNSERIALIZE;
+
+static void
+print_document_terms (Xapian::Document doc)
+{
+ Xapian::TermIterator i;
+
+ printf (" Terms:\n");
+
+ for (i = doc.termlist_begin (); i != doc.termlist_end (); i++)
+ cout << "\t" << *i << endl;
+}
+
+static int
+vector_int_contains (vector<int> v, int i)
+{
+ vector<int>::iterator result;
+
+ result = find (v.begin(), v.end(), i);
+
+ return result != v.end();
+}
+
+static void
+print_document_values (Xapian::Document doc)
+{
+ Xapian::ValueIterator i;
+ int value_no, value_int;
+ double value_float;
+
+ printf (" Values:\n");
+
+ for (i = doc.values_begin (); i != doc.values_end (); i++) {
+ value_no = i.get_valueno();
+
+ cout << "\t" << i.get_valueno() << ": ";
+
+ if (vector_int_contains (UNSERIALIZE, value_no)) {
+ value_float = Xapian::sortable_unserialise (*i);
+ value_int = value_float;
+ if (value_int == value_float)
+ cout << value_int;
+ else
+ cout << value_float;
+ } else {
+ cout << *i;
+ }
+
+ cout << endl;
+ }
+}
+
+static void
+print_document (Xapian::Database db, Xapian::docid id)
+{
+ Xapian::Document doc;
+
+ printf ("Document %u:\n", id);
+
+ doc = db.get_document (id);
+
+ printf (" Data:\n");
+ cout << "\t" << doc.get_data () << endl;
+
+ print_document_terms (doc);
+
+ print_document_values (doc);
+}
+