mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 18:29:53 +00:00
update pack/unpack routines
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@100 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
This commit is contained in:
parent
81a771094d
commit
a114f4a5a5
32 changed files with 503 additions and 366 deletions
|
|
@ -111,7 +111,7 @@ struct tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
|||
tuple() {}
|
||||
tuple(typename tuple_type<A0>::transparent_reference _a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference _a<%=j%><%}%>) :
|
||||
a0(_a0)<%1.upto(i) {|j|%>, a<%=j%>(_a<%=j%>)<%}%> {}
|
||||
tuple(object o) { convert(*this, o); }
|
||||
tuple(object o) { o.convert(this); }
|
||||
template <int N> typename tuple_element<value_type, N>::reference get()
|
||||
{ return tuple_element<value_type, N>(*this).get(); }
|
||||
template <int N> typename const_tuple_element<value_type, N>::const_reference get() const
|
||||
|
|
@ -138,7 +138,7 @@ type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& operator>> (
|
|||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.via.container.size < <%=i+1%>) { throw type_error(); }
|
||||
<%0.upto(i) {|j|%>
|
||||
convert<A<%=j%>>(v.template get<<%=j%>>(), o.via.container.ptr[<%=j%>]);<%}%>
|
||||
o.via.container.ptr[<%=j%>].convert<A<%=j%>>(&v.template get<<%=j%>>());<%}%>
|
||||
return v;
|
||||
}
|
||||
<%}%>
|
||||
|
|
@ -158,7 +158,7 @@ const packer<Stream>& operator<< (
|
|||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
|
||||
o.pack_array(<%=i+1%>);
|
||||
<%0.upto(i) {|j|%>
|
||||
pack(o, v.template get<<%=j%>>());<%}%>
|
||||
o.pack(v.template get<<%=j%>>());<%}%>
|
||||
return o;
|
||||
}
|
||||
<%}%>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue