aboutsummaryrefslogtreecommitdiff
path: root/bpkg/manifest
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-03 18:35:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-06 17:23:53 +0200
commit9730f26a59b1c5bf844c056ac413448b2c96d86a (patch)
tree327bdce747964a12c75a90710c8eaa5f761d86c9 /bpkg/manifest
parentfc620d941a5ffdb3baa7f8399ecaf5b8c03b5c03 (diff)
Implement the completion of relative repository location to remote/absolute
Diffstat (limited to 'bpkg/manifest')
-rw-r--r--bpkg/manifest43
1 files changed, 42 insertions, 1 deletions
diff --git a/bpkg/manifest b/bpkg/manifest
index e8c2714..0ec3a3a 100644
--- a/bpkg/manifest
+++ b/bpkg/manifest
@@ -302,14 +302,32 @@ namespace bpkg
//
repository_location () = default;
+ // Creates remote/absolute repository location. Throws invalid_argument
+ // if the location is a relative path.
+ //
explicit
repository_location (const std::string&);
+ // Creates a potentially relative repository location. If base is not
+ // empty, use it to complete the relative location to remote/absolute.
+ // Throws invalid_argument if base itself is relative or the resulting
+ // completed location is invalid.
+ //
+ repository_location (const std::string&, const repository_location& base);
+
+ // Note that relative locations have no canonical name.
+ //
const std::string&
canonical_name () const noexcept {return canonical_name_;}
+ // There are 3 types of locations: remote, local absolute filesystem
+ // path and local relative filesystem path. Plus there is the special
+ // empty location. The following predicates can be used to determine
+ // what kind of location it is. Note that except for empty(), all the
+ // other predicates throw std::logic_error for an empty location.
+ //
bool
- empty () const noexcept {return canonical_name_.empty ();}
+ empty () const noexcept {return path_.empty ();}
bool
local () const
@@ -320,6 +338,29 @@ namespace bpkg
return host_.empty ();
}
+ bool
+ remote () const
+ {
+ return !local ();
+ }
+
+ bool
+ absolute () const
+ {
+ return local () && path_.absolute ();
+ }
+
+ bool
+ relative () const
+ {
+ if (empty ())
+ throw std::logic_error ("empty location");
+
+ // Note that in remote locations path is always absolute.
+ //
+ return path_.relative ();
+ }
+
const butl::dir_path&
path () const
{