Commit 5c3574d5 authored by David Flynn's avatar David Flynn
Browse files

po-lite: upgrade OptionFunc to use function object rather than pointer

This enables use of lambda expressions and bound functions as
argument option helpers -- helpful when having to perform some
complex action on variables.

git-svn-id: 94298a81-5874-47c9-aab8-bfb24faeed7f
parent d96e8e84
......@@ -34,6 +34,7 @@
#include <functional>
#include <iostream>
#include <sstream>
#include <string>
......@@ -164,7 +165,7 @@ namespace df
typedef void (Func)(Options&, const std::string&, ErrorReporter&);
OptionFunc(const std::string& name, Options& parent_, Func *func_, const std::string& desc)
OptionFunc(const std::string& name, Options& parent_, std::function<Func> func_, const std::string& desc)
: OptionBase(name, desc), parent(parent_), func(func_)
......@@ -186,7 +187,7 @@ namespace df
Options& parent;
Func* func;
std::function<Func> func;
class OptionSpecific;
......@@ -249,7 +250,7 @@ namespace df
* handle evaluating the option's value.
operator()(const std::string& name, OptionFunc::Func *func, const std::string& desc = "")
operator()(const std::string& name, std::function<OptionFunc::Func> func, const std::string& desc = "")
parent.addOption(new OptionFunc(name, parent, func, desc));
return *this;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment