summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/io/stream_reader.h20
-rw-r--r--include/io/stream_writer.h12
2 files changed, 32 insertions, 0 deletions
diff --git a/include/io/stream_reader.h b/include/io/stream_reader.h
index 926d2453c6..877f6498ed 100644
--- a/include/io/stream_reader.h
+++ b/include/io/stream_reader.h
@@ -40,7 +40,27 @@ class input_error : public std::runtime_error
};
/**
+* @brief Reads a named tag from the stream, making sure that it is a compound
+* @param is the stream to read from
+* @param e the byte order of the source data. The Java edition
+* of Minecraft uses Big Endian, the Pocket edition uses Little Endian
+* @throw input_error on failure, or if the tag in the stream is not a compound
+*/
+std::pair<std::string, std::unique_ptr<tag_compound>> read_compound(std::istream& is, endian::endian e = endian::big);
+
+/**
+* @brief Reads a named tag from the stream
+* @param is the stream to read from
+* @param e the byte order of the source data. The Java edition
+* of Minecraft uses Big Endian, the Pocket edition uses Little Endian
+* @throw input_error on failure
+*/
+std::pair<std::string, std::unique_ptr<tag>> read_tag(std::istream& is, endian::endian e = endian::big);
+
+/**
* @brief Helper class for reading NBT tags from input streams
+ *
+ * Can be reused to read multiple tags
*/
class stream_reader
{
diff --git a/include/io/stream_writer.h b/include/io/stream_writer.h
index c94a7d4ece..c771426bb3 100644
--- a/include/io/stream_writer.h
+++ b/include/io/stream_writer.h
@@ -37,7 +37,19 @@ class output_error : public std::runtime_error
};*/
/**
+* @brief Writes a named tag into the stream, including the tag type
+* @param key the name of the tag
+* @param t the tag
+* @param os the stream to write to
+* @param e the byte order of the written data. The Java edition
+* of Minecraft uses Big Endian, the Pocket edition uses Little Endian
+*/
+void write_tag(const std::string& key, const tag& t, std::ostream& os, endian::endian e = endian::big);
+
+/**
* @brief Helper class for writing NBT tags to output streams
+ *
+ * Can be reused to write multiple tags
*/
class stream_writer
{