DR-Tarantool
view release on metacpan or search on metacpan
lib/DR/Tarantool/Spaces.pm view on Meta::CPAN
It supports the following field types:
=over
=item NUM, NUM64, STR
The standard L<Tarantool|http://tarantool.org> types.
=item UTF8STR
The same as B<STR>, but the string is utf8-decoded
after it's received from the server.
=item INT & INT64
The same as B<NUM> and B<NUM64>, but contain signed values.
=item JSON
The field is encoded with L<JSON::XS> when putting
into a database, and decoded after is received back
from the server.
=back
=head1 METHODS
=head2 new
my $spaces = DR::Tarantool::Spaces->new( $spaces );
* \retval > 0 - the number of remaining bytes to read
* \pre cur < end
* \pre mp_typeof(*cur) == MP_ARRAY
*/
MP_PROTO __attribute__((pure)) ptrdiff_t
mp_check_array(const char *cur, const char *end);
/**
* \brief Decode an array header from MsgPack \a data.
*
* All array members must be decoded after the header.
* \param data - the pointer to a buffer
* \return the number of elements in an array
* \post *data = *data + mp_sizeof_array(retval)
* \sa \link mp_encode_array() An usage example \endlink
*/
MP_PROTO uint32_t
mp_decode_array(const char **data);
/**
* \brief Calculate exact buffer size needed to store a map header of
* \retval > 0 - the number of remaining bytes to read
* \pre cur < end
* \pre mp_typeof(*cur) == MP_MAP
*/
MP_PROTO __attribute__((pure)) ptrdiff_t
mp_check_map(const char *cur, const char *end);
/**
* \brief Decode a map header from MsgPack \a data.
*
* All map key-value pairs must be decoded after the header.
* \param data - the pointer to a buffer
* \return the number of key/value pairs in a map
* \post *data = *data + mp_sizeof_array(retval)
* \sa \link mp_encode_map() An usage example \endlink
*/
MP_PROTO uint32_t
mp_decode_map(const char **data);
/**
* \brief Calculate exact buffer size needed to store an integer \a num.
* \post *data = *data + mp_sizeof_strl(retval)
* \sa mp_encode_strl
*/
MP_PROTO uint32_t
mp_decode_strl(const char **data);
/**
* \brief Decode a string from MsgPack \a data
* \param data - the pointer to a buffer
* \param len - the pointer to save a string length
* \return a pointer to a decoded string
* \post *data = *data + mp_sizeof_str(*len)
* \sa mp_encode_binl
*/
MP_PROTO const char *
mp_decode_str(const char **data, uint32_t *len);
/**
* \brief Decode a length of a binstring from MsgPack \a data
* \param data - the pointer to a buffer
* \return a length of a binstring
* \post *data = *data + mp_sizeof_binl(retval)
* \sa mp_encode_binl
*/
MP_PROTO uint32_t
mp_decode_binl(const char **data);
/**
* \brief Decode a binstring from MsgPack \a data
* \param data - the pointer to a buffer
* \param len - the pointer to save a binstring length
* \return a pointer to a decoded binstring
* \post *data = *data + mp_sizeof_str(*len)
* \sa mp_encode_binl
*/
MP_PROTO const char *
mp_decode_bin(const char **data, uint32_t *len);
/**
* \brief Calculate exact buffer size needed to store the nil value.
* The return value is always 1. The function was added to provide integrity of
* the library.
* \retval > 0 - the number of remaining bytes to read
* \pre cur < end
* \pre mp_typeof(*cur) == MP_BOOL
*/
MP_PROTO __attribute__((pure)) ptrdiff_t
mp_check_bool(const char *cur, const char *end);
/**
* \brief Decode a bool value from MsgPack \a data
* \param data - the pointer to a buffer
* \return a decoded bool value
* \post *data = *data + mp_sizeof_bool(retval)
*/
MP_PROTO bool
mp_decode_bool(const char **data);
/**
* \brief Skip one element in a packed \a data.
*
* The function is faster than mp_typeof + mp_decode_XXX() combination.
* For arrays and maps the function also skips all members.
( run in 0.243 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )