diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2021-08-04 20:31:30 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-08-05 12:18:08 +0300 |
commit | 0592d58e5366eac92bc99ef9bdb4368e07c0ddf9 (patch) | |
tree | b0eac4fbf15f8c502321a3ad9c1ac670c070b1f3 /libbpkg/manifest.hxx | |
parent | da2d334f608c9fb9bf88f90cc50cd564441581f7 (diff) |
Add extract_package_name() and extract_package_version()
Diffstat (limited to 'libbpkg/manifest.hxx')
-rw-r--r-- | libbpkg/manifest.hxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index b666716..bdb7a9b 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -1568,6 +1568,36 @@ namespace bpkg butl::manifest_name_value start, bool ignore_unknown); }; + + // Extract the package name component from <name>[/<version>] or + // <name><version-constraint>. Throw invalid_argument on parsing error. + // + // Note: the version and version constraint are not verified. + // + LIBBPKG_EXPORT package_name + extract_package_name (const char*, bool allow_version = true); + + inline package_name + extract_package_name (const std::string& s, bool allow_version = true) + { + return extract_package_name (s.c_str (), allow_version); + } + + // Extract the package version component from <name>[/<version>]. Return + // empty version if none is specified. Throw invalid_argument on parsing + // error and for the earliest and stub versions. + // + // Note: the package name is not verified. + // + LIBBPKG_EXPORT version + extract_package_version (const char*, bool fold_zero_revision = true); + + inline version + extract_package_version (const std::string& s, + bool fold_zero_revision = true) + { + return extract_package_version (s.c_str (), fold_zero_revision); + } } #endif // LIBBPKG_MANIFEST_HXX |