specialize std::hash for border::side and get rid of border::default

This commit is contained in:
Thomas Fussell 2016-08-01 18:47:17 -04:00
parent 4234a62b8b
commit 69bd89da63
2 changed files with 29 additions and 18 deletions

View File

@ -36,14 +36,8 @@
namespace xlnt { namespace xlnt {
/// <summary> enum class XLNT_CLASS border_side
/// Describes the border style of a particular cell.
/// </summary>
class XLNT_CLASS border : public hashable
{ {
public:
enum class XLNT_CLASS side
{
start, start,
end, end,
top, top,
@ -51,7 +45,32 @@ public:
diagonal, diagonal,
vertical, vertical,
horizontal horizontal
}; };
} // namespace xlnt
namespace std {
template<>
struct hash<xlnt::border_side>
{
size_t operator()(const xlnt::border_side &k) const
{
return static_cast<std::size_t>(k);
}
};
} // namepsace std
namespace xlnt {
/// <summary>
/// Describes the border style of a particular cell.
/// </summary>
class XLNT_CLASS border : public hashable
{
public:
using side = border_side;
class XLNT_CLASS border_property class XLNT_CLASS border_property
{ {
@ -72,14 +91,11 @@ public:
border_style style_; border_style style_;
}; };
static border default();
static const std::unordered_map<side, std::string> &get_side_names(); static const std::unordered_map<side, std::string> &get_side_names();
border(); border();
bool has_side(side s) const; bool has_side(side s) const;
border_property &get_side(side s);
const border_property &get_side(side s) const; const border_property &get_side(side s) const;
void set_side(side s, const border_property &prop); void set_side(side s, const border_property &prop);

View File

@ -69,11 +69,6 @@ void border::border_property::set_style(border_style s)
style_ = s; style_ = s;
} }
border border::default()
{
return border();
}
border::border() border::border()
{ {
sides_ = sides_ =