atlas
Version.h
1 /*
2  * (C) Copyright 2020 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation
8  * nor does it submit to any jurisdiction.
9  */
10 
11 #pragma once
12 
13 #include <cstdint>
14 
15 #include "eckit/types/SemanticVersion.h"
16 
17 namespace atlas {
18 namespace io {
19 
20 struct Version { // 8 bytes
21  std::uint32_t major{0};
22  std::uint32_t minor{2};
23 
24  std::string str() const { return std::to_string( major ) + "." + std::to_string( minor ); }
25  operator std::string() const { return str(); }
26  operator eckit::SemanticVersion() const { return eckit::SemanticVersion{major, minor, 0}; }
27 
28  bool operator<( const Version& v ) const {
29  return eckit::SemanticVersion{major, minor, 0} < eckit::SemanticVersion{v.major, v.minor, 0};
30  }
31  bool operator==( const Version& v ) const {
32  return eckit::SemanticVersion{major, minor, 0} == eckit::SemanticVersion{v.major, v.minor, 0};
33  }
34  bool operator!=( const Version& v ) const { return !( *this == v ); }
35  bool operator<=( const Version& v ) const { return ( *this < v ) or ( *this == v ); }
36  bool operator>( const Version& v ) const { return !( *this <= v ); }
37  bool operator>=( const Version& v ) const { return ( *this > v ) or ( *this == v ); }
38 
39 
40  friend std::ostream& operator<<( std::ostream& out, const Version& v ) {
41  out << v.str();
42  return out;
43  }
44 };
45 
46 
47 } // namespace io
48 } // namespace atlas
std::uint32_t major
Major version.
Definition: Version.h:21
Definition: Version.h:20
std::uint32_t minor
Minor version.
Definition: Version.h:22
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33