denc(s[i], p);
}
}
+
+ // nohead
+ template<typename U=T>
+ static typename std::enable_if<sizeof(U) &&
+ !traits::featured>::type
+ encode_nohead(const std::vector<T>& s, buffer::list::contiguous_appender& p) {
+ for (const T& e : s) {
+ denc(e, p);
+ }
+ }
+ template<typename U=T>
+ static typename std::enable_if<sizeof(U) &&
+ traits::featured>::type
+ encode_nohead(const std::vector<T>& s, buffer::list::contiguous_appender& p,
+ uint64_t f) {
+ for (const T& e : s) {
+ denc(e, p, f);
+ }
+ }
+ static void decode_nohead(size_t num, std::vector<T>& s,
+ buffer::ptr::iterator& p) {
+ s.resize(num);
+ for (unsigned i=0; i<num; ++i) {
+ denc(s[i], p);
+ }
+ }
+
};
//
s.insert(temp);
}
}
+
+ // nohead
+ template<typename U=T>
+ static typename std::enable_if<sizeof(U) &&
+ !traits::featured>::type
+ encode_nohead(const std::set<T>& s, buffer::list::contiguous_appender& p) {
+ for (const T& e : s) {
+ denc(e, p);
+ }
+ }
+ template<typename U=T>
+ static typename std::enable_if<sizeof(U) &&
+ traits::featured>::type
+ encode_nohead(const std::set<T>& s, buffer::list::contiguous_appender& p,
+ uint64_t f) {
+ for (const T& e : s) {
+ denc(e, p, f);
+ }
+ }
+ static void decode_nohead(size_t num, std::set<T>& s,
+ buffer::ptr::iterator& p) {
+ s.clear();
+ while (num--) {
+ T temp;
+ denc(temp, p);
+ s.insert(temp);
+ }
+ }
+
};
//
denc(v[key], p);
}
}
+
+ // nohead variants
+ template<typename AA=A>
+ static typename std::enable_if<sizeof(AA) &&
+ !featured>::type
+ encode_nohead(const std::map<A,B>& v, bufferlist::contiguous_appender& p) {
+ for (const auto& i : v) {
+ denc(i.first, p);
+ denc(i.second, p);
+ }
+ }
+ template<typename AA=A>
+ static typename std::enable_if<sizeof(AA) &&
+ featured, void>::type
+ encode_nohead(const std::map<A,B>& v, bufferlist::contiguous_appender& p,
+ uint64_t f) {
+ for (const auto& i : v) {
+ denc(i.first, p, f);
+ denc(i.second, p, f);
+ }
+ }
+ static void decode_nohead(size_t num, std::map<A,B>& v,
+ buffer::ptr::iterator& p) {
+ v.clear();
+ A key;
+ while (num--) {
+ denc(key, p);
+ denc(v[key], p);
+ }
+ }
};
p.advance((ssize_t)cp.get_offset());
}
+// nohead variants
+template<typename T, typename traits=denc_traits<T>>
+inline typename std::enable_if<traits::supported == 1 &&
+ !traits::featured>::type encode_nohead(
+ const T& o,
+ bufferlist& bl)
+{
+ size_t len = 0;
+ traits::bound_encode(o, len);
+ auto a = bl.get_contiguous_appender(len);
+ traits::encode_nohead(o, a);
+}
+
+template<typename T, typename traits=denc_traits<T>>
+inline typename std::enable_if<traits::supported == 1 &&
+ !traits::featured>::type decode_nohead(
+ size_t num,
+ T& o,
+ bufferlist::iterator& p)
+{
+ if (!num)
+ return;
+ if (p.end())
+ throw buffer::end_of_buffer();
+ bufferptr tmp;
+ bufferlist::iterator t = p;
+ t.copy_shallow(p.get_bl().length() - p.get_off(), tmp);
+ auto cp = tmp.begin();
+ traits::decode_nohead(num, o, cp);
+ p.advance((ssize_t)cp.get_offset());
+}
+
+
// ----------------------------------------------------------------
// DENC
}
}
-template<class T>
-inline void encode_nohead(const std::set<T>& s, bufferlist& bl)
+template<class T, class C, typename traits=denc_traits<T>>
+inline typename std::enable_if<!traits::supported>::type
+ encode_nohead(const std::set<T>& s, bufferlist& bl)
{
for (typename std::set<T>::const_iterator p = s.begin(); p != s.end(); ++p)
encode(*p, bl);
}
-template<class T>
-inline void decode_nohead(int len, std::set<T>& s, bufferlist::iterator& p)
+template<class T, class C, typename traits=denc_traits<T>>
+inline typename std::enable_if<!traits::supported>::type
+ decode_nohead(int len, std::set<T>& s, bufferlist::iterator& p)
{
for (int i=0; i<len; i++) {
T v;
decode(v[i], p);
}
-template<class T>
-inline void encode_nohead(const std::vector<T>& v, bufferlist& bl)
+template<class T, typename traits=denc_traits<T>>
+inline typename std::enable_if<!traits::supported>::type
+ encode_nohead(const std::vector<T>& v, bufferlist& bl)
{
for (typename std::vector<T>::const_iterator p = v.begin(); p != v.end(); ++p)
encode(*p, bl);
}
-template<class T>
-inline void decode_nohead(int len, std::vector<T>& v, bufferlist::iterator& p)
+template<class T, typename traits=denc_traits<T>>
+inline typename std::enable_if<!traits::supported>::type
+ decode_nohead(int len, std::vector<T>& v, bufferlist::iterator& p)
{
v.resize(len);
for (__u32 i=0; i<v.size(); i++)
decode(m[k], p);
}
}
-template<class T, class U>
-inline void encode_nohead(const std::map<T,U>& m, bufferlist& bl)
+template<class T, class U,
+ typename t_traits=denc_traits<T>, typename u_traits=denc_traits<U>>
+inline typename std::enable_if<!t_traits::supported ||
+ !u_traits::supported>::type
+ encode_nohead(const std::map<T,U>& m, bufferlist& bl)
{
for (typename std::map<T,U>::const_iterator p = m.begin(); p != m.end(); ++p) {
encode(p->first, bl);
encode(p->second, bl);
}
}
-template<class T, class U>
-inline void encode_nohead(const std::map<T,U>& m, bufferlist& bl, uint64_t features)
+template<class T, class U,
+ typename t_traits=denc_traits<T>, typename u_traits=denc_traits<U>>
+inline typename std::enable_if<!t_traits::supported ||
+ !u_traits::supported>::type
+ encode_nohead(const std::map<T,U>& m, bufferlist& bl, uint64_t features)
{
for (typename std::map<T,U>::const_iterator p = m.begin(); p != m.end(); ++p) {
encode(p->first, bl, features);
encode(p->second, bl, features);
}
}
-template<class T, class U>
-inline void decode_nohead(int n, std::map<T,U>& m, bufferlist::iterator& p)
+template<class T, class U,
+ typename t_traits=denc_traits<T>, typename u_traits=denc_traits<U>>
+inline typename std::enable_if<!t_traits::supported ||
+ !u_traits::supported>::type
+ decode_nohead(int n, std::map<T,U>& m, bufferlist::iterator& p)
{
m.clear();
while (n--) {