<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.15"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>libzypp: Comparison using relational operator zypp::Rel.</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(initResizable); /* @license-end */</script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">libzypp  <span id="projectnumber">17.9.0</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.15 --> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(function() { initMenu('',false,false,'search.php','Search'); }); /* @license-end */</script> <div id="main-nav"></div> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(function(){initNavTree('group__RelCompare.html','');}); /* @license-end */ </script> <div id="doc-content"> <div class="header"> <div class="summary"> <a href="#nested-classes">Classes</a> | <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">Comparison using relational operator zypp::Rel.</div> </div> </div><!--header--> <div class="contents"> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a> Classes</h2></td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structzypp_1_1Compare.html">zypp::Compare< Tp ></a></td></tr> <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">General compare functor returning <code>-1, 0, 1</code>. <a href="structzypp_1_1Compare.html#details">More...</a><br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structzypp_1_1CompareBy.html">zypp::CompareBy< Tp, TCompare ></a></td></tr> <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">Functor to compare two elements by <a class="el" href="structzypp_1_1Rel.html">Rel</a> based on a general <em>TCompare</em> functor. <a href="structzypp_1_1CompareBy.html#details">More...</a><br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structzypp_1_1CompareByEQ.html">zypp::CompareByEQ< Tp, TCompare ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structzypp_1_1CompareByNE.html">zypp::CompareByNE< Tp, TCompare ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structzypp_1_1CompareByLT.html">zypp::CompareByLT< Tp, TCompare ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structzypp_1_1CompareByLE.html">zypp::CompareByLE< Tp, TCompare ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structzypp_1_1CompareByGT.html">zypp::CompareByGT< Tp, TCompare ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structzypp_1_1CompareByGE.html">zypp::CompareByGE< Tp, TCompare ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structzypp_1_1CompareByANY.html">zypp::CompareByANY< Tp, TCompare ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structzypp_1_1CompareByNONE.html">zypp::CompareByNONE< Tp, TCompare ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:ga4245cf6b48eb6c19ed7e18589d4d1b9a"><td class="memTemplParams" colspan="2">template<class Tp , class TCompare > </td></tr> <tr class="memitem:ga4245cf6b48eb6c19ed7e18589d4d1b9a"><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="classbool.html">bool</a> </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__RelCompare.html#ga4245cf6b48eb6c19ed7e18589d4d1b9a">zypp::compareByRel</a> (<a class="el" href="structzypp_1_1Rel.html">Rel</a> op, const Tp &lhs, const Tp &rhs, TCompare compare)</td></tr> <tr class="memdesc:ga4245cf6b48eb6c19ed7e18589d4d1b9a"><td class="mdescLeft"> </td><td class="mdescRight">Comparison of two elements using relational operator <em>op</em>. <a href="group__RelCompare.html#ga4245cf6b48eb6c19ed7e18589d4d1b9a">More...</a><br /></td></tr> <tr class="separator:ga4245cf6b48eb6c19ed7e18589d4d1b9a"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ga116631ef189082c4dd7e2479e422af8a"><td class="memTemplParams" colspan="2">template<class Tp > </td></tr> <tr class="memitem:ga116631ef189082c4dd7e2479e422af8a"><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="classbool.html">bool</a> </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__RelCompare.html#ga116631ef189082c4dd7e2479e422af8a">zypp::compareByRel</a> (<a class="el" href="structzypp_1_1Rel.html">Rel</a> op, const Tp &lhs, const Tp &rhs)</td></tr> <tr class="memdesc:ga116631ef189082c4dd7e2479e422af8a"><td class="mdescLeft"> </td><td class="mdescRight"><a class="el" href="group__RelCompare.html#ga4245cf6b48eb6c19ed7e18589d4d1b9a">compareByRel</a> convenience using Compare<Tp> as general compare functor. <a href="group__RelCompare.html#ga116631ef189082c4dd7e2479e422af8a">More...</a><br /></td></tr> <tr class="separator:ga116631ef189082c4dd7e2479e422af8a"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <p>Take a class like <a class="el" href="classzypp_1_1Edition.html" title="Edition represents [epoch:]version[-release]">zypp::Edition</a>. Editions are comaprable. You can compare them lexicographical, or according to their version and release values, or match them (i.e. taking empty version or release values as wildcard).</p> <p>No matter which way is appropriate within a certain context. You need functions to compare, and may want to use classes like <a class="el" href="structzypp_1_1Range.html">zypp::Range</a>, based on the desired comparison.</p> <p>All the class has to do, is providing a general comparison method (preferably static) </p><div class="fragment"><div class="line"><span class="comment">// Compare two elements returning -1, 0, 1</span></div><div class="line"><span class="comment">// if the elemants compare <,==,>.</span></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">int</span> compare( <span class="keyword">const</span> Tp & lhs, <span class="keyword">const</span> Tp & rhs );</div></div><!-- fragment --><p><code><a class="el" href="structzypp_1_1Compare.html" title="General compare functor returning -1, 0, 1.">Compare</a><Tp></code> provides a functor wrapping <code>compare</code>. In case the general comparison method is named differently, the class, or you, have to provide an approriate functor.</p> <p><code>compareByRel</code> then compares two elements using a certain operator and general comparison method. </p><div class="fragment"><div class="line"><a class="code" href="group__RelCompare.html#ga4245cf6b48eb6c19ed7e18589d4d1b9a">compareByRel</a>( <a class="code" href="structzypp_1_1Rel.html#acf87bde5e682c492c9db9cf48135e265">Rel::EQ</a>, lhs, rhs, <a class="code" href="classzypp_1_1IdStringType.html#aec4135e45049399405a16a8891d080c6">Edition::compare</a> );</div><div class="line"><a class="code" href="group__RelCompare.html#ga4245cf6b48eb6c19ed7e18589d4d1b9a">compareByRel</a>( <a class="code" href="structzypp_1_1Rel.html#acf87bde5e682c492c9db9cf48135e265">Rel::EQ</a>, lhs, rhs, <a class="code" href="classzypp_1_1Edition.html#a035179d5ccc3316823fa92bbca552539">Edition::match</a> );</div><div class="line"><a class="code" href="group__RelCompare.html#ga4245cf6b48eb6c19ed7e18589d4d1b9a">compareByRel</a>( <a class="code" href="structzypp_1_1Rel.html#acf87bde5e682c492c9db9cf48135e265">Rel::EQ</a>, lhs, rhs ); <span class="comment">// defaults to Compare<Edition></span></div><div class="line"> <span class="comment">// thus Edition::compare</span></div></div><!-- fragment --><p>Furthermore a bunch of functors using a certain opertator is defined. All templated by type and general comparison method (defaults to <a class="el" href="structzypp_1_1Compare.html" title="General compare functor returning -1, 0, 1.">Compare</a><Tp>). </p><div class="fragment"><div class="line"><span class="comment">// Editions sets use lexicographical order per default:</span></div><div class="line">std::set<Edition></div><div class="line"></div><div class="line"><span class="comment">// An Edition set using Edition::compare as order:</span></div><div class="line">std::set<Edition,CompareByLT<Edition> >;</div><div class="line"></div><div class="line"><span class="comment">// Edition::match is not transitive, thus not an appropriate</span></div><div class="line"><span class="comment">// order relation for std::set or std::map.</span></div></div><!-- fragment --><p>Classes like zypp:<a class="el" href="structzypp_1_1Range.html">Range</a> are templated by by type and general comparison method as well. Thus you may use <a class="el" href="classzypp_1_1Edition.html" title="Edition represents [epoch:]version[-release]">Edition</a> ranges based on <a class="el" href="classzypp_1_1Edition.html#a4d4a488c5b9cd9a4a0554c0e7f13d2d7" title="compare functor.">Edition::Compare</a>, as well as ranges based on <a class="el" href="structzypp_1_1Edition_1_1Match.html" title="match functor.">Edition::Match</a> (<a class="el" href="classzypp_1_1Edition.html" title="Edition represents [epoch:]version[-release]">Edition</a> provides these two functors).</p> <p>Again: Everything a class has to provide is the general comparison method. Comparison functors and ranges are then immediately available. </p> <h2 class="groupheader">Function Documentation</h2> <a id="ga4245cf6b48eb6c19ed7e18589d4d1b9a"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga4245cf6b48eb6c19ed7e18589d4d1b9a">◆ </a></span>compareByRel() <span class="overload">[1/2]</span></h2> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<class Tp , class TCompare > </div> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classbool.html">bool</a> zypp::compareByRel </td> <td>(</td> <td class="paramtype"><a class="el" href="structzypp_1_1Rel.html">Rel</a> </td> <td class="paramname"><em>op</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const Tp & </td> <td class="paramname"><em>lhs</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const Tp & </td> <td class="paramname"><em>rhs</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">TCompare </td> <td class="paramname"><em>compare</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Comparison of two elements using relational operator <em>op</em>. </p> <p>Expects <em>TCompare</em> to be a binary operator returning <code>-1, 0, 1</code> if the elemants compare <code><,==,></code>. </p><div class="fragment"><div class="line"><span class="comment">// Signature of compare function or functor:</span></div><div class="line"><span class="keywordtype">int</span> compare( <span class="keyword">const</span> Tp & lhs, <span class="keyword">const</span> Tp & rhs );</div></div><!-- fragment --> <ul> <li>If <em>op</em> is <a class="el" href="structzypp_1_1Rel.html#ab9b87f803fe36f4f05a6280e65498d2a">Rel::ANY</a>, the expression is always <code>true</code>. </li> <li>If <em>op</em> is <a class="el" href="structzypp_1_1Rel.html#a982a7e193215b0050d8dd5b5d906992e">Rel::NONE</a>, the expression is always <code>false</code>. </li> <li>Otherwise the expression is evaluated using <em>compare</em>. </li> </ul> <p class="definition">Definition at line <a class="el" href="RelCompare_8h_source.html#l00108">108</a> of file <a class="el" href="RelCompare_8h_source.html">RelCompare.h</a>.</p> </div> </div> <a id="ga116631ef189082c4dd7e2479e422af8a"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga116631ef189082c4dd7e2479e422af8a">◆ </a></span>compareByRel() <span class="overload">[2/2]</span></h2> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<class Tp > </div> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classbool.html">bool</a> zypp::compareByRel </td> <td>(</td> <td class="paramtype"><a class="el" href="structzypp_1_1Rel.html">Rel</a> </td> <td class="paramname"><em>op</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const Tp & </td> <td class="paramname"><em>lhs</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const Tp & </td> <td class="paramname"><em>rhs</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p><a class="el" href="group__RelCompare.html#ga4245cf6b48eb6c19ed7e18589d4d1b9a">compareByRel</a> convenience using Compare<Tp> as general compare functor. </p> <p class="definition">Definition at line <a class="el" href="RelCompare_8h_source.html#l00144">144</a> of file <a class="el" href="RelCompare_8h_source.html">RelCompare.h</a>.</p> </div> </div> </div><!-- contents --> </div><!-- doc-content --> <!-- start footer part --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="footer">Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.15 </li> </ul> </div> </body> </html>