Sha256: de23f28ae22da2df4e158b36f562dbd8156314b6adea774ca8f3469744ab39f8

Contents?: true

Size: 1.72 KB

Versions: 26

Compression:

Stored size: 1.72 KB

Contents

//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2015 KONDO Takatoshi
//
//    Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//    http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MSGPACK_V1_CHECK_CONTAINER_SIZE_HPP
#define MSGPACK_V1_CHECK_CONTAINER_SIZE_HPP

#include "msgpack/v1/adaptor/check_container_size_decl.hpp"
#include <stdexcept>

namespace msgpack {

/// @cond
MSGPACK_API_VERSION_NAMESPACE(v1) {
/// @endcond

struct container_size_overflow : public std::runtime_error {
    explicit container_size_overflow(const std::string& msg)
        :std::runtime_error(msg) {}
#if !defined(MSGPACK_USE_CPP03)
    explicit container_size_overflow(const char* msg):
        std::runtime_error(msg) {}
#endif // !defined(MSGPACK_USE_CPP03)
};

namespace detail {

template <std::size_t N>
inline void check_container_size(std::size_t size) {
    if (size > 0xffffffff) throw container_size_overflow("container size overflow");
}

template <>
inline void check_container_size<4>(std::size_t /*size*/) {
}

template <std::size_t N>
inline void check_container_size_for_ext(std::size_t size) {
    if (size > 0xffffffff) throw container_size_overflow("container size overflow");
}

template <>
inline void check_container_size_for_ext<4>(std::size_t size) {
    if (size > 0xfffffffe) throw container_size_overflow("container size overflow");
}

} // namespace detail

template <typename T>
inline uint32_t checked_get_container_size(T size) {
    detail::check_container_size<sizeof(T)>(size);
    return static_cast<uint32_t>(size);
}


/// @cond
}  // MSGPACK_API_VERSION_NAMESPACE(v1)
/// @endcond

}  // namespace msgpack

#endif // MSGPACK_V1_CHECK_CONTAINER_SIZE_HPP

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
rroonga-9.0.7-x64-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp
rroonga-9.0.7-x86-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp
script_core-0.1.1 ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp
rroonga-9.0.3-x64-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp
rroonga-9.0.3-x86-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp
rroonga-9.0.2-x64-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp
rroonga-9.0.2-x86-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp
script_core-0.1.0 ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp
script_core-0.0.6 ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp
script_core-0.0.5 ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp
script_core-0.0.4 ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp
script_core-0.0.3 ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp
script_core-0.0.2 ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp
script_core-0.0.1 ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp
rroonga-7.1.1-x64-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp
rroonga-7.1.1-x86-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp
rroonga-7.0.2-x86-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp
rroonga-7.0.2-x64-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp
rroonga-6.1.3-x64-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp
rroonga-6.1.3-x86-mingw32 vendor/local/include/msgpack/v1/adaptor/check_container_size.hpp