forked from premiere/premiere-libtorrent
made entry not require exceptions
This commit is contained in:
parent
cb9fbea5f7
commit
53c125a9b3
|
@ -161,8 +161,10 @@ namespace libtorrent
|
|||
// is a dictionary, otherwise they will throw
|
||||
entry& operator[](char const* key);
|
||||
entry& operator[](std::string const& key);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
const entry& operator[](char const* key) const;
|
||||
const entry& operator[](std::string const& key) const;
|
||||
#endif
|
||||
entry* find_key(char const* key);
|
||||
entry const* find_key(char const* key) const;
|
||||
|
||||
|
@ -221,55 +223,80 @@ namespace libtorrent
|
|||
copy(e);
|
||||
}
|
||||
|
||||
|
||||
inline entry::integer_type& entry::integer()
|
||||
{
|
||||
if (m_type == undefined_t) construct(int_t);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (m_type != int_t) throw type_error("invalid type requested from entry");
|
||||
#endif
|
||||
TORRENT_ASSERT(m_type == int_t);
|
||||
return *reinterpret_cast<integer_type*>(data);
|
||||
}
|
||||
|
||||
inline entry::integer_type const& entry::integer() const
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (m_type != int_t) throw type_error("invalid type requested from entry");
|
||||
#endif
|
||||
TORRENT_ASSERT(m_type == int_t);
|
||||
return *reinterpret_cast<const integer_type*>(data);
|
||||
}
|
||||
|
||||
inline entry::string_type& entry::string()
|
||||
{
|
||||
if (m_type == undefined_t) construct(string_t);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (m_type != string_t) throw type_error("invalid type requested from entry");
|
||||
#endif
|
||||
TORRENT_ASSERT(m_type == string_t);
|
||||
return *reinterpret_cast<string_type*>(data);
|
||||
}
|
||||
|
||||
inline entry::string_type const& entry::string() const
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (m_type != string_t) throw type_error("invalid type requested from entry");
|
||||
#endif
|
||||
TORRENT_ASSERT(m_type == string_t);
|
||||
return *reinterpret_cast<const string_type*>(data);
|
||||
}
|
||||
|
||||
inline entry::list_type& entry::list()
|
||||
{
|
||||
if (m_type == undefined_t) construct(list_t);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (m_type != list_t) throw type_error("invalid type requested from entry");
|
||||
#endif
|
||||
TORRENT_ASSERT(m_type == list_t);
|
||||
return *reinterpret_cast<list_type*>(data);
|
||||
}
|
||||
|
||||
inline entry::list_type const& entry::list() const
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (m_type != list_t) throw type_error("invalid type requested from entry");
|
||||
#endif
|
||||
TORRENT_ASSERT(m_type == list_t);
|
||||
return *reinterpret_cast<const list_type*>(data);
|
||||
}
|
||||
|
||||
inline entry::dictionary_type& entry::dict()
|
||||
{
|
||||
if (m_type == undefined_t) construct(dictionary_t);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (m_type != dictionary_t) throw type_error("invalid type requested from entry");
|
||||
#endif
|
||||
TORRENT_ASSERT(m_type == dictionary_t);
|
||||
return *reinterpret_cast<dictionary_type*>(data);
|
||||
}
|
||||
|
||||
inline entry::dictionary_type const& entry::dict() const
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (m_type != dictionary_t) throw type_error("invalid type requested from entry");
|
||||
#endif
|
||||
TORRENT_ASSERT(m_type == dictionary_t);
|
||||
return *reinterpret_cast<const dictionary_type*>(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,6 +126,7 @@ namespace libtorrent
|
|||
return &i->second;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
const entry& entry::operator[](char const* key) const
|
||||
{
|
||||
dictionary_type::const_iterator i = dict().find(key);
|
||||
|
@ -138,6 +139,7 @@ namespace libtorrent
|
|||
{
|
||||
return (*this)[key.c_str()];
|
||||
}
|
||||
#endif
|
||||
|
||||
entry::entry(dictionary_type const& v)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue