summaryrefslogtreecommitdiff
path: root/src/io
diff options
context:
space:
mode:
authorljfa <ljfa-ag@web.de>2015-08-07 15:24:13 +0200
committerljfa <ljfa-ag@web.de>2015-08-07 15:31:36 +0200
commit20fb31d81b3dfcf66867b4660a887f7b113f4833 (patch)
tree6ac975a3acce213080c5673962c37edd1fb95956 /src/io
parentc596c4f7ae529e2dd9976c1963634825595c2218 (diff)
downloadProject-Tick-20fb31d81b3dfcf66867b4660a887f7b113f4833.tar.gz
Project-Tick-20fb31d81b3dfcf66867b4660a887f7b113f4833.zip
Add read_compound method
Diffstat (limited to 'src/io')
-rw-r--r--src/io/stream_reader.cpp15
1 files changed, 15 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>.
*/
#include "io/stream_reader.h"
+#include "make_unique.h"
+#include "tag_compound.h"
#include <istream>
namespace nbt
@@ -39,6 +41,19 @@ endian::endian stream_reader::get_endian() const
return endian;
}
+std::pair<std::string, std::unique_ptr<tag_compound>> 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<tag_compound>();
+ comp->read_payload(*this);
+ return {std::move(key), std::move(comp)};
+}
+
std::pair<std::string, std::unique_ptr<tag>> stream_reader::read_tag()
{
tag_type type = read_type();