aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-10-14 10:00:31 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-10-14 10:00:31 +0000
commite2f9100bbb31b6061110ad4d41d72e4d125ca4eb (patch)
tree02af9c54275356844d642e81acd97dfb511d1a50
parentd8299511cd5c233dbf93d14ddb8058ecb95410b0 (diff)
downloadpaludis-e2f9100bbb31b6061110ad4d41d72e4d125ca4eb.tar.gz
paludis-e2f9100bbb31b6061110ad4d41d72e4d125ca4eb.tar.xz
StringifyFormatter can now format strings.
-rw-r--r--paludis/stringify_formatter-impl.hh4
-rw-r--r--paludis/stringify_formatter.cc10
-rw-r--r--paludis/stringify_formatter.hh3
3 files changed, 16 insertions, 1 deletions
diff --git a/paludis/stringify_formatter-impl.hh b/paludis/stringify_formatter-impl.hh
index e271db5..855ad5c 100644
--- a/paludis/stringify_formatter-impl.hh
+++ b/paludis/stringify_formatter-impl.hh
@@ -42,6 +42,7 @@ namespace paludis
template <>
struct Implementation<StringifyFormatter>
{
+ const CanFormat<std::string> * const f_str;
const CanFormat<IUseFlag> * const f_iuse;
const CanFormat<UseFlagName> * const f_use;
const CanFormat<KeywordName> * const f_keyword;
@@ -58,6 +59,7 @@ namespace paludis
const CanSpace * const f_space;
Implementation(
+ const CanFormat<std::string> * const f_str_v,
const CanFormat<IUseFlag> * const f_iuse_v,
const CanFormat<UseFlagName> * const f_use_v,
const CanFormat<KeywordName> * const f_keyword_v,
@@ -73,6 +75,7 @@ namespace paludis
const CanFormat<NamedSetDepSpec> * const f_named_v,
const CanSpace * const f_space_v
) :
+ f_str(f_str_v),
f_iuse(f_iuse_v),
f_use(f_use_v),
f_keyword(f_keyword_v),
@@ -174,6 +177,7 @@ namespace paludis
template <typename T_>
StringifyFormatter::StringifyFormatter(const T_ & t) :
PrivateImplementationPattern<StringifyFormatter>(new Implementation<StringifyFormatter>(
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<std::string> *>::value, std::string>::get(&t),
StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<IUseFlag> *>::value, IUseFlag>::get(&t),
StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<UseFlagName> *>::value, UseFlagName>::get(&t),
StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<KeywordName> *>::value, KeywordName>::get(&t),
diff --git a/paludis/stringify_formatter.cc b/paludis/stringify_formatter.cc
index 8eb4d8f..2b7b692 100644
--- a/paludis/stringify_formatter.cc
+++ b/paludis/stringify_formatter.cc
@@ -28,7 +28,7 @@ using namespace paludis;
StringifyFormatter::StringifyFormatter() :
PrivateImplementationPattern<StringifyFormatter>(new Implementation<StringifyFormatter>(
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
{
}
@@ -37,6 +37,14 @@ StringifyFormatter::~StringifyFormatter()
}
std::string
+StringifyFormatter::format(const std::string & s, const format::Plain & k) const
+{
+ if (_imp->f_str)
+ return _imp->f_str->format(s, k);
+ return s;
+}
+
+std::string
StringifyFormatter::format(const UseFlagName & s, const format::Enabled & k) const
{
if (_imp->f_use)
diff --git a/paludis/stringify_formatter.hh b/paludis/stringify_formatter.hh
index d6c027e..caeb506 100644
--- a/paludis/stringify_formatter.hh
+++ b/paludis/stringify_formatter.hh
@@ -58,6 +58,7 @@ namespace paludis
*/
class PALUDIS_VISIBLE StringifyFormatter :
private PrivateImplementationPattern<StringifyFormatter>,
+ public CanFormat<std::string>,
public CanFormat<UseFlagName>,
public CanFormat<IUseFlag>,
public CanFormat<KeywordName>,
@@ -92,6 +93,8 @@ namespace paludis
///\}
+ virtual std::string format(const std::string &, const format::Plain &) const;
+
virtual std::string format(const UseFlagName &, const format::Enabled &) const;
virtual std::string format(const UseFlagName &, const format::Disabled &) const;
virtual std::string format(const UseFlagName &, const format::Forced &) const;