Website Summary Files Commits Branches @commit @diff @stats
path: root / spasm / src / string.hpp
blob: 8ffb2147c0911dca84d30a38f07c2071c68be954 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

#include <string>

namespace SpasmImpl
{
typedef std::string SPString;

class SPStringValue
{
   public:
    explicit SPStringValue(SPString s) : m_Value(std::move(s)) {}

    SPStringValue(const SPStringValue&) = delete;
    SPStringValue(SPStringValue&&) = default;
    SPStringValue& operator=(const SPStringValue&) = delete;
    SPStringValue& operator=(SPStringValue&&) = default;

    const SPString& GetValue() const { return m_Value; }

    bool operator==(const SPStringValue& rhs) const
    {
        return m_Value == rhs.m_Value;
    }

    bool operator==(const SPString& rhs) const { return m_Value == rhs; }

   private:
    SPString m_Value;
};
}  // namespace SpasmImpl

namespace std
{
template <>
struct hash<SpasmImpl::SPStringValue>
{
    size_t operator()(const SpasmImpl::SPStringValue& v) const
    {
        return std::hash<SpasmImpl::SPString>{}(v.GetValue());
    }
};
}  // namespace std