Dependency

Represents a dependency specification.

A dependency specification either represents a specific version or version range, or a path to a package. In addition to that it has optional and default_ flags to control how non-mandatory dependencies are handled. The package name is notably not part of the dependency specification.

Constructors

this
this(string spec)

Constructs a new dependency specification from a string

this
this(const Version ver)

Constructs a new dependency specification that matches a specific version.

this
this(NativePath path)

Constructs a new dependency specification that matches a specific path.

Members

Functions

default_
bool default_()
void default_(bool value)

Determines if an optional dependency should be chosen by default.

isExactVersion
bool isExactVersion()

Returns true iff the version range only matches a specific version.

mapToPath
Dependency mapToPath(NativePath path)

Returns a modified dependency that gets mapped to a given path.

matches
bool matches(const(Version) v)
bool matches(ref const(Version) v)

Tests if the specification matches a specific version.

matches
bool matches(string vers)

Tests if the specification matches a specific version.

matchesAny
bool matchesAny()

Determines if this dependency specification matches arbitrary versions.

merge
Dependency merge(ref const(Dependency) o)

Merges two dependency specifications.

opCmp
int opCmp(const Dependency o)

Compares dependency specifications.

opEquals
bool opEquals(const Dependency o)

Compares dependency specifications.

optional
bool optional()
void optional(bool optional)

Determines if the dependency is required or optional.

path
void path(NativePath value)
NativePath path()

If set, overrides any version based dependency selection.

toHash
size_t toHash()

Compares dependency specifications.

toJson
Json toJson()

Returns a JSON representation of the dependency specification.

toString
string toString()

Returns a human-readable string representation of the dependency specification.

valid
bool valid()

Determines if this dependency specification is valid.

versionSpec
void versionSpec(string ves)
string versionSpec()

Sets/gets the matching version range as a specification string.

version_
Version version_()

Returns the exact version matched by the version range.

Static functions

any
Dependency any()

A Dependency, which matches every valid version.

fromJson
Dependency fromJson(Json verspec)

Constructs a new Dependency from its JSON representation.

invalid
Dependency invalid()

An invalid dependency (with no possible version matches).

Meta