[DEV] add etk::to_string

This commit is contained in:
Edouard DUPIN 2015-03-05 11:20:24 +01:00
parent 63b327cb67
commit d1cf215113
2 changed files with 33 additions and 0 deletions

View File

@ -87,3 +87,19 @@ std::vector<enum audio::channel> audio::getListChannelFromString(const std::stri
}
return out;
}
namespace etk {
template<> std::string to_string<enum audio::channel>(const enum audio::channel& _variable) {
return listValues[_variable];
}
template <> bool from_string<enum audio::channel>(enum audio::channel& _variableRet, const std::string& _value) {
for (int32_t iii=0; iii<listValuesSize; ++iii) {
if (_value == listValues[iii]) {
_variableRet = static_cast<enum audio::channel>(iii);
return true;
}
}
_variableRet = audio::channel_unknow;
return false;
}
}

View File

@ -81,3 +81,20 @@ uint32_t audio::getFormatBytes(audio::format _format) {
AUDIO_ERROR("undefined format : " << _format);
return 0;
}
namespace etk {
template<> std::string to_string<enum audio::format>(const enum audio::format& _variable) {
return listValues[_variable];
}
template <> bool from_string<enum audio::format>(enum audio::format& _variableRet, const std::string& _value) {
for (int32_t iii=0; iii<listValuesSize; ++iii) {
if (_value == listValues[iii]) {
_variableRet = static_cast<enum audio::format>(iii);
return true;
}
}
_variableRet = audio::format_unknow;
return false;
}
}