CodeSonar C++ API
[For improved navigation, enable JavaScript.]
Public Types | Public Member Functions | Related Functions | List of all members
cs::xr_occurrence_iterator Class Reference

Iterator over the occurrences (xr_tuple) of a token. More...

Public Types

typedef const xr_tupleconst_pointer
 const pointer to the type of the iterator elements. More...
 
typedef const xr_tupleconst_reference
 const reference to the type of the iterator elements. More...
 
typedef cs_ssize_t difference_type
 Type of distance between iterators. More...
 
typedef std::forward_iterator_tag iterator_category
 Iterator is a ForwardIterator. More...
 
typedef xr_tuplepointer
 Pointer to the type of the iterator elements. More...
 
typedef xr_tuplereference
 Reference to the type of the iterator elements. More...
 

Public Member Functions

 xr_occurrence_iterator (const xr_occurrence_iterator &other)
 Copy constructor. More...
 
void advance ()
 Advance the iterator by one position. More...
 
std::string as_repr () const
 Get a representation of the iterator that includes information useful for debugging. More...
 
std::string as_string () const
 Get a simple string representation of the iterator. More...
 
bool at_end () const
 Check: is the iterator at the end of the structure? More...
 
size_t get_matched_count () const
 Get the number of tuples (xr_tuple) in the query result set for this. More...
 
size_t get_scanned_count () const
 Get the total number of tuples (xr_tuple) examined while retrieving the set to be iterated over by this. More...
 
size_t get_unscanned_count () const
 Get the number of tuples (xr_tuple) that were indexed for examination but ultimately not examined while retrieving the set to be iterated over by this. More...
 
bool operator!= (const xr_occurrence_iterator &other) const
 Iterator inequality. More...
 
xr_tuple operator* () const
 Iterator dereference operator. More...
 
xr_occurrence_iteratoroperator++ ()
 Advance the iterator. More...
 
xr_occurrence_iteratoroperator= (xr_occurrence_iterator other)
 Iterator assignment operator. More...
 
bool operator== (const xr_occurrence_iterator &other) const
 Iterator equality. More...
 
void swap (xr_occurrence_iterator &other)
 Exchange the contents of this and other. More...
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &out, const xr_occurrence_iterator &a)
 Print a representation of an xr_occurrence_iterator object to the specified stream. More...
 

Detailed Description

Iterator over the occurrences (xr_tuple) of a token.

Initialize with sfile::token_occurrence_iterator().

Use as you would any other C++ iterator. For example:

// set up sfile sf, then...
for (cs::xr_occurrence_iterator it = sf.token_occurrence_iterator(36, "foo"); !it.at_end(); ++it){
std::cout << "xr_tuple: " << *it;
}

Member Typedef Documentation

◆ const_pointer

typedef const xr_tuple* cs::xr_occurrence_iterator::const_pointer
inherited

const pointer to the type of the iterator elements.

◆ const_reference

typedef const xr_tuple& cs::xr_occurrence_iterator::const_reference
inherited

const reference to the type of the iterator elements.

◆ difference_type

typedef cs_ssize_t cs::xr_occurrence_iterator::difference_type
inherited

Type of distance between iterators.

◆ iterator_category

typedef std::forward_iterator_tag cs::xr_occurrence_iterator::iterator_category
inherited

Iterator is a ForwardIterator.

◆ pointer

typedef xr_tuple* cs::xr_occurrence_iterator::pointer
inherited

Pointer to the type of the iterator elements.

◆ reference

typedef xr_tuple& cs::xr_occurrence_iterator::reference
inherited

Reference to the type of the iterator elements.

Constructor & Destructor Documentation

◆ xr_occurrence_iterator()

cs::xr_occurrence_iterator::xr_occurrence_iterator ( const xr_occurrence_iterator other)

Copy constructor.

Member Function Documentation

◆ advance()

void cs::xr_occurrence_iterator::advance ( )
inlineinherited

Advance the iterator by one position.

Exceptions
result::OUT_OF_ELEMENTS

◆ as_repr()

std::string cs::xr_occurrence_iterator::as_repr ( ) const
inlineinherited

Get a representation of the iterator that includes information useful for debugging.

Returns
The string representation.

◆ as_string()

std::string cs::xr_occurrence_iterator::as_string ( ) const
inlineinherited

Get a simple string representation of the iterator.

Returns
The string representation.

◆ at_end()

bool cs::xr_occurrence_iterator::at_end ( ) const
inlineinherited

Check: is the iterator at the end of the structure?

Returns
true if the iterator is at the end of the structure (there are no more elements to iterate over), false otherwise.

◆ get_matched_count()

size_t cs::xr_occurrence_iterator::get_matched_count ( ) const
inlineinherited

Get the number of tuples (xr_tuple) in the query result set for this.

Returns
The number of tuples in the query result set.

Note that the return value may grow as iteration progresses. For the final value, call after at_end() returns true.

Exceptions
result::ERROR_INVALID_ARGUMENTIf this was initialized with a sfile::token_occurrence_iterator() call whose flags argument did not include xr_occ_iter_flags::POPULATE_COUNTERS, or if this was not initialized with sfile::token_occurrence_iterator() at all.

◆ get_scanned_count()

size_t cs::xr_occurrence_iterator::get_scanned_count ( ) const
inlineinherited

Get the total number of tuples (xr_tuple) examined while retrieving the set to be iterated over by this.

Returns
The total number of tuples examined: the tuples enumerated by get_matched_count(), plus all tuples examined but discarded as non-matching.

Note that the return value may grow as iteration progresses. For the final value, call after at_end() returns true.

Exceptions
result::ERROR_INVALID_ARGUMENTIf this was initialized with a sfile::token_occurrence_iterator() call whose flags argument did not include xr_occ_iter_flags::POPULATE_COUNTERS, or if this was not initialized with sfile::token_occurrence_iterator() at all.

◆ get_unscanned_count()

size_t cs::xr_occurrence_iterator::get_unscanned_count ( ) const
inlineinherited

Get the number of tuples (xr_tuple) that were indexed for examination but ultimately not examined while retrieving the set to be iterated over by this.

Returns
The total number of tuples indexed for examination but ultimately not examined.

Note that the return value may grow as iteration progresses. For the final value, call after at_end() returns true.

Exceptions
result::ERROR_INVALID_ARGUMENTIf this was initialized with a sfile::token_occurrence_iterator() call whose flags argument did not include xr_occ_iter_flags::POPULATE_COUNTERS, or if this was not initialized with sfile::token_occurrence_iterator() at all.

◆ operator!=()

bool cs::xr_occurrence_iterator::operator!= ( const xr_occurrence_iterator other) const
inlineinherited

Iterator inequality.

Parameters
[in]otherThe iterator to compare against.
Returns
false if and only if this and other are at the same position. Behavior is undefined if this and other are not iterating over the same collection.

◆ operator*()

xr_tuple cs::xr_occurrence_iterator::operator* ( ) const

Iterator dereference operator.

Returns
The element at the current iterator position.
Exceptions
result::OUT_OF_ELEMENTSif the iterator is at the end of the container.

◆ operator++()

xr_occurrence_iterator& cs::xr_occurrence_iterator::operator++ ( )
inlineinherited

Advance the iterator.

Exceptions
result::OUT_OF_ELEMENTSif the iterator is at the end of the container.

◆ operator=()

xr_occurrence_iterator& cs::xr_occurrence_iterator::operator= ( xr_occurrence_iterator  other)

Iterator assignment operator.

Parameters
[in]otherThe iterator to assign.
Returns
A pointer to this.

◆ operator==()

bool cs::xr_occurrence_iterator::operator== ( const xr_occurrence_iterator other) const
inlineinherited

Iterator equality.

Returns
true if and only if this and other are at the same position. Behavior is undefined if this and other are not iterating over the same collection.

◆ swap()

void cs::xr_occurrence_iterator::swap ( xr_occurrence_iterator other)
inlineinherited

Exchange the contents of this and other.

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  out,
const xr_occurrence_iterator a 
)
related

Print a representation of an xr_occurrence_iterator object to the specified stream.

Parameters
[in]outThe stream to print to.
[in]aThe xr_occurrence_iterator object to print.
Returns
void

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