28.3.1 Object classes representing semantic–version specifications

We can use objects of class mbfl_semver_spec to build semantic–version representations from strings as follows:

mbfl_default_object_declare(SEMVER_SPEC)
mbfl_declare_varref(MAJOR)

mbfl_semver_spec_make_from_string _(SEMVER_SPEC) "1.2.3-devel.0+x86-64"

mbfl_semver_spec_major_number_var _(MAJOR) _(SEMVER_SPEC)
"$MAJOR" ⇒ 1

and from components as follows:

mbfl_default_object_declare(SEMVER_SPEC)
mbfl_declare_varref(STRREP)

mbfl_semver_spec_make_from_components _(SEMVER_SPEC) 1 2 3 devel.0 x86-64

mbfl_semver_spec_string_var _(STRREP) _(SEMVER_SPEC)
"$STRREP" ⇒ "1.2.3-devel.0+x86-64"
Class: mbfl_semver_spec
Superclass: mbfl_default_object
Metaclass: mbfl_default_class

Class of objects representing semantic–version specifications. It is used both to build new string representations of semantic–version specifications and to represent the result of parsing a semantic–version specification string.

When the data variable of an object of this class is used as parameter to function: in this documentation that parameter is named SEMVER_SPEC.

Constructor on mbfl_semver_spec_t: mbfl_semver_spec_make_from_string SEMVER_SPEC INPUT_STRING

Initialise a previously declared object of class mbfl_semver_spec using the string representation INPUT_STRING. The string might optionally contain the leading ‘v’. When successful return true; otherwise return false.

If SEMVER_SPEC has already been initialised by a previous call to a constructor: the old semantic–version specification is deleted.

Constructor on mbfl_semver_spec_t: mbfl_semver_spec_make_from_components SEMVER_SPEC MAJOR MINOR PATCH_LEVEL
Constructor on mbfl_semver_spec_t: mbfl_semver_spec_make_from_components SEMVER_SPEC MAJOR MINOR PATCH_LEVEL PRERELEASE_VERSION BUILD_METADATA

Initialise a previously declared object of class mbfl_semver_spec using the given parameters. When successful return true; otherwise return false.

The parameters PRERELEASE_VERSION and BUILD_METADATA are optional: when not given, the corresponding component is set to the empty string.

If SEMVER_SPEC has already been initialised by a previous call to a constructor: the old semantic–version specification is deleted.

Predicate on mbfl_semver_spec_t: mbfl_semver_spec_is_a OBJ

Return true if OBJ is the data variable of an object of class mbfl_semver_spec; otherwise return false.

mbfl_default_object_declare(SEMVER_SPEC)

mbfl_semver_spec_make_from_string _(SEMVER_SPEC) "1.2.3-devel.0+x86-64"

mbfl_semver_spec_is_a _(SEMVER_SPEC)    ⇒ 0
mbfl_semver_spec_is_a 'ciao'            ⇒ 1
Accessor on mbfl_semver_spec_t: mbfl_semver_spec_major_number_var _RV SEMVER_SPEC
Mutator on mbfl_semver_spec_t: mbfl_semver_spec_major_number_set SEMVER_SPEC MAJOR_NUMBER

Accessor and mutator for the major number specification. When successful return true; otherwise return false.

mbfl_default_object_declare(SEMVER_SPEC)
mbfl_declare_varref(MAJOR)

mbfl_semver_spec_make_from_string _(SEMVER_SPEC) "1.2.3-devel.0+x86-64"
mbfl_semver_spec_major_number_var _(MAJOR) _(SEMVER_SPEC)
"$MAJOR" ⇒ 1
Accessor on mbfl_semver_spec_t: mbfl_semver_spec_minor_version_var _RV SEMVER_SPEC
Mutator on mbfl_semver_spec_t: mbfl_semver_spec_minor_version_set SEMVER_SPEC MINOR_VERSION

Accessor and mutator for the minor number specification. When successful return true; otherwise return false.

mbfl_default_object_declare(SEMVER_SPEC)
mbfl_declare_varref(MINOR)

mbfl_semver_spec_make_from_string _(SEMVER_SPEC) "1.2.3-devel.0+x86-64"
mbfl_semver_spec_minor_number_var _(MINOR) _(SEMVER_SPEC)
"$MINOR" ⇒ 2
Accessor on mbfl_semver_spec_t: mbfl_semver_spec_patch_level_var _RV SEMVER_SPEC
Mutator on mbfl_semver_spec_t: mbfl_semver_spec_patch_level_set SEMVER_SPEC PATCH_LEVEL

Accessor and mutator for the patch level specification. When successful return true; otherwise return false.

mbfl_default_object_declare(SEMVER_SPEC)
mbfl_declare_varref(PATCH_LEVEL)

mbfl_semver_spec_make_from_string _(SEMVER_SPEC) "1.2.3-devel.0+x86-64"
mbfl_semver_spec_patch_level_var _(PATCH_LEVEL) _(SEMVER_SPEC)
"$PATCH_LEVEL" ⇒ 3
Accessor on mbfl_semver_spec_t: mbfl_semver_spec_prerelease_version_var _RV SEMVER_SPEC
Mutator on mbfl_semver_spec_t: mbfl_semver_spec_prerelease_version_set SEMVER_SPEC PRERELEASE_VERSION

Accessor and mutator for the prerelease version specification; this value does not contain the leading hyphen character ‘-’. When successful return true; otherwise return false.

mbfl_default_object_declare(SEMVER_SPEC)
mbfl_declare_varref(PRERELEASE_VERSION)

mbfl_semver_spec_make_from_string _(SEMVER_SPEC) "1.2.3-devel.0+x86-64"
mbfl_semver_spec_prerelease_version_var _(PRERELEASE_VERSION) _(SEMVER_SPEC)
"$PRERELEASE_VERSION" ⇒ devel.0
Accessor on mbfl_semver_spec_t: mbfl_semver_spec_build_metadata_var _RV SEMVER_SPEC
Mutator on mbfl_semver_spec_t: mbfl_semver_spec_build_metadata_set SEMVER_SPEC BUILD_METADATA

Accessor and mutator for the build metadata; it does not contain the leading plus character ‘+’. When successful return true; otherwise return false.

mbfl_default_object_declare(SEMVER_SPEC)
mbfl_declare_varref(BUILD_METADATA)

mbfl_semver_spec_make_from_string _(SEMVER_SPEC) "1.2.3-devel.0+x86-64"
mbfl_semver_spec_build_metadata_var _(BUILD_METADATA) _(SEMVER_SPEC)
"$BUILD_METADATA" ⇒ x86-64
Accessor on mbfl_semver_spec_t: mbfl_semver_spec_string_var _RV SEMVER_SPEC

Accessor for the string representation of a semantic–version; the resulting string does not contain the leading ‘v’ character. When successful return true; otherwise return false.

mbfl_default_object_declare(SEMVER_SPEC)
mbfl_declare_varref(STRING)

mbfl_semver_spec_make_from_string _(SEMVER_SPEC) "1.2.3-devel.0+x86-64"
mbfl_semver_spec_string_var _(STRING) _(SEMVER_SPEC)
"$STRING" ⇒ 1.2.3-devel.0+x86-64

This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.