diff options
| author | ljfa-ag <ljfa-ag@web.de> | 2015-08-11 11:16:10 +0200 |
|---|---|---|
| committer | ljfa-ag <ljfa-ag@web.de> | 2015-08-11 11:19:53 +0200 |
| commit | b5f3570924b49eb8564b68b02e5dbd18f0ad9a06 (patch) | |
| tree | 681efd2bb049d88d780352372d89c4c59caaeffa /src | |
| parent | 7122475522a290e39fb32999efc5ed20aef0a315 (diff) | |
| download | Project-Tick-b5f3570924b49eb8564b68b02e5dbd18f0ad9a06.tar.gz Project-Tick-b5f3570924b49eb8564b68b02e5dbd18f0ad9a06.zip | |
Inline crtp_tag and tag_primitive methods
Diffstat (limited to 'src')
| -rw-r--r-- | src/tag.cpp | 4 | ||||
| -rw-r--r-- | src/tag_primitive.cpp | 111 |
2 files changed, 4 insertions, 111 deletions
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 <limits> #include <ostream> #include <stdexcept> #include <typeinfo> @@ -27,6 +28,9 @@ namespace nbt { +static_assert(std::numeric_limits<float>::is_iec559 && std::numeric_limits<double>::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 <http://www.gnu.org/licenses/>. - */ -#include "tag_primitive.h" -#include "io/stream_reader.h" -#include <limits> -#include <sstream> - -namespace nbt -{ - -static_assert(std::numeric_limits<float>::is_iec559 && std::numeric_limits<double>::is_iec559, - "The floating point values for NBT must conform to IEC 559/IEEE 754"); - -template<class T> -tag_primitive<T>::tag_primitive(T val) noexcept: - value(val) -{} - -template<class T> -tag_primitive<T>& tag_primitive<T>::operator=(T val) -{ - value = val; - return *this; -} - -template<class T> -void tag_primitive<T>::set(T val) -{ - value = val; -} - -template<class T> -tag_primitive<T>::operator T&() -{ - return value; -} - -template<class T> -tag_primitive<T>::operator T() const -{ - return value; -} - -template<class T> -T tag_primitive<T>::get() const -{ - return value; -} - -template<class T> -void tag_primitive<T>::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<class T> -bool operator==(const tag_primitive<T>& lhs, const tag_primitive<T>& rhs) -{ - return lhs.get() == rhs.get(); -} - -template<class T> -bool operator!=(const tag_primitive<T>& lhs, const tag_primitive<T>& rhs) -{ - return !(lhs == rhs); -} - -//Enforce template instantiations -template class tag_primitive<int8_t>; -template class tag_primitive<int16_t>; -template class tag_primitive<int32_t>; -template class tag_primitive<int64_t>; -template class tag_primitive<float>; -template class tag_primitive<double>; -template bool operator==<int8_t> (const tag_primitive<int8_t>& , const tag_primitive<int8_t>&); -template bool operator==<int16_t>(const tag_primitive<int16_t>&, const tag_primitive<int16_t>&); -template bool operator==<int32_t>(const tag_primitive<int32_t>&, const tag_primitive<int32_t>&); -template bool operator==<int64_t>(const tag_primitive<int64_t>&, const tag_primitive<int64_t>&); -template bool operator==<float> (const tag_primitive<float>& , const tag_primitive<float>&); -template bool operator==<double> (const tag_primitive<double>& , const tag_primitive<double>&); -template bool operator!=<int8_t> (const tag_primitive<int8_t>& , const tag_primitive<int8_t>&); -template bool operator!=<int16_t>(const tag_primitive<int16_t>&, const tag_primitive<int16_t>&); -template bool operator!=<int32_t>(const tag_primitive<int32_t>&, const tag_primitive<int32_t>&); -template bool operator!=<int64_t>(const tag_primitive<int64_t>&, const tag_primitive<int64_t>&); -template bool operator!=<float> (const tag_primitive<float>& , const tag_primitive<float>&); -template bool operator!=<double> (const tag_primitive<double>& , const tag_primitive<double>&); - -} |
