Noise: Prevent unittest crash caused by division by zero
[oweals/minetest.git] / src / metadata.h
index a96bfc408d20333850da7fb9ff4e24f69b0a3907..a8270b4c4f8d7a4c64e3a2be8978c44b108258cd 100644 (file)
@@ -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;
-
-       // Generic key/value store
-       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
-       std::string resolveString(const std::string &str, u16 recursion = 0) const;
+       virtual ~Metadata() {}
+
+       virtual void clear();
+       virtual bool empty() const;
+
+       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;
+       virtual bool setString(const std::string &name, const std::string &var);
        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