summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorljfa-ag <ljfa-ag@web.de>2015-06-21 10:55:43 +0200
committerljfa-ag <ljfa-ag@web.de>2015-06-21 11:17:20 +0200
commit483714e26ef6fca97353ca34654e5588bc61dda0 (patch)
tree6f266e108b4b3a02923520cdf8d1bbbaf50157b2
parent8458a8d07f5990c33c15acfa2ac316b0a9d6ede0 (diff)
downloadProject-Tick-483714e26ef6fca97353ca34654e5588bc61dda0.tar.gz
Project-Tick-483714e26ef6fca97353ca34654e5588bc61dda0.zip
Add tag.h
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt12
-rw-r--r--include/tag.h37
-rw-r--r--test/CMakeLists.txt6
-rw-r--r--test/microtest.h14
-rw-r--r--test/nbttest.cpp9
6 files changed, 79 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 6c2e80ec8d..a7f172c739 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,4 @@
/lib
/obj
/build
-/doxygen/html
+/doxygen
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000000..9f105284ea
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 2.6)
+project(libnbt++)
+set(libnbt++_VERSION_MAJOR 2)
+set(libnbt++_VERSION_MINOR 0)
+
+add_definitions(-std=c++11)
+include_directories(include)
+add_library(nbt++ STATIC
+ )
+
+enable_testing()
+add_subdirectory(test)
diff --git a/include/tag.h b/include/tag.h
new file mode 100644
index 0000000000..a17406ff2b
--- /dev/null
+++ b/include/tag.h
@@ -0,0 +1,37 @@
+#ifndef TAG_H_INCLUDED
+#define TAG_H_INCLUDED
+
+#include <cstdint>
+
+namespace nbt
+{
+
+/** Tag type values used in the binary format */
+enum class tag_type : int8_t
+{
+ End = 0,
+ Byte = 1,
+ Short = 2,
+ Int = 3,
+ Long = 4,
+ Float = 5,
+ Double = 6,
+ Byte_Array = 7,
+ String = 8,
+ List = 9,
+ Compound = 10,
+ Int_Array = 11
+};
+
+/** Base class for all tag classes */
+class tag
+{
+public:
+ virtual ~tag() noexcept {}
+
+ virtual tag_type get_type() const noexcept = 0;
+};
+
+}
+
+#endif // TAG_H_INCLUDED
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000000..04672d2666
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,6 @@
+enable_testing()
+include_directories(${libnbt++_SOURCE_DIR}/include)
+
+add_executable(nbttest nbttest.cpp)
+target_link_libraries(nbttest nbt++)
+add_test(nbttest nbttest)
diff --git a/test/microtest.h b/test/microtest.h
new file mode 100644
index 0000000000..8691ebb748
--- /dev/null
+++ b/test/microtest.h
@@ -0,0 +1,14 @@
+#ifndef MICROTEST_H
+#define MICROTEST_H
+
+#include <type_traits>
+
+#define FAIL_TEST { std::cerr << "Assertion failed at " __FILE__ ":" << __LINE__ << std::endl; \
+ exit(EXIT_FAILURE); }
+#define ASSERT(expr) { if(!(expr)) FAIL_TEST }
+#define EXPECT_EXCEPTION(expr, type) { \
+ try { (expr); std::cerr << "Expected " #type " to be thrown" << std::endl; FAIL_TEST } \
+ catch(type&) {} \
+ catch(...) { std::cerr << "Expected " #type " to be thrown" << std::endl; FAIL_TEST } }
+
+#endif
diff --git a/test/nbttest.cpp b/test/nbttest.cpp
new file mode 100644
index 0000000000..eead43efd0
--- /dev/null
+++ b/test/nbttest.cpp
@@ -0,0 +1,9 @@
+#include "microtest.h"
+#include "tag.h"
+#include <cstdlib>
+#include <iostream>
+
+int main()
+{
+ return EXIT_SUCCESS;
+}