xapian-core  1.4.21
document.h
Go to the documentation of this file.
1 
4 /* Copyright 1999,2000,2001 BrightStation PLC
5  * Copyright 2002 Ananova Ltd
6  * Copyright 2002,2003,2004,2006,2007,2009,2010,2011,2012,2013,2014,2018 Olly Betts
7  * Copyright 2009 Lemur Consulting Ltd
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef XAPIAN_INCLUDED_DOCUMENT_H
26 #define XAPIAN_INCLUDED_DOCUMENT_H
27 
28 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
29 # error Never use <xapian/document.h> directly; include <xapian.h> instead.
30 #endif
31 
32 #include <string>
33 
34 #include <xapian/attributes.h>
35 #include <xapian/intrusive_ptr.h>
36 #include <xapian/types.h>
37 #include <xapian/termiterator.h>
38 #include <xapian/valueiterator.h>
39 #include <xapian/visibility.h>
40 
41 namespace Xapian {
42 
62  public:
63  class Internal;
66 
71  explicit Document(Internal *internal_);
72 
78  Document(const Document &other);
79 
85  void operator=(const Document &other);
86 
87 #ifdef XAPIAN_MOVE_SEMANTICS
88  Document(Document&& o);
90 
92  Document& operator=(Document&& o);
93 #endif
94 
96  Document();
97 
99  ~Document();
100 
108  std::string get_value(Xapian::valueno slot) const;
109 
119  void add_value(Xapian::valueno slot, const std::string &value);
120 
122  void remove_value(Xapian::valueno slot);
123 
125  void clear_values();
126 
134  std::string get_data() const;
135 
144  void set_data(const std::string &data);
145 
160  void add_posting(const std::string & tname,
161  Xapian::termpos tpos,
162  Xapian::termcount wdfinc = 1);
163 
173  void add_term(const std::string & tname, Xapian::termcount wdfinc = 1);
174 
191  void add_boolean_term(const std::string & term) { add_term(term, 0); }
192 
212  void remove_posting(const std::string & tname,
213  Xapian::termpos tpos,
214  Xapian::termcount wdfdec = 1);
215 
234  Xapian::termpos remove_postings(const std::string& term,
235  Xapian::termpos term_pos_first,
236  Xapian::termpos term_pos_last,
237  Xapian::termcount wdf_dec = 1);
238 
246  void remove_term(const std::string & tname);
247 
249  void clear_terms();
250 
254  Xapian::termcount termlist_count() const;
255 
257  TermIterator termlist_begin() const;
258 
260  TermIterator XAPIAN_NOTHROW(termlist_end() const) {
261  return TermIterator();
262  }
263 
265  Xapian::termcount values_count() const;
266 
268  ValueIterator values_begin() const;
269 
271  ValueIterator XAPIAN_NOTHROW(values_end() const) {
272  return ValueIterator();
273  }
274 
286  docid get_docid() const;
287 
295  std::string serialise() const;
296 
299  static Document unserialise(const std::string &serialised);
300 
302  std::string get_description() const;
303 };
304 
305 }
306 
307 #endif // XAPIAN_INCLUDED_DOCUMENT_H
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
typedefs for Xapian
Compiler attribute macros.
A document in the database, possibly plus modifications.
Definition: document.h:41
Class for iterating over document values.
Definition: valueiterator.h:40
TermIterator termlist_end() const
Equivalent end iterator for termlist_begin().
Definition: document.h:260
#define XAPIAN_VISIBILITY_DEFAULT
Definition: visibility.h:28
Class for iterating over a list of terms.
Definition: termiterator.h:41
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
Define XAPIAN_VISIBILITY_* macros.
Class for iterating over document values.
ValueIterator values_end() const
Equivalent end iterator for values_begin().
Definition: document.h:271
unsigned valueno
The number for a value slot in a document.
Definition: types.h:108
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
Definition: types.h:83
void add_boolean_term(const std::string &term)
Add a boolean filter term to the document.
Definition: document.h:191
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
A smart pointer that uses intrusive reference counting.
Definition: intrusive_ptr.h:81
Class for iterating over a list of terms.
A handle representing a document in a Xapian database.
Definition: document.h:61