LCOV - lcov.info - ept/apt/version.h

LTP GCOV extension - code coverage report
Current view: | directory - ept/apt - version.h
Test: | lcov.info
Date: | 2008-08-14 |  | Instrumented lines: | 9
Code covered: | 100.0 % |  | Executed lines: | 9

           1                 : #ifndef EPT_APT_VERSION_H
           2                 : #define EPT_APT_VERSION_H
           3                 :
           4                 : /** \file
           5                 :  * Representation of a package with a version
           6                 :  */
           7                 :
           8                 : /*
           9                 :  * Copyright (C) 2007  Enrico Zini <enrico@enricozini.org>
          10                 :  *
          11                 :  * This library is free software; you can redistribute it and/or
          12                 :  * modify it under the terms of the GNU Lesser General Public
          13                 :  * License as published by the Free Software Foundation; either
          14                 :  * version 2.1 of the License, or (at your option) any later version.
          15                 :  *
          16                 :  * This library is distributed in the hope that it will be useful,
          17                 :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
          18                 :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
          19                 :  * Lesser General Public License for more details.
          20                 :  *
          21                 :  * You should have received a copy of the GNU Lesser General Public
          22                 :  * License along with this library; if not, write to the Free Software
          23                 :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
          24                 :  */
          25                 :
          26                 : #include <string>
          27                 :
          28                 : namespace ept {
          29                 : namespace apt {
          30                 :
          31                 : /**
          32                 :  * Lightweight Version class that represent a package with a version, with very
          33                 :  * cheap value copy operations.
          34                 :  *
          35                 :  * This class can be used to query package information from various information
          36                 :  * sources.  The purpose is create a middle ground that makes sure that all
          37                 :  * sort of different information sources about packages are referring to the
          38                 :  * same package.
          39                 :  */
          40                 : class Version
          41              55 : {
          42                 : protected:
          43                 :         std::string m_name;
          44                 :         std::string m_version;
          45                 :
          46                 : public:
          47                 :         /**
          48                 :          * Create an invalid Version
          49                 :          */
          50               7 :         Version() {}
          51                 :
          52                 :         /**
          53                 :          * Create a Version from strings
          54                 :          */
          55              34 :         Version(const std::string& name, const std::string& version)
          56              34 :                 : m_name(name), m_version(version) {}
          57                 :
          58                 :         /**
          59                 :          * Return the package name
          60                 :          */
          61              81 :         std::string name() const { return m_name; }
          62                 :
          63                 :         /**
          64                 :          * Return the package version, or the empty string if this is a
          65                 :          * versionless package.
          66                 :          */
          67              38 :         std::string version() const { return m_version; }
          68                 :
          69                 :         /**
          70                 :          * Return the upstream part of the version
          71                 :          */
          72                 :         std::string upstreamVersion() const;
          73                 :
          74                 :         /**
          75                 :          * Return true if this package contains a valid value
          76                 :          */
          77              11 :         bool isValid() const { return !m_name.empty() && !m_version.empty(); }
          78                 :
          79                 :         /**
          80                 :          * Comparison operators
          81                 :          */
          82               9 :         bool operator==(const Version& pkg) const { return m_name == pkg.m_name && m_version == pkg.m_version; }
          83               5 :         bool operator!=(const Version& pkg) const { return m_name != pkg.m_name || m_version != pkg.m_version; }
          84                 :         bool operator<=(const Version& pkg) const;
          85                 :         bool operator<(const Version& pkg) const;
          86                 :         bool operator>=(const Version& pkg) const;
          87                 :         bool operator>(const Version& pkg) const;
          88                 : };
          89                 :
          90                 : }
          91                 : }
          92                 :
          93                 : // vim:set ts=4 sw=4:
          94                 : #endif

Generated by: LTP GCOV extension version 1.6