~ubuntu-branches/ubuntu/trusty/miro/trusty

« back to all changes in this revision

Viewing changes to portable/libtorrent/bindings/python/src/utility.cpp

  • Committer: Daniel Hahler
  • Date: 2010-04-13 18:51:35 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: ubuntu-launchpad@thequod.de-20100413185135-xi24v1diqg8w406x
Merging shared upstream rev into target branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright Daniel Wallin 2006. Use, modification and distribution is
2
 
// subject to the Boost Software License, Version 1.0. (See accompanying
3
 
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
 
 
5
 
#include <libtorrent/identify_client.hpp>
6
 
#include <libtorrent/bencode.hpp>
7
 
#include <boost/python.hpp>
8
 
 
9
 
using namespace boost::python;
10
 
using namespace libtorrent;
11
 
 
12
 
object client_fingerprint_(peer_id const& id)
13
 
{
14
 
    boost::optional<fingerprint> result = client_fingerprint(id);
15
 
    return result ? object(*result) : object();
16
 
}
17
 
 
18
 
entry bdecode_(std::string const& data)
19
 
{
20
 
    return bdecode(data.begin(), data.end());
21
 
}
22
 
 
23
 
std::string bencode_(entry const& e)
24
 
{
25
 
    std::string result;
26
 
    bencode(std::back_inserter(result), e);
27
 
    return result;
28
 
}
29
 
 
30
 
void bind_utility()
31
 
{
32
 
    def("identify_client", &libtorrent::identify_client);
33
 
    def("client_fingerprint", &client_fingerprint_);
34
 
    def("bdecode", &bdecode_);
35
 
    def("bencode", &bencode_);
36
 
}
37