python: add wrapper for Value::data

This commit is contained in:
Adrien Béraud committed 2015-08-24 16:38:40 +02:00
1 parent be1cc96a91
commit 6182dce1ad
2 files changed
+7

No files matched your search

+6
View File
@@ -30,6 +30,7 @@
from libcpp.map cimport map as map
from libcpp cimport bool
from libcpp.utility cimport pair
from libcpp.string cimport string
from cython.parallel import parallel, prange
from cython.operator cimport dereference as deref, preincrement as inc, predecrement as dec
@@ -117,6 +118,11 @@ cdef class Value(object):
self._value.reset(new cpp.Value(val, len(val)))
def __str__(self):
return self._value.get().toString().decode()
property data:
def __get__(self):
string(<char*>self._value.get().data.data(), self._value.get().data.size())
def __set__(self, bytes value):
self._value.get().data = value
cdef class NodeSetIter(object):
cdef map[cpp.InfoHash, cpp.shared_ptr[cpp.Node]]* _nodes
+1
View File
@@ -45,6 +45,7 @@ cdef extern from "opendht/value.h" namespace "dht":
Value(vector[uint8_t]) except +
Value(const uint8_t* dat_ptr, size_t dat_len) except +
string toString() const
vector[uint8_t] data
cdef extern from "opendht/crypto.h" namespace "dht::crypto":
ctypedef pair[shared_ptr[PrivateKey], shared_ptr[Certificate]] Identity