memgraph/storage/model/label.hpp

39 lines
777 B
C++
Raw Normal View History

2015-12-06 23:37:42 +08:00
#pragma once
#include <stdint.h>
#include <ostream>
#include "utils/total_ordering.hpp"
class Label : public TotalOrdering<Label>
{
public:
2016-01-02 19:20:51 +08:00
Label(const std::string& name) : name(name) {}
Label(std::string&& name) : name(std::move(name)) {}
Label(const Label&) = default;
Label(Label&&) = default;
2015-12-06 23:37:42 +08:00
friend bool operator<(const Label& lhs, const Label& rhs)
{
2016-01-02 19:20:51 +08:00
return lhs.name < rhs.name;
2015-12-06 23:37:42 +08:00
}
friend bool operator==(const Label& lhs, const Label& rhs)
{
2016-01-02 19:20:51 +08:00
return lhs.name == rhs.name;
2015-12-06 23:37:42 +08:00
}
friend std::ostream& operator<<(std::ostream& stream, const Label& label)
{
2016-01-02 19:20:51 +08:00
return stream << label.name;
2015-12-06 23:37:42 +08:00
}
operator const std::string&() const
{
2016-01-02 19:20:51 +08:00
return name;
2015-12-06 23:37:42 +08:00
}
private:
2016-01-02 19:20:51 +08:00
std::string name;
2015-12-06 23:37:42 +08:00
};