summaryrefslogtreecommitdiff
path: root/src/metadata.h
diff options
context:
space:
mode:
authorrubenwardy <rubenwardy@gmail.com>2017-01-31 19:49:01 +0000
committerrubenwardy <rubenwardy@gmail.com>2017-02-04 22:07:55 +0000
commitf2aa2c6a986dec47856c49ae5f54fbf3c688e027 (patch)
treed12fbb3e62776efaafe059a7fdbfa9938e7298cd /src/metadata.h
parentc2e7b1f57941cb34cb7e3d71dc040fad53a64e3e (diff)
downloadminetest-f2aa2c6a986dec47856c49ae5f54fbf3c688e027.tar.gz
minetest-f2aa2c6a986dec47856c49ae5f54fbf3c688e027.tar.bz2
minetest-f2aa2c6a986dec47856c49ae5f54fbf3c688e027.zip
Add ItemStack key-value meta storage
Diffstat (limited to 'src/metadata.h')
-rw-r--r--src/metadata.h38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/metadata.h b/src/metadata.h
index a629c0615..4bb3c2ee7 100644
--- a/src/metadata.h
+++ b/src/metadata.h
@@ -25,35 +25,37 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <vector>
#include "util/string.h"
-/*
- NodeMetadata stores arbitary amounts of data for special blocks.
- Used for furnaces, chests and signs.
-
- There are two interaction methods: inventory menu and text input.
- Only one can be used for a single metadata, thus only inventory OR
- text input should exist in a metadata.
-*/
-
-class Inventory;
-class IItemDefManager;
-
class Metadata
{
public:
- void clear();
- bool empty() const;
+ virtual ~Metadata() {}
+
+ virtual void clear();
+ virtual bool empty() const;
- // Generic key/value store
+ bool operator==(const Metadata &other) const;
+ inline bool operator!=(const Metadata &other) const
+ {
+ return !(*this == other);
+ }
+
+ //
+ // Key-value related
+ //
+
+ size_t size() const;
+ bool contains(const std::string &name) const;
const std::string &getString(const std::string &name, u16 recursion = 0) const;
void setString(const std::string &name, const std::string &var);
- // Support variable names in values
- const std::string &resolveString(const std::string &str, u16 recursion = 0) const;
const StringMap &getStrings() const
{
return m_stringvars;
}
-private:
+ // Add support for variable names in values
+ const std::string &resolveString(const std::string &str, u16 recursion = 0) const;
+protected:
StringMap m_stringvars;
+
};
#endif