infinipaint/src/GUIStuff/GUIManagerID.hpp

41 lines
910 B
C++
Raw Normal View History

2025-07-06 20:43:53 +03:00
#pragma once
#include <stack>
#include <Helpers/Hashes.hpp>
namespace GUIStuff {
struct GUIManagerID {
GUIManagerID() = default;
GUIManagerID(int64_t numID);
GUIManagerID(const std::string& strID);
bool operator==(const GUIManagerID& other) const;
bool idIsStr;
std::string idStr;
int64_t idNum = 0;
};
typedef std::vector<GUIManagerID> GUIManagerIDStack;
}
template <> struct std::hash<GUIStuff::GUIManagerID> {
size_t operator()(const GUIStuff::GUIManagerID& v) const
{
if(v.idIsStr)
return std::hash<std::string>{}(v.idStr);
else
return std::hash<uint64_t>{}(v.idNum);
}
};
template <> struct std::hash<GUIStuff::GUIManagerIDStack> {
size_t operator()(const GUIStuff::GUIManagerIDStack& v) const
{
uint64_t h = 0;
for(const auto& i : v)
hash_combine(h, i);
return h;
}
};