summaryrefslogtreecommitdiff
path: root/msgpack/_msgpack.pyx
diff options
context:
space:
mode:
authorJoel Nothman <joel.nothman@gmail.com>2012-09-25 01:18:33 +1000
committerJoel Nothman <joel.nothman@gmail.com>2012-09-25 01:19:07 +1000
commit0431a766f4e069d74627441aa3facbc7e64e4511 (patch)
treed571b0c381cd579be529402992d7dc2e27e53f23 /msgpack/_msgpack.pyx
parentd56e2b2c8aa1005fbac3b584cd003ba0cdece2e2 (diff)
downloadmsgpack-python-0431a766f4e069d74627441aa3facbc7e64e4511.tar.gz
read_array/map_header functionality
Diffstat (limited to 'msgpack/_msgpack.pyx')
-rw-r--r--msgpack/_msgpack.pyx10
1 files changed, 10 insertions, 0 deletions
diff --git a/msgpack/_msgpack.pyx b/msgpack/_msgpack.pyx
index 0fc3739..7131d1f 100644
--- a/msgpack/_msgpack.pyx
+++ b/msgpack/_msgpack.pyx
@@ -212,6 +212,8 @@ cdef extern from "unpack.h":
size_t len, size_t* off) except -1
execute_fn template_construct
execute_fn template_skip
+ execute_fn read_array_header
+ execute_fn read_map_header
void template_init(template_context* ctx)
object template_data(template_context* ctx)
@@ -482,6 +484,14 @@ cdef class Unpacker(object):
"""read and ignore one object, returning None"""
return self._unpack(template_skip)
+ def read_array_header(self):
+ """assuming the next object is an array, return its size n, such that the next n unpack() calls will iterate over its contents."""
+ return self._unpack(read_array_header)
+
+ def read_map_header(self):
+ """assuming the next object is a map, return its size n, such that the next n * 2 unpack() calls will iterate over its key-value pairs."""
+ return self._unpack(read_map_header)
+
def __iter__(self):
return self