* Moving download variables into command_download.cc.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@902 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-05-18 14:24:57 +00:00
parent 9fe72cb3b5
commit 7d1bb524ba
14 changed files with 243 additions and 175 deletions
+2 -2
View File
@@ -3,10 +3,10 @@ noinst_LIBRARIES = libsub_utils.a
libsub_utils_a_SOURCES = \
command_slot.cc \
command_slot.h \
command_download_slot.cc \
command_download_slot.h \
command_variable.cc \
command_variable.h \
command_download_slot.cc \
command_download_slot.h \
directory.cc \
directory.h \
list_focus.h \
+19
View File
@@ -36,6 +36,7 @@
#include "config.h"
#include "core/download.h"
#include "utils/parse.h"
#include "command_download_slot.h"
@@ -140,4 +141,22 @@ CommandDownloadSlot::call_string(Variable* rawVariable, core::Download* download
// return variable->m_variable;
// }
torrent::Object
set_variable_d_fn_t::operator () (core::Download* download, const torrent::Object& arg1) {
if (m_firstKey == NULL)
download->bencode()->get_key(m_secondKey) = arg1;
else
download->bencode()->get_key(m_firstKey).get_key(m_secondKey) = arg1;
return torrent::Object();
}
torrent::Object
get_variable_d_fn_t::operator () (core::Download* download, const torrent::Object& arg1) {
if (m_firstKey == NULL)
return download->bencode()->get_key(m_secondKey);
else
return download->bencode()->get_key(m_firstKey).get_key(m_secondKey);
}
}
+27
View File
@@ -171,6 +171,33 @@ object_d_fn(Return (*func)(core::Download*)) {
// template <typename Func> object_value_fn1_t<Func>* object_value_fn(Func func) { return new object_value_fn1_t<Func>(func); }
// template <typename Func> object_string_fn1_t<Func>* object_string_fn(Func func) { return new object_string_fn1_t<Func>(func); }
class set_variable_d_fn_t : public rak::function_base2<torrent::Object, core::Download*, const torrent::Object&> {
public:
set_variable_d_fn_t(const char* firstKey, const char* secondKey) : m_firstKey(firstKey), m_secondKey(secondKey) {}
virtual torrent::Object operator () (core::Download* download, const torrent::Object& arg1);
private:
const char* m_firstKey;
const char* m_secondKey;
};
class get_variable_d_fn_t : public rak::function_base2<torrent::Object, core::Download*, const torrent::Object&> {
public:
get_variable_d_fn_t(const char* firstKey, const char* secondKey) : m_firstKey(firstKey), m_secondKey(secondKey) {}
virtual torrent::Object operator () (core::Download* download, const torrent::Object& arg1);
private:
const char* m_firstKey;
const char* m_secondKey;
};
inline set_variable_d_fn_t*
set_variable_d_fn(const char* firstKey, const char* secondKey) { return new set_variable_d_fn_t(firstKey, secondKey); }
inline get_variable_d_fn_t*
get_variable_d_fn(const char* firstKey, const char* secondKey) { return new get_variable_d_fn_t(firstKey, secondKey); }
}
#endif
-3
View File
@@ -40,9 +40,6 @@
namespace utils {
extern CommandVariable commandVariables[10];
extern CommandVariable* commandVariablesItr;
const torrent::Object
CommandVariable::set_bool(Variable* rawVariable, const torrent::Object& rawArgs) {
CommandVariable* variable = static_cast<CommandVariable*>(rawVariable);