00001 00004 /* Copyright 1999,2000,2001 BrightStation PLC 00005 * Copyright 2002 Ananova Ltd 00006 * Copyright 2002,2003,2004,2006,2007,2009,2010 Olly Betts 00007 * Copyright 2009 Lemur Consulting Ltd 00008 * 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License as 00011 * published by the Free Software Foundation; either version 2 of the 00012 * License, or (at your option) any later version. 00013 * 00014 * This program 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 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00022 * USA 00023 */ 00024 00025 #ifndef XAPIAN_INCLUDED_DOCUMENT_H 00026 #define XAPIAN_INCLUDED_DOCUMENT_H 00027 00028 #include <string> 00029 00030 #include <xapian/base.h> 00031 #include <xapian/types.h> 00032 #include <xapian/termiterator.h> 00033 #include <xapian/valueiterator.h> 00034 #include <xapian/visibility.h> 00035 00036 namespace Xapian { 00037 00056 class XAPIAN_VISIBILITY_DEFAULT Document { 00057 public: 00058 class Internal; 00060 Xapian::Internal::RefCntPtr<Internal> internal; 00061 00066 explicit Document(Internal *internal_); 00067 00073 Document(const Document &other); 00074 00080 void operator=(const Document &other); 00081 00083 Document(); 00084 00086 ~Document(); 00087 00095 std::string get_value(Xapian::valueno slot) const; 00096 00106 void add_value(Xapian::valueno slot, const std::string &value); 00107 00109 void remove_value(Xapian::valueno slot); 00110 00112 void clear_values(); 00113 00121 std::string get_data() const; 00122 00131 void set_data(const std::string &data); 00132 00147 void add_posting(const std::string & tname, 00148 Xapian::termpos tpos, 00149 Xapian::termcount wdfinc = 1); 00150 00160 void add_term(const std::string & tname, Xapian::termcount wdfinc = 1); 00161 00178 void add_boolean_term(const std::string & term) { add_term(term, 0); } 00179 00199 void remove_posting(const std::string & tname, 00200 Xapian::termpos tpos, 00201 Xapian::termcount wdfdec = 1); 00202 00210 void remove_term(const std::string & tname); 00211 00213 void clear_terms(); 00214 00218 Xapian::termcount termlist_count() const; 00219 00221 TermIterator termlist_begin() const; 00222 00224 TermIterator termlist_end() const { 00225 return TermIterator(); 00226 } 00227 00229 Xapian::termcount values_count() const; 00230 00232 ValueIterator values_begin() const; 00233 00235 ValueIteratorEnd_ values_end() const { 00236 return ValueIteratorEnd_(); 00237 } 00238 00250 docid get_docid() const; 00251 00259 std::string serialise() const; 00260 00263 static Document unserialise(const std::string &s); 00264 00266 std::string get_description() const; 00267 }; 00268 00269 } 00270 00271 #endif // XAPIAN_INCLUDED_DOCUMENT_H