* Removed the Object ctor taking an Object::type_type.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1026 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2008-01-06 15:41:30 +00:00
parent 77a7d13b39
commit 87e02737ce
13 changed files with 35 additions and 31 deletions
+8 -8
View File
@@ -257,11 +257,11 @@ f_multicall(core::Download* download, const torrent::Object& rawArgs) {
// Add some pre-parsing of the commands, so we don't spend time
// parsing and searching command map for every single call.
torrent::Object resultRaw(torrent::Object::TYPE_LIST);
torrent::Object resultRaw = torrent::Object::create_list();
torrent::Object::list_type& result = resultRaw.as_list();
for (torrent::FileList::const_iterator itr = download->file_list()->begin(), last = download->file_list()->end(); itr != last; itr++) {
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object(torrent::Object::TYPE_LIST))->as_list();
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object::create_list())->as_list();
for (torrent::Object::list_const_iterator cItr = ++args.begin(), cLast = args.end(); cItr != args.end(); cItr++) {
const std::string& cmd = cItr->as_string();
@@ -284,11 +284,11 @@ t_multicall(core::Download* download, const torrent::Object& rawArgs) {
// Add some pre-parsing of the commands, so we don't spend time
// parsing and searching command map for every single call.
torrent::Object resultRaw(torrent::Object::TYPE_LIST);
torrent::Object resultRaw = torrent::Object::create_list();
torrent::Object::list_type& result = resultRaw.as_list();
for (int itr = 0, last = download->tracker_list()->size(); itr != last; itr++) {
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object(torrent::Object::TYPE_LIST))->as_list();
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object::create_list())->as_list();
for (torrent::Object::list_const_iterator cItr = ++args.begin(), cLast = args.end(); cItr != args.end(); cItr++) {
const std::string& cmd = cItr->as_string();
@@ -313,11 +313,11 @@ p_multicall(core::Download* download, const torrent::Object& rawArgs) {
// Add some pre-parsing of the commands, so we don't spend time
// parsing and searching command map for every single call.
torrent::Object resultRaw(torrent::Object::TYPE_LIST);
torrent::Object resultRaw = torrent::Object::create_list();
torrent::Object::list_type& result = resultRaw.as_list();
for (torrent::ConnectionList::const_iterator itr = download->connection_list()->begin(), last = download->connection_list()->end(); itr != last; itr++) {
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object(torrent::Object::TYPE_LIST))->as_list();
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object::create_list())->as_list();
for (torrent::Object::list_const_iterator cItr = ++args.begin(), cLast = args.end(); cItr != args.end(); cItr++) {
const std::string& cmd = cItr->as_string();
@@ -462,8 +462,8 @@ initialize_command_download() {
//
// 'loaded_file' is the file this instance of the torrent was loaded
// from, and should not be changed.
ADD_CD_VARIABLE_STRING("tied_to_file", "rtorrent", "tied_to_file");
ADD_CD_VARIABLE_STRING("loaded_file", "rtorrent", "loaded_file");
ADD_CD_VARIABLE_STRING_PUBLIC("tied_to_file", "rtorrent", "tied_to_file");
ADD_CD_VARIABLE_STRING ("loaded_file", "rtorrent", "loaded_file");
// The "state_changed" variable is required to be a valid unix time
// value, it indicates the last time the torrent changed its state,
+3 -3
View File
@@ -274,7 +274,7 @@ apply_download_list(const torrent::Object& rawArgs) {
if (viewItr == viewManager->end())
throw torrent::input_error("Could not find view.");
torrent::Object result(torrent::Object::TYPE_LIST);
torrent::Object result = torrent::Object::create_list();
torrent::Object::list_type& resultList = result.as_list();
for (core::View::const_iterator itr = (*viewItr)->begin_visible(), last = (*viewItr)->end_visible(); itr != last; itr++) {
@@ -317,11 +317,11 @@ d_multicall(const torrent::Object& rawArgs) {
// Add some pre-parsing of the commands, so we don't spend time
// parsing and searching command map for every single call.
torrent::Object resultRaw(torrent::Object::TYPE_LIST);
torrent::Object resultRaw = torrent::Object::create_list();
torrent::Object::list_type& result = resultRaw.as_list();
for (core::View::const_iterator vItr = (*viewItr)->begin_visible(), vLast = (*viewItr)->end_visible(); vItr != vLast; vItr++) {
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object(torrent::Object::TYPE_LIST))->as_list();
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object::create_list())->as_list();
for (torrent::Object::list_const_iterator cItr = ++args.begin(), cLast = args.end(); cItr != args.end(); cItr++) {
const std::string& cmd = cItr->as_string();
+1 -1
View File
@@ -72,7 +72,7 @@ apply_f_path(torrent::File* file) {
torrent::Object
apply_f_path_components(torrent::File* file) {
torrent::Object resultRaw(torrent::Object::TYPE_LIST);
torrent::Object resultRaw = torrent::Object::create_list();
torrent::Object::list_type& result = resultRaw.as_list();
for (torrent::Path::const_iterator itr = file->path()->begin(), last = file->path()->end(); itr != last; itr++)
+4 -1
View File
@@ -98,7 +98,7 @@ apply_view_sort(const torrent::Object& rawArgs) {
torrent::Object
apply_view_list(const torrent::Object&) {
torrent::Object rawResult(torrent::Object::TYPE_LIST);
torrent::Object rawResult = torrent::Object::create_list();
torrent::Object::list_type& result = rawResult.as_list();
for (core::ViewManager::const_iterator itr = control->view_manager()->begin(), last = control->view_manager()->end(); itr != last; itr++)
@@ -227,6 +227,9 @@ apply_if(rpc::target_type target, const torrent::Object& rawArgs) {
case torrent::Object::TYPE_VALUE:
result = conditional->as_value();
break;
case torrent::Object::TYPE_NONE:
result = false;
break;
default:
throw torrent::input_error("Type not supported by 'if'.");
};
+3 -3
View File
@@ -67,7 +67,7 @@ DhtManager::load_dht_cache() {
if (m_start == dht_disable || !control->core()->download_store()->is_enabled())
return;
torrent::Object cache(torrent::Object::TYPE_MAP);
torrent::Object cache = torrent::Object::create_map();
std::fstream cache_file((control->core()->download_store()->path() + "rtorrent.dht_cache").c_str(), std::ios::in | std::ios::binary);
if (cache_file.is_open()) {
@@ -147,7 +147,7 @@ DhtManager::save_dht_cache() {
if (!cache_file.is_open())
return;
torrent::Object cache(torrent::Object::TYPE_MAP);
torrent::Object cache = torrent::Object::create_map();
cache_file << *torrent::dht_manager()->store_cache(&cache);
if (!cache_file.good())
@@ -279,7 +279,7 @@ DhtManager::log_statistics(bool force) {
torrent::Object
DhtManager::dht_statistics() {
torrent::Object dhtStats(torrent::Object::TYPE_MAP);
torrent::Object dhtStats = torrent::Object::create_map();
dhtStats.insert_key("dht", dht_settings[m_start]);
dhtStats.insert_key("active", torrent::dht_manager()->is_active());
+2 -3
View File
@@ -136,9 +136,6 @@ DownloadFactory::receive_load() {
} else {
std::fstream* stream = new std::fstream(rak::path_expand(m_uri).c_str(), std::ios::in | std::ios::binary);
m_stream = stream;
// Since FileStatusCache checks file stats, it will automatically
// cull away invalid paths.
m_isFile = true;
if (!stream->is_open())
@@ -332,7 +329,9 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre
rtorrent->insert_preserve_value("complete", 0);
rtorrent->insert_preserve_value("hashing", Download::variable_hashing_stopped);
rtorrent->insert_preserve_cstr("tied_to_file", "");
rtorrent->insert_key("loaded_file", m_isFile ? m_uri : std::string());
if (rtorrent->has_key_value("priority"))
rpc::call_command("d.set_priority", rtorrent->get_key_value("priority") % 4, rpc::make_target(download));
+1 -1
View File
@@ -405,7 +405,7 @@ Manager::try_create_download(const std::string& uri, int flags, const command_li
// If the path was attempted loaded before, skip it.
if (!(flags & create_raw_data) &&
!is_network_uri(uri) &&
!m_fileStatusCache->insert(uri, 0))
!file_status_cache()->insert(uri, 0))
return;
// Adding download.
+4 -4
View File
@@ -69,7 +69,7 @@ CommandSlot<Target>::call_list(Command* rawCommand, Target target, const torrent
case torrent::Object::TYPE_STRING:
case torrent::Object::TYPE_NONE:
{
torrent::Object tmpList(torrent::Object::TYPE_LIST);
torrent::Object tmpList = torrent::Object::create_list();
tmpList.as_list().push_back(rawArgs);
return command->m_slot(target, tmpList);
@@ -91,7 +91,7 @@ CommandSlot<void>::call_list(Command* rawCommand, const torrent::Object& rawArgs
case torrent::Object::TYPE_STRING:
case torrent::Object::TYPE_NONE:
{
torrent::Object tmpList(torrent::Object::TYPE_LIST);
torrent::Object tmpList = torrent::Object::create_list();
tmpList.as_list().push_back(rawArgs);
return command->m_slot(tmpList);
@@ -114,7 +114,7 @@ CommandSlot<Target>::call_value_base(Command* rawCommand, Target target, const t
case torrent::Object::TYPE_STRING:
{
torrent::Object argValue(torrent::Object::TYPE_VALUE);
torrent::Object argValue = torrent::Object::create_value();
if (!parse_whole_value_nothrow(arg.as_string().c_str(), &argValue.as_value(), base, unit))
throw torrent::input_error("Not a value.");
@@ -139,7 +139,7 @@ CommandSlot<void>::call_value_base(Command* rawCommand, const torrent::Object& r
case torrent::Object::TYPE_STRING:
{
torrent::Object argValue(torrent::Object::TYPE_VALUE);
torrent::Object argValue = torrent::Object::create_value();
if (!parse_whole_value_nothrow(arg.as_string().c_str(), &argValue.as_value(), base, unit))
throw torrent::input_error("Not a value.");
+2 -2
View File
@@ -170,7 +170,7 @@ parse_value_nothrow(const char* src, int64_t* value, int base, int unit) {
const char*
parse_object(const char* first, const char* last, torrent::Object* dest, bool (*delim)(const char)) {
if (*first == '{') {
*dest = torrent::Object(torrent::Object::TYPE_LIST);
*dest = torrent::Object::create_list();
first = parse_list(first + 1, last, dest, &parse_is_delim_list);
first = parse_skip_wspace(first, last);
@@ -216,7 +216,7 @@ parse_whole_list(const char* first, const char* last, torrent::Object* dest) {
first = parse_skip_wspace(first, last);
if (first != last && parse_is_seperator(*first)) {
torrent::Object tmp = torrent::Object(torrent::Object::TYPE_LIST);
torrent::Object tmp = torrent::Object::create_list();
tmp.swap(*dest);
dest->as_list().push_back(tmp);
+1 -1
View File
@@ -109,7 +109,7 @@ inline void call_command_d_set_std_string(const std::string& key, cor
inline torrent::Object
call_command_d_range(const char* key, core::Download* download, torrent::Object::list_const_iterator first, torrent::Object::list_const_iterator last) {
// Change to using range ctor.
torrent::Object rawArgs(torrent::Object::TYPE_LIST);
torrent::Object rawArgs = torrent::Object::create_list();
torrent::Object::list_type& args = rawArgs.as_list();
while (first != last)
+2 -2
View File
@@ -106,7 +106,7 @@ xmlrpc_to_object(xmlrpc_env* env, xmlrpc_value* value) {
case XMLRPC_TYPE_ARRAY:
{
torrent::Object result(torrent::Object::TYPE_LIST);
torrent::Object result = torrent::Object::create_list();
torrent::Object::list_type& listRef = result.as_list();
unsigned int last = xmlrpc_array_size(env, value);
@@ -292,7 +292,7 @@ xmlrpc_to_object_target(xmlrpc_env* env, xmlrpc_value* value, int callType, void
torrent::Object result;
if (current + 1 < last) {
result = torrent::Object(torrent::Object::TYPE_LIST);
result = torrent::Object::create_list();
torrent::Object::list_type& listRef = result.as_list();
// Move this into a helper function?
+2 -2
View File
@@ -175,8 +175,8 @@ Download::create_info() {
element->push_back("");
element->push_column("Connection type:", te_command("d.get_connection_current="));
element->push_column("Safe sync:", te_command("if=$get_safe_sync=,yes,no"));
element->push_column("Send buffer:", te_command("cat=$to_mb=$get_send_buffer_size=,\" KB\""));
element->push_column("Receive buffer:", te_command("cat=$to_mb=$get_receive_buffer_size=,\" KB\""));
element->push_column("Send buffer:", te_command("cat=$to_kb=$get_send_buffer_size=,\" KB\""));
element->push_column("Receive buffer:", te_command("cat=$to_kb=$get_receive_buffer_size=,\" KB\""));
element->push_back("");
element->push_column("Upload:", te_command("cat=$to_kb=$d.get_up_rate=,\" KB / \",$to_xb=$d.get_up_total="));
+2
View File
@@ -67,6 +67,8 @@ public:
using base_type::erase;
// static int flag_
// Insert and return true if the entry does not exist or the new
// file's mtime is more recent.
bool insert(const std::string& path, int flags);