nmarwen / semver

Semantic Versioning C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Semantic Versioning C++

         _____                            _   _
        / ____|                          | | (_)
       | (___   ___ _ __ ___   __ _ _ __ | |_ _  ___
        \___ \ / _ \ '_ ` _ \ / _` | '_ \| __| |/ __|
        ____) |  __/ | | | | | (_| | | | | |_| | (__
       |_____/ \___|_| |_| |_|\__,_|_| |_|\__|_|\___|
__      __           _             _                _____
\ \    / /          (_)           (_)              / ____|_     _
 \ \  / /__ _ __ ___ _  ___  _ __  _ _ __   __ _  | |   _| |_ _| |_
  \ \/ / _ \ '__/ __| |/ _ \| '_ \| | '_ \ / _` | | |  |_   _|_   _|
   \  /  __/ |  \__ \ | (_) | | | | | | | | (_| | | |____|_|   |_|
    \/ \___|_|  |___/_|\___/|_| |_|_|_| |_|\__, |  \_____|
                                            __/ |
                                           |___/
Branch Linux/OSX Windows License Codacy
master Build Status Build status License Codacy Badge

C++ library compare and manipulate versions are available as extensions to the <major>.<minor>.<patch>-<prerelease>.<prereleaseversion> format complying with Semantic Versioning 2.0.0

Features

  • C++11
  • Header-only
  • Dependency-free
  • Constexpr comparison: <, <=, ==, !=, > >=
  • From/To string
  • Create
constexpr Version v;
constexpr Version v1 = Version(1, 2, 3, Version::PreReleaseType::kReleaseCandidate, 4);
constexpr Version v2 = v1;
  • Сomparison
constexpr semver::Version v1(1, 4, 3);
constexpr semver::Version v2(1, 2, 4, semver::Version::PreReleaseType::kAlpha, 10);
static_assert(v1 != v2, "");
static_assert(!(v1 == v2), "");
static_assert(v1 > v2, "");
static_assert(v1 >= v2, "");
static_assert(v2 < v1, "");
static_assert(v2 <= v1, "");
  • To string
constexpr semver::Version v(1, 2, 3, Version::PreReleaseType::kReleaseCandidate, 4);
const std::string s = v.ToString(); // "1.2.3-rc.4"
  • From string
const std::string s("1.2.3-rc.4");
Version v1(s);
Version v2;
v2.FromString(s);
Version v3 = "1.2.3-rc.4"_version;
  • To char array
constexpr semver::Version v(1, 2, 3, Version::PreReleaseType::kReleaseCandidate, 4);
char s1[kVersionStringLength];
v.ToString(s1); // "1.2.3-rc.4"
  • From char array
const char s[] = "1.2.3-rc.4";
Version v1(s);
Version v2;
v2.FromString(s);

Integration

You should add required file semver.hpp and switch to C++11.

Compiler compatibility

  • GCC
  • Clang
  • MSVC

Licensed under the MIT License

About

Semantic Versioning C++

License:MIT License


Languages

Language:C++ 97.1%Language:CMake 2.9%