Added API versioning.

This commit is contained in:
Takatoshi Kondo 2014-10-12 22:48:15 +09:00
parent cd03ab62f8
commit 3ddeb08e6e
41 changed files with 261 additions and 11 deletions

View File

@ -120,6 +120,7 @@ IF (MSGPACK_ENABLE_CXX)
include/msgpack/type.hpp
include/msgpack/unpack.hpp
include/msgpack/version.hpp
include/msgpack/versioning.hpp
include/msgpack/vrefbuffer.hpp
include/msgpack/zbuffer.hpp
include/msgpack/zone.hpp

View File

@ -18,6 +18,8 @@
#ifndef MSGPACK_CPP03_DEFINE_HPP
#define MSGPACK_CPP03_DEFINE_HPP
#include "msgpack/versioning.hpp"
#define MSGPACK_DEFINE(...) \
template <typename Packer> \
void msgpack_pack(Packer& pk) const \
@ -37,6 +39,7 @@
// MSGPACK_ADD_ENUM must be used in the global namespace.
#define MSGPACK_ADD_ENUM(enum) \
namespace msgpack { \
MSGPACK_API_VERSION_NAMESPACE(v1) { \
template <> \
inline object const& operator>> (object const& o, enum& v) \
{ \
@ -58,9 +61,11 @@
} \
}; \
} \
} \
}
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
@ -141,6 +146,7 @@ define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_define(A0& a0<%1.upto(i) {|j|%>,
<%}%>
} // namespace type
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,10 +18,13 @@
#ifndef MSGPACK_CPP03_MSGPACK_TUPLE_HPP
#define MSGPACK_CPP03_MSGPACK_TUPLE_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
// FIXME operator==
@ -191,6 +194,8 @@ inline void operator<< (
}
<%}%>
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -22,6 +22,7 @@
#include <memory>
#include <vector>
#include "msgpack/versioning.hpp"
#include "msgpack/cpp_config.hpp"
#ifndef MSGPACK_ZONE_CHUNK_SIZE
@ -35,6 +36,8 @@
<% GENERATION_LIMIT = 15 %>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
class zone {
struct finalizer {
finalizer(void (*func)(void*), void* data):m_func(func), m_data(data) {}
@ -301,6 +304,8 @@ T* zone::allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>)
}
<%}%>
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP03_ZONE_HPP

View File

@ -18,11 +18,13 @@
#ifndef MSGPACK_TYPE_BOOL_HPP
#define MSGPACK_TYPE_BOOL_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <vector>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
inline object const& operator>> (object const& o, bool& v)
{
@ -49,6 +51,8 @@ inline void operator<< (object::with_zone& o, bool v)
{ static_cast<object&>(o) << v; }
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif /* msgpack/type/bool.hpp */

View File

@ -18,11 +18,14 @@
#ifndef MSGPACK_TYPE_CHAR_PTR_HPP
#define MSGPACK_TYPE_CHAR_PTR_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <cstring>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const char* v)
{
@ -50,6 +53,7 @@ inline void operator<< (object& o, const char* v)
o.via.str.size = static_cast<uint32_t>(size);
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -19,6 +19,8 @@
#ifndef MSGPACK_CPP11_ARRAY_HPP
#define MSGPACK_CPP11_ARRAY_HPP
#include "msgpack/versioning.hpp"
#include <array>
#include "msgpack/object.hpp"
@ -26,6 +28,8 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T, std::size_t N>
inline object const& operator>> (object const& o, std::array<T, N>& v) {
if(o.type != type::ARRAY) { throw type_error(); }
@ -64,6 +68,7 @@ inline void operator<< (object::with_zone& o, const std::array<T, N>& v) {
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,11 +18,14 @@
#ifndef MSGPACK_TYPE_ARRAY_CHAR_HPP
#define MSGPACK_TYPE_ARRAY_CHAR_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <array>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <std::size_t N>
inline object const& operator>> (object const& o, std::array<char, N>& v)
{
@ -69,6 +72,8 @@ inline void operator<< (object::with_zone& o, const std::array<char, N>& v)
std::memcpy(ptr, v.data(), v.size());
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_ARRAY_CHAR_HPP

View File

@ -19,6 +19,8 @@
#ifndef MSGPACK_CPP11_FORWARD_LIST_HPP
#define MSGPACK_CPP11_FORWARD_LIST_HPP
#include "msgpack/versioning.hpp"
#include <forward_list>
#include "msgpack/object.hpp"
@ -26,6 +28,8 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
inline object const& operator>> (object const& o, std::forward_list<T>& v)
{
@ -64,6 +68,7 @@ inline void operator<< (object::with_zone& o, const std::forward_list<T>& v)
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,6 +18,8 @@
#ifndef MSGPACK_CPP11_TUPLE_HPP
#define MSGPACK_CPP11_TUPLE_HPP
#include "msgpack/versioning.hpp"
#include <tuple>
#include "msgpack/object.hpp"
@ -25,6 +27,8 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
// --- Pack ( from tuple to packer stream ---
template <typename Stream, typename Tuple, std::size_t N>
struct StdTuplePacker {
@ -140,6 +144,8 @@ inline void operator<< (
StdTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
}
} // msgpack
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP11_TUPLE_HPP

View File

@ -18,11 +18,13 @@
#ifndef MSGPACK_TYPE_DEQUE_HPP
#define MSGPACK_TYPE_DEQUE_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <deque>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
inline object const& operator>> (object const& o, std::deque<T>& v)
@ -70,6 +72,7 @@ inline void operator<< (object::with_zone& o, const std::deque<T>& v)
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,6 +18,8 @@
#ifndef MSGPACK_CPP03_DEFINE_HPP
#define MSGPACK_CPP03_DEFINE_HPP
#include "msgpack/versioning.hpp"
#define MSGPACK_DEFINE(...) \
template <typename Packer> \
void msgpack_pack(Packer& pk) const \
@ -37,6 +39,7 @@
// MSGPACK_ADD_ENUM must be used in the global namespace.
#define MSGPACK_ADD_ENUM(enum) \
namespace msgpack { \
MSGPACK_API_VERSION_NAMESPACE(v1) { \
template <> \
inline object const& operator>> (object const& o, enum& v) \
{ \
@ -58,9 +61,11 @@
} \
}; \
} \
} \
}
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
@ -3458,6 +3463,7 @@ define<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16
} // namespace type
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,10 +18,13 @@
#ifndef MSGPACK_CPP03_MSGPACK_TUPLE_HPP
#define MSGPACK_CPP03_MSGPACK_TUPLE_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
// FIXME operator==
@ -13118,6 +13121,8 @@ inline void operator<< (
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,6 +18,8 @@
#ifndef MSGPACK_CPP11_DEFINE_HPP
#define MSGPACK_CPP11_DEFINE_HPP
#include "msgpack/versioning.hpp"
#include <type_traits>
#define MSGPACK_DEFINE(...) \
@ -39,6 +41,7 @@
// MSGPACK_ADD_ENUM must be used in the global namespace.
#define MSGPACK_ADD_ENUM(enum) \
namespace msgpack { \
MSGPACK_API_VERSION_NAMESPACE(v1) { \
template <> \
inline object const& operator>> (object const& o, enum& v) \
{ \
@ -61,9 +64,11 @@
} \
}; \
} \
} \
}
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
template <typename Tuple, std::size_t N>
@ -165,6 +170,7 @@ define<Args...> make_define(Args&... args)
}
} // namespace type
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP11_DEFINE_HPP

View File

@ -18,6 +18,8 @@
#ifndef MSGPACK_CPP11_MSGPACK_TUPLE_HPP
#define MSGPACK_CPP11_MSGPACK_TUPLE_HPP
#include "msgpack/versioning.hpp"
#include <tuple>
#include "msgpack/object.hpp"
@ -25,6 +27,8 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
// tuple
using std::get;
@ -203,6 +207,8 @@ inline void operator<< (
MsgpackTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
}
} // msgpack
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP11_MSGPACK_TUPLE_HPP

View File

@ -18,11 +18,14 @@
#ifndef MSGPACK_TYPE_FIXINT_HPP
#define MSGPACK_TYPE_FIXINT_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include "msgpack/adaptor/int.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
@ -202,6 +205,8 @@ inline void operator<< (object::with_zone& o, type::fix_uint64 v)
{ static_cast<object&>(o) << v; }
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif /* msgpack/type/fixint.hpp */

View File

@ -18,11 +18,13 @@
#ifndef MSGPACK_TYPE_FLOAT_HPP
#define MSGPACK_TYPE_FLOAT_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <vector>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
// FIXME check overflow, underflow
@ -96,6 +98,8 @@ inline void operator<< (object::with_zone& o, double v)
{ static_cast<object&>(o) << v; }
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif /* msgpack/type/float.hpp */

View File

@ -18,11 +18,13 @@
#ifndef MSGPACK_TYPE_INT_HPP
#define MSGPACK_TYPE_INT_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <limits>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1){
namespace type {
namespace detail {
@ -323,6 +325,8 @@ inline void operator<< (object::with_zone& o, const unsigned long long& v)
{ static_cast<object&>(o) << v; }
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif /* msgpack/type/int.hpp */

View File

@ -18,11 +18,13 @@
#ifndef MSGPACK_TYPE_LIST_HPP
#define MSGPACK_TYPE_LIST_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <list>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
inline object const& operator>> (object const& o, std::list<T>& v)
@ -70,6 +72,7 @@ inline void operator<< (object::with_zone& o, const std::list<T>& v)
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,6 +18,7 @@
#ifndef MSGPACK_TYPE_MAP_HPP
#define MSGPACK_TYPE_MAP_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <map>
#include <vector>
@ -25,6 +26,7 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
@ -198,6 +200,7 @@ inline void operator<< (object::with_zone& o, const std::multimap<K,V>& v)
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,10 +18,13 @@
#ifndef MSGPACK_TYPE_NIL_HPP
#define MSGPACK_TYPE_NIL_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
struct nil { };
@ -58,6 +61,7 @@ inline void object::as<void>() const
convert(v);
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,11 +18,13 @@
#ifndef MSGPACK_TYPE_PAIR_HPP
#define MSGPACK_TYPE_PAIR_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <utility>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T1, typename T2>
inline object const& operator>> (object const& o, std::pair<T1, T2>& v)
@ -54,6 +56,7 @@ inline void operator<< (object::with_zone& o, const std::pair<T1, T2>& v)
p[1] = object(v.second, o.zone);
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,12 +18,15 @@
#ifndef MSGPACK_TYPE_RAW_HPP
#define MSGPACK_TYPE_RAW_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <string.h>
#include <string>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
struct raw_ref {
@ -88,6 +91,8 @@ inline void operator<< (object::with_zone& o, const type::raw_ref& v)
{ static_cast<object&>(o) << v; }
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif /* msgpack/type/raw.hpp */

View File

@ -18,11 +18,14 @@
#ifndef MSGPACK_TYPE_SET_HPP
#define MSGPACK_TYPE_SET_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <set>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
inline object const& operator>> (object const& o, std::set<T>& v)
@ -115,6 +118,7 @@ inline void operator<< (object::with_zone& o, const std::multiset<T>& v)
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,11 +18,13 @@
#ifndef MSGPACK_TYPE_STRING_HPP
#define MSGPACK_TYPE_STRING_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <string>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
inline object const& operator>> (object const& o, std::string& v)
{
@ -64,6 +66,7 @@ inline void operator<< (object& o, const std::string& v)
o.via.str.size = static_cast<uint32_t>(v.size());
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,6 +18,7 @@
#ifndef MSGPACK_TYPE_TR1_UNORDERED_MAP_HPP
#define MSGPACK_TYPE_TR1_UNORDERED_MAP_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
@ -42,6 +43,7 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename K, typename V>
inline object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_map<K, V>& v)
@ -141,6 +143,7 @@ inline void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_m
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,6 +18,7 @@
#ifndef MSGPACK_TYPE_TR1_UNORDERED_SET_HPP
#define MSGPACK_TYPE_TR1_UNORDERED_SET_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
@ -41,6 +42,7 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
inline object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_set<T>& v)
@ -133,6 +135,7 @@ inline void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_m
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,11 +18,13 @@
#ifndef MSGPACK_TYPE_VECTOR_HPP
#define MSGPACK_TYPE_VECTOR_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <vector>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
inline object const& operator>> (object const& o, std::vector<T>& v)
@ -74,6 +76,7 @@ inline void operator<< (object::with_zone& o, const std::vector<T>& v)
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,11 +18,14 @@
#ifndef MSGPACK_TYPE_VECTOR_CHAR_HPP
#define MSGPACK_TYPE_VECTOR_CHAR_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/object.hpp"
#include <vector>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
inline object const& operator>> (object const& o, std::vector<char>& v)
{
switch (o.type) {
@ -66,6 +69,8 @@ inline void operator<< (object::with_zone& o, const std::vector<char>& v)
std::memcpy(ptr, v.data(), v.size());
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_TYPE_VECTOR_CHAR_HPP

View File

@ -18,6 +18,8 @@
#ifndef MSGPACK_CPP_CONFIG_HPP
#define MSGPACK_CPP_CONFIG_HPP
#include "msgpack/versioning.hpp"
#if !defined(MSGPACK_USE_CPP03)
// If MSVC would support C++11 completely,
// then 'defined(_MSC_VER)' would replace with
@ -40,6 +42,8 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename T>
struct unique_ptr : std::auto_ptr<T> {
explicit unique_ptr(T* p = 0) throw() : std::auto_ptr<T>(p) {}
@ -69,7 +73,9 @@ template <typename T>
struct enable_if<false, T> {
};
} // msgpack
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#else // __cplusplus < 201103
@ -78,6 +84,8 @@ struct enable_if<false, T> {
#include <tuple>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
// unique_ptr
using std::unique_ptr;
// using std::make_unique; // since C++14
@ -88,7 +96,8 @@ namespace msgpack {
using std::swap;
using std::enable_if;
} // msgpack
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // __cplusplus < 201103

View File

@ -22,6 +22,7 @@
#include <memory>
#include <vector>
#include "msgpack/versioning.hpp"
#include "msgpack/cpp_config.hpp"
#ifndef MSGPACK_ZONE_CHUNK_SIZE
@ -35,6 +36,8 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
class zone {
struct finalizer {
finalizer(void (*func)(void*), void* data):m_func(func), m_data(data) {}
@ -631,6 +634,8 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP03_ZONE_HPP

View File

@ -18,6 +18,8 @@
#ifndef MSGPACK_CPP11_ZONE_HPP
#define MSGPACK_CPP11_ZONE_HPP
#include "msgpack/versioning.hpp"
#include <cstdlib>
#include <memory>
#include <vector>
@ -34,6 +36,8 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
class zone {
private:
struct finalizer {
@ -341,6 +345,8 @@ T* zone::allocate(Args... args)
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_CPP11_ZONE_HPP

View File

@ -18,11 +18,14 @@
#ifndef MSGPACK_FBUFFER_HPP__
#define MSGPACK_FBUFFER_HPP__
#include "msgpack/versioning.hpp"
#include <cstdio>
#include <stdexcept>
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
class fbuffer {
public:
@ -49,8 +52,8 @@ private:
FILE* m_file;
};
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif /* msgpack/fbuffer.hpp */

View File

@ -18,6 +18,7 @@
#ifndef MSGPACK_OBJECT_HPP
#define MSGPACK_OBJECT_HPP
#include "msgpack/versioning.hpp"
#include "object.h"
#include "pack.hpp"
#include "zone.hpp"
@ -29,6 +30,7 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
class type_error : public std::bad_cast { };
@ -568,6 +570,8 @@ inline std::ostream& operator<< (std::ostream& s, const object& o)
return s;
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#include "msgpack/type.hpp"

View File

@ -18,6 +18,8 @@
#ifndef MSGPACK_PACK_HPP
#define MSGPACK_PACK_HPP
#include "msgpack/versioning.hpp"
#include <stdexcept>
#include <limits>
#include <cstring>
@ -26,6 +28,7 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
template <typename Stream>
class packer {
@ -1018,7 +1021,8 @@ inline void packer<Stream>::pack_imp_int64(T d)
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif /* msgpack/pack.hpp */

View File

@ -18,6 +18,8 @@
#ifndef MSGPACK_SBUFFER_HPP
#define MSGPACK_SBUFFER_HPP
#include "msgpack/versioning.hpp"
#include <stdexcept>
#ifndef MSGPACK_SBUFFER_INIT_SIZE
@ -26,6 +28,7 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
class sbuffer {
public:
@ -110,8 +113,8 @@ private:
size_t m_alloc;
};
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif /* msgpack/sbuffer.hpp */

View File

@ -17,6 +17,8 @@
//
#ifndef MSGPACK_UNPACK_HPP
#define MSGPACK_UNPACK_HPP
#include "msgpack/versioning.hpp"
#include "object.hpp"
#include "zone.hpp"
#include "unpack_define.h"
@ -47,6 +49,8 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
typedef bool (*unpack_reference_func)(type::object_type, uint64_t, void*);
namespace detail {
@ -1456,6 +1460,8 @@ inline bool unpacker::default_reference_func(type::object_type /*type*/, uint64_
return true;
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -0,0 +1,77 @@
/*
* MessagePack for C++ version switcher
*
* Copyright (C) 2014 KONDO Takatoshi
*
* 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_VERSIONING_HPP
#define MSGPACK_VERSIONING_HPP
#if !defined(MSGPACK_DEFAULT_API_VERSION)
#define MSGPACK_DEFAULT_API_VERSION 1
#endif
#define MSGPACK_DEFAULT_API_NS MSGPACK_PP_CAT(v, MSGPACK_DEFAULT_API_VERSION)
#if MSGPACK_DEFAULT_API_VERSION == 1
#define MSGPACK_PP_ENABLE_NS_v1 ()
//#elif MSGPACK_DEFAULT_API_VERSION == 2
//#define MSGPACK_PP_ENABLE_NS_v2 ()
#else
#error
#endif
#define MSGPACK_PP_CAT(a, ...) MSGPACK_PP_PRIMITIVE_CAT(a, __VA_ARGS__)
#define MSGPACK_PP_PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
#define MSGPACK_PP_IIF(c) MSGPACK_PP_PRIMITIVE_CAT(MSGPACK_PP_IIF_, c)
#define MSGPACK_PP_IIF_0(t, ...) __VA_ARGS__
#define MSGPACK_PP_IIF_1(t, ...) t
#define MSGPACK_PP_PROBE(x) x, 1
#if defined(__MSC_VER)
#define MSGPACK_PP_MSVC_VA_ARGS_WORKAROUND(define, args) define args
#define MSGPACK_PP_CHECK(...) MSGPACK_PP_MSVC_VA_ARGS_WORKAROUND(MSGPACK_PP_CHECK_N, (__VA_ARGS__, 0))
#define MSGPACK_PP_CHECK_N(x, n, ...) n
#else // defined(__MSC_VER)
#define MSGPACK_PP_CHECK(...) MSGPACK_PP_CHECK_N(__VA_ARGS__, 0)
#define MSGPACK_PP_CHECK_N(x, n, ...) n
#endif // defined(__MSC_VER)
#define MSGPACK_PP_NS_ENABLED_PROBE(ns) MSGPACK_PP_NS_ENABLED_PROBE_PROXY( MSGPACK_PP_ENABLE_NS_##ns )
#define MSGPACK_PP_NS_ENABLED_PROBE_PROXY(...) MSGPACK_PP_NS_ENABLED_PROBE_PRIMIVIE(__VA_ARGS__)
#define MSGPACK_PP_NS_ENABLED_PROBE_PRIMIVIE(x) MSGPACK_PP_NS_ENABLED_PROBE_COMBINE_ x
#define MSGPACK_PP_NS_ENABLED_PROBE_COMBINE_(...) MSGPACK_PP_PROBE(~)
#define MSGPACK_PP_IS_NS_ENABLED(ns) MSGPACK_PP_CHECK(MSGPACK_PP_NS_ENABLED_PROBE(ns))
#if __cplusplus < 201103
#define MSGPACK_API_VERSION_NAMESPACE(ns) MSGPACK_PP_IIF(MSGPACK_PP_IS_NS_ENABLED(ns)) \
(namespace ns{}; using namespace ns; namespace ns, \
namespace ns)
#else // __cplusplus < 201103
#define MSGPACK_API_VERSION_NAMESPACE(ns) MSGPACK_PP_IIF(MSGPACK_PP_IS_NS_ENABLED(ns)) \
(inline namespace ns, namespace ns)
#endif // __cplusplus < 201103
#endif // MSGPACK_VERSIONING_HPP

View File

@ -18,6 +18,8 @@
#ifndef MSGPACK_VREFBUFFER_HPP
#define MSGPACK_VREFBUFFER_HPP
#include "msgpack/versioning.hpp"
#include <stdexcept>
#ifndef MSGPACK_VREFBUFFER_REF_SIZE
@ -39,6 +41,8 @@ struct iovec {
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace detail {
// int64, uint64, double
std::size_t const packer_max_buffer_size = 9;
@ -274,6 +278,7 @@ private:
};
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -18,6 +18,8 @@
#ifndef MSGPACK_ZBUFFER_HPP
#define MSGPACK_ZBUFFER_HPP
#include "msgpack/versioning.hpp"
#include <stdexcept>
#include <zlib.h>
@ -31,6 +33,7 @@
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
class zbuffer {
public:
@ -155,8 +158,8 @@ private:
size_t m_init_size;
};
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif /* msgpack/zbuffer.hpp */

View File

@ -89,6 +89,7 @@ nobase_include_HEADERS += \
../include/msgpack/type.hpp \
../include/msgpack/unpack.hpp \
../include/msgpack/version.hpp \
../include/msgpack/versioning.hpp \
../include/msgpack/vrefbuffer.hpp \
../include/msgpack/zbuffer.hpp \
../include/msgpack/zone.hpp