xapian-core  1.4.25
vectortermlist.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2011,2015 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <config.h>
22 
23 #include "vectortermlist.h"
24 
25 #include "net/length.h"
26 #include "omassert.h"
27 #include "xapian/error.h"
28 
29 using namespace std;
30 
33 {
34  return num_terms;
35 }
36 
37 string
39 {
40  // Check we've started but not reached the end.
41  Assert(p != data.data());
43  return current_term;
44 }
45 
48 {
49  // Check we've started but not reached the end.
50  Assert(p != data.data());
52  return 1;
53 }
54 
57 {
58  throw Xapian::InvalidOperationError("VectorTermList::get_termfreq() not meaningful");
59 }
60 
61 TermList *
63 {
64  // Check we've not reached the end.
66 
67  const char * end = data.data() + data.size();
68  if (p == end) {
69  current_term.resize(0);
70  p = NULL;
71  } else {
72  size_t len;
73  decode_length_and_check(&p, end, len);
74  current_term.assign(p, len);
75  p += len;
76  }
77 
78  return NULL;
79 }
80 
81 TermList *
82 VectorTermList::skip_to(const string &)
83 {
84  // skip_to only makes sense for termlists which are in sorted order.
85  throw Xapian::InvalidOperationError("VectorTermList::skip_to() not meaningful");
86 }
87 
88 bool
90 {
91  return p == NULL;
92 }
93 
96 {
97  throw Xapian::InvalidOperationError("VectorTermList::positionlist_count() not meaningful");
98 }
99 
102 {
103  throw Xapian::InvalidOperationError("VectorTermList::positionlist_begin() not meaningful");
104 }
#define Assert(COND)
Definition: omassert.h:122
TermList * next()
Advance the current position to the next term in the termlist.
length encoded as a string
InvalidOperationError indicates the API was used in an invalid way.
Definition: error.h:283
Abstract base class for termlists.
Definition: termlist.h:39
STL namespace.
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
A vector-like container of terms which can be iterated.
Hierarchy of classes which Xapian can throw as exceptions.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
Xapian::PositionIterator positionlist_begin() const
Return a PositionIterator for the current position.
Class for iterating over term positions.
bool at_end() const
Return true if the current position is past the last term in this list.
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
void decode_length_and_check(const char **p, const char *end, unsigned &out)
Decode a length encoded by encode_length.
Definition: length.cc:112
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:38
Various assertion macros.
TermList * skip_to(const std::string &)
Skip forward to the specified term.
std::string get_termname() const
Return the termname at the current position.