aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Stephen P. Bennett <spb@exherbo.org> 2006-01-19 22:25:04 +0000
committerAvatar Stephen P. Bennett <spb@exherbo.org> 2006-01-19 22:25:04 +0000
commite9b3450bf166c9e778c939345e71a392d14630ec (patch)
treeddc2493bc3ef6486268beb1fae4b24a2955cf70b
parent25aa93d22cdab199489d31b2b54574db7283cb5e (diff)
downloadpaludis-e9b3450bf166c9e778c939345e71a392d14630ec.tar.gz
paludis-e9b3450bf166c9e778c939345e71a392d14630ec.tar.xz
Use the new visitor templates for args/
-rw-r--r--paludis/args/alias_arg.hh8
-rw-r--r--paludis/args/args_option.hh29
-rw-r--r--paludis/args/args_visitor.hh7
-rw-r--r--paludis/args/switch_arg.hh8
4 files changed, 15 insertions, 37 deletions
diff --git a/paludis/args/alias_arg.hh b/paludis/args/alias_arg.hh
index e154667..59b9839 100644
--- a/paludis/args/alias_arg.hh
+++ b/paludis/args/alias_arg.hh
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ * Copyright (c) 2006 Stephen Bennett <spb@gentoo.org>
*
* 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
@@ -38,7 +39,7 @@ namespace paludis
*
* \ingroup Args
*/
- class AliasArg : public ArgsOption
+ class AliasArg : public ArgsOption, public Visitable<AliasArg, ArgsVisitorTypes>
{
private:
ArgsOption * const _other;
@@ -58,11 +59,6 @@ namespace paludis
{
_other->set_specified(value);
}
-
- void accept(ArgsVisitor * const v)
- {
- v->visit(this);
- }
};
}
}
diff --git a/paludis/args/args_option.hh b/paludis/args/args_option.hh
index 2812f7f..c292493 100644
--- a/paludis/args/args_option.hh
+++ b/paludis/args/args_option.hh
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ * Copyright (c) 2006 Stephen Bennett <spb@gentoo.org>
*
* 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
@@ -41,7 +42,7 @@ namespace paludis
*
* \ingroup Args
*/
- class ArgsOption
+ class ArgsOption : public virtual VisitableInterface<ArgsVisitorTypes>
{
friend class ArgsHandler;
@@ -121,11 +122,6 @@ namespace paludis
virtual ~ArgsOption()
{
}
-
- /**
- * Accept a visitor.
- */
- virtual void accept(ArgsVisitor * const) = 0;
};
/**
@@ -133,7 +129,7 @@ namespace paludis
*
* \ingroup Args
*/
- class StringArg : public ArgsOption
+ class StringArg : public ArgsOption, public Visitable<StringArg, ArgsVisitorTypes>
{
private:
std::string _argument;
@@ -155,11 +151,6 @@ namespace paludis
* Set the argument returned by argument().
*/
void set_argument(const std::string& arg) { _argument = arg; }
-
- void accept(ArgsVisitor * const v)
- {
- v->visit(this);
- }
};
/**
@@ -167,7 +158,7 @@ namespace paludis
*
* \ingroup Args
*/
- class IntegerArg : public ArgsOption
+ class IntegerArg : public ArgsOption, public Visitable<IntegerArg, ArgsVisitorTypes>
{
private:
int _argument;
@@ -187,11 +178,6 @@ namespace paludis
* Set the argument returned by argument().
*/
void set_argument(const int arg) { _argument = arg; }
-
- void accept(ArgsVisitor * const v)
- {
- v->visit(this);
- }
};
/**
@@ -199,7 +185,7 @@ namespace paludis
*
* \ingroup Args
*/
- class EnumArg : public ArgsOption
+ class EnumArg : public ArgsOption, public Visitable<EnumArg, ArgsVisitorTypes>
{
private:
const std::map<std::string, std::string> _allowed_args;
@@ -268,11 +254,6 @@ namespace paludis
* Returns an iterator pointing just beyond the last valid argument.
*/
AllowedArgIterator end_allowed_args() const { return _allowed_args.end(); }
-
- void accept(ArgsVisitor * const v)
- {
- v->visit(this);
- }
};
}
}
diff --git a/paludis/args/args_visitor.hh b/paludis/args/args_visitor.hh
index 8fd8e71..22f1e15 100644
--- a/paludis/args/args_visitor.hh
+++ b/paludis/args/args_visitor.hh
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ * Copyright (c) 2006 Stephen Bennett <spb@gentoo.org>
*
* 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
@@ -21,6 +22,7 @@
#define PALUDIS_GUARD_ARGS_ARGS_VISITOR_HH 1
#include <list>
+#include <paludis/visitor.hh>
/** \file
* Declaration for ArgsVisitor
@@ -39,10 +41,13 @@ namespace paludis
class IntegerArg;
class EnumArg;
+ typedef VisitorTypes<ArgsOption *, StringArg *, AliasArg *, SwitchArg *,
+ IntegerArg *, EnumArg *> ArgsVisitorTypes;
+
/**
* Visitor class. Processes command-line options as they are found.
*/
- class ArgsVisitor
+ class ArgsVisitor : public ArgsVisitorTypes::Visitor
{
private:
std::list<std::string>::iterator *_args_index;
diff --git a/paludis/args/switch_arg.hh b/paludis/args/switch_arg.hh
index fd85e06..33d8fa8 100644
--- a/paludis/args/switch_arg.hh
+++ b/paludis/args/switch_arg.hh
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ * Copyright (c) 2006 Stephen Bennett <spb@gentoo.org>
*
* 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
@@ -39,7 +40,7 @@ namespace paludis
*
* \ingroup Args
*/
- class SwitchArg : public ArgsOption
+ class SwitchArg : public ArgsOption, public Visitable<SwitchArg, ArgsVisitorTypes>
{
public:
/**
@@ -47,11 +48,6 @@ namespace paludis
*/
SwitchArg(ArgsGroup * const group, std::string long_name, char short_name,
std::string description);
-
- void accept(ArgsVisitor * const v)
- {
- v->visit(this);
- }
};
}
}