From 935d29a30d42ceb3dba002518646c442363bc871 Mon Sep 17 00:00:00 2001 From: DankParrot Date: Wed, 12 Aug 2020 18:50:49 -0700 Subject: [PATCH] NBT: Bool operator --- src/nbt/NBT.cpp | 5 +++++ src/nbt/NBT.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/nbt/NBT.cpp b/src/nbt/NBT.cpp index 218faef..8aa86a4 100644 --- a/src/nbt/NBT.cpp +++ b/src/nbt/NBT.cpp @@ -137,6 +137,11 @@ namespace NBT return nbt_dump_ascii(m_node); } + Tag::operator bool() const + { + return m_node != NULL && m_node->type != TAG_INVALID; + } + std::ostream& operator<<(std::ostream& stream, const Tag& tag) { return stream << tag.ToString(); diff --git a/src/nbt/NBT.h b/src/nbt/NBT.h index a925798..f937407 100644 --- a/src/nbt/NBT.h +++ b/src/nbt/NBT.h @@ -45,6 +45,8 @@ namespace NBT const DataBuffer GetData() const; const char* ToString() const; + + operator bool() const; }; // Operator overload for ostream