aboutsummaryrefslogtreecommitdiff
path: root/libbpkg/manifest.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-03-06 23:37:15 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-03-08 13:25:59 +0300
commitb2bd3dc5f992b1898061e6836ea2b8b04ec243f1 (patch)
tree2b3d94615ce7c8c4a01c7024b3286e4b8925d6c4 /libbpkg/manifest.hxx
parent9f695c1d19e55e0581c184831bafcf6360defd52 (diff)
Add support for dir repository
Diffstat (limited to 'libbpkg/manifest.hxx')
-rw-r--r--libbpkg/manifest.hxx100
1 files changed, 89 insertions, 11 deletions
diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx
index ada6cd3..0e2ee9d 100644
--- a/libbpkg/manifest.hxx
+++ b/libbpkg/manifest.hxx
@@ -395,6 +395,9 @@ namespace bpkg
pkg_package_manifest (butl::manifest_parser&, bool ignore_unknown = false);
LIBBPKG_EXPORT package_manifest
+ dir_package_manifest (butl::manifest_parser&, bool ignore_unknown = false);
+
+ LIBBPKG_EXPORT package_manifest
git_package_manifest (butl::manifest_parser&, bool ignore_unknown = false);
// Create an element of the package list manifest.
@@ -405,6 +408,11 @@ namespace bpkg
bool ignore_unknown = false);
LIBBPKG_EXPORT package_manifest
+ dir_package_manifest (butl::manifest_parser&,
+ butl::manifest_name_value start,
+ bool ignore_unknown = false);
+
+ LIBBPKG_EXPORT package_manifest
git_package_manifest (butl::manifest_parser&,
butl::manifest_name_value start,
bool ignore_unknown = false);
@@ -418,10 +426,13 @@ namespace bpkg
m.serialize (s);
}
- // Normally there is no need to serialize git package manifest, unless for
- // testing.
+ // Normally there is no need to serialize dir and git package manifests,
+ // unless for testing.
//
LIBBPKG_EXPORT void
+ dir_package_manifest (butl::manifest_serializer&, const package_manifest&);
+
+ LIBBPKG_EXPORT void
git_package_manifest (butl::manifest_serializer&, const package_manifest&);
class LIBBPKG_EXPORT pkg_package_manifests:
@@ -445,6 +456,26 @@ namespace bpkg
serialize (butl::manifest_serializer&) const;
};
+ class LIBBPKG_EXPORT dir_package_manifests:
+ public std::vector<package_manifest>
+ {
+ public:
+ using base_type = std::vector<package_manifest>;
+
+ using base_type::base_type;
+
+ public:
+ dir_package_manifests () = default;
+ dir_package_manifests (butl::manifest_parser&,
+ bool ignore_unknown = false);
+
+ // Normally there is no need to serialize dir package manifests, unless for
+ // testing.
+ //
+ void
+ serialize (butl::manifest_serializer&) const;
+ };
+
class LIBBPKG_EXPORT git_package_manifests:
public std::vector<package_manifest>
{
@@ -524,7 +555,7 @@ namespace bpkg
// Repository type.
//
- enum class repository_type {pkg, git};
+ enum class repository_type {pkg, dir, git};
LIBBPKG_EXPORT std::string
to_string (repository_type);
@@ -538,6 +569,15 @@ namespace bpkg
return os << to_string (t);
}
+ // Repository basis.
+ //
+ enum class repository_basis
+ {
+ archive,
+ directory,
+ version_control
+ };
+
// Guess the repository type for the URL:
//
// 1. If scheme is git then git.
@@ -656,6 +696,20 @@ namespace bpkg
return type_;
}
+ repository_basis
+ basis () const
+ {
+ switch (type ())
+ {
+ case repository_type::pkg: return repository_basis::archive;
+ case repository_type::dir: return repository_basis::directory;
+ case repository_type::git: return repository_basis::version_control;
+ }
+
+ assert (false); // Can't be here.
+ return repository_basis::archive;
+ }
+
// URL of an empty location is empty.
//
const repository_url&
@@ -717,20 +771,19 @@ namespace bpkg
bool
archive_based () const
{
- switch (type ())
- {
- case repository_type::pkg: return true;
- case repository_type::git: return false;
- }
+ return basis () == repository_basis::archive;
+ }
- assert (false); // Can't be here.
- return false;
+ bool
+ directory_based () const
+ {
+ return basis () == repository_basis::directory;
}
bool
version_control_based () const
{
- return !archive_based ();
+ return basis () == repository_basis::version_control;
}
// String representation of an empty location is the empty string.
@@ -835,6 +888,10 @@ namespace bpkg
bool ignore_unknown = false);
LIBBPKG_EXPORT repository_manifest
+ dir_repository_manifest (butl::manifest_parser&,
+ bool ignore_unknown = false);
+
+ LIBBPKG_EXPORT repository_manifest
git_repository_manifest (butl::manifest_parser&,
bool ignore_unknown = false);
@@ -846,6 +903,11 @@ namespace bpkg
bool ignore_unknown = false);
LIBBPKG_EXPORT repository_manifest
+ dir_repository_manifest (butl::manifest_parser&,
+ butl::manifest_name_value start,
+ bool ignore_unknown = false);
+
+ LIBBPKG_EXPORT repository_manifest
git_repository_manifest (butl::manifest_parser&,
butl::manifest_name_value start,
bool ignore_unknown = false);
@@ -866,6 +928,22 @@ namespace bpkg
serialize (butl::manifest_serializer&) const;
};
+ class LIBBPKG_EXPORT dir_repository_manifests:
+ public std::vector<repository_manifest>
+ {
+ public:
+ using base_type = std::vector<repository_manifest>;
+
+ using base_type::base_type;
+
+ dir_repository_manifests () = default;
+ dir_repository_manifests (butl::manifest_parser&,
+ bool ignore_unknown = false);
+
+ void
+ serialize (butl::manifest_serializer&) const;
+ };
+
class LIBBPKG_EXPORT git_repository_manifests:
public std::vector<repository_manifest>
{