aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-19 12:03:27 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-19 12:03:27 +0000
commit605084e3a31f384b828d2641a9eb3f62eaa172a8 (patch)
tree70d2cf3cc48174f0b583e05c16dca113cfa83ed3
parent89ca9dde4924544dcd09941ae0c39c537be90340 (diff)
downloadpaludis-605084e3a31f384b828d2641a9eb3f62eaa172a8.tar.gz
paludis-605084e3a31f384b828d2641a9eb3f62eaa172a8.tar.xz
ArgsOption::forwardable_args
-rw-r--r--paludis/args/args_option.cc86
-rw-r--r--paludis/args/args_option.hh21
2 files changed, 105 insertions, 2 deletions
diff --git a/paludis/args/args_option.cc b/paludis/args/args_option.cc
index af1f142..f790863 100644
--- a/paludis/args/args_option.cc
+++ b/paludis/args/args_option.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -101,6 +101,15 @@ SwitchArg::forwardable_string() const
return "";
}
+const std::tr1::shared_ptr<Sequence<std::string> >
+SwitchArg::forwardable_args() const
+{
+ std::tr1::shared_ptr<Sequence<std::string> > result(new Sequence<std::string>);
+ if (specified())
+ result->push_back("--" + long_name());
+ return result;
+}
+
AliasArg::AliasArg(ArgsOption * const o, const std::string & our_long_name, bool is_hidden) :
ArgsOption(o->group(), our_long_name, '\0', "Alias for --" + o->long_name()),
_other(o), _hidden(is_hidden)
@@ -114,6 +123,13 @@ AliasArg::forwardable_string() const
return "";
}
+const std::tr1::shared_ptr<Sequence<std::string> >
+AliasArg::forwardable_args() const
+{
+ std::tr1::shared_ptr<Sequence<std::string> > result(new Sequence<std::string>);
+ return result;
+}
+
StringArg::StringArg(ArgsGroup * const g, const std::string & our_long_name,
const char our_short_name, const std::string & our_description) :
ArgsOption(g, our_long_name, our_short_name, our_description),
@@ -138,6 +154,18 @@ StringArg::forwardable_string() const
return "";
}
+const std::tr1::shared_ptr<Sequence<std::string> >
+StringArg::forwardable_args() const
+{
+ std::tr1::shared_ptr<Sequence<std::string> > result(new Sequence<std::string>);
+ if (specified())
+ {
+ result->push_back("--" + long_name());
+ result->push_back(argument());
+ }
+ return result;
+}
+
namespace paludis
{
template<>
@@ -226,6 +254,22 @@ StringSetArg::forwardable_string() const
return "";
}
+const std::tr1::shared_ptr<Sequence<std::string> >
+StringSetArg::forwardable_args() const
+{
+ std::tr1::shared_ptr<Sequence<std::string> > result(new Sequence<std::string>);
+ if (specified())
+ {
+ for (ConstIterator i(begin_args()), i_end(end_args()) ;
+ i != i_end ; ++i)
+ {
+ result->push_back("--" + long_name());
+ result->push_back(*i);
+ }
+ }
+ return result;
+}
+
namespace paludis
{
template<>
@@ -281,6 +325,22 @@ StringSequenceArg::forwardable_string() const
return "";
}
+const std::tr1::shared_ptr<Sequence<std::string> >
+StringSequenceArg::forwardable_args() const
+{
+ std::tr1::shared_ptr<Sequence<std::string> > result(new Sequence<std::string>);
+ if (specified())
+ {
+ for (ConstIterator i(begin_args()), i_end(end_args()) ;
+ i != i_end ; ++i)
+ {
+ result->push_back("--" + long_name());
+ result->push_back(*i);
+ }
+ }
+ return result;
+}
+
IntegerArg::IntegerArg(ArgsGroup * const our_group, const std::string & our_long_name,
char our_short_name, const std::string & our_description) :
ArgsOption(our_group, our_long_name, our_short_name, our_description)
@@ -296,6 +356,18 @@ IntegerArg::forwardable_string() const
return "";
}
+const std::tr1::shared_ptr<Sequence<std::string> >
+IntegerArg::forwardable_args() const
+{
+ std::tr1::shared_ptr<Sequence<std::string> > result(new Sequence<std::string>);
+ if (specified())
+ {
+ result->push_back("--" + long_name());
+ result->push_back(stringify(argument()));
+ }
+ return result;
+}
+
namespace paludis
{
template<>
@@ -459,6 +531,18 @@ EnumArg::forwardable_string() const
return "";
}
+const std::tr1::shared_ptr<Sequence<std::string> >
+EnumArg::forwardable_args() const
+{
+ std::tr1::shared_ptr<Sequence<std::string> > result(new Sequence<std::string>);
+ if (specified())
+ {
+ result->push_back("--" + long_name());
+ result->push_back(argument());
+ }
+ return result;
+}
+
StringSetArg::~StringSetArg()
{
}
diff --git a/paludis/args/args_option.hh b/paludis/args/args_option.hh
index e56c540..52294bc 100644
--- a/paludis/args/args_option.hh
+++ b/paludis/args/args_option.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
* Copyright (c) 2006 Stephen Bennett
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -26,6 +26,8 @@
#include <paludis/util/type_list.hh>
#include <paludis/util/named_value.hh>
#include <paludis/util/simple_visitor.hh>
+#include <paludis/util/sequence-fwd.hh>
+#include <tr1/memory>
/** \file
* Declarations for ArgsOption.
@@ -163,6 +165,16 @@ namespace paludis
* \since 0.40
*/
virtual const std::string forwardable_string() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Ourself as a sequence of strings.
+ *
+ * For example, { '--foo', 'bar' } or { '--foo', 'bar', '--foo', 'baz' }
+ * if not specified, an empty sequence.
+ *
+ * \since 0.46
+ */
+ virtual const std::tr1::shared_ptr<Sequence<std::string> > forwardable_args() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
};
/**
@@ -192,6 +204,7 @@ namespace paludis
virtual bool can_be_negated() const;
virtual const std::string forwardable_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<Sequence<std::string> > forwardable_args() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
@@ -234,6 +247,7 @@ namespace paludis
virtual bool can_be_negated() const;
virtual const std::string forwardable_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<Sequence<std::string> > forwardable_args() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
@@ -338,6 +352,7 @@ namespace paludis
virtual bool can_be_negated() const;
virtual const std::string forwardable_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<Sequence<std::string> > forwardable_args() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
@@ -383,6 +398,7 @@ namespace paludis
virtual bool can_be_negated() const;
virtual const std::string forwardable_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<Sequence<std::string> > forwardable_args() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -436,6 +452,7 @@ namespace paludis
virtual bool can_be_negated() const;
virtual const std::string forwardable_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<Sequence<std::string> > forwardable_args() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
@@ -469,6 +486,7 @@ namespace paludis
virtual bool can_be_negated() const;
virtual const std::string forwardable_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<Sequence<std::string> > forwardable_args() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
@@ -598,6 +616,7 @@ namespace paludis
virtual bool can_be_negated() const;
virtual const std::string forwardable_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<Sequence<std::string> > forwardable_args() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
}