Mercurial > hg > piper-cpp
diff bits/DefaultPluginOutputIdMapper.h @ 65:2d866edd79d5
Merge from noexcept branch
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 23 Sep 2016 14:23:10 +0100 |
parents | 8a4bcb3dc3a6 |
children |
line wrap: on
line diff
--- a/bits/DefaultPluginOutputIdMapper.h Fri Sep 23 14:20:29 2016 +0100 +++ b/bits/DefaultPluginOutputIdMapper.h Fri Sep 23 14:23:10 2016 +0100 @@ -49,19 +49,18 @@ } } - virtual int idToIndex(std::string outputId) const { + virtual int idToIndex(std::string outputId) const noexcept { int n = int(m_ids.size()); for (int i = 0; i < n; ++i) { if (outputId == m_ids[i]) { return i; } } - //!!! todo: this should in fact throw, or otherwise return an error - return 0; + return -1; } - virtual std::string indexToId(int index) const { - //!!! todo: this should in fact throw, or otherwise return an error + virtual std::string indexToId(int index) const noexcept { + if (index < 0 || size_t(index) >= m_ids.size()) return ""; return m_ids[index]; }