| 25 | } |
| 26 | |
| 27 | std::string version::to_string() const |
| 28 | { |
| 29 | std::string version = std::to_string(hi()) + "." + std::to_string(mid()); |
| 30 | |
| 31 | if (lo()) |
| 32 | { |
| 33 | version += '.'; |
| 34 | version += std::to_string(lo()); |
| 35 | } |
| 36 | |
| 37 | if (type() != version_type::release) |
| 38 | { |
| 39 | if (!postfix().empty()) |
| 40 | { |
| 41 | version += "-" + postfix(); |
| 42 | } |
| 43 | |
| 44 | version += ' '; |
| 45 | version += utils::to_string(type()); |
| 46 | |
| 47 | if (type_index() > 1) |
| 48 | { |
| 49 | version += " " + std::to_string(type_index()); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return version; |
| 54 | } |
| 55 | |
| 56 | // Based on https://www.geeksforgeeks.org/compare-two-version-numbers/ |
| 57 | int compare_versions(const std::string& v1, const std::string& v2, bool& ok) |