#pragma once #ifndef GITVERSION_PARSER_H #define GITVERSION_PARSER_H #include #include #include namespace gitversion { struct VersionInfo { bool isDevVersion = false; bool isStableVersion = false; std::string versionTag; std::string gitCommitId; std::string majorVersion; std::string minorVersion; std::string hotfixVersion; unsigned int commitsSinceTag = 0; }; class Parser final { public: static VersionInfo parse(const std::string &versionString); private: static std::pair> _splitAt(const std::string &versionString, char delimiter); static std::tuple _extractMajorMinorHotfixTag(const std::string &versionNumber); static std::tuple _extractMajorMinorHotfix(const std::string &versionNumber); static std::tuple _extractGitCommitIdAndCommitsSinceTag(const std::string &versionInfo); }; } #endif