LTP GCOV extension - code coverage report
Current view: directory - ept/apt - version.cc
Test: lcov.info
Date: 2008-08-14 Instrumented lines: 34
Code covered: 88.2 % Executed lines: 30

       1                 : /** \file
       2                 :  * Provide a very lightweight Version class that represent a package with a
       3                 :  * version, with very cheap value copy operations.
       4                 :  */
       5                 : 
       6                 : /* 
       7                 :  * Copyright (C) 2007  Enrico Zini <enrico@enricozini.org>
       8                 :  *
       9                 :  * This library is free software; you can redistribute it and/or
      10                 :  * modify it under the terms of the GNU Lesser General Public
      11                 :  * License as published by the Free Software Foundation; either
      12                 :  * version 2.1 of the License, or (at your option) any later version.
      13                 :  *
      14                 :  * This library is distributed in the hope that it will be useful,
      15                 :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17                 :  * Lesser General Public License for more details.
      18                 :  *
      19                 :  * You should have received a copy of the GNU Lesser General Public
      20                 :  * License along with this library; if not, write to the Free Software
      21                 :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      22                 :  */
      23                 : 
      24                 : #include <ept/apt/version.h>
      25                 : #include <apt-pkg/debversion.h>
      26                 : 
      27                 : using namespace std;
      28                 : 
      29                 : namespace ept {
      30                 : namespace apt {
      31                 : 
      32               4 : std::string Version::upstreamVersion() const
      33                 : {
      34                 :         // Skip the epoch, if it is there
      35               4 :         size_t start = m_version.find(':');
      36               4 :         if (start == string::npos)
      37               3 :                 start = 0;
      38                 :         else
      39               1 :                 ++start;
      40                 : 
      41                 :         // Skip everything after the trailing '-', if it is there
      42               4 :         size_t end = m_version.rfind('-');
      43               4 :         if (end == string::npos)
      44               1 :                 end = m_version.size();
      45                 : 
      46               4 :         return m_version.substr(start, end-start);
      47                 : }
      48                 : 
      49                 : /* Version comparison by Debian policy */
      50                 : 
      51               4 : bool Version::operator<=(const Version& pkg) const
      52                 : {
      53               4 :         if (name() < pkg.name())
      54               1 :                 return true;
      55               3 :         if (name() == pkg.name())
      56               3 :                 return debVS.CmpVersion(version(), pkg.version()) <= 0;
      57               0 :         return false;
      58                 : }
      59               5 : bool Version::operator<(const Version& pkg) const
      60                 : {
      61               5 :         if (name() < pkg.name())
      62               1 :                 return true;
      63               4 :         if (name() == pkg.name())
      64               4 :                 return debVS.CmpVersion(version(), pkg.version()) < 0;
      65               0 :         return false;
      66                 : }
      67               4 : bool Version::operator>=(const Version& pkg) const
      68                 : {
      69               4 :         if (name() > pkg.name())
      70               0 :                 return true;
      71               4 :         if (name() == pkg.name())
      72               3 :                 return debVS.CmpVersion(version(), pkg.version()) >= 0;
      73               1 :         return false;
      74                 : }
      75               5 : bool Version::operator>(const Version& pkg) const
      76                 : {
      77               5 :         if (name() > pkg.name())
      78               0 :                 return true;
      79               5 :         if (name() == pkg.name())
      80               4 :                 return debVS.CmpVersion(version(), pkg.version()) > 0;
      81               1 :         return false;
      82                 : }
      83                 : 
      84                 : }
      85               6 : }
      86                 : 
      87                 : // vim:set ts=4 sw=4:

Generated by: LTP GCOV extension version 1.6