primitive_detail.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * libnbt++ - A library for the Minecraft Named Binary Tag format.
  3. * Copyright (C) 2013, 2015 ljfa-ag
  4. *
  5. * This file is part of libnbt++.
  6. *
  7. * libnbt++ is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * libnbt++ is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with libnbt++. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef PRIMITIVE_DETAIL_H_INCLUDED
  21. #define PRIMITIVE_DETAIL_H_INCLUDED
  22. #include <type_traits>
  23. ///@cond
  24. namespace nbt
  25. {
  26. namespace detail
  27. {
  28. ///Meta-struct that holds the tag_type value for a specific primitive type
  29. template<class T> struct get_primitive_type
  30. { static_assert(sizeof(T) != sizeof(T), "Invalid type paramter for tag_primitive, can only use types that NBT uses"); };
  31. template<> struct get_primitive_type<int8_t> : public std::integral_constant<tag_type, tag_type::Byte> {};
  32. template<> struct get_primitive_type<int16_t> : public std::integral_constant<tag_type, tag_type::Short> {};
  33. template<> struct get_primitive_type<int32_t> : public std::integral_constant<tag_type, tag_type::Int> {};
  34. template<> struct get_primitive_type<int64_t> : public std::integral_constant<tag_type, tag_type::Long> {};
  35. template<> struct get_primitive_type<float> : public std::integral_constant<tag_type, tag_type::Float> {};
  36. template<> struct get_primitive_type<double> : public std::integral_constant<tag_type, tag_type::Double> {};
  37. }
  38. }
  39. ///@endcond
  40. #endif // PRIMITIVE_DETAIL_H_INCLUDED