2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
15 constexpr uint32_t EncodeVersion(uint32_t major, uint32_t minor, uint32_t patch)
17 return (major << 22) | (minor << 12) | patch;
22 // Encodes a semantic version https://semver.org/ into a 32 bit integer in the following fashion
24 // bits 22:31 major: Unsigned 10-bit integer. Major component of the schema version number.
25 // bits 12:21 minor: Unsigned 10-bit integer. Minor component of the schema version number.
26 // bits 0:11 patch: Unsigned 12-bit integer. Patch component of the schema version number.
31 Version(uint32_t encodedValue)
33 m_Major = (encodedValue >> 22) & 1023;
34 m_Minor = (encodedValue >> 12) & 1023;
35 m_Patch = encodedValue & 4095;
38 Version(uint32_t major, uint32_t minor, uint32_t patch)
39 : m_Major(major), m_Minor(minor), m_Patch(patch) {}
41 uint32_t GetEncodedValue()
43 return mlutil::Impl::EncodeVersion(m_Major, m_Minor, m_Patch);
46 uint32_t GetMajor() {return m_Major;}
47 uint32_t GetMinor() {return m_Minor;}
48 uint32_t GetPatch() {return m_Patch;}