mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-07 10:42:31 +00:00
* Removed old non-download set/get functions from VariableMap.
* Added forgotten command_download.cc file. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@900 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -72,19 +72,6 @@ VariableMap::insert(key_type key, Variable* variable, generic_slot genericSlot,
|
||||
base_type::insert(itr, value_type(key, variable_map_data_type(variable, genericSlot, NULL, flags, parm, doc)));
|
||||
}
|
||||
|
||||
const VariableMap::mapped_type
|
||||
VariableMap::get(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_genericSlot != NULL)
|
||||
return itr->second.m_genericSlot(itr->second.m_variable, torrent::Object());
|
||||
|
||||
return itr->second.m_variable->get();
|
||||
}
|
||||
|
||||
const VariableMap::mapped_type
|
||||
VariableMap::get_d(core::Download* download, key_type key) const {
|
||||
const_iterator itr = base_type::find(key);
|
||||
@@ -101,23 +88,6 @@ VariableMap::get_d(core::Download* download, key_type key) const {
|
||||
return itr->second.m_variable->get_d(download);
|
||||
}
|
||||
|
||||
void
|
||||
VariableMap::set(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_genericSlot != NULL) {
|
||||
itr->second.m_genericSlot(itr->second.m_variable, arg);
|
||||
return;
|
||||
}
|
||||
|
||||
itr->second.m_variable->set(arg);
|
||||
}
|
||||
|
||||
void
|
||||
VariableMap::set_d(core::Download* download, key_type key, const mapped_type& arg) {
|
||||
iterator itr = base_type::find(key);
|
||||
@@ -188,7 +158,7 @@ VariableMap::process_single(const char* first, const char* last) {
|
||||
mapped_type args;
|
||||
first = parse_whole_list(first + 1, last, &args);
|
||||
|
||||
set(key.c_str(), args);
|
||||
call_command(key.c_str(), args);
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
@@ -116,28 +116,15 @@ public:
|
||||
const char* parm = "", const char* doc = "");
|
||||
|
||||
// Consider uninlining the helper functions.
|
||||
|
||||
const mapped_type get(key_type key) const;
|
||||
const mapped_type get_d(core::Download* download, key_type key) const;
|
||||
|
||||
const std::string get_string(key_type key) const { return get(key).as_string(); }
|
||||
const std::string get_d_string(core::Download* download, key_type key) const { return get_d(download, key).as_string(); }
|
||||
|
||||
mapped_value_type get_value(key_type key) const { return get(key).as_value(); }
|
||||
mapped_value_type get_d_value(core::Download* download, key_type key) const { return get_d(download, key).as_value(); }
|
||||
|
||||
void set(key_type key, const mapped_type& arg);
|
||||
void set_d(core::Download* download, key_type key, const mapped_type& arg);
|
||||
|
||||
void set_string(key_type key, const std::string& arg) { set(key, 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_value(key_type key, mapped_value_type arg) { set(key, mapped_type(arg)); }
|
||||
void set_d_value(core::Download* download, key_type key, mapped_value_type arg) { set_d(download, key, mapped_type(arg)); }
|
||||
|
||||
void set_std_string(const std::string& key, const std::string& arg) { set(key.c_str(), 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()); }
|
||||
@@ -153,6 +140,12 @@ public:
|
||||
// The new API, which is atm just a wrapper over the old and
|
||||
// requires seperate calls to get and set. These will be merged.
|
||||
const mapped_type call_command(key_type key, const mapped_type& arg);
|
||||
const mapped_type call_command_void(key_type key) { return call_command(key, torrent::Object()); }
|
||||
const std::string call_command_string(key_type key) { return call_command(key, torrent::Object()).as_string(); }
|
||||
mapped_value_type call_command_value(key_type key) { return call_command(key, torrent::Object()).as_value(); }
|
||||
|
||||
void call_command_set_string(key_type key, const std::string& arg) { call_command(key, mapped_type(arg)); }
|
||||
void call_command_set_std_string(const std::string& key, const std::string& arg) { call_command(key.c_str(), mapped_type(arg)); }
|
||||
|
||||
private:
|
||||
VariableMap(const VariableMap&);
|
||||
|
||||
Reference in New Issue
Block a user