summaryrefslogtreecommitdiff
path: root/src/value.cpp
diff options
context:
space:
mode:
authorYongDo-Hyun <froster12@naver.com>2025-12-27 13:05:30 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-03-27 19:57:09 +0300
commitb6d496b1e83853cd272a8ffdea273c59bbf4b87c (patch)
tree249509918badba23d7d45af345ef7c2a06212b44 /src/value.cpp
parent37a3f01be6fb37d6cb04ae12216b5d74cef2aca9 (diff)
downloadProject-Tick-b6d496b1e83853cd272a8ffdea273c59bbf4b87c.tar.gz
Project-Tick-b6d496b1e83853cd272a8ffdea273c59bbf4b87c.zip
feat: add numeric tag creation methods and corresponding tests for value assignments
Signed-off-by: YongDo-Hyun <froster12@naver.com>
Diffstat (limited to 'src/value.cpp')
-rw-r--r--src/value.cpp19
1 files changed, 1 insertions, 18 deletions
diff --git a/src/value.cpp b/src/value.cpp
index f07e28d82c..bf0ffcad78 100644
--- a/src/value.cpp
+++ b/src/value.cpp
@@ -67,30 +67,13 @@ void value::set(tag&& t)
namespace // helper functions local to this translation unit
{
template<typename T>
- std::unique_ptr<tag> make_numeric_tag(tag_type type, T val)
- {
- switch(type)
- {
- case tag_type::Byte: return std::unique_ptr<tag>(new tag_byte(val));
- case tag_type::Short: return std::unique_ptr<tag>(new tag_short(val));
- case tag_type::Int: return std::unique_ptr<tag>(new tag_int(val));
- case tag_type::Long: return std::unique_ptr<tag>(new tag_long(val));
- case tag_type::Float: return std::unique_ptr<tag>(new tag_float(val));
- case tag_type::Double: return std::unique_ptr<tag>(new tag_double(val));
- default: return nullptr;
- }
- }
-
- template<typename T>
void assign_numeric_impl(std::unique_ptr<tag>& tag_ptr, T val,
tag_type default_type)
{
using nbt::tag_type;
if(!tag_ptr)
{
- tag_ptr = make_numeric_tag(default_type, val);
- if(!tag_ptr)
- throw std::invalid_argument("Invalid default_type");
+ tag_ptr = tag::create(default_type, val);
return;
}