summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorljfa-ag <ljfa-ag@web.de>2015-07-22 15:20:32 +0200
committerljfa-ag <ljfa-ag@web.de>2015-07-22 15:20:32 +0200
commit473f094be33ccd92c003ec25c9a9f940629ecdc9 (patch)
tree4849f963d8d8f64fb52971b4f5ac34b11e655c9a
parent35041b1d15c0068779e090f6b094a98d92f232d2 (diff)
downloadProject-Tick-473f094be33ccd92c003ec25c9a9f940629ecdc9.tar.gz
Project-Tick-473f094be33ccd92c003ec25c9a9f940629ecdc9.zip
Add operator<< for tag_type
-rw-r--r--include/tag.h5
-rw-r--r--src/tag.cpp22
2 files changed, 26 insertions, 1 deletions
diff --git a/include/tag.h b/include/tag.h
index b972a16da6..63125f1dc5 100644
--- a/include/tag.h
+++ b/include/tag.h
@@ -21,6 +21,7 @@
#define TAG_H_INCLUDED
#include <cstdint>
+#include <iosfwd>
#include <memory>
namespace nbt
@@ -41,7 +42,7 @@ enum class tag_type : int8_t
List = 9,
Compound = 10,
Int_Array = 11,
- Null = -1
+ Null = -1 ///< Used to denote empty @ref value s
};
///Base class for all NBT tag classes
@@ -75,6 +76,8 @@ private:
virtual bool equals(const tag& rhs) const = 0;
};
+std::ostream& operator<<(std::ostream& os, tag_type tt);
+
}
#endif // TAG_H_INCLUDED
diff --git a/src/tag.cpp b/src/tag.cpp
index da5c3fa68e..76c850f3c8 100644
--- a/src/tag.cpp
+++ b/src/tag.cpp
@@ -18,6 +18,7 @@
* along with libnbt++. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tag.h"
+#include <ostream>
#include <typeinfo>
namespace nbt
@@ -40,4 +41,25 @@ bool operator!=(const tag& lhs, const tag& rhs)
return !(lhs == rhs);
}
+std::ostream& operator<<(std::ostream& os, tag_type tt)
+{
+ switch(tt)
+ {
+ case tag_type::End: return os << "end";
+ case tag_type::Byte: return os << "byte";
+ case tag_type::Short: return os << "short";
+ case tag_type::Int: return os << "int";
+ case tag_type::Long: return os << "long";
+ case tag_type::Float: return os << "float";
+ case tag_type::Double: return os << "double";
+ case tag_type::Byte_Array: return os << "byte_array";
+ case tag_type::List: return os << "list";
+ case tag_type::Compound: return os << "compound";
+ case tag_type::Int_Array: return os << "int_array";
+ case tag_type::Null: return os << "null";
+
+ default: return os << "invalid";
+ }
+}
+
}