From b5f3570924b49eb8564b68b02e5dbd18f0ad9a06 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Tue, 11 Aug 2015 11:16:10 +0200 Subject: Inline crtp_tag and tag_primitive methods --- src/tag.cpp | 4 ++ src/tag_primitive.cpp | 111 -------------------------------------------------- 2 files changed, 4 insertions(+), 111 deletions(-) delete mode 100644 src/tag_primitive.cpp (limited to 'src') diff --git a/src/tag.cpp b/src/tag.cpp index 5b6f1142e2..b0825b52e6 100644 --- a/src/tag.cpp +++ b/src/tag.cpp @@ -20,6 +20,7 @@ #include "tag.h" #include "nbt_tags.h" #include "text/json_formatter.h" +#include #include #include #include @@ -27,6 +28,9 @@ 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; diff --git a/src/tag_primitive.cpp b/src/tag_primitive.cpp deleted file mode 100644 index dd07fea662..0000000000 --- a/src/tag_primitive.cpp +++ /dev/null @@ -1,111 +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_primitive.h" -#include "io/stream_reader.h" -#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"); - -template -tag_primitive::tag_primitive(T val) noexcept: - value(val) -{} - -template -tag_primitive& tag_primitive::operator=(T val) -{ - value = val; - return *this; -} - -template -void tag_primitive::set(T val) -{ - value = val; -} - -template -tag_primitive::operator T&() -{ - return value; -} - -template -tag_primitive::operator T() const -{ - return value; -} - -template -T tag_primitive::get() const -{ - return value; -} - -template -void tag_primitive::read_payload(io::stream_reader& reader) -{ - reader.read_num(value); - if(!reader.get_istr()) - { - std::ostringstream str; - str << "Error reading tag_" << type; - throw io::input_error(str.str()); - } -} - -template -bool operator==(const tag_primitive& lhs, const tag_primitive& rhs) -{ - return lhs.get() == rhs.get(); -} - -template -bool operator!=(const tag_primitive& lhs, const tag_primitive& rhs) -{ - return !(lhs == rhs); -} - -//Enforce template instantiations -template class tag_primitive; -template class tag_primitive; -template class tag_primitive; -template class tag_primitive; -template class tag_primitive; -template class tag_primitive; -template bool operator== (const tag_primitive& , const tag_primitive&); -template bool operator==(const tag_primitive&, const tag_primitive&); -template bool operator==(const tag_primitive&, const tag_primitive&); -template bool operator==(const tag_primitive&, const tag_primitive&); -template bool operator== (const tag_primitive& , const tag_primitive&); -template bool operator== (const tag_primitive& , const tag_primitive&); -template bool operator!= (const tag_primitive& , const tag_primitive&); -template bool operator!=(const tag_primitive&, const tag_primitive&); -template bool operator!=(const tag_primitive&, const tag_primitive&); -template bool operator!=(const tag_primitive&, const tag_primitive&); -template bool operator!= (const tag_primitive& , const tag_primitive&); -template bool operator!= (const tag_primitive& , const tag_primitive&); - -} -- cgit 0.0.5-2-1-g0f52