Data-MessagePack-Stream

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

msgpack-3.3.0/test/object.cpp
msgpack-3.3.0/test/object_with_zone.cpp
msgpack-3.3.0/test/pack_unpack.cpp
msgpack-3.3.0/test/pack_unpack_c.cpp
msgpack-3.3.0/test/raw.cpp
msgpack-3.3.0/test/reference.cpp
msgpack-3.3.0/test/reference_cpp11.cpp
msgpack-3.3.0/test/reference_wrapper_cpp11.cpp
msgpack-3.3.0/test/shared_ptr_cpp11.cpp
msgpack-3.3.0/test/size_equal_only.cpp
msgpack-3.3.0/test/streaming.cpp
msgpack-3.3.0/test/streaming_c.cpp
msgpack-3.3.0/test/test_allocator.hpp
msgpack-3.3.0/test/unique_ptr_cpp11.cpp
msgpack-3.3.0/test/user_class.cpp
msgpack-3.3.0/test/version.cpp
msgpack-3.3.0/test/visitor.cpp
msgpack-3.3.0/test/zone.cpp
t/RT74518.t
t/basic.t
t/boolean-roundtrip.t
t/bug-issue3.t

META.json  view on Meta::CPAN

{
   "abstract" : "yet another messagepack streaming deserializer",
   "author" : [
      "Daisuke Murase <typester@cpan.org>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Minilla/v3.1.10",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'yet another messagepack streaming deserializer'
author:
  - 'Daisuke Murase <typester@cpan.org>'
build_requires:
  Test::More: '0.98'
configure_requires:
  Devel::PPPort: '3.42'
  File::Which: '0'
  Module::Build: '0.4005'
  Module::Build::XSUtil: '0'
dynamic_config: 0

README.md  view on Meta::CPAN

[![Build Status](https://travis-ci.org/typester/Data-MessagePack-Stream.svg?branch=master)](https://travis-ci.org/typester/Data-MessagePack-Stream)
# NAME

Data::MessagePack::Stream - yet another messagepack streaming deserializer

# SYNOPSIS

    use Data::Dumper;
    my $unpacker = Data::MessagePack::Stream->new;

    while (read($fh, my $buf, 1024)) {
        $unpacker->feed($buf);

        while ($unpacker->next) {
            print Dumper($unpacker->data);
        }
    }

# DESCRIPTION

Data::MessagePack::Stream is streaming deserializer for MessagePack.

This module is alternate for [Data::MessagePack::Unpacker](https://metacpan.org/pod/Data%3A%3AMessagePack%3A%3AUnpacker).
Unlike original unpacker, this module support internal buffer and it's possible to handle streaming data correctly.

# METHODS

## new

    my $unpacker = Data::MessagePack::Stream->new;

Create new stream unpacker.

## feed($data)

lib/Data/MessagePack/Stream.pm  view on Meta::CPAN


1;

__END__

=for stopwords
messagepack deserializer parsable unpacker unpacker's

=head1 NAME

Data::MessagePack::Stream - yet another messagepack streaming deserializer

=head1 SYNOPSIS

    use Data::Dumper;
    my $unpacker = Data::MessagePack::Stream->new;

    while (read($fh, my $buf, 1024)) {
        $unpacker->feed($buf);

        while ($unpacker->next) {
            print Dumper($unpacker->data);
        }
    }

=head1 DESCRIPTION

Data::MessagePack::Stream is streaming deserializer for MessagePack.

This module is alternate for L<Data::MessagePack::Unpacker>.
Unlike original unpacker, this module support internal buffer and it's possible to handle streaming data correctly.

=head1 METHODS

=head2 new

    my $unpacker = Data::MessagePack::Stream->new;

Create new stream unpacker.

=head2 feed($data)

msgpack-3.3.0/ChangeLog  view on Meta::CPAN

  * Remove some warnings (#599, #602, #605)

# 2017-06-07 version 2.1.2

* Improve documents (#565)
  * Fix empty map parse bug (#568)
  * Improve build system (#569, #570, #572, #579, #591, #592)
  * Remove some warnings (#574, #578, #586, #588)
  * Improve cross platform configuration (#577, #582)
  * Add cmake package config support (#580)
  * Fix streaming unpack bug (#585)

# 2017-02-04 version 2.1.1

  * Fix unpacker's buffer management bug (#561)
  * Add boost string_view adaptor (#558)
  * Remove some warnings (#557, #559)
  * Improve coding style (#556)

# 2017-01-10 version 2.1.0

msgpack-3.3.0/ChangeLog  view on Meta::CPAN

  * Add msgpack_sbuffer_new and msgpack_sbuffer_free
  * Add msgpack_unpacker_next and msgpack_unpack_next
  * msgpack::unpack returns void
  * Add MSGPACK_VERSION{,_MAJOR,_MINOR} macros to check header version
  * Add msgpack_version{,_major,_minor} functions to check library version
  * ./configure supports --disable-cxx option not to build C++ API

# 2010-04-29 version 0.5.0:

  * msgpack_object_type is changed. MSGPACK_OBJECT_NIL is now 0x00.
  * New safe streaming deserializer API.
  * Add object::object(const T&) and object::operator=(const T&)
  * Add operator==(object, const T&)
  * MSGPACK_DEFINE macro defines msgpack_object(object* obj, zone* z)
  * C++ programs doesn't need to link "msgpackc" library.

msgpack-3.3.0/include/msgpack/unpack.h  view on Meta::CPAN

    size_t initial_buffer_size;
    void* ctx;
} msgpack_unpacker;


#ifndef MSGPACK_UNPACKER_INIT_BUFFER_SIZE
#define MSGPACK_UNPACKER_INIT_BUFFER_SIZE (64*1024)
#endif

/**
 * Initializes a streaming deserializer.
 * The initialized deserializer must be destroyed by msgpack_unpacker_destroy(msgpack_unpacker*).
 */
MSGPACK_DLLEXPORT
bool msgpack_unpacker_init(msgpack_unpacker* mpac, size_t initial_buffer_size);

/**
 * Destroys a streaming deserializer initialized by msgpack_unpacker_init(msgpack_unpacker*, size_t).
 */
MSGPACK_DLLEXPORT
void msgpack_unpacker_destroy(msgpack_unpacker* mpac);


/**
 * Creates a streaming deserializer.
 * The created deserializer must be destroyed by msgpack_unpacker_free(msgpack_unpacker*).
 */
MSGPACK_DLLEXPORT
msgpack_unpacker* msgpack_unpacker_new(size_t initial_buffer_size);

/**
 * Frees a streaming deserializer created by msgpack_unpacker_new(size_t).
 */
MSGPACK_DLLEXPORT
void msgpack_unpacker_free(msgpack_unpacker* mpac);


#ifndef MSGPACK_UNPACKER_RESERVE_SIZE
#define MSGPACK_UNPACKER_RESERVE_SIZE (32*1024)
#endif

/**

msgpack-3.3.0/include/msgpack/unpack.h  view on Meta::CPAN


/**
 * Initializes a msgpack_unpacked object.
 * The initialized object must be destroyed by msgpack_unpacked_destroy(msgpack_unpacker*).
 * Use the object with msgpack_unpacker_next(msgpack_unpacker*, msgpack_unpacked*) or
 * msgpack_unpack_next(msgpack_unpacked*, const char*, size_t, size_t*).
 */
static inline void msgpack_unpacked_init(msgpack_unpacked* result);

/**
 * Destroys a streaming deserializer initialized by msgpack_unpacked().
 */
static inline void msgpack_unpacked_destroy(msgpack_unpacked* result);

/**
 * Releases the memory zone from msgpack_unpacked object.
 * The released zone must be freed by msgpack_zone_free(msgpack_zone*).
 */
static inline msgpack_zone* msgpack_unpacked_release_zone(msgpack_unpacked* result);


msgpack-3.3.0/test/CMakeLists.txt  view on Meta::CPAN

INCLUDE_DIRECTORIES (
    ${GTEST_INCLUDE_DIRS}
    ${ZLIB_INCLUDE_DIRS}
)

SET (tests_C
    buffer_c.cpp
    fixint_c.cpp
    msgpack_c.cpp
    pack_unpack_c.cpp
    streaming_c.cpp
)

IF (NOT MSGPACK_CXX_ONLY)
    LIST (APPEND check_PROGRAMS
        ${tests_C}
    )
ENDIF ()

IF (MSGPACK_ENABLE_CXX)
    LIST (APPEND check_PROGRAMS

msgpack-3.3.0/test/CMakeLists.txt  view on Meta::CPAN

        msgpack_container.cpp
        msgpack_stream.cpp
        msgpack_tuple.cpp
        msgpack_vref.cpp
        object.cpp
        object_with_zone.cpp
        pack_unpack.cpp
        raw.cpp
        reference.cpp
        size_equal_only.cpp
        streaming.cpp
        user_class.cpp
        version.cpp
        visitor.cpp
        zone.cpp
    )

    IF (MSGPACK_BOOST)
        LIST (APPEND check_PROGRAMS
            boost_fusion.cpp
            boost_variant.cpp

msgpack-3.3.0/test/streaming.cpp  view on Meta::CPAN

#endif //defined(__GNUC__)

#include <gtest/gtest.h>

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif //defined(__GNUC__)

#include <sstream>

TEST(streaming, basic)
{
    msgpack::sbuffer buffer;

    msgpack::packer<msgpack::sbuffer> pk(&buffer);
    pk.pack(1);
    pk.pack(2);
    pk.pack(3);

    const char* input = buffer.data();
    const char* const eof = input + buffer.size();

msgpack-3.3.0/test/streaming.cpp  view on Meta::CPAN

            }
        }

        EXPECT_TRUE(input < eof);
    }
}

// obsolete
#if MSGPACK_DEFAULT_API_VERSION == 1

TEST(streaming, basic_pointer)
{
    msgpack::sbuffer buffer;

    msgpack::packer<msgpack::sbuffer> pk(&buffer);
    pk.pack(1);
    pk.pack(2);
    pk.pack(3);

    const char* input = buffer.data();
    const char* const eof = input + buffer.size();

msgpack-3.3.0/test/streaming.cpp  view on Meta::CPAN

        }

        EXPECT_TRUE(input < eof);
    }
}

#endif // MSGPACK_DEFAULT_API_VERSION == 1

#if !defined(MSGPACK_USE_CPP03)

TEST(streaming, move)
{
    msgpack::sbuffer buffer;

    msgpack::packer<msgpack::sbuffer> pk(&buffer);
    pk.pack(1);
    pk.pack(2);
    pk.pack(3);

    const char* input = buffer.data();
    const char* const eof = input + buffer.size();

msgpack-3.3.0/test/streaming.cpp  view on Meta::CPAN

        EXPECT_EQ(expect, obj.as<int>());
    }

    int expect;

private:
    std::istream& input;
    msgpack::unpacker pac;
};

TEST(streaming, event)
{
    std::stringstream stream;
    msgpack::packer<std::ostream> pk(&stream);

    event_handler handler(stream);

    pk.pack(1);
    handler.expect = 1;
    handler.on_read();

msgpack-3.3.0/test/streaming.cpp  view on Meta::CPAN


    pk.pack(3);
    handler.expect = 3;
    handler.on_read();
}

// obsolete
#if MSGPACK_DEFAULT_API_VERSION == 1

// backward compatibility
TEST(streaming, basic_compat)
{
    std::ostringstream stream;
    msgpack::packer<std::ostream> pk(&stream);

    pk.pack(1);
    pk.pack(2);
    pk.pack(3);

    std::istringstream input(stream.str());

msgpack-3.3.0/test/streaming.cpp  view on Meta::CPAN

        EXPECT_EQ(expect, obj.as<int>());
    }

    int expect;

private:
    std::istream& input;
    msgpack::unpacker pac;
};

TEST(streaming, event_compat)
{
    std::stringstream stream;
    msgpack::packer<std::ostream> pk(&stream);

    event_handler_compat handler(stream);

    pk.pack(1);
    handler.expect = 1;
    handler.on_read();

msgpack-3.3.0/test/streaming_c.cpp  view on Meta::CPAN

#endif //defined(__GNUC__)

#include <gtest/gtest.h>

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif //defined(__GNUC__)

#include <stdio.h>

TEST(streaming, basic)
{
    msgpack_sbuffer* buffer = msgpack_sbuffer_new();

    msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write);

    // 1, 2, 3, "str", ["str_data"], "bin", ["bin_data"], {0.3: 0.4}
    EXPECT_EQ(0, msgpack_pack_int(pk, 1));
    EXPECT_EQ(0, msgpack_pack_int(pk, 2));
    EXPECT_EQ(0, msgpack_pack_int(pk, 3));
    EXPECT_EQ(0, msgpack_pack_str(pk, 3));

msgpack-3.3.0/test/streaming_c.cpp  view on Meta::CPAN

                }
            }
        }
    }

    msgpack_unpacker_destroy(&pac);
    msgpack_unpacked_destroy(&result);
    msgpack_sbuffer_free(buffer);
}

TEST(streaming, basic_with_size)
{
    int ret;
    size_t bytes;
    size_t parsed = 0;
    msgpack_sbuffer* buffer = msgpack_sbuffer_new();
    msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write);
    msgpack_unpacked result;
    msgpack_unpacker *unp;

    // 1, 2, 3, "str", ["str_data"], "bin", ["bin_data"], {0.3: 0.4}



( run in 0.283 second using v1.01-cache-2.11-cpan-4d50c553e7e )