From 20fb31d81b3dfcf66867b4660a887f7b113f4833 Mon Sep 17 00:00:00 2001 From: ljfa Date: Fri, 7 Aug 2015 15:24:13 +0200 Subject: Add read_compound method --- src/io/stream_reader.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/io/stream_reader.cpp b/src/io/stream_reader.cpp index 541a416d83..15f29dba1d 100644 --- a/src/io/stream_reader.cpp +++ b/src/io/stream_reader.cpp @@ -18,6 +18,8 @@ * along with libnbt++. If not, see . */ #include "io/stream_reader.h" +#include "make_unique.h" +#include "tag_compound.h" #include namespace nbt @@ -39,6 +41,19 @@ endian::endian stream_reader::get_endian() const return endian; } +std::pair> stream_reader::read_compound() +{ + if(read_type() != tag_type::Compound) + { + is.setstate(std::ios::failbit); + throw input_error("Tag is not a compound"); + } + std::string key = read_string(); + auto comp = make_unique(); + comp->read_payload(*this); + return {std::move(key), std::move(comp)}; +} + std::pair> stream_reader::read_tag() { tag_type type = read_type(); -- cgit 0.0.5-2-1-g0f52