* Cleanup of old Variable stuff.

* Fixed a bug that would cause ^O to make an extra call to
"set_directory" for the log, instead of "get_directory".


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@909 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-05-31 16:40:34 +00:00
parent 13dc0c942a
commit 8a1220fd5b
11 changed files with 48 additions and 756 deletions
-2
View File
@@ -18,8 +18,6 @@ libsub_utils_a_SOURCES = \
socket_fd.h \
variable.cc \
variable.h \
variable_generic.cc \
variable_generic.h \
variable_map.cc \
variable_map.h
+18 -39
View File
@@ -54,37 +54,18 @@ const torrent::Object
CommandDownloadSlot::call_list(Variable* rawVariable, core::Download* download, const torrent::Object& rawArgs) {
CommandDownloadSlot* command = static_cast<CommandDownloadSlot*>(rawVariable);
// const torrent::Object& arg = to_single_argument(rawArgs);
// switch (arg.type()) {
// case torrent::Object::TYPE_VALUE:
// variable->m_variable = arg.as_value() ? (int64_t)1 : (int64_t)0;
// break;
// case torrent::Object::TYPE_STRING:
// // Move the checks into some is_true, is_false think in Variable.
// if (arg.as_string() == "yes" || arg.as_string() == "true")
// variable->m_variable = (int64_t)1;
// else if (arg.as_string() == "no" || arg.as_string() == "false")
// variable->m_variable = (int64_t)0;
// else
// throw torrent::input_error("String does not parse as a boolean.");
// break;
// default:
// throw torrent::input_error("Input is not a boolean.");
// }
// return variable->m_variable;
switch (rawArgs.type()) {
// case torrent::Object::TYPE_STRING:
// break;
case torrent::Object::TYPE_LIST:
return command->m_slot(download, rawArgs);
case torrent::Object::TYPE_VALUE:
case torrent::Object::TYPE_STRING:
{
torrent::Object tmpList(torrent::Object::TYPE_LIST);
tmpList.as_list().push_back(rawArgs);
return command->m_slot(download, tmpList);
}
default:
throw torrent::input_error("Not a list.");
}
@@ -122,25 +103,23 @@ CommandDownloadSlot::call_string(Variable* rawVariable, core::Download* download
const torrent::Object& arg = to_single_argument(rawArgs);
switch (arg.type()) {
// case torrent::Object::TYPE_VALUE:
// break;
case torrent::Object::TYPE_STRING:
return command->m_slot(download, arg);
break;
case torrent::Object::TYPE_NONE:
throw torrent::input_error("CDS: void.");
case torrent::Object::TYPE_VALUE:
throw torrent::input_error("CDS: value.");
case torrent::Object::TYPE_LIST:
throw torrent::input_error("CDS: list.");
default:
throw torrent::input_error("Not a string.");
}
}
// const torrent::Object&
// CommandDownloadSlot::get_generic(Variable* rawVariable, const torrent::Object& args) {
// CommandVariable* variable = static_cast<CommandVariable*>(rawVariable);
// return variable->m_variable;
// }
torrent::Object
set_variable_d_fn_t::operator () (core::Download* download, const torrent::Object& arg1) {
if (m_firstKey == NULL)
+9 -28
View File
@@ -53,37 +53,18 @@ const torrent::Object
CommandSlot::call_list(Variable* rawVariable, const torrent::Object& rawArgs) {
CommandSlot* command = static_cast<CommandSlot*>(rawVariable);
// const torrent::Object& arg = to_single_argument(rawArgs);
// switch (arg.type()) {
// case torrent::Object::TYPE_VALUE:
// variable->m_variable = arg.as_value() ? (int64_t)1 : (int64_t)0;
// break;
// case torrent::Object::TYPE_STRING:
// // Move the checks into some is_true, is_false think in Variable.
// if (arg.as_string() == "yes" || arg.as_string() == "true")
// variable->m_variable = (int64_t)1;
// else if (arg.as_string() == "no" || arg.as_string() == "false")
// variable->m_variable = (int64_t)0;
// else
// throw torrent::input_error("String does not parse as a boolean.");
// break;
// default:
// throw torrent::input_error("Input is not a boolean.");
// }
// return variable->m_variable;
switch (rawArgs.type()) {
// case torrent::Object::TYPE_STRING:
// break;
case torrent::Object::TYPE_LIST:
return command->m_slot(rawArgs);
case torrent::Object::TYPE_VALUE:
case torrent::Object::TYPE_STRING:
{
torrent::Object tmpList(torrent::Object::TYPE_LIST);
tmpList.as_list().push_back(rawArgs);
return command->m_slot(tmpList);
}
default:
throw torrent::input_error("Not a list.");
}
-307
View File
@@ -1,307 +0,0 @@
// rTorrent - BitTorrent client
// Copyright (C) 2006, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include <stdlib.h>
#include "parse.h"
#include "variable_generic.h"
namespace utils {
const torrent::Object& VariableAny::get() { return m_variable; }
void VariableAny::set(const torrent::Object& arg) { m_variable = arg; }
void
VariableValue::set(const torrent::Object& arg) {
int64_t value;
switch (arg.type()) {
case torrent::Object::TYPE_NONE:
m_variable = (int64_t)0;
break;
case torrent::Object::TYPE_VALUE:
m_variable = arg;
break;
case torrent::Object::TYPE_STRING:
string_to_value_unit(arg.as_string().c_str(), &value, 0, 1);
m_variable = value;
break;
default:
throw torrent::input_error("VariableValue unsupported type restriction.");
}
}
void
VariableBool::set(const torrent::Object& arg) {
switch (arg.type()) {
case torrent::Object::TYPE_VALUE:
m_variable = arg.as_value() ? (int64_t)1 : (int64_t)0;
break;
case torrent::Object::TYPE_STRING:
// Move the checks into some is_true, is_false think in Variable.
if (arg.as_string() == "yes" || arg.as_string() == "true")
m_variable = (int64_t)1;
else if (arg.as_string() == "no" || arg.as_string() == "false")
m_variable = (int64_t)0;
else
throw torrent::input_error("String does not parse as a boolean.");
break;
default:
throw torrent::input_error("Input is not a boolean.");
}
}
const torrent::Object&
VariableObject::get_d(core::Download* download) {
if (m_root.empty())
return download->bencode()->get_key(m_key);
else
return download->bencode()->get_key(m_root).get_key(m_key);
}
void
VariableObject::set_d(core::Download* download, const torrent::Object& arg) {
// Consider removing if TYPE_NONE.
torrent::Object* root;
if (m_root.empty())
root = download->bencode();
else
root = &download->bencode()->get_key(m_root);
switch (m_type) {
case torrent::Object::TYPE_NONE:
root->insert_key(m_key, arg);
break;
case torrent::Object::TYPE_STRING:
if (arg.is_string())
root->insert_key(m_key, arg);
else
throw torrent::input_error("VariableObject could not convert to string.");
break;
case torrent::Object::TYPE_VALUE:
if (arg.is_value())
root->insert_key(m_key, arg);
else
throw torrent::input_error("VariableObject could not convert to value.");
break;
default:
throw torrent::input_error("VariableObject unsupported type restriction.");
}
}
const torrent::Object& VariableDownload::get() { return m_global->get(); }
const torrent::Object& VariableDownload::get_d(core::Download* download) { return m_download->get_d(download); }
void VariableDownload::set(const torrent::Object& arg) { m_global->set(arg); }
void VariableDownload::set_d(core::Download* download, const torrent::Object& arg) { m_download->set_d(download, arg); }
//
// New and prettified.
//
const torrent::Object&
VariableVoidSlot::get() {
return m_cache;
}
void
VariableVoidSlot::set(const torrent::Object& arg) {
if (!m_slotSet.is_valid())
return;
m_slotSet();
}
const torrent::Object&
VariableValueSlot::get() {
if (!m_slotGet.is_valid())
return m_cache = torrent::Object();
m_cache = m_slotGet() / m_unit;
return m_cache;
}
void
VariableValueSlot::set(const torrent::Object& rawArg) {
if (!m_slotSet.is_valid())
return;
const torrent::Object* arg;
if (rawArg.type() == torrent::Object::TYPE_LIST && rawArg.as_list().size() == 1)
arg = &rawArg.as_list().front();
else
arg = &rawArg;
value_type value;
switch (arg->type()) {
case torrent::Object::TYPE_STRING:
string_to_value_unit(arg->as_string().c_str(), &value, m_base, m_unit);
// Check if we hit the end of the input.
m_slotSet(value);
break;
case torrent::Object::TYPE_VALUE:
m_slotSet(arg->as_value());
break;
default:
throw torrent::input_error("Not a value");
}
}
const torrent::Object&
VariableDownloadValueSlot::get_d(core::Download* download) {
// Should clear the cache.
if (!m_slotGetDownload.is_valid())
return m_cache = torrent::Object();
return m_cache = m_slotGetDownload(download) / m_unit;
}
void
VariableDownloadValueSlot::set_d(core::Download* download, const torrent::Object& arg) {
if (!m_slotSetDownload.is_valid())
return;
value_type value;
switch (arg.type()) {
case torrent::Object::TYPE_STRING:
string_to_value_unit(arg.as_string().c_str(), &value, m_base, m_unit);
// Check if we hit the end of the input.
m_slotSetDownload(download, value);
break;
case torrent::Object::TYPE_VALUE:
m_slotSetDownload(download, arg.as_value());
break;
default:
throw torrent::input_error("Not a value");
}
}
const torrent::Object&
VariableStringSlot::get() {
if (!m_slotGet.is_valid())
return m_cache = torrent::Object();
return m_cache = m_slotGet();
}
void
VariableStringSlot::set(const torrent::Object& arg) {
if (!m_slotSet.is_valid())
return;
switch (arg.type()) {
case torrent::Object::TYPE_STRING:
m_slotSet(arg.as_string());
break;
case torrent::Object::TYPE_NONE:
m_slotSet(std::string());
break;
case torrent::Object::TYPE_LIST:
m_slotSet(convert_list_to_string(arg));
break;
default:
throw torrent::input_error("Not a string.");
}
}
const torrent::Object&
VariableDownloadStringSlot::get_d(core::Download* download) {
// Should clear the cache.
if (!m_slotGetDownload.is_valid())
return m_cache = torrent::Object();
return m_cache = m_slotGetDownload(download);
}
void
VariableDownloadStringSlot::set_d(core::Download* download, const torrent::Object& arg) {
if (!m_slotSetDownload.is_valid())
return;
switch (arg.type()) {
case torrent::Object::TYPE_STRING:
m_slotSetDownload(download, arg.as_string());
break;
case torrent::Object::TYPE_NONE:
m_slotSetDownload(download, std::string());
break;
default:
throw torrent::input_error("Not a string.");
}
}
void
VariableDownloadListSlot::set_d(core::Download* download, const torrent::Object& arg) {
switch (arg.type()) {
// case torrent::Object::TYPE_STRING:
// break;
case torrent::Object::TYPE_LIST:
m_slotSet(download, arg.as_list());
break;
default:
throw torrent::input_error("Not a list.");
}
}
}
-315
View File
@@ -1,315 +0,0 @@
// rTorrent - BitTorrent client
// Copyright (C) 2006, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
// Parts of this seems ugly in an attempt to avoid copying
// data. Propably need to rewrite torrent::Object.
#ifndef RTORRENT_UTILS_VARIABLE_GENERIC_H
#define RTORRENT_UTILS_VARIABLE_GENERIC_H
#include <cstdio>
#include <string>
#include <limits>
#include <inttypes.h>
#include <rak/functional_fun.h>
#include <torrent/object.h>
#include <torrent/exceptions.h>
#include "variable.h"
#include "core/download.h"
namespace utils {
class VariableAny : public Variable {
public:
VariableAny(const torrent::Object& v = torrent::Object()) :
m_variable(v) {}
virtual const torrent::Object& get();
virtual void set(const torrent::Object& arg);
protected:
torrent::Object m_variable;
};
class VariableValue : public VariableAny {
public:
VariableValue(int64_t v) { m_variable = v; }
virtual void set(const torrent::Object& arg);
};
class VariableBool : public VariableAny {
public:
VariableBool(bool state = false) { m_variable = state ? (int64_t)1 : (int64_t)0; }
virtual void set(const torrent::Object& arg);
};
class VariableDownload : public Variable {
public:
VariableDownload(Variable* varGlobal, Variable* varDownload) :
m_global(varGlobal), m_download(varDownload) {}
virtual const torrent::Object& get();
virtual void set(const torrent::Object& arg);
virtual const torrent::Object& get_d(core::Download* download);
virtual void set_d(core::Download* download, const torrent::Object& arg);
protected:
Variable* m_global;
Variable* m_download;
};
class VariableObject : public Variable {
public:
typedef torrent::Object::type_type Type;
VariableObject(const std::string& root, const std::string& key, Type t = torrent::Object::TYPE_NONE) :
m_root(root), m_key(key), m_type(t) {}
virtual const torrent::Object& get_d(core::Download* download);
virtual void set_d(core::Download* download, const torrent::Object& arg);
private:
std::string m_root;
std::string m_key;
Type m_type;
};
//
// New and pretty.
//
class VariableVoidSlot : public Variable {
public:
typedef rak::function0<void> slot_set_type;
VariableVoidSlot(slot_set_type::base_type* slotSet) {
m_slotSet.set(slotSet);
}
virtual const torrent::Object& get();
virtual void set(const torrent::Object& arg);
private:
slot_set_type m_slotSet;
// Store the cache here to avoid unnessesary copying and such. This
// should not result in any unresonable memory usage since few
// strings will be very large.
torrent::Object m_cache;
};
class VariableValueSlot : public Variable {
public:
typedef rak::function0<value_type> slot_get_type;
typedef rak::function1<void, value_type> slot_set_type;
typedef std::pair<value_type, value_type> range_type;
template <typename SlotGet, typename SlotSet>
VariableValueSlot(SlotGet* slotGet, SlotSet* slotSet, unsigned int base = 0, unsigned int unit = 1,
range_type range = range_type(std::numeric_limits<value_type>::min(), std::numeric_limits<value_type>::max())) :
m_base(base),
m_unit(unit),
m_range(range) {
m_slotGet.set(rak::convert_fn<value_type>(slotGet));
m_slotSet.set(rak::convert_fn<void, value_type>(slotSet));
}
template <typename SlotGet>
VariableValueSlot(SlotGet* slotGet, void* slotSet, unsigned int base = 0, unsigned int unit = 1,
range_type range = range_type(std::numeric_limits<value_type>::min(), std::numeric_limits<value_type>::max())) :
m_base(base),
m_unit(unit),
m_range(range) {
m_slotGet.set(rak::convert_fn<value_type>(slotGet));
m_slotSet.set(NULL);
}
virtual const torrent::Object& get();
virtual void set(const torrent::Object& arg);
private:
slot_get_type m_slotGet;
slot_set_type m_slotSet;
unsigned int m_base;
unsigned int m_unit;
range_type m_range;
// Store the cache here to avoid unnessesary copying and such. This
// should not result in any unresonable memory usage since few
// strings will be very large.
torrent::Object m_cache;
};
class VariableDownloadValueSlot : public Variable {
public:
typedef rak::function1<value_type, core::Download*> slot_get_d_type;
typedef rak::function2<void, core::Download*, value_type> slot_set_d_type;
typedef std::pair<value_type, value_type> range_type;
template <typename SlotGetDownload, typename SlotSetDownload>
VariableDownloadValueSlot(SlotGetDownload* slotGetDownload, SlotSetDownload* slotSetDownload,
unsigned int base = 0, unsigned int unit = 1,
range_type range = range_type(std::numeric_limits<value_type>::min(), std::numeric_limits<value_type>::max())) :
m_base(base),
m_unit(unit),
m_range(range) {
m_slotGetDownload.set(rak::convert_fn<value_type, core::Download*>(slotGetDownload));
m_slotSetDownload.set(rak::convert_fn<void, core::Download*, value_type>(slotSetDownload));
}
template <typename SlotGetDownload>
VariableDownloadValueSlot(SlotGetDownload* slotGetDownload, void* slotSetDownload,
unsigned int base = 0, unsigned int unit = 1,
range_type range = range_type(std::numeric_limits<value_type>::min(), std::numeric_limits<value_type>::max())) :
m_base(base),
m_unit(unit),
m_range(range) {
m_slotGetDownload.set(rak::convert_fn<value_type, core::Download*>(slotGetDownload));
m_slotSetDownload.set(NULL);
}
virtual const torrent::Object& get_d(core::Download* download);
virtual void set_d(core::Download* download, const torrent::Object& arg);
private:
slot_get_d_type m_slotGetDownload;
slot_set_d_type m_slotSetDownload;
unsigned int m_base;
unsigned int m_unit;
range_type m_range;
// Store the cache here to avoid unnessesary copying and such. This
// should not result in any unresonable memory usage since few
// strings will be very large.
torrent::Object m_cache;
};
class VariableStringSlot : public Variable {
public:
typedef rak::function0<string_type> slot_get_type;
typedef rak::function1<void, const string_type&> slot_set_type;
template <typename SlotSet>
VariableStringSlot(void* slotGet, SlotSet* slotSet) {
m_slotGet.set(NULL);
m_slotSet.set(rak::convert_fn<void, const string_type&>(slotSet));
}
template <typename SlotGet, typename SlotSet>
VariableStringSlot(SlotGet* slotGet, SlotSet* slotSet) {
m_slotGet.set(rak::convert_fn<string_type>(slotGet));
m_slotSet.set(rak::convert_fn<void, const string_type&>(slotSet));
}
virtual const torrent::Object& get();
virtual void set(const torrent::Object& arg);
private:
slot_get_type m_slotGet;
slot_set_type m_slotSet;
// Store the cache here to avoid unnessesary copying and such. This
// should not result in any unresonable memory usage since few
// strings will be very large.
torrent::Object m_cache;
};
class VariableDownloadStringSlot : public Variable {
public:
typedef rak::function1<string_type, core::Download*> slot_get_d_type;
typedef rak::function2<void, core::Download*, const string_type&> slot_set_d_type;
template <typename SlotSetDownload>
VariableDownloadStringSlot(void* slotGetDownload, SlotSetDownload* slotSetDownload) {
m_slotGetDownload.set(NULL);
m_slotSetDownload.set(rak::convert_fn<void, core::Download*, const string_type&>(slotSetDownload));
}
template <typename SlotGetDownload>
VariableDownloadStringSlot(SlotGetDownload* slotGetDownload, void* slotSetDownload) {
m_slotGetDownload.set(rak::convert_fn<string_type, core::Download*>(slotGetDownload));
m_slotSetDownload.set(NULL);
}
template <typename SlotGetDownload, typename SlotSetDownload>
VariableDownloadStringSlot(SlotGetDownload* slotGetDownload, SlotSetDownload* slotSetDownload) {
m_slotGetDownload.set(rak::convert_fn<string_type, core::Download*>(slotGetDownload));
m_slotSetDownload.set(rak::convert_fn<void, core::Download*, const string_type&>(slotSetDownload));
}
virtual const torrent::Object& get_d(core::Download* download);
virtual void set_d(core::Download* download, const torrent::Object& arg);
private:
slot_get_d_type m_slotGetDownload;
slot_set_d_type m_slotSetDownload;
// Store the cache here to avoid unnessesary copying and such. This
// should not result in any unresonable memory usage since few
// strings will be very large.
torrent::Object m_cache;
};
class VariableDownloadListSlot : public Variable {
public:
typedef rak::function2<void, core::Download*, const list_type&> slot_set_type;
template <typename SlotSet>
VariableDownloadListSlot(SlotSet* slotSet) {
m_slotSet.set(slotSet);
}
virtual void set_d(core::Download* download, const torrent::Object& arg);
private:
slot_set_type m_slotSet;
};
}
#endif
+1 -39
View File
@@ -83,44 +83,6 @@ VariableMap::insert(key_type key, const variable_map_data_type src) {
src.m_flags | flag_dont_delete, src.m_parm, src.m_doc)));
}
const VariableMap::mapped_type
VariableMap::get_d(core::Download* download, key_type key) const {
const_iterator itr = base_type::find(key);
if (itr == base_type::end())
throw torrent::input_error("Variable \"" + std::string(key) + "\" does not exist.");
if (itr->second.m_downloadSlot != NULL)
return itr->second.m_downloadSlot(itr->second.m_variable, download, torrent::Object());
if (itr->second.m_genericSlot != NULL)
return itr->second.m_genericSlot(itr->second.m_variable, torrent::Object());
return itr->second.m_variable->get_d(download);
}
void
VariableMap::set_d(core::Download* download, key_type key, const mapped_type& arg) {
iterator itr = base_type::find(key);
// Later, allow the user to create new variables. Have a slot to
// register that thing.
if (itr == base_type::end())
throw torrent::input_error("Variable \"" + std::string(key) + "\" does not exist.");
if (itr->second.m_downloadSlot != NULL) {
itr->second.m_downloadSlot(itr->second.m_variable, download, arg);
return;
}
if (itr->second.m_genericSlot != NULL) {
itr->second.m_genericSlot(itr->second.m_variable, arg);
return;
}
itr->second.m_variable->set_d(download, arg);
}
struct variable_map_is_space : std::unary_function<char, bool> {
bool operator () (char c) const {
return std::isspace(c);
@@ -191,7 +153,7 @@ VariableMap::process_d_single(core::Download* download, const char* first, const
mapped_type args;
first = parse_whole_list(first + 1, last, &args);
set_d(download, key.c_str(), args);
call_command_d(key.c_str(), download, args);
return first;
}
+7 -10
View File
@@ -118,16 +118,6 @@ public:
void insert(key_type key, const variable_map_data_type src);
// Consider uninlining the helper functions.
const mapped_type get_d(core::Download* download, key_type key) const;
const std::string get_d_string(core::Download* download, key_type key) const { return get_d(download, key).as_string(); }
mapped_value_type get_d_value(core::Download* download, key_type key) const { return get_d(download, key).as_value(); }
void set_d(core::Download* download, key_type key, const mapped_type& arg);
void set_d_string(core::Download* download, key_type key, const std::string& arg) { set_d(download, key, mapped_type(arg)); }
void set_d_std_string(core::Download* download, const std::string& key, const std::string& arg) { set_d(download, key.c_str(), mapped_type(arg)); }
void set_d_value(core::Download* download, key_type key, mapped_value_type arg) { set_d(download, key, mapped_type(arg)); }
const char* process_single(const char* first);
const char* process_single(const char* first, const char* last);
void process_std_single(const std::string& cmd) { process_single(cmd.c_str(), cmd.c_str() + cmd.size()); }
@@ -151,6 +141,13 @@ public:
void call_command_set_std_string(const std::string& key, const std::string& arg) { call_command(key.c_str(), mapped_type(arg)); }
const mapped_type call_command_d(key_type key, core::Download* download, const mapped_type& arg);
const mapped_type call_command_d_void(key_type key, core::Download* download) { return call_command_d(key, download, torrent::Object()); }
const std::string call_command_d_string(key_type key, core::Download* download) { return call_command_d(key, download, torrent::Object()).as_string(); }
mapped_value_type call_command_d_value(key_type key, core::Download* download) { return call_command_d(key, download, torrent::Object()).as_value(); }
void call_command_d_set_value(key_type key, core::Download* download, mapped_value_type arg) { call_command_d(key, download, mapped_type(arg)); }
void call_command_d_set_string(key_type key, core::Download* download, const std::string& arg) { call_command_d(key, download, mapped_type(arg)); }
void call_command_d_set_std_string(const std::string& key, core::Download* download, const std::string& arg) { call_command_d(key.c_str(), download, mapped_type(arg)); }
private:
VariableMap(const VariableMap&);