aboutsummaryrefslogtreecommitdiff
path: root/include/katja/database.hpp
blob: ca85ab183cfaba696aaabb9ff0f283433f94e3a8 (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
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */
#pragma once

#include <string>
#include <map>

namespace katja
{
    constexpr const char *database = "/var/lib/pkgtools/packages";

    class database_package
    {
        database_package(std::string&& name, std::string&& version,
                std::string&& architecture, std::string&& build_tag);

        static database_package create_database_package(const std::string& fullname);

    public:
        const std::string name;
        const std::string version;
        const std::string architecture;
        const std::string build_tag;

        database_package(const std::string& fullname);

        bool operator<(const database_package& that) const;
        bool operator>(const database_package& that) const;

        std::string to_string() const;
    };

    using package_database = std::multimap<std::string, database_package>;

    package_database read_installed_database();
}