font_set: add operator== and 'swap' impl

This commit is contained in:
artemp 2014-05-27 12:33:20 +01:00
parent d25abed9d2
commit f6a79ecaec
2 changed files with 23 additions and 8 deletions

View File

@ -35,16 +35,22 @@ namespace mapnik
class MAPNIK_DECL font_set
{
public:
// ctor/copy/move/dtor
font_set(std::string const& name);
font_set(font_set const& rhs);
font_set& operator=(font_set const& rhs);
font_set(font_set &&) = default;
font_set& operator=(font_set rhs);
~font_set();
// comparison
bool operator==(font_set const& rhs) const;
std::size_t size() const;
void set_name(std::string const& name);
std::string const& get_name() const;
void add_face_name(std::string const& face_name);
std::vector<std::string> const& get_face_names() const;
~font_set();
private:
friend void swap(font_set & lhs, font_set & rhs);
std::string name_;
std::vector<std::string> face_names_;
};

View File

@ -36,16 +36,25 @@ font_set::font_set(font_set const& rhs)
: name_(rhs.name_),
face_names_(rhs.face_names_) {}
font_set& font_set::operator=(font_set const& other)
font_set& font_set::operator=(font_set other)
{
if (this == &other)
return *this;
name_ = other.name_;
face_names_ = other.face_names_;
swap(*this, other);
return *this;
}
void swap(font_set & lhs, font_set & rhs)
{
using std::swap;
swap(lhs.name_, rhs.name_);
swap(lhs.face_names_, rhs.face_names_);
}
bool font_set::operator==(font_set const& rhs) const
{
return name_ == rhs.name_ &&
face_names_ == rhs.face_names_;
}
font_set::~font_set() {}
std::size_t font_set::size() const