mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-07 10:42:31 +00:00
* Added system.method.{insert,erase} commands that allows
user-specified commands. "system.method.insert=foo,print=Bar" git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1069 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+21
-1
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <vector>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/data/file_list_iterator.h>
|
||||
@@ -46,13 +47,18 @@
|
||||
namespace rpc {
|
||||
|
||||
CommandMap::~CommandMap() {
|
||||
std::vector<const char*> keys;
|
||||
|
||||
for (iterator itr = base_type::begin(), last = base_type::end(); itr != last; itr++) {
|
||||
if (!(itr->second.m_flags & flag_dont_delete))
|
||||
delete itr->second.m_variable;
|
||||
|
||||
if (itr->second.m_flags & flag_delete_key)
|
||||
; // Remove from map and then delte the key.
|
||||
keys.push_back(itr->first);
|
||||
}
|
||||
|
||||
for (std::vector<const char*>::iterator itr = keys.begin(), last = keys.end(); itr != last; itr++)
|
||||
delete [] *itr;
|
||||
}
|
||||
|
||||
CommandMap::iterator
|
||||
@@ -79,6 +85,20 @@ CommandMap::insert(key_type key, const command_map_data_type src) {
|
||||
itr->second.m_genericSlot = src.m_genericSlot;
|
||||
}
|
||||
|
||||
void
|
||||
CommandMap::erase(iterator itr) {
|
||||
if (itr == end())
|
||||
return;
|
||||
|
||||
if (!(itr->second.m_flags & flag_dont_delete))
|
||||
delete itr->second.m_variable;
|
||||
|
||||
const char* key = itr->second.m_flags & flag_delete_key ? itr->first : NULL;
|
||||
|
||||
base_type::erase(itr);
|
||||
delete [] key;
|
||||
}
|
||||
|
||||
const CommandMap::mapped_type
|
||||
CommandMap::call_command(key_type key, const mapped_type& arg, target_type target) {
|
||||
const_iterator itr = base_type::find(key);
|
||||
|
||||
Reference in New Issue
Block a user