xapian-core  2.0.0
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Xapian::TermIterator Class Reference

Class for iterating over a list of terms. More...

#include <termiterator.h>

+ Collaboration diagram for Xapian::TermIterator:

Classes

class  Internal
 Abstract base class for termlists. More...
 

Public Member Functions

 TermIterator (const TermIterator &o)
 Copy constructor. More...
 
TermIteratoroperator= (const TermIterator &o)
 Assignment. More...
 
 TermIterator (TermIterator &&o)
 Move constructor. More...
 
TermIteratoroperator= (TermIterator &&o)
 Move assignment operator. More...
 
 TermIterator () noexcept
 Default constructor. More...
 
 ~TermIterator ()
 Destructor. More...
 
std::string operator* () const
 Return the term at the current position. More...
 
Xapian::termcount get_wdf () const
 Return the wdf for the term at the current position. More...
 
Xapian::doccount get_termfreq () const
 Return the term frequency for the term at the current position. More...
 
Xapian::termcount positionlist_count () const
 Return the length of the position list for the current position. More...
 
PositionIterator positionlist_begin () const
 Return a PositionIterator for the current term. More...
 
PositionIterator positionlist_end () const noexcept
 Return an end PositionIterator for the current term. More...
 
TermIteratoroperator++ ()
 Advance the iterator to the next position. More...
 
DerefWrapper_< std::string > operator++ (int)
 Advance the iterator to the next position (postfix version). More...
 
void skip_to (std::string_view term)
 Advance the iterator to term term. More...
 
std::string get_description () const
 Return a string describing this object. More...
 

Private Types

typedef std::input_iterator_tag iterator_category
 
typedef std::string value_type
 
typedef Xapian::termcount_diff difference_type
 
typedef value_typepointer
 
typedef value_type reference
 

Private Member Functions

 TermIterator (Internal *internal_)
 
void decref ()
 
void post_advance (Internal *res)
 

Private Attributes

Internalinternal
 

Detailed Description

Class for iterating over a list of terms.

Definition at line 41 of file termiterator.h.

Member Typedef Documentation

◆ difference_type

Definition at line 153 of file termiterator.h.

◆ iterator_category

typedef std::input_iterator_tag Xapian::TermIterator::iterator_category
private

TermIterator is what the C++ STL calls an input_iterator.

The following typedefs allow std::iterator_traits<> to work so that this iterator can be used with the STL.

These are deliberately hidden from the Doxygen-generated docs, as the machinery here isn't interesting to API users. They just need to know that Xapian iterator classes are compatible with the STL.

Definition at line 149 of file termiterator.h.

◆ pointer

Definition at line 155 of file termiterator.h.

◆ reference

Definition at line 157 of file termiterator.h.

◆ value_type

typedef std::string Xapian::TermIterator::value_type
private

Definition at line 151 of file termiterator.h.

Constructor & Destructor Documentation

◆ TermIterator() [1/4]

Xapian::TermIterator::TermIterator ( Internal internal_)
explicitprivate

Wrap an existing Internal.

Definition at line 58 of file termiterator.cc.

References decref(), internal, LOGCALL_CTOR, Xapian::TermIterator::Internal::next(), and post_advance().

◆ TermIterator() [2/4]

Xapian::TermIterator::TermIterator ( const TermIterator o)

Copy constructor.

Definition at line 73 of file termiterator.cc.

References LOGCALL_CTOR.

◆ TermIterator() [3/4]

Xapian::TermIterator::TermIterator ( TermIterator &&  o)
inline

Move constructor.

Definition at line 59 of file termiterator.h.

◆ TermIterator() [4/4]

Xapian::TermIterator::TermIterator ( )
inlinenoexcept

Default constructor.

Creates an uninitialised iterator, which can't be used before being assigned to, but is sometimes syntactically convenient.

Definition at line 79 of file termiterator.h.

◆ ~TermIterator()

Xapian::TermIterator::~TermIterator ( )
inline

Destructor.

Definition at line 83 of file termiterator.h.

Member Function Documentation

◆ decref()

void Xapian::TermIterator::decref ( )
private

Definition at line 34 of file termiterator.cc.

References Assert.

Referenced by operator=(), and TermIterator().

◆ get_description()

std::string Xapian::TermIterator::get_description ( ) const

Return a string describing this object.

Definition at line 151 of file termiterator.cc.

Referenced by DEFINE_TESTCASE().

◆ get_termfreq()

Xapian::doccount Xapian::TermIterator::get_termfreq ( ) const

Return the term frequency for the term at the current position.

Note that for a TermIterator returned by calling termlist_begin() on a Document object obtained from a sharded database, this method will return the term frequency from the shard that the document is in rather than for the combined database.

Definition at line 119 of file termiterator.cc.

References Assert, Xapian::TermIterator::Internal::get_termfreq(), internal, LOGCALL, and RETURN.

Referenced by dbcheck(), DEFINE_TESTCASE(), main(), RemoteServer::msg_termlist(), closedb1_iterators::perform(), remotefailure1_iterators::perform(), and show_termlist().

◆ get_wdf()

Xapian::termcount Xapian::TermIterator::get_wdf ( ) const

◆ operator*()

string Xapian::TermIterator::operator* ( ) const

Return the term at the current position.

Definition at line 94 of file termiterator.cc.

References Assert, Xapian::TermIterator::Internal::get_termname(), internal, LOGCALL, and RETURN.

◆ operator++() [1/2]

TermIterator & Xapian::TermIterator::operator++ ( )

Advance the iterator to the next position.

Definition at line 102 of file termiterator.cc.

References Assert, internal, LOGCALL, Xapian::TermIterator::Internal::next(), post_advance(), and RETURN.

◆ operator++() [2/2]

DerefWrapper_<std::string> Xapian::TermIterator::operator++ ( int  )
inline

Advance the iterator to the next position (postfix version).

Definition at line 117 of file termiterator.h.

References term.

◆ operator=() [1/2]

TermIterator & Xapian::TermIterator::operator= ( const TermIterator o)

Assignment.

Definition at line 82 of file termiterator.cc.

References Xapian::Internal::intrusive_base::_refs, decref(), internal, LOGCALL, and RETURN.

◆ operator=() [2/2]

TermIterator& Xapian::TermIterator::operator= ( TermIterator &&  o)
inline

Move assignment operator.

Definition at line 65 of file termiterator.h.

◆ positionlist_begin()

PositionIterator Xapian::TermIterator::positionlist_begin ( ) const

◆ positionlist_count()

Xapian::termcount Xapian::TermIterator::positionlist_count ( ) const

Return the length of the position list for the current position.

Definition at line 127 of file termiterator.cc.

References Assert, internal, LOGCALL, Xapian::TermIterator::Internal::positionlist_count(), and RETURN.

Referenced by dbcheck(), DEFINE_TESTCASE(), format_doc_termlist(), RemoteServer::msg_positionlistcount(), and HoneyInverter::set_positionlist().

◆ positionlist_end()

PositionIterator Xapian::TermIterator::positionlist_end ( ) const
inlinenoexcept

◆ post_advance()

void Xapian::TermIterator::post_advance ( Internal res)
private

Definition at line 42 of file termiterator.cc.

References Xapian::Internal::intrusive_base::_refs.

Referenced by operator++(), skip_to(), and TermIterator().

◆ skip_to()

void Xapian::TermIterator::skip_to ( std::string_view  term)

Advance the iterator to term term.

If the iteration is over an unsorted list of terms, then this method will throw Xapian::InvalidOperationError.

Parameters
termThe term to advance to. If this term isn't in the stream being iterated, then the iterator is moved to the next term after it which is.

Definition at line 143 of file termiterator.cc.

References internal, LOGCALL_VOID, post_advance(), Xapian::TermIterator::Internal::skip_to(), and term.

Referenced by TermGroup::as_group(), DEFINE_TESTCASE(), and RemoteServer::msg_positionlistcount().

Member Data Documentation

◆ internal

Internal* Xapian::TermIterator::internal
private

The documentation for this class was generated from the following files: