stringify_formatter.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 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_STRINGIFY_FORMATTER_HH
00021 #define PALUDIS_GUARD_PALUDIS_STRINGIFY_FORMATTER_HH 1
00022 
00023 #include <paludis/stringify_formatter-fwd.hh>
00024 #include <paludis/formatter.hh>
00025 #include <paludis/name.hh>
00026 #include <paludis/dep_spec-fwd.hh>
00027 #include <paludis/util/private_implementation_pattern.hh>
00028 #include <paludis/util/fs_entry-fwd.hh>
00029 
00030 /** \file
00031  * Declarations for the StringifyFormatter class.
00032  *
00033  * \ingroup g_formatters
00034  *
00035  * \section Examples
00036  *
00037  * - \ref example_stringify_formatter.cc "example_stringify_formatter.cc"
00038  * - \ref example_formatter.cc "example_formatter.cc"
00039  */
00040 
00041 namespace paludis
00042 {
00043     /**
00044      * A StringifyFormatter is a Formatter that implements every format function
00045      * by calling paludis::stringify().
00046      *
00047      * A StringifyFormatter can also act as a wrapper class around another
00048      * Formatter. Any CanFormat<> interface implemented by that other formatter
00049      * is used; any not implemented by the other formatter is implemented using
00050      * paludis::stringify().
00051      *
00052      * Indenting is done via simple spaces; newlines are done via a newline
00053      * character. Again, when used as a wrapper, this can be overridden by the
00054      * wrapped class.
00055      *
00056      * \ingroup g_formatters
00057      * \since 0.26
00058      * \nosubgrouping
00059      */
00060     class PALUDIS_VISIBLE StringifyFormatter :
00061         private PrivateImplementationPattern<StringifyFormatter>,
00062         public CanFormat<std::string>,
00063         public CanFormat<ChoiceValue>,
00064         public CanFormat<KeywordName>,
00065         public CanFormat<PackageDepSpec>,
00066         public CanFormat<BlockDepSpec>,
00067         public CanFormat<FetchableURIDepSpec>,
00068         public CanFormat<SimpleURIDepSpec>,
00069         public CanFormat<DependencyLabelsDepSpec>,
00070         public CanFormat<URILabelsDepSpec>,
00071         public CanFormat<PlainTextDepSpec>,
00072         public CanFormat<LicenseDepSpec>,
00073         public CanFormat<ConditionalDepSpec>,
00074         public CanFormat<NamedSetDepSpec>,
00075         public CanFormat<FSEntry>,
00076         public CanFormat<PackageID>,
00077         public CanFormat<PlainTextLabelDepSpec>,
00078         public CanSpace
00079     {
00080         private:
00081             StringifyFormatter(const StringifyFormatter &);
00082 
00083         public:
00084             ///\name Basic operations
00085             ///\{
00086 
00087             StringifyFormatter();
00088 
00089             /**
00090              * StringifyFormatter can be constructed as a wrapper around another
00091              * formatter.
00092              */
00093             template <typename T_> explicit StringifyFormatter(const T_ &);
00094 
00095             ~StringifyFormatter();
00096 
00097             ///\}
00098 
00099             virtual std::string format(const std::string &, const format::Plain &) const;
00100 
00101             virtual std::string format(const ChoiceValue &, const format::Enabled &) const;
00102             virtual std::string format(const ChoiceValue &, const format::Disabled &) const;
00103             virtual std::string format(const ChoiceValue &, const format::Forced &) const;
00104             virtual std::string format(const ChoiceValue &, const format::Masked &) const;
00105             virtual std::string format(const ChoiceValue &, const format::Plain &) const;
00106             virtual std::string decorate(const ChoiceValue &, const std::string &, const format::Changed &) const;
00107             virtual std::string decorate(const ChoiceValue &, const std::string &, const format::Added &) const;
00108 
00109             virtual std::string format(const KeywordName &, const format::Accepted &) const;
00110             virtual std::string format(const KeywordName &, const format::Unaccepted &) const;
00111             virtual std::string format(const KeywordName &, const format::Plain &) const;
00112 
00113             virtual std::string format(const PackageDepSpec &, const format::Plain &) const;
00114             virtual std::string format(const PackageDepSpec &, const format::Installed &) const;
00115             virtual std::string format(const PackageDepSpec &, const format::Installable &) const;
00116 
00117             virtual std::string format(const BlockDepSpec &, const format::Plain &) const;
00118 
00119             virtual std::string format(const FetchableURIDepSpec &, const format::Plain &) const;
00120 
00121             virtual std::string format(const SimpleURIDepSpec &, const format::Plain &) const;
00122 
00123             virtual std::string format(const DependencyLabelsDepSpec &, const format::Plain &) const;
00124 
00125             virtual std::string format(const NamedSetDepSpec &, const format::Plain &) const;
00126 
00127             virtual std::string format(const URILabelsDepSpec &, const format::Plain &) const;
00128 
00129             virtual std::string format(const PlainTextDepSpec &, const format::Plain &) const;
00130 
00131             virtual std::string format(const LicenseDepSpec &, const format::Plain &) const;
00132             virtual std::string format(const LicenseDepSpec &, const format::Accepted &) const;
00133             virtual std::string format(const LicenseDepSpec &, const format::Unaccepted &) const;
00134 
00135             virtual std::string format(const ConditionalDepSpec &, const format::Enabled &) const;
00136             virtual std::string format(const ConditionalDepSpec &, const format::Disabled &) const;
00137             virtual std::string format(const ConditionalDepSpec &, const format::Forced &) const;
00138             virtual std::string format(const ConditionalDepSpec &, const format::Masked &) const;
00139             virtual std::string format(const ConditionalDepSpec &, const format::Plain &) const;
00140             virtual std::string decorate(const ConditionalDepSpec &, const std::string &, const format::Changed &) const;
00141             virtual std::string decorate(const ConditionalDepSpec &, const std::string &, const format::Added &) const;
00142 
00143             virtual std::string format(const FSEntry &, const format::Plain &) const;
00144 
00145             virtual std::string format(const PackageID &, const format::Plain &) const;
00146             virtual std::string format(const PackageID &, const format::Installed &) const;
00147             virtual std::string format(const PackageID &, const format::Installable &) const;
00148 
00149             virtual std::string format(const PlainTextLabelDepSpec &, const format::Plain &) const;
00150 
00151             virtual std::string newline() const;
00152             virtual std::string indent(const int) const;
00153     };
00154 }
00155 
00156 #endif

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