forked from premiere/premiere-libtorrent
changed back the entry to use std::map for dictionaries
This commit is contained in:
parent
f824714b0e
commit
8c8a375168
|
@ -709,7 +709,7 @@ or a string. This is its synopsis::
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::list<std::pair<std::string, entry> > dictionary_type;
|
typedef std::map<std::string, entry> dictionary_type;
|
||||||
typedef std::string string_type;
|
typedef std::string string_type;
|
||||||
typedef std::list<entry> list_type;
|
typedef std::list<entry> list_type;
|
||||||
typedef size_type integer_type;
|
typedef size_type integer_type;
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace libtorrent
|
||||||
// the key is always a string. If a generic entry would be allowed
|
// the key is always a string. If a generic entry would be allowed
|
||||||
// as a key, sorting would become a problem (e.g. to compare a string
|
// as a key, sorting would become a problem (e.g. to compare a string
|
||||||
// to a list). The definition doesn't mention such a limit though.
|
// to a list). The definition doesn't mention such a limit though.
|
||||||
typedef std::list<std::pair<std::string, entry> > dictionary_type;
|
typedef std::map<std::string, entry> dictionary_type;
|
||||||
typedef std::string string_type;
|
typedef std::string string_type;
|
||||||
typedef std::list<entry> list_type;
|
typedef std::list<entry> list_type;
|
||||||
typedef size_type integer_type;
|
typedef size_type integer_type;
|
||||||
|
@ -145,8 +145,6 @@ namespace libtorrent
|
||||||
void operator=(list_type const&);
|
void operator=(list_type const&);
|
||||||
void operator=(integer_type const&);
|
void operator=(integer_type const&);
|
||||||
|
|
||||||
void sort();
|
|
||||||
|
|
||||||
integer_type& integer();
|
integer_type& integer();
|
||||||
const integer_type& integer() const;
|
const integer_type& integer() const;
|
||||||
string_type& string();
|
string_type& string();
|
||||||
|
|
|
@ -64,27 +64,6 @@ namespace
|
||||||
}
|
}
|
||||||
char const* m_str;
|
char const* m_str;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class It, class Pred>
|
|
||||||
void bubble_sort(It start, It end, Pred p)
|
|
||||||
{
|
|
||||||
if (start == end) return;
|
|
||||||
--end;
|
|
||||||
for (It i = start; i != end; ++i)
|
|
||||||
{
|
|
||||||
bool unsorted = false;
|
|
||||||
for (It j = i; j != end; ++j)
|
|
||||||
{
|
|
||||||
It next = boost::next(j);
|
|
||||||
if (!p(*j, *next))
|
|
||||||
{
|
|
||||||
swap(*j, *next);
|
|
||||||
unsorted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!unsorted) return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
|
@ -307,18 +286,6 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void entry::sort()
|
|
||||||
{
|
|
||||||
using boost::bind;
|
|
||||||
if (type() == dictionary_t)
|
|
||||||
{
|
|
||||||
bubble_sort(dict().begin(), dict().end()
|
|
||||||
, bind(std::less<std::string>()
|
|
||||||
, bind(&entry::dictionary_type::value_type::first, _1)
|
|
||||||
, bind(&entry::dictionary_type::value_type::first, _2)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void entry::print(std::ostream& os, int indent) const
|
void entry::print(std::ostream& os, int indent) const
|
||||||
{
|
{
|
||||||
assert(indent >= 0);
|
assert(indent >= 0);
|
||||||
|
|
|
@ -435,7 +435,6 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
path_e.list().push_back(*j);
|
path_e.list().push_back(*j);
|
||||||
}
|
}
|
||||||
file_e.sort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,8 +451,6 @@ namespace libtorrent
|
||||||
p.append((char*)i->begin(), (char*)i->end());
|
p.append((char*)i->begin(), (char*)i->end());
|
||||||
}
|
}
|
||||||
|
|
||||||
info.sort();
|
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +504,6 @@ namespace libtorrent
|
||||||
dict["created by"] = m_created_by;
|
dict["created by"] = m_created_by;
|
||||||
|
|
||||||
dict["info"] = create_info_metadata();
|
dict["info"] = create_info_metadata();
|
||||||
dict.sort();
|
|
||||||
|
|
||||||
entry const& info_section = dict["info"];
|
entry const& info_section = dict["info"];
|
||||||
std::vector<char> buf;
|
std::vector<char> buf;
|
||||||
|
|
Loading…
Reference in New Issue