paludis Version 3.0.2
The one true package mangler
name.hh
Go to the documentation of this file.
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2005, 2006, 2007, 2008, 2010, 2011 Ciaran McCreesh
5 *
6 * This file is part of the Paludis package manager. Paludis is free software;
7 * you can redistribute it and/or modify it under the terms of the GNU General
8 * Public License version 2, as published by the Free Software Foundation.
9 *
10 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef PALUDIS_GUARD_PALUDIS_NAME_HH
21#define PALUDIS_GUARD_PALUDIS_NAME_HH 1
22
23#include <paludis/name-fwd.hh>
25#include <paludis/util/wrapped_value.hh>
26#include <paludis/util/operators.hh>
27#include <paludis/util/set.hh>
28#include <paludis/util/wrapped_forward_iterator.hh>
29#include <paludis/util/wrapped_output_iterator.hh>
30
31#include <string>
32#include <iosfwd>
33
34/** \file
35 * Declarations for Name classes.
36 *
37 * \ingroup g_names
38 *
39 * \section Examples
40 *
41 * - \ref example_name.cc "example_name.cc"
42 */
43
44namespace paludis
45{
46 /**
47 * A PackageNamePartError is thrown if an invalid value is assigned to
48 * a PackageNamePart.
49 *
50 * \ingroup g_names
51 * \ingroup g_exceptions
52 */
54 public NameError
55 {
56 public:
57 /**
58 * Constructor.
59 */
60 PackageNamePartError(const std::string & name) noexcept;
61 };
62
63 template <>
64 struct PALUDIS_VISIBLE WrappedValueTraits<PackageNamePartTag>
65 {
66 typedef std::string UnderlyingType;
67 typedef void ValidationParamsType;
68 typedef PackageNamePartError ExceptionType;
69
70 static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
71 };
72
74
75 /**
76 * A CategoryNamePartError is thrown if an invalid value is assigned to
77 * a CategoryNamePart.
78 *
79 * \ingroup g_exceptions
80 * \ingroup g_names
81 */
83 public NameError
84 {
85 public:
86 /**
87 * Constructor.
88 */
89 CategoryNamePartError(const std::string & name) noexcept;
90 };
91
92 template <>
94 {
95 typedef std::string UnderlyingType;
96 typedef void ValidationParamsType;
97 typedef CategoryNamePartError ExceptionType;
98
99 static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
100 };
101
103
104 /**
105 * Represents a category plus package name.
106 *
107 * \ingroup g_names
108 * \nosubgrouping
109 */
110 class PALUDIS_VISIBLE QualifiedPackageName :
112 {
113 private:
114 CategoryNamePart _cat;
115 PackageNamePart _pkg;
116
117 public:
118 QualifiedPackageName(const CategoryNamePart &, const PackageNamePart &);
119 explicit QualifiedPackageName(const std::string &);
120
121 std::size_t hash() const PALUDIS_ATTRIBUTE((warn_unused_result));
122
123 bool operator< (const QualifiedPackageName &) const PALUDIS_ATTRIBUTE((warn_unused_result));
124 bool operator== (const QualifiedPackageName &) const PALUDIS_ATTRIBUTE((warn_unused_result));
125
126 const CategoryNamePart category() const PALUDIS_ATTRIBUTE((warn_unused_result))
127 {
128 return _cat;
129 }
130
131 const PackageNamePart package() const PALUDIS_ATTRIBUTE((warn_unused_result))
132 {
133 return _pkg;
134 }
135 };
136
137 inline const QualifiedPackageName
139 {
140 return QualifiedPackageName(c, p);
141 }
142
143 /**
144 * A SlotNameError is thrown if an invalid value is assigned to
145 * a SlotName.
146 *
147 * \ingroup g_names
148 * \ingroup g_exceptions
149 */
151 {
152 public:
153 /**
154 * Constructor.
155 */
156 SlotNameError(const std::string & name) noexcept;
157 };
158
159 template <>
161 {
162 typedef std::string UnderlyingType;
163 typedef void ValidationParamsType;
164 typedef SlotNameError ExceptionType;
165
166 static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
167 };
168
169 /**
170 * A RepositoryNameError is thrown if an invalid value is assigned to
171 * a RepositoryName.
172 *
173 * \ingroup g_exceptions
174 * \ingroup g_names
175 */
177 {
178 public:
179 /**
180 * Constructor.
181 */
182 RepositoryNameError(const std::string & name) noexcept;
183 };
184
185 template <>
187 {
188 typedef std::string UnderlyingType;
189 typedef void ValidationParamsType;
190 typedef RepositoryNameError ExceptionType;
191
192 static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
193 };
194
195 /**
196 * A KeywordNameError is thrown if an invalid value is assigned to
197 * a KeywordName.
198 *
199 * \ingroup g_names
200 * \ingroup g_exceptions
201 */
203 {
204 public:
205 /**
206 * Constructor.
207 */
208 KeywordNameError(const std::string & name) noexcept;
209 };
210
211 template <>
213 {
214 typedef std::string UnderlyingType;
215 typedef void ValidationParamsType;
216 typedef KeywordNameError ExceptionType;
217
218 static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
219 };
220
221 /**
222 * A SetNameError is thrown if an invalid value is assigned to
223 * a SetName.
224 *
225 * \ingroup g_exceptions
226 * \ingroup g_names
227 */
229 {
230 public:
231 /**
232 * Constructor.
233 */
234 SetNameError(const std::string & name) noexcept;
235 };
236
237 template <>
239 {
240 typedef std::string UnderlyingType;
241 typedef void ValidationParamsType;
242 typedef SetNameError ExceptionType;
243
244 static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
245 };
246
247 /**
248 * A PartNameError is thrown if an invalid value is assigned to a PartName.
249 *
250 * \ingroup g_exceptions
251 * \ingroup g_names
252 */
254 {
255 public:
256 /**
257 * Constructor
258 */
259 PartNameError(const std::string & name) noexcept;
260 };
261
262 template <>
264 {
265 typedef std::string UnderlyingType;
266 typedef void ValidationParamsType;
267 typedef PartNameError ExceptionType;
268
269 static bool validate(const std::string &)
270 PALUDIS_ATTRIBUTE((warn_unused_result));
271 };
272
274 extern template class PALUDIS_VISIBLE WrappedValue<SlotNameTag>;
275 extern template class PALUDIS_VISIBLE WrappedValue<KeywordNameTag>;
276 extern template class PALUDIS_VISIBLE WrappedValue<SetNameTag>;
277 extern template class PALUDIS_VISIBLE WrappedValue<PartNameTag>;
278
279 extern template class PALUDIS_VISIBLE Set<CategoryNamePart>;
282
283 extern template class PALUDIS_VISIBLE Set<QualifiedPackageName>;
286}
287
288#endif
Definition name.hh:84
CategoryNamePartError(const std::string &name) noexcept
Definition name.hh:203
KeywordNameError(const std::string &name) noexcept
NameError(const std::string &name, const std::string &role) noexcept
Definition name.hh:55
PackageNamePartError(const std::string &name) noexcept
Definition name.hh:254
PartNameError(const std::string &name) noexcept
Definition name.hh:112
Definition name.hh:177
RepositoryNameError(const std::string &name) noexcept
Definition name.hh:229
SetNameError(const std::string &name) noexcept
Definition set.hh:51
Definition name.hh:151
SlotNameError(const std::string &name) noexcept
Definition wrapped_forward_iterator.hh:42
Definition wrapped_output_iterator.hh:38
Definition wrapped_value.hh:45
WrappedValue< CategoryNamePartTag > CategoryNamePart
Definition name-fwd.hh:61
WrappedValue< PackageNamePartTag > PackageNamePart
Definition name-fwd.hh:47
bool operator==(const PackageID &, const PackageID &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE
Generator operator+(const Generator &, const Generator &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24
Definition wrapped_value-fwd.hh:32