summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorljfa-ag <ljfa-ag@web.de>2015-06-29 23:12:51 +0200
committerljfa-ag <ljfa-ag@web.de>2015-06-29 23:12:51 +0200
commit5390c8e5a84aa4bbbf87981dbe13f60b0ee96655 (patch)
tree8f3916d31c683cc6bae3ab65279a23e3688187f8
parentb81ebe6cba109a215254bfae074f8fc6f334eca8 (diff)
downloadProject-Tick-5390c8e5a84aa4bbbf87981dbe13f60b0ee96655.tar.gz
Project-Tick-5390c8e5a84aa4bbbf87981dbe13f60b0ee96655.zip
Implement tag_compound
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/tag_compound.cpp77
2 files changed, 78 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 576f0a5b5e..0884cf2a11 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,7 @@ set(libnbt++_VERSION_MINOR 0)
add_definitions(-std=c++11)
include_directories(include)
add_library(nbt++ STATIC
+ src/tag_compound.cpp
src/tag_string.cpp)
enable_testing()
diff --git a/src/tag_compound.cpp b/src/tag_compound.cpp
new file mode 100644
index 0000000000..af0d685826
--- /dev/null
+++ b/src/tag_compound.cpp
@@ -0,0 +1,77 @@
+/*
+ * libnbt++ - A library for the Minecraft Named Binary Tag format.
+ * Copyright (C) 2013, 2015 ljfa-ag
+ *
+ * This file is part of libnbt++.
+ *
+ * libnbt++ is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libnbt++ is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libnbt++. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "tag_compound.h"
+
+namespace nbt
+{
+
+value& tag_compound::at(const std::string& key)
+{
+ return tags.at(key);
+}
+
+const value& tag_compound::at(const std::string& key) const
+{
+ return tags.at(key);
+}
+
+value& tag_compound::operator[](const std::string& key)
+{
+ return tags[key];
+}
+
+bool tag_compound::erase(const std::string& key)
+{
+ return tags.erase(key) != 0;
+}
+
+bool tag_compound::has_key(const std::string& key) const
+{
+ return tags.find(key) != tags.end();
+}
+
+size_t tag_compound::size() const
+{
+ return tags.size();
+}
+
+void tag_compound::clear()
+{
+ tags.clear();
+}
+
+auto tag_compound::begin() -> iterator { return tags.begin(); }
+auto tag_compound::end() -> iterator { return tags.end(); }
+auto tag_compound::begin() const -> const_iterator { return tags.begin(); }
+auto tag_compound::end() const -> const_iterator { return tags.end(); }
+auto tag_compound::cbegin() const -> const_iterator { return tags.cbegin(); }
+auto tag_compound::cend() const -> const_iterator { return tags.cend(); }
+
+tag_type tag_compound::get_type() const noexcept
+{
+ return type;
+}
+
+bool tag_compound::equals(const tag& rhs) const
+{
+ return tags == static_cast<const tag_compound&>(rhs).tags;
+}
+
+}