From 4b9bb2ab4894c52f60baba3273c27948ad022292 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 20 Jul 2018 23:09:33 +0200 Subject: Add Tag print functions and nbtdump tool --- src/NBT/CompoundTag.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/NBT/CompoundTag.hpp') diff --git a/src/NBT/CompoundTag.hpp b/src/NBT/CompoundTag.hpp index 39fa25d..6be0479 100644 --- a/src/NBT/CompoundTag.hpp +++ b/src/NBT/CompoundTag.hpp @@ -54,6 +54,20 @@ public: return Type::Compound; } + virtual void print(std::ostream& os, const std::string &indent) const { + os << "{" << std::endl; + + std::string inner = indent + " "; + + for (const auto &item : *this) { + os << inner << item.first << ": " << item.second->getType() << " "; + item.second->print(os, inner); + os << std::endl; + } + + os << indent << "}"; + } + template std::shared_ptr get(const std::string &key) const { auto it = find(key); if (it == end()) -- cgit v1.2.3