From 5d5bee49928e36d552c8df62bb820af82bd24032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 23 Sep 2015 01:21:19 +0200 Subject: GH-1238 re-integrate nbt library --- depends/libnbtplusplus | 1 + depends/libnbtplusplus/src/tag.cpp | 105 ------------------------------------- 2 files changed, 1 insertion(+), 105 deletions(-) create mode 160000 depends/libnbtplusplus delete mode 100644 depends/libnbtplusplus/src/tag.cpp (limited to 'depends/libnbtplusplus/src/tag.cpp') diff --git a/depends/libnbtplusplus b/depends/libnbtplusplus new file mode 160000 index 00000000..9d17b0a9 --- /dev/null +++ b/depends/libnbtplusplus @@ -0,0 +1 @@ +Subproject commit 9d17b0a9b93e684a5ac6cac8f70d9a7909a877cf diff --git a/depends/libnbtplusplus/src/tag.cpp b/depends/libnbtplusplus/src/tag.cpp deleted file mode 100644 index df4d8cb5..00000000 --- a/depends/libnbtplusplus/src/tag.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * libnbt++ - A library for the Minecraft Named Binary Tag format. - * Copyright (C) 2013, 2015 ljfa-ag - * - * This file is part of libnbt++. - * - * libnbt++ is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * libnbt++ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with libnbt++. If not, see . - */ -#include "tag.h" -#include "nbt_tags.h" -#include "text/json_formatter.h" -#include -#include -#include -#include - -namespace nbt -{ - -static_assert(std::numeric_limits::is_iec559 && std::numeric_limits::is_iec559, - "The floating point values for NBT must conform to IEC 559/IEEE 754"); - -bool is_valid_type(int type, bool allow_end) -{ - return (allow_end ? 0 : 1) <= type && type <= 11; -} - -std::unique_ptr tag::clone() && -{ - return std::move(*this).move_clone(); -} - -std::unique_ptr tag::create(tag_type type) -{ - switch(type) - { - case tag_type::Byte: return make_unique(); - case tag_type::Short: return make_unique(); - case tag_type::Int: return make_unique(); - case tag_type::Long: return make_unique(); - case tag_type::Float: return make_unique(); - case tag_type::Double: return make_unique(); - case tag_type::Byte_Array: return make_unique(); - case tag_type::String: return make_unique(); - case tag_type::List: return make_unique(); - case tag_type::Compound: return make_unique(); - case tag_type::Int_Array: return make_unique(); - - default: throw std::invalid_argument("Invalid tag type"); - } -} - -bool operator==(const tag& lhs, const tag& rhs) -{ - if(typeid(lhs) != typeid(rhs)) - return false; - return lhs.equals(rhs); -} - -bool operator!=(const tag& lhs, const tag& rhs) -{ - return !(lhs == rhs); -} - -std::ostream& operator<<(std::ostream& os, tag_type tt) -{ - switch(tt) - { - case tag_type::End: return os << "end"; - case tag_type::Byte: return os << "byte"; - case tag_type::Short: return os << "short"; - case tag_type::Int: return os << "int"; - case tag_type::Long: return os << "long"; - case tag_type::Float: return os << "float"; - case tag_type::Double: return os << "double"; - case tag_type::Byte_Array: return os << "byte_array"; - case tag_type::String: return os << "string"; - case tag_type::List: return os << "list"; - case tag_type::Compound: return os << "compound"; - case tag_type::Int_Array: return os << "int_array"; - case tag_type::Null: return os << "null"; - - default: return os << "invalid"; - } -} - -std::ostream& operator<<(std::ostream& os, const tag& t) -{ - static const text::json_formatter formatter; - formatter.print(os, t); - return os; -} - -} -- cgit v1.2.3