deprecate old state saving functions, merge dht state with session state

This commit is contained in:
Arvid Norberg
2010-03-04 16:42:39 +00:00
parent 9edb348093
commit 281b6368f7
9 changed files with 149 additions and 84 deletions

View File

@@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/entry.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/escape_string.hpp"
#include "libtorrent/lazy_entry.hpp"
#if defined(_MSC_VER)
#define for if (false) {} else for
@@ -207,6 +208,40 @@ namespace libtorrent
m_type = int_t;
}
// convert a lazy_entry into an old skool entry
void entry::operator=(lazy_entry const& e)
{
switch (e.type())
{
case lazy_entry::string_t:
this->string() = e.string_value();
break;
case lazy_entry::int_t:
this->integer() = e.int_value();
break;
case lazy_entry::dict_t:
{
dictionary_type& d = this->dict();
for (int i = 0; i < e.dict_size(); ++i)
{
std::pair<std::string, lazy_entry const*> elem = e.dict_at(i);
d[elem.first] = *elem.second;
}
break;
}
case lazy_entry::list_t:
{
list_type& l = this->list();
for (int i = 0; i < e.list_size(); ++i)
{
l.push_back(entry());
l.back() = *e.list_at(i);
}
break;
}
}
}
void entry::operator=(dictionary_type const& v)
{
destruct();