Compare commits

..

13 Commits

Author SHA1 Message Date
frsyuki
dba7f480ed cpp: add missing preprocess.sh file 2009-08-19 17:50:15 +09:00
frsyuki
3a39accb0b cpp: preprocess eruby templates on ./bootstrap; released package doesn't require erb 2009-08-19 17:47:22 +09:00
frsyuki
387eca6fbf cpp-0.3.7 2009-08-19 17:36:05 +09:00
frsyuki
b2381d0513 cpp: fix overflow check for minimum number of signed integer type 2009-08-19 15:10:10 +09:00
frsyuki
92952f6566 c++: fix object >> std::string 2009-08-10 22:16:44 +09:00
frsyuki
a62a5d6c69 c++: fix type.hpp 2009-08-10 18:33:35 +09:00
frsyuki
0627324da6 c++: rebuild type/*.hpp 2009-08-10 18:26:01 +09:00
frsyuki
394331cd4e c++: add std::pair and std::set serializer 2009-08-10 17:34:21 +09:00
frsyuki
0491768fb2 c++: fix Makefile.am 2009-08-10 15:58:43 +09:00
frsyuki
a5705183d6 0.3.5 2009-08-07 13:32:32 +09:00
frsyuki
95a6316cc7 cpp: fix msgpack::type::make_define() 2009-08-07 13:32:07 +09:00
frsyuki
be32e3b1fb cpp: add missing msgpack::type::make_tuple() 2009-08-07 13:31:42 +09:00
frsyuki
b4cb5e23c0 fix Makefile.am 2009-08-07 11:28:23 +09:00
21 changed files with 320 additions and 99 deletions

View File

@@ -1,5 +1,4 @@
if ENABLE_CXX if ENABLE_CXX
export ERB
SUBDIRS = c cpp SUBDIRS = c cpp
else else
SUBDIRS = c SUBDIRS = c

4
README
View File

@@ -8,9 +8,7 @@ Binary-based efficient data interchange format.
MessagePack is only tested on Linux and Mac OS X, but it may run on other MessagePack is only tested on Linux and Mac OS X, but it may run on other
UNIX-like platforms. UNIX-like platforms.
Following programs are required to build: gcc >= 4.1 is required to build.
- gcc >= 4.1 with C++ support
- ruby >= 1.8 (ruby is used as a preprocessor)
*Installation *Installation

View File

@@ -31,11 +31,8 @@ if test x"$1" = x"--help"; then
fi fi
#if [ -z "$NO_NEST" ];then
# cd c && ./bootstrap $@; cd ..
# cd cpp && ./bootstrap $@; cd ..
#fi
mkdir -p ac mkdir -p ac
(cd cpp && ./preprocess.sh $@; cd ..)
ACLOCAL="aclocal" ACLOCAL="aclocal"

View File

@@ -1,6 +1,6 @@
AC_INIT(msgpack/unpack_template.h) AC_INIT(msgpack/unpack_template.h)
AC_CONFIG_AUX_DIR(ac) AC_CONFIG_AUX_DIR(ac)
AM_INIT_AUTOMAKE(msgpack, 0.3.4) AM_INIT_AUTOMAKE(msgpack, 0.3.7)
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(config.h)
AC_SUBST(CFLAGS) AC_SUBST(CFLAGS)
@@ -23,11 +23,6 @@ if test "$enable_cxx" != "no"; then
if test "" = "$CXXFLAGS"; then if test "" = "$CXXFLAGS"; then
CXXFLAGS="-g -O4" CXXFLAGS="-g -O4"
fi fi
AC_CHECK_PROG(ERB, erb, erb)
if test "x$ERB" = x; then
AC_MSG_ERROR([cannot find erb. Ruby is needed to build.])
fi
fi fi
# FIXME # FIXME

View File

@@ -12,39 +12,21 @@ nobase_include_HEADERS = \
msgpack/object.hpp \ msgpack/object.hpp \
msgpack/zone.hpp \ msgpack/zone.hpp \
msgpack/type.hpp \ msgpack/type.hpp \
msgpack/type/array.hpp \ msgpack/type/bool.hpp \
msgpack/type/boolean.hpp \
msgpack/type/float.hpp \ msgpack/type/float.hpp \
msgpack/type/integer.hpp \ msgpack/type/int.hpp \
msgpack/type/list.hpp \
msgpack/type/deque.hpp \
msgpack/type/map.hpp \ msgpack/type/map.hpp \
msgpack/type/nil.hpp \ msgpack/type/nil.hpp \
msgpack/type/pair.hpp \
msgpack/type/raw.hpp \ msgpack/type/raw.hpp \
msgpack/type/set.hpp \
msgpack/type/string.hpp \
msgpack/type/vector.hpp \
msgpack/type/tuple.hpp \ msgpack/type/tuple.hpp \
msgpack/type/define.hpp msgpack/type/define.hpp
# FIXME
object.lo: msgpack/type/tuple.hpp msgpack/zone.hpp
msgpack/type/tuple.hpp: msgpack/type/tuple.hpp.erb
$(ERB) $< > $@.tmp
mv $@.tmp $@
msgpack/type/define.hpp: msgpack/type/define.hpp.erb
$(ERB) $< > $@.tmp
mv $@.tmp $@
msgpack/zone.hpp: msgpack/zone.hpp.erb
$(ERB) $< > $@.tmp
mv $@.tmp $@
MOSTLYCLEANFILES = \
msgpack/type/tuple.hpp \
msgpack/zone.hpp
EXTRA_DIST = \
msgpack/type/tuple.hpp.erb \
msgpack/zone.hpp.erb
libmsgpack_la_LIBADD = -L../c -lmsgpackc libmsgpack_la_LIBADD = -L../c -lmsgpackc
# -version-info CURRENT:REVISION:AGE # -version-info CURRENT:REVISION:AGE

View File

@@ -16,7 +16,6 @@
// limitations under the License. // limitations under the License.
// //
#include "msgpack/object.hpp" #include "msgpack/object.hpp"
#include <string.h> #include <string.h>
namespace msgpack { namespace msgpack {

11
cpp/preprocess.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
function preprocess() {
erb $1.erb > $1.tmp
mv $1.tmp $1
}
preprocess msgpack/type/tuple.hpp
preprocess msgpack/type/define.hpp
preprocess msgpack/zone.hpp

View File

@@ -1,10 +1,15 @@
#include "msgpack/type/array.hpp" #include "msgpack/type/bool.hpp"
#include "msgpack/type/boolean.hpp"
#include "msgpack/type/float.hpp" #include "msgpack/type/float.hpp"
#include "msgpack/type/integer.hpp" #include "msgpack/type/int.hpp"
#include "msgpack/type/list.hpp"
#include "msgpack/type/deque.hpp"
#include "msgpack/type/map.hpp" #include "msgpack/type/map.hpp"
#include "msgpack/type/nil.hpp" #include "msgpack/type/nil.hpp"
#include "msgpack/type/pair.hpp"
#include "msgpack/type/raw.hpp" #include "msgpack/type/raw.hpp"
#include "msgpack/type/set.hpp"
#include "msgpack/type/string.hpp"
#include "msgpack/type/vector.hpp"
#include "msgpack/type/tuple.hpp" #include "msgpack/type/tuple.hpp"
#include "msgpack/type/define.hpp" #include "msgpack/type/define.hpp"

View File

@@ -15,8 +15,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
#ifndef MSGPACK_TYPE_BOOLEAN_HPP__ #ifndef MSGPACK_TYPE_BOOL_HPP__
#define MSGPACK_TYPE_BOOLEAN_HPP__ #define MSGPACK_TYPE_BOOL_HPP__
#include "msgpack/object.hpp" #include "msgpack/object.hpp"
#include <vector> #include <vector>
@@ -31,7 +31,6 @@ inline bool& operator>> (object o, bool& v)
return v; return v;
} }
template <typename Stream> template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const bool& v) inline packer<Stream>& operator<< (packer<Stream>& o, const bool& v)
{ {

View File

@@ -52,7 +52,6 @@ struct define<> {
if(o.type != type::ARRAY) { throw type_error(); } if(o.type != type::ARRAY) { throw type_error(); }
} }
}; };
<%0.upto(GENERATION_LIMIT) {|i|%> <%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>> template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
struct define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> { struct define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
@@ -79,11 +78,10 @@ struct define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
}; };
<%}%> <%}%>
define<> make_define() inline define<> make_define()
{ {
return define<>(); return define<>();
} }
<%0.upto(GENERATION_LIMIT) {|i|%> <%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>> template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_define(A0& a0<%1.upto(i) {|j|%>, A<%=j%>& a<%=j%><%}%>) define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_define(A0& a0<%1.upto(i) {|j|%>, A<%=j%>& a<%=j%><%}%>)
@@ -92,7 +90,6 @@ define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_define(A0& a0<%1.upto(i) {|j|%>,
} }
<%}%> <%}%>
} // namespace type } // namespace type
} // namespace msgpack } // namespace msgpack

56
cpp/type/deque.hpp Normal file
View File

@@ -0,0 +1,56 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_DEQUE_HPP__
#define MSGPACK_TYPE_DEQUE_HPP__
#include "msgpack/object.hpp"
#include <deque>
namespace msgpack {
template <typename T>
inline std::deque<T>& operator>> (object o, std::deque<T>& v)
{
if(o.type != type::ARRAY) { throw type_error(); }
v.resize(o.via.array.size);
object* p = o.via.array.ptr;
object* const pend = o.via.array.ptr + o.via.array.size;
typename std::deque<T>::iterator it = v.begin();
for(; p < pend; ++p, ++it) {
p->convert(&*it);
}
return v;
}
template <typename Stream, typename T>
inline packer<Stream>& operator<< (packer<Stream>& o, const std::deque<T>& v)
{
o.pack_array(v.size());
for(typename std::deque<T>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(*it);
}
return o;
}
} // namespace msgpack
#endif /* msgpack/type/deque.hpp */

View File

@@ -34,7 +34,6 @@ inline float& operator>> (object o, float& v)
return v; return v;
} }
template <typename Stream> template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const float& v) inline packer<Stream>& operator<< (packer<Stream>& o, const float& v)
{ {
@@ -50,7 +49,6 @@ inline double& operator>> (object o, double& v)
return v; return v;
} }
template <typename Stream> template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const double& v) inline packer<Stream>& operator<< (packer<Stream>& o, const double& v)
{ {

View File

@@ -15,8 +15,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
#ifndef MSGPACK_TYPE_INTEGER_HPP__ #ifndef MSGPACK_TYPE_INT_HPP__
#define MSGPACK_TYPE_INTEGER_HPP__ #define MSGPACK_TYPE_INT_HPP__
#include "msgpack/object.hpp" #include "msgpack/object.hpp"
#include <limits> #include <limits>
@@ -37,7 +37,7 @@ namespace detail {
{ throw type_error(); } { throw type_error(); }
return o.via.u64; return o.via.u64;
} else if(o.type == type::NEGATIVE_INTEGER) { } else if(o.type == type::NEGATIVE_INTEGER) {
if(o.via.i64 < (int64_t)-std::numeric_limits<T>::max()) if(o.via.i64 < (int64_t)std::numeric_limits<T>::min())
{ throw type_error(); } { throw type_error(); }
return o.via.i64; return o.via.i64;
} }
@@ -143,5 +143,5 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const unsigned long long&
} // namespace msgpack } // namespace msgpack
#endif /* msgpack/type/integer.hpp */ #endif /* msgpack/type/int.hpp */

56
cpp/type/list.hpp Normal file
View File

@@ -0,0 +1,56 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_LIST_HPP__
#define MSGPACK_TYPE_LIST_HPP__
#include "msgpack/object.hpp"
#include <list>
namespace msgpack {
template <typename T>
inline std::list<T>& operator>> (object o, std::list<T>& v)
{
if(o.type != type::ARRAY) { throw type_error(); }
v.resize(o.via.array.size);
object* p = o.via.array.ptr;
object* const pend = o.via.array.ptr + o.via.array.size;
typename std::list<T>::iterator it = v.begin();
for(; p < pend; ++p, ++it) {
p->convert(&*it);
}
return v;
}
template <typename Stream, typename T>
inline packer<Stream>& operator<< (packer<Stream>& o, const std::list<T>& v)
{
o.pack_array(v.size());
for(typename std::list<T>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(*it);
}
return o;
}
} // namespace msgpack
#endif /* msgpack/type/list.hpp */

50
cpp/type/pair.hpp Normal file
View File

@@ -0,0 +1,50 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_PAIR_HPP__
#define MSGPACK_TYPE_PAIR_HPP__
#include "msgpack/object.hpp"
#include <utility>
namespace msgpack {
template <typename T1, typename T2>
inline std::pair<T1, T2>& operator>> (object o, std::pair<T1, T2>& v)
{
if(o.type != type::ARRAY) { throw type_error(); }
if(o.via.array.size != 2) { throw type_error(); }
o.via.array.ptr[0].convert(&v.first);
o.via.array.ptr[1].convert(&v.second);
return v;
}
template <typename Stream, typename T1, typename T2>
inline packer<Stream>& operator<< (packer<Stream>& o, const std::pair<T1, T2>& v)
{
o.pack_array(2);
o.pack(v.first);
o.pack(v.second);
return o;
}
} // namespace msgpack
#endif /* msgpack/type/pair.hpp */

View File

@@ -69,16 +69,6 @@ inline type::raw_ref& operator>> (object o, type::raw_ref& v)
return v; return v;
} }
inline std::string& operator>> (object o, std::string& v)
{
type::raw_ref r;
o >> r;
v.assign(r.ptr, r.size);
return v;
}
template <typename Stream> template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const type::raw_ref& v) inline packer<Stream>& operator<< (packer<Stream>& o, const type::raw_ref& v)
{ {
@@ -88,15 +78,6 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const type::raw_ref& v)
} }
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const std::string& v)
{
o.pack_raw(v.size());
o.pack_raw_body(v.data(), v.size());
return o;
}
} // namespace msgpack } // namespace msgpack
#endif /* msgpack/type/raw.hpp */ #endif /* msgpack/type/raw.hpp */

55
cpp/type/set.hpp Normal file
View File

@@ -0,0 +1,55 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_SET_HPP__
#define MSGPACK_TYPE_SET_HPP__
#include "msgpack/object.hpp"
#include <set>
namespace msgpack {
template <typename T>
inline std::set<T>& operator>> (object o, std::set<T>& v)
{
if(o.type != type::ARRAY) { throw type_error(); }
object* p = o.via.array.ptr + o.via.array.size;
object* const pbegin = o.via.array.ptr;
while(p > pbegin) {
--p;
v.insert(p->as<T>());
}
return v;
}
template <typename Stream, typename T>
inline packer<Stream>& operator<< (packer<Stream>& o, const std::set<T>& v)
{
o.pack_array(v.size());
for(typename std::set<T>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(*it);
}
return o;
}
} // namespace msgpack
#endif /* msgpack/type/set.hpp */

46
cpp/type/string.hpp Normal file
View File

@@ -0,0 +1,46 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef MSGPACK_TYPE_STRING_HPP__
#define MSGPACK_TYPE_STRING_HPP__
#include "msgpack/object.hpp"
#include <string>
namespace msgpack {
inline std::string& operator>> (object o, std::string& v)
{
if(o.type != type::RAW) { throw type_error(); }
v.assign(o.via.raw.ptr, o.via.raw.size);
return v;
}
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const std::string& v)
{
o.pack_raw(v.size());
o.pack_raw_body(v.data(), v.size());
return o;
}
} // namespace msgpack
#endif /* msgpack/type/string.hpp */

View File

@@ -64,7 +64,6 @@ struct tuple_type<const T&> {
typedef const T& transparent_reference; typedef const T& transparent_reference;
}; };
<%0.upto(GENERATION_LIMIT) {|i|%> <%0.upto(GENERATION_LIMIT) {|i|%>
<%0.upto(i) {|j|%> <%0.upto(i) {|j|%>
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>> template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
@@ -78,7 +77,6 @@ private:
<%}%> <%}%>
<%}%> <%}%>
<%0.upto(GENERATION_LIMIT) {|i|%> <%0.upto(GENERATION_LIMIT) {|i|%>
<%0.upto(i) {|j|%> <%0.upto(i) {|j|%>
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>> template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
@@ -91,16 +89,6 @@ private:
<%}%> <%}%>
<%}%> <%}%>
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<A0>::transparent_reference a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference a<%=j%><%}%>)
{
return tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>(a0<%1.upto(i) {|j|%>, a<%=j%><%}%>);
}
<%}%>
template <> template <>
struct tuple<> { struct tuple<> {
typedef tuple<> value_type; typedef tuple<> value_type;
@@ -122,6 +110,18 @@ struct tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
}; };
<%}%> <%}%>
inline tuple<> make_tuple()
{
return tuple<>();
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<A0>::transparent_reference a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference a<%=j%><%}%>)
{
return tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>(a0<%1.upto(i) {|j|%>, a<%=j%><%}%>);
}
<%}%>
} // namespace type } // namespace type
@@ -144,7 +144,6 @@ type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& operator>> (
} }
<%}%> <%}%>
template <typename Stream> template <typename Stream>
const packer<Stream>& operator<< ( const packer<Stream>& operator<< (
packer<Stream>& o, packer<Stream>& o,
@@ -164,7 +163,6 @@ const packer<Stream>& operator<< (
} }
<%}%> <%}%>
} // namespace msgpack } // namespace msgpack
#endif /* msgpack/type/tuple.hpp */ #endif /* msgpack/type/tuple.hpp */

View File

@@ -15,8 +15,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
#ifndef MSGPACK_TYPE_ARRAY_HPP__ #ifndef MSGPACK_TYPE_VECTOR_HPP__
#define MSGPACK_TYPE_ARRAY_HPP__ #define MSGPACK_TYPE_VECTOR_HPP__
#include "msgpack/object.hpp" #include "msgpack/object.hpp"
#include <vector> #include <vector>
@@ -38,7 +38,6 @@ inline std::vector<T>& operator>> (object o, std::vector<T>& v)
return v; return v;
} }
template <typename Stream, typename T> template <typename Stream, typename T>
inline packer<Stream>& operator<< (packer<Stream>& o, const std::vector<T>& v) inline packer<Stream>& operator<< (packer<Stream>& o, const std::vector<T>& v)
{ {
@@ -53,5 +52,5 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const std::vector<T>& v)
} // namespace msgpack } // namespace msgpack
#endif /* msgpack/type/array.hpp */ #endif /* msgpack/type/vector.hpp */

View File

@@ -22,14 +22,14 @@ public:
ssize_t count = ssize_t count =
read(m_sock, m_pac.buffer(), m_pac.buffer_capacity()); read(m_sock, m_pac.buffer(), m_pac.buffer_capacity());
if(count < 0) { if(count <= 0) {
if(count == 0) {
throw std::runtime_error("connection closed");
}
if(errno == EAGAIN || errno == EINTR) { if(errno == EAGAIN || errno == EINTR) {
return; return;
} else {
throw std::runtime_error(strerror(errno));
} }
} else if(count == 0) { throw std::runtime_error(strerror(errno));
throw std::runtime_error("connection closed");
} }
m_pac.buffer_consumed(count); m_pac.buffer_consumed(count);