OpenCPN Partial API docs
Loading...
Searching...
No Matches
testvers.cpp
1#include "semantic_vers.h"
2#include <iostream>
3
4// c++ -I../include -I../build/include testvers.cpp semantic_vers.cpp
5// a.out 1.4.6 7.8.9+deadbee
6
7int main(int argc, char** argv) {
10 if (argc > 1) {
11 auto tmp = SemanticVersion::parse(argv[1]);
12 v1 = tmp;
13 std::cout << "First version: " << v1 << "\n";
14 }
15 if (argc > 2) {
16 auto tmp = SemanticVersion::parse(argv[2]);
17 v2 = tmp;
18 std::cout << "Second version: " << v2 << "\n";
19 } else {
20 exit(0);
21 }
22 std::cout << "1 > 2"
23 << " " << (v1 > v2 ? "True" : "False") << "\n";
24 std::cout << "1 < 2"
25 << " " << (v1 < v2 ? "True" : "False") << "\n";
26 std::cout << "1 == 2"
27 << " " << (v1 == v2 ? "True" : "False") << "\n";
28 std::cout << "1 != 2"
29 << " " << (v1 != v2 ? "True" : "False") << "\n";
30 std::cout << "1 <= 2"
31 << " " << (v1 <= v2 ? "True" : "False") << "\n";
32 std::cout << "1 >= 2"
33 << " " << (v1 >= v2 ? "True" : "False") << "\n";
34}
Versions uses a modified semantic versioning scheme: major.minor.revision.post-tag+build.
Definition: semantic_vers.h:51
static SemanticVersion parse(std::string s)
Parse a version string, sets major == -1 on errors.