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 118 119 120 121 122 123 124 125 126 127 128
|
// Copyright Contributors to the DNF5 project.
// Copyright Contributors to the libdnf project.
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// This file is part of libdnf: https://github.com/rpm-software-management/libdnf/
//
// Libdnf is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or
// (at your option) any later version.
//
// Libdnf 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#ifndef LIBDNF5_MODULE_NSCVAP_HPP
#define LIBDNF5_MODULE_NSCVAP_HPP
#include "libdnf5/defs.h"
#include <memory>
#include <string>
#include <vector>
namespace libdnf5::module {
class LIBDNF_API Nsvcap {
public:
enum class Form {
NSVCAP = 1,
NSVCA = 2,
NSVAP = 3,
NSVA = 4,
NSAP = 5,
NSA = 6,
NSVCP = 7,
NSVP = 8,
NSVC = 9,
NSV = 10,
NSP = 11,
NS = 12,
NAP = 13,
NA = 14,
NP = 15,
N = 16,
NSCP = 17,
NSC = 18,
};
Nsvcap();
~Nsvcap();
Nsvcap(const Nsvcap & src);
Nsvcap & operator=(const Nsvcap & src);
Nsvcap(Nsvcap && src) noexcept;
Nsvcap & operator=(Nsvcap && src) noexcept;
/// The default forms and their order determine module_spec matching
static const std::vector<Form> & get_default_module_spec_forms();
/// Parse a string in a given form.
/// If the parsing is successful, the attributes of this class are set accordingly, otherwise, they are left unchanged.
///
/// @param nsvcap_str A string to parse.
/// @param form A module form in which the string should be.
/// @return `true` if the pattern matched the form, `false` otherwise.
/// @since 5.0.6
bool parse(const std::string & nsvcap_str, Form form);
/// Parse a string in one of the given forms.
/// If the parsing is successful, the attributes of this class are set accordingly, otherwise, they are left unchanged.
///
/// @param pattern A string to parse.
/// @param forms Module forms in one of which the string should be.
/// @return `true` if the nsvcap_str matched one of the forms, `false` otherwise.
/// @since 5.0.6
static std::vector<Nsvcap> parse(const std::string & pattern, const std::vector<Form> & forms);
/// Parse a string.
/// If the parsing is successful, the attributes of this class are set accordingly, otherwise, they are left unchanged.
///
/// @param pattern A string to parse.
/// @return `true` if the nsvcap_str matched any form, `false` otherwise.
/// @since 5.0.6
static std::vector<Nsvcap> parse(const std::string & pattern);
/// Clear the attributes of this class - set them to empty strings.
///
/// @since 5.0.6
void clear();
const std::string & get_name() const noexcept;
const std::string & get_stream() const noexcept;
const std::string & get_version() const noexcept;
const std::string & get_context() const noexcept;
const std::string & get_arch() const noexcept;
const std::string & get_profile() const noexcept;
void set_name(const std::string & name);
void set_stream(const std::string & stream);
void set_version(const std::string & version);
void set_context(const std::string & context);
void set_arch(const std::string & arch);
void set_profile(const std::string & profile);
void set_name(std::string && name);
void set_stream(std::string && stream);
void set_version(std::string && version);
void set_context(std::string && context);
void set_arch(std::string && arch);
void set_profile(std::string && profile);
private:
class LIBDNF_LOCAL Impl;
std::unique_ptr<Impl> p_impl;
};
} // namespace libdnf5::module
#endif //LIBDNF5_MODULE_NSCVAP_HPP
|