Skip to content

Commit

Permalink
add implicit conversions to std::string and const char *
Browse files Browse the repository at this point in the history
  • Loading branch information
skaupper committed Feb 27, 2017
1 parent f2ca5a2 commit d96de59
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/bkengine/Keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace bkengine
Keys(const std::string &keyString) : keyString(keyString) {}
bool operator==(const Keys &) const;
bool operator!=(const Keys &) const;

operator const std::string() const;
operator const char *() const;
std::string toString() const;

static Keys UNKNOWN;
Expand Down Expand Up @@ -167,6 +170,9 @@ namespace bkengine
Buttons(const std::string &buttonString) : buttonString(buttonString) {}
bool operator==(const Buttons &) const;
bool operator!=(const Buttons &) const;

operator const std::string() const;
operator const char *() const;
std::string toString();

static Buttons UNKNOWN;
Expand Down
20 changes: 20 additions & 0 deletions src/Keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@ bool Keys::operator!=(const Keys &key) const
return !(key == *this);
}

Keys::operator const std::string() const
{
return keyString;
}

Keys::operator const char *() const
{
return keyString.c_str();
}

std::string Keys::toString() const
{
return keyString;
Expand All @@ -173,6 +183,16 @@ bool Buttons::operator!=(const Buttons &button) const
return !(button == *this);
}

Buttons::operator const std::string() const
{
return buttonString;
}

Buttons::operator const char *() const
{
return buttonString.c_str();
}

std::string Buttons::toString()
{
return buttonString;
Expand Down

0 comments on commit d96de59

Please sign in to comment.