name.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
00005  *
00006  * This file is part of the Paludis package manager. Paludis is free software;
00007  * you can redistribute it and/or modify it under the terms of the GNU General
00008  * Public License version 2, as published by the Free Software Foundation.
00009  *
00010  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00013  * details.
00014  *
00015  * You should have received a copy of the GNU General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef PALUDIS_GUARD_PALUDIS_NAME_HH
00021 #define PALUDIS_GUARD_PALUDIS_NAME_HH 1
00022 
00023 #include <paludis/name-fwd.hh>
00024 #include <paludis/util/exception.hh>
00025 #include <paludis/util/instantiation_policy.hh>
00026 #include <paludis/util/validated.hh>
00027 #include <paludis/util/named_value.hh>
00028 
00029 #include <string>
00030 #include <iosfwd>
00031 
00032 /** \file
00033  * Declarations for Name classes.
00034  *
00035  * \ingroup g_names
00036  *
00037  * \section Examples
00038  *
00039  * - \ref example_name.cc "example_name.cc"
00040  */
00041 
00042 namespace paludis
00043 {
00044     namespace n
00045     {
00046         struct category;
00047         struct package;
00048     }
00049 
00050     /**
00051      * A PackageNamePartError is thrown if an invalid value is assigned to
00052      * a PackageNamePart.
00053      *
00054      * \ingroup g_names
00055      * \ingroup g_exceptions
00056      */
00057     class PALUDIS_VISIBLE PackageNamePartError :
00058         public NameError
00059     {
00060         public:
00061             /**
00062              * Constructor.
00063              */
00064             PackageNamePartError(const std::string & name) throw ();
00065     };
00066 
00067     /**
00068      * A PackageNamePartValidator handles validation rules for the value
00069      * of a PackageNamePart.
00070      *
00071      * \ingroup g_names
00072      */
00073     struct PALUDIS_VISIBLE PackageNamePartValidator :
00074         private InstantiationPolicy<PackageNamePartValidator, instantiation_method::NonInstantiableTag>
00075     {
00076         /**
00077          * If the parameter is not a valid value for a PackageNamePart,
00078          * throw a PackageNamePartError.
00079          */
00080         static void validate(const std::string &);
00081     };
00082 
00083     /**
00084      * A CategoryNamePartError is thrown if an invalid value is assigned to
00085      * a CategoryNamePart.
00086      *
00087      * \ingroup g_exceptions
00088      * \ingroup g_names
00089      */
00090     class PALUDIS_VISIBLE CategoryNamePartError :
00091         public NameError
00092     {
00093         public:
00094             /**
00095              * Constructor.
00096              */
00097             CategoryNamePartError(const std::string & name) throw ();
00098     };
00099 
00100     /**
00101      * A CategoryNamePartValidator handles validation rules for the value
00102      * of a CategoryNamePart.
00103      *
00104      * \ingroup g_names
00105      */
00106     struct PALUDIS_VISIBLE CategoryNamePartValidator :
00107         private InstantiationPolicy<CategoryNamePartValidator, instantiation_method::NonInstantiableTag>
00108     {
00109         /**
00110          * If the parameter is not a valid value for a CategoryNamePart,
00111          * throw a CategoryNamePartError.
00112          */
00113         static void validate(const std::string &);
00114     };
00115 
00116     /**
00117      * Represents a category plus package name.
00118      *
00119      * \ingroup g_names
00120      * \nosubgrouping
00121      */
00122     struct PALUDIS_VISIBLE QualifiedPackageName :
00123         relational_operators::HasRelationalOperators
00124     {
00125         NamedValue<n::category, CategoryNamePart> category;
00126         NamedValue<n::package, PackageNamePart> package;
00127 
00128         QualifiedPackageName(const CategoryNamePart &, const PackageNamePart &);
00129         explicit QualifiedPackageName(const std::string &);
00130 
00131         std::size_t hash() const PALUDIS_ATTRIBUTE((warn_unused_result));
00132 
00133         bool operator< (const QualifiedPackageName &) const PALUDIS_ATTRIBUTE((warn_unused_result));
00134         bool operator== (const QualifiedPackageName &) const PALUDIS_ATTRIBUTE((warn_unused_result));
00135     };
00136 
00137     /**
00138      * A QualifiedPackageNameError may be thrown if an invalid name is
00139      * assigned to a QualifiedPackageName (alternatively, the exception
00140      * raised may be a PackageNamePartError or a CategoryNamePartError).
00141      *
00142      * \ingroup g_names
00143      * \ingroup g_exceptions
00144      */
00145     class PALUDIS_VISIBLE QualifiedPackageNameError : public NameError
00146     {
00147         public:
00148             /**
00149              * Constructor.
00150              */
00151             QualifiedPackageNameError(const std::string &) throw ();
00152     };
00153 
00154     inline const QualifiedPackageName
00155     operator+ (const CategoryNamePart & c, const PackageNamePart & p)
00156     {
00157         return QualifiedPackageName(c, p);
00158     }
00159 
00160     /**
00161      * A SlotNameError is thrown if an invalid value is assigned to
00162      * a SlotName.
00163      *
00164      * \ingroup g_names
00165      * \ingroup g_exceptions
00166      */
00167     class PALUDIS_VISIBLE SlotNameError : public NameError
00168     {
00169         public:
00170             /**
00171              * Constructor.
00172              */
00173             SlotNameError(const std::string & name) throw ();
00174     };
00175 
00176     /**
00177      * A SlotNameValidator handles validation rules for the value of a
00178      * SlotName.
00179      *
00180      * \ingroup g_names
00181      */
00182     struct PALUDIS_VISIBLE SlotNameValidator :
00183         private InstantiationPolicy<SlotNameValidator, instantiation_method::NonInstantiableTag>
00184     {
00185         /**
00186          * If the parameter is not a valid value for a SlotName,
00187          * throw a SlotNameError.
00188          */
00189         static void validate(const std::string &);
00190     };
00191 
00192     /**
00193      * A RepositoryNameError is thrown if an invalid value is assigned to
00194      * a RepositoryName.
00195      *
00196      * \ingroup g_exceptions
00197      * \ingroup g_names
00198      */
00199     class PALUDIS_VISIBLE RepositoryNameError : public NameError
00200     {
00201         public:
00202             /**
00203              * Constructor.
00204              */
00205             RepositoryNameError(const std::string & name) throw ();
00206     };
00207 
00208     /**
00209      * A RepositoryNameValidator handles validation rules for the value
00210      * of a RepositoryName.
00211      *
00212      * \ingroup g_names
00213      */
00214     struct PALUDIS_VISIBLE RepositoryNameValidator :
00215         private InstantiationPolicy<RepositoryNameValidator, instantiation_method::NonInstantiableTag>
00216     {
00217         /**
00218          * If the parameter is not a valid value for a RepositoryName,
00219          * throw a RepositoryNameError.
00220          */
00221         static void validate(const std::string &);
00222     };
00223 
00224     /**
00225      * Arbitrary useless comparator for RepositoryName.
00226      *
00227      * \ingroup g_names
00228      */
00229     struct PALUDIS_VISIBLE RepositoryNameComparator
00230     {
00231         /**
00232          * Perform the comparison.
00233          */
00234         bool operator() (const RepositoryName & lhs, const RepositoryName & rhs) const
00235         {
00236             return lhs.data() < rhs.data();
00237         }
00238     };
00239 
00240     /**
00241      * A KeywordNameValidator handles validation rules for the value of a
00242      * KeywordName.
00243      *
00244      * \ingroup g_names
00245      */
00246     struct PALUDIS_VISIBLE KeywordNameValidator :
00247         private InstantiationPolicy<KeywordNameValidator, instantiation_method::NonInstantiableTag>
00248     {
00249         /**
00250          * If the parameter is not a valid value for a KeywordName,
00251          * throw a KeywordNameError.
00252          */
00253         static void validate(const std::string &);
00254     };
00255 
00256     /**
00257      * A KeywordNameError is thrown if an invalid value is assigned to
00258      * a KeywordName.
00259      *
00260      * \ingroup g_names
00261      * \ingroup g_exceptions
00262      */
00263     class PALUDIS_VISIBLE KeywordNameError : public NameError
00264     {
00265         public:
00266             /**
00267              * Constructor.
00268              */
00269             KeywordNameError(const std::string & name) throw ();
00270     };
00271 
00272     /**
00273      * Comparator for a KeywordName.
00274      *
00275      * \ingroup g_names
00276      * \since 0.26
00277      */
00278     class PALUDIS_VISIBLE KeywordNameComparator
00279     {
00280         public:
00281             /**
00282              * Perform a less-than comparison.
00283              */
00284             bool operator() (const std::string &, const std::string &) const;
00285     };
00286 
00287     /**
00288      * A SetNameValidator handles validation rules for the value of a
00289      * SetName.
00290      *
00291      * \ingroup g_exceptions
00292      */
00293     struct PALUDIS_VISIBLE SetNameValidator :
00294         private InstantiationPolicy<SetNameValidator, instantiation_method::NonInstantiableTag>
00295     {
00296         /**
00297          * If the parameter is not a valid value for a SetName,
00298          * throw a SetNameError.
00299          */
00300         static void validate(const std::string &);
00301     };
00302 
00303     /**
00304      * A SetNameError is thrown if an invalid value is assigned to
00305      * a SetName.
00306      *
00307      * \ingroup g_exceptions
00308      * \ingroup g_names
00309      */
00310     class PALUDIS_VISIBLE SetNameError : public NameError
00311     {
00312         public:
00313             /**
00314              * Constructor.
00315              */
00316             SetNameError(const std::string & name) throw ();
00317     };
00318 }
00319 
00320 #endif

Generated on Mon Sep 21 10:36:08 2009 for paludis by  doxygen 1.5.4