aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/unavailable/unavailable_repository_dependencies_key.cc
blob: 297696439362168aa7e250f03cd65b3fee8b96df (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* vim: set sw=4 sts=4 et foldmethod=syntax : */

/*
 * Copyright (c) 2010 Ciaran McCreesh
 *
 * This file is part of the Paludis package manager. Paludis is free software;
 * you can redistribute it and/or modify it under the terms of the GNU General
 * Public License version 2, as published by the Free Software Foundation.
 *
 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <paludis/repositories/unavailable/unavailable_repository_dependencies_key.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/set.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/return_literal_function.hh>
#include <paludis/dep_label.hh>
#include <paludis/comma_separated_dep_parser.hh>
#include <paludis/comma_separated_dep_printer.hh>
#include <memory>

using namespace paludis;
using namespace paludis::unavailable_repository;

namespace paludis
{
    template <>
    struct Imp<UnavailableRepositoryDependenciesKey>
    {
        const Environment * const env;
        const std::shared_ptr<const DependencySpecTree> value;
        const std::shared_ptr<DependenciesLabelSequence> labels;

        const std::string raw_name;
        const std::string human_name;
        const MetadataKeyType type;

        Imp(const Environment * const e,
                const std::string & r, const std::string & h, const MetadataKeyType t,
                const std::string & v) :
            env(e),
            value(CommaSeparatedDepParser::parse(e, v)),
            labels(std::make_shared<DependenciesLabelSequence>()),
            raw_name(r),
            human_name(h),
            type(t)
        {
            labels->push_back(std::make_shared<DependenciesBuildLabel>("build", return_literal_function(true)));
        }
    };
}

UnavailableRepositoryDependenciesKey::UnavailableRepositoryDependenciesKey(const Environment * const env,
        const std::string & r, const std::string & h, const MetadataKeyType t,
        const std::string & v) :
    Pimp<UnavailableRepositoryDependenciesKey>(env, r, h, t, v)
{
}

UnavailableRepositoryDependenciesKey::~UnavailableRepositoryDependenciesKey()
{
}

const std::shared_ptr<const DependencySpecTree>
UnavailableRepositoryDependenciesKey::value() const
{
    return _imp->value;
}

const std::string
UnavailableRepositoryDependenciesKey::raw_name() const
{
    return _imp->raw_name;
}

const std::string
UnavailableRepositoryDependenciesKey::human_name() const
{
    return _imp->human_name;
}

MetadataKeyType
UnavailableRepositoryDependenciesKey::type() const
{
    return _imp->type;
}

std::string
UnavailableRepositoryDependenciesKey::pretty_print(const DependencySpecTree::ItemFormatter & f) const
{
    CommaSeparatedDepPrinter p(_imp->env, f, false);
    _imp->value->top()->accept(p);
    return p.result();
}

std::string
UnavailableRepositoryDependenciesKey::pretty_print_flat(const DependencySpecTree::ItemFormatter & f) const
{
    CommaSeparatedDepPrinter p(_imp->env, f, true);
    _imp->value->top()->accept(p);
    return p.result();
}

const std::shared_ptr<const DependenciesLabelSequence>
UnavailableRepositoryDependenciesKey::initial_labels() const
{
    return _imp->labels;
}