xapian-core  1.4.19
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Xapian::ValueIterator Class Reference

Class for iterating over document values. More...

#include <valueiterator.h>

+ Collaboration diagram for Xapian::ValueIterator:

Classes

class  Internal
 Abstract base class for value streams. More...
 

Public Member Functions

 ValueIterator (const ValueIterator &o)
 Copy constructor. More...
 
ValueIteratoroperator= (const ValueIterator &o)
 Assignment. More...
 
 ValueIterator ()
 Default constructor. More...
 
 ~ValueIterator ()
 Destructor. More...
 
std::string operator* () const
 Return the value at the current position. More...
 
ValueIteratoroperator++ ()
 Advance the iterator to the next position. More...
 
DerefWrapper_< std::string > operator++ (int)
 Advance the iterator to the next position (postfix version). More...
 
Xapian::docid get_docid () const
 Return the docid at the current position. More...
 
Xapian::valueno get_valueno () const
 Return the value slot number for the current position. More...
 
void skip_to (Xapian::docid docid_or_slot)
 Advance the iterator to document id or value slot docid_or_slot. More...
 
bool check (Xapian::docid docid)
 Check if the specified docid occurs. 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::doccount_diff difference_type
 
typedef std::string * pointer
 
typedef std::string & reference
 

Private Member Functions

void decref ()
 
 ValueIterator (Internal *internal_)
 

Private Attributes

Internalinternal
 

Detailed Description

Class for iterating over document values.

Definition at line 40 of file valueiterator.h.

Member Typedef Documentation

◆ difference_type

ValueIterator 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 195 of file valueiterator.h.

◆ iterator_category

typedef std::input_iterator_tag Xapian::ValueIterator::iterator_category
private

ValueIterator 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 191 of file valueiterator.h.

◆ pointer

typedef std::string* Xapian::ValueIterator::pointer
private

ValueIterator 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 197 of file valueiterator.h.

◆ reference

typedef std::string& Xapian::ValueIterator::reference
private

ValueIterator 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 199 of file valueiterator.h.

◆ value_type

typedef std::string Xapian::ValueIterator::value_type
private

ValueIterator 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 193 of file valueiterator.h.

Constructor & Destructor Documentation

◆ ValueIterator() [1/3]

Xapian::ValueIterator::ValueIterator ( Internal internal_)
explicitprivate

Construct given internals.

Definition at line 41 of file valueiterator.cc.

References Assert, Xapian::ValueIterator::Internal::at_end(), decref(), internal, and LOGCALL_CTOR.

◆ ValueIterator() [2/3]

Xapian::ValueIterator::ValueIterator ( const ValueIterator o)

Copy constructor.

Definition at line 60 of file valueiterator.cc.

References LOGCALL_CTOR.

◆ ValueIterator() [3/3]

Xapian::ValueIterator::ValueIterator ( )
inline

Default constructor.

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

Definition at line 81 of file valueiterator.h.

◆ ~ValueIterator()

Xapian::ValueIterator::~ValueIterator ( )
inline

Destructor.

Definition at line 85 of file valueiterator.h.

References Xapian::operator*().

Member Function Documentation

◆ check()

bool Xapian::ValueIterator::check ( Xapian::docid  docid)

Check if the specified docid occurs.

The caller is required to ensure that the specified document id did actually exists in the database.

This method acts like skip_to() if that can be done at little extra cost, in which case it then returns true. This is how chert and glass databases behave because they store values in streams which allow for an efficient implementation of skip_to().

Otherwise it simply checks if a particular docid is present. If it is, it returns true. If it isn't, it returns false, and leaves the position unspecified (and hence the result of calling methods which depend on the current position, such as get_docid(), are also unspecified). In this state, next() will advance to the first matching position after document did, and skip_to() will act as it would if the position was the first matching position after document did.

Currently the inmemory and remote backends behave in the latter way because they don't support streamed values and so skip_to() must check each document it skips over which is significantly slower.

Parameters
docidThe document id to check.

Definition at line 131 of file valueiterator.cc.

References Xapian::ValueIterator::Internal::at_end(), Xapian::ValueIterator::Internal::check(), decref(), internal, LOGCALL, and RETURN.

Referenced by Xapian::ValuePostingSource::check(), and DEFINE_TESTCASE().

◆ decref()

void Xapian::ValueIterator::decref ( )
private

Definition at line 34 of file valueiterator.cc.

References Assert.

Referenced by check(), operator++(), operator=(), skip_to(), and ValueIterator().

◆ get_description()

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

Return a string describing this object.

Definition at line 145 of file valueiterator.cc.

◆ get_docid()

Xapian::docid Xapian::ValueIterator::get_docid ( ) const

Return the docid at the current position.

If we're iterating over values of a document, this method will throw Xapian::InvalidOperationError.

Definition at line 102 of file valueiterator.cc.

References Assert, Xapian::ValueIterator::Internal::get_docid(), internal, LOGCALL, and RETURN.

Referenced by DEFINE_TESTCASE(), Xapian::ValuePostingSource::get_docid(), and main().

◆ get_valueno()

Xapian::valueno Xapian::ValueIterator::get_valueno ( ) const

Return the value slot number for the current position.

If the iterator is over all values in a slot, this returns that slot's number. If the iterator is over the values in a particular document, it returns the number of each slot in turn.

Definition at line 110 of file valueiterator.cc.

References Assert, Xapian::ValueIterator::Internal::get_valueno(), internal, LOGCALL, and RETURN.

Referenced by ChertValueManager::add_document(), GlassValueManager::add_document(), DEFINE_TESTCASE(), InMemoryDatabase::finish_add_doc(), serialise_document(), and show_values().

◆ operator*()

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

Return the value at the current position.

Definition at line 81 of file valueiterator.cc.

References Assert, Xapian::ValueIterator::Internal::get_value(), internal, LOGCALL, and RETURN.

◆ operator++() [1/2]

ValueIterator & Xapian::ValueIterator::operator++ ( )

Advance the iterator to the next position.

Definition at line 89 of file valueiterator.cc.

References Assert, Xapian::ValueIterator::Internal::at_end(), decref(), internal, LOGCALL, and RETURN.

◆ operator++() [2/2]

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

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

Definition at line 96 of file valueiterator.h.

◆ operator=()

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

Assignment.

Definition at line 69 of file valueiterator.cc.

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

◆ skip_to()

void Xapian::ValueIterator::skip_to ( Xapian::docid  docid_or_slot)

Advance the iterator to document id or value slot docid_or_slot.

If this iterator is over values in a document, then this method advances the iterator to value slot docid_or_slot, or the first slot after it if there is no value in slot slot.

If this iterator is over values in a particular slot, then this method advances the iterator to document id docid_or_slot, or the first document id after it if there is no value in the slot we're iterating over for document docid_or_slot.

Note: The "two-faced" nature of this method is due to how C++ overloading works. Xapian::docid and Xapian::valueno are both typedefs for the same unsigned integer type, so overloading can't distinguish them.

Parameters
docid_or_slotThe docid/slot to advance to.

Definition at line 118 of file valueiterator.cc.

References Xapian::ValueIterator::Internal::at_end(), decref(), internal, and LOGCALL_VOID.

Referenced by DEFINE_TESTCASE(), and Xapian::ValuePostingSource::skip_to().

Member Data Documentation

◆ internal

Internal* Xapian::ValueIterator::internal
private

Reference counted internals.

Definition at line 45 of file valueiterator.h.

Referenced by check(), get_docid(), get_valueno(), Xapian::iterator_valid(), operator*(), operator++(), operator=(), skip_to(), and ValueIterator().


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