From 2b3f7e4b90b5787dbe8b4b40dcfc806bcb3f014e Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Tue, 23 Jun 2015 22:14:00 +0200 Subject: Create tag_string.h --- include/libnbt.h | 1 + include/tag_primitive.h | 6 ++--- include/tag_string.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 include/tag_string.h (limited to 'include') diff --git a/include/libnbt.h b/include/libnbt.h index 7eb0d1341f..4105be7560 100644 --- a/include/libnbt.h +++ b/include/libnbt.h @@ -21,5 +21,6 @@ #define LIBNBT_H_INCLUDED #include "tag_primitive.h" +#include "tag_string.h" #endif // LIBNBT_H_INCLUDED diff --git a/include/tag_primitive.h b/include/tag_primitive.h index 397ea64da3..f5fab1bdf9 100644 --- a/include/tag_primitive.h +++ b/include/tag_primitive.h @@ -44,13 +44,13 @@ public: tag_primitive(T value = 0); - tag_primitive& operator=(T value); - void set(T value); - operator T&(); operator T() const; T get() const; + tag_primitive& operator=(T value); + void set(T value); + tag_type get_type() const noexcept override; private: diff --git a/include/tag_string.h b/include/tag_string.h new file mode 100644 index 0000000000..1e4c76ae6c --- /dev/null +++ b/include/tag_string.h @@ -0,0 +1,59 @@ +/* + * 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 . + */ +#ifndef TAG_STRING_H_INCLUDED +#define TAG_STRING_H_INCLUDED + +#include "tag.h" +#include + +namespace nbt +{ + +///Contains a UTF-8 string +class tag_string : public tag +{ +public: + ///The type of the tag + static constexpr tag_type type = tag_type::String; + + tag_string(const std::string& str); + tag_string(std::string&& str = ""); + + bool operator==(const std::string& rhs) const; + bool operator!=(const std::string& rhs) const; + + operator std::string&(); + operator const std::string&() const; + const std::string& get() const; + + tag_string& operator=(const std::string& str); + tag_string& operator=(std::string&& str); + void set(const std::string& str); + void set(std::string&& str); + + tag_type get_type() const noexcept override; + +private: + std::string value; +}; + +} + +#endif // TAG_STRING_H_INCLUDED -- cgit 0.0.5-2-1-g0f52