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

Abstract base class for xref_tuple comparators: functors that specify an ordering on the results (xr_tuple) of an xr_query. More...

Public Member Functions

virtual ~xr_tuple_comparator ()
 Destructor. More...
 
virtual int operator() (const xr_tuple &a, const xr_tuple &b)=0
 Comparison function for xr_tuple. More...
 

Detailed Description

Abstract base class for xref_tuple comparators: functors that specify an ordering on the results (xr_tuple) of an xr_query.

Note that in many cases you will not want to specify a comparator for an xr_query: doing so will typically slow down the query because all query results must be retrieved and sorted before the query 'Offset' and 'Limit' can be applied.

To specify an ordering on the results of an xr_query, subclass xr_tuple_comparator and define operator() so that it applies the appropriate checks to determine, given xr_tuple objects A and B, whether A<B, A==B, or A>B according to your ordering scheme.

Once you have defined your subclass, create an instance and add it to the xr_query with xr_query::set_cmp().

Constructor & Destructor Documentation

◆ ~xr_tuple_comparator()

virtual cs::xr_tuple_comparator::~xr_tuple_comparator ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ operator()()

virtual int cs::xr_tuple_comparator::operator() ( const xr_tuple a,
const xr_tuple b 
)
pure virtual

Comparison function for xr_tuple.

Parameters
[in]aThe first argument to the comparison.
[in]bThe second argument to the comparison.
Returns
An integer N such that:
  • N<0 if a < b
  • N==0 if a == b
  • N>0 if a > b

When you subclass xr_tuple_comparator, implement this operator with the logic for comparing xr_tuple objects according to the ordering you wish to impose.


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