xapian-core  1.4.27
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,2023 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 
145  void set_data(const std::string &data);
146 
161  void add_posting(const std::string & tname,
162  Xapian::termpos tpos,
163  Xapian::termcount wdfinc = 1);
164 
174  void add_term(const std::string & tname, Xapian::termcount wdfinc = 1);
175 
192  void add_boolean_term(const std::string & term) { add_term(term, 0); }
193 
213  void remove_posting(const std::string & tname,
214  Xapian::termpos tpos,
215  Xapian::termcount wdfdec = 1);
216 
235  Xapian::termpos remove_postings(const std::string& term,
236  Xapian::termpos term_pos_first,
237  Xapian::termpos term_pos_last,
238  Xapian::termcount wdf_dec = 1);
239 
247  void remove_term(const std::string & tname);
248 
250  void clear_terms();
251 
255  Xapian::termcount termlist_count() const;
256 
267  TermIterator termlist_begin() const;
268 
270  TermIterator XAPIAN_NOTHROW(termlist_end() const) {
271  return TermIterator();
272  }
273 
275  Xapian::termcount values_count() const;
276 
278  ValueIterator values_begin() const;
279 
281  ValueIterator XAPIAN_NOTHROW(values_end() const) {
282  return ValueIterator();
283  }
284 
296  docid get_docid() const;
297 
305  std::string serialise() const;
306 
309  static Document unserialise(const std::string &serialised);
310 
312  std::string get_description() const;
313 };
314 
315 }
316 
317 #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:43
Class for iterating over document values.
Definition: valueiterator.h:40
TermIterator termlist_end() const
Equivalent end iterator for termlist_begin().
Definition: document.h:270
#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:281
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:192
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