aboutsummaryrefslogtreecommitdiff
path: root/include/PackageVersion.hpp
blob: 1d966fd62f87bdbca1f376507f77c64f2a294b45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef SIBS_PACKAGEVERSION_HPP
#define SIBS_PACKAGEVERSION_HPP

#include <string>

namespace sibs
{
    /*
     * Different package version syntax:
     * ANY: "major.minor.patch" (xxx.xxx.xxx)
     *      Checks for package in several different places. First pkg-config, then local lib dir (~/.cache/sibs/lib), then git/server.
     *      Example: "2.1.002"
     * GIT: "branch:revision"
     *      Checks for package in any of the configures git servers (default: github).
     *      Example: "master:HEAD"
     * LATEST: "latest"
     *      Checks for package in several different places. First git/server then pkg-config then local lib dir (~/.cache/sibs/lib).
     *
     *
     * GIT and LATEST first check if local lib (~/.cache/sibs/lib) contains latest version by comparing the revision to remote revision.
     */
    class PackageVersion
    {
    public:
        enum class Type
        {
            ANY,
            GIT,
            LATEST
        };

        PackageVersion(int _major, int _minor, int _patch) : type(Type::ANY), major(_major), minor(_minor), patch(_patch) {}
        PackageVersion(const std::string &&_gitBranch, const std::string &&_gitRevision) :
            type(Type::GIT),
            gitBranch(_gitBranch),
            gitRevision(_gitRevision)
        {

        }

        static PackageVersion latest() { return PackageVersion(Type::LATEST); }
    private:
        PackageVersion(Type _type) : type(_type) {}
    private:
        Type type;

        int major;
        int minor;
        int patch;

        std::string gitBranch;
        std::string gitRevision;
    };
}

#endif //SIBS_PACKAGEVERSION_HPP