From 5390c8e5a84aa4bbbf87981dbe13f60b0ee96655 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Mon, 29 Jun 2015 23:12:51 +0200 Subject: Implement tag_compound --- src/tag_compound.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/tag_compound.cpp (limited to 'src') 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 . + */ +#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(rhs).tags; +} + +} -- cgit 0.0.5-2-1-g0f52