Skip to content

Commit

Permalink
advisory: Add missing methods to AdvisoryPackage
Browse files Browse the repository at this point in the history
Adds missing methods get_epoch() and get_release().
This way the AdvisoryPackage object's nevra can be compared with
another AdvisoryPackage (or Nevra, or rpm::Package).
  • Loading branch information
m-blaha authored and kontura committed Jul 17, 2023
1 parent 1b2a8c8 commit ef374fd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/libdnf5/advisory/advisory_package.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,21 @@ class AdvisoryPackage {
/// @return Name of this AdvisoryPackage as std::string.
std::string get_name() const;

/// Get epoch of this AdvisoryPackage.
///
/// @return Epoch of this AdvisoryPackage as std::string.
std::string get_epoch() const;

/// Get version of this AdvisoryPackage.
///
/// @return Version of this AdvisoryPackage as std::string.
std::string get_version() const;

/// Get release version of this AdvisoryPackage.
///
/// @return Release of this AdvisoryPackage as std::string.
std::string get_release() const;

/// Get evr of this AdvisoryPackage.
///
/// @return Evr of this AdvisoryPackage as std::string.
Expand Down
18 changes: 18 additions & 0 deletions libdnf5/advisory/advisory_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,18 @@ std::string AdvisoryPackage::get_name() const {
return p_impl->get_name();
}

std::string AdvisoryPackage::get_epoch() const {
return p_impl->get_epoch();
}

std::string AdvisoryPackage::get_version() const {
return p_impl->get_version();
}

std::string AdvisoryPackage::get_release() const {
return p_impl->get_release();
}

std::string AdvisoryPackage::get_evr() const {
return p_impl->get_evr();
}
Expand Down Expand Up @@ -102,11 +110,21 @@ std::string AdvisoryPackage::Impl::get_name() const {
return get_rpm_pool(base).id2str(name);
}

std::string AdvisoryPackage::Impl::get_epoch() const {
auto & pool = get_rpm_pool(base);
return pool.split_evr(pool.id2str(evr)).e_def();
}

std::string AdvisoryPackage::Impl::get_version() const {
auto & pool = get_rpm_pool(base);
return pool.split_evr(pool.id2str(evr)).v;
}

std::string AdvisoryPackage::Impl::get_release() const {
auto & pool = get_rpm_pool(base);
return pool.split_evr(pool.id2str(evr)).r;
}

std::string AdvisoryPackage::Impl::get_evr() const {
return get_rpm_pool(base).id2str(evr);
}
Expand Down
2 changes: 2 additions & 0 deletions libdnf5/advisory/advisory_package_private.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ namespace libdnf5::advisory {
class AdvisoryPackage::Impl {
public:
std::string get_name() const;
std::string get_epoch() const;
std::string get_version() const;
std::string get_release() const;
std::string get_evr() const;
std::string get_arch() const;
Id get_name_id() const { return name; };
Expand Down

0 comments on commit ef374fd

Please sign in to comment.