Created
June 21, 2013 21:44
-
-
Save Shaptic/5834567 to your computer and use it in GitHub Desktop.
Implementation of the header gist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Option.hpp" | |
COption::COption(){} | |
COption::COption(const string_t& value) : | |
m_value(value) {} | |
COption::COption(const COption& Opt) : | |
m_value(Opt.m_value) {} | |
COption& COption::operator=(const COption& Opt) | |
{ | |
m_value = Opt.m_value; | |
return (*this); | |
} | |
COption& COption::operator=(const string_t& name) | |
{ | |
m_value = name; | |
return (*this); | |
} | |
COption& COption::operator=(const char* name) | |
{ | |
m_value = string_t(name); | |
return (*this); | |
} | |
COption& COption::operator=(const bool name) | |
{ | |
m_value = name ? "1" : "0"; | |
return (*this); | |
} | |
bool COption::operator==(const COption& value) const | |
{ | |
return (value.m_value == m_value); | |
} | |
bool COption::operator==(const string_t& value) const | |
{ | |
return (value == m_value); | |
} | |
bool COption::operator==(const bool value) const | |
{ | |
return value ? m_value != "0" : m_value == "0"; | |
} | |
bool COption::operator==(const float value) const | |
{ | |
return math::compf(std::stof(m_value), value); | |
} | |
std::ostream& util::operator<<(std::ostream& o, const COption& Opt) | |
{ | |
return (o << Opt.m_value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment