From 8163afbfaeb65cc37885f4e905c0d0ea586ba3f5 Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 1 Aug 2016 18:20:51 +0000 Subject: [PATCH] CheckedSerialize now public, fix in type mismatch throw in Value git-svn-id: svn://ultimatepp.org/upp/trunk@10133 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Util.h | 2 ++ uppsrc/Core/Value.hpp | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/uppsrc/Core/Util.h b/uppsrc/Core/Util.h index b1b737b2d..d819e678f 100644 --- a/uppsrc/Core/Util.h +++ b/uppsrc/Core/Util.h @@ -404,6 +404,8 @@ public: // ------------------- Advanced streaming -------------------- +void CheckedSerialize(const Callback1 serialize, Stream& stream, int version = Null); + bool Load(Callback1 serialize, Stream& stream, int version = Null); bool Store(Callback1 serialize, Stream& stream, int version = Null); bool LoadFromFile(Callback1 serialize, const char *file = NULL, int version = Null); diff --git a/uppsrc/Core/Value.hpp b/uppsrc/Core/Value.hpp index 816a0d3a8..d7adfeb3f 100644 --- a/uppsrc/Core/Value.hpp +++ b/uppsrc/Core/Value.hpp @@ -244,11 +244,9 @@ inline const T& Value::To() const if(x) return x->Get(); } - else { - ASSERT(t < 255); - if(Is((byte)t)) - return GetSmallRaw(); - } + else + if(t < 255 && Is((byte)t)) + return GetSmallRaw(); throw ValueTypeError(String().Cat() << "Invalid value conversion: " << GetName() << " -> " << typeid(T).name(), *this, t);