Mercurial > hg > piper-cpp
diff bits/DefaultPluginOutputIdMapper.h @ 60:8a4bcb3dc3a6
Replace exceptions throughout the JSON-handling and adapter code with string-arg error handling. No longer need exception handling enabled in Emscripten (with its consequent runtime overhead - though we still need to check whether this error handling regime is actually faster).
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Tue, 20 Sep 2016 16:35:47 +0100 |
parents | f4244a2d55ac |
children |
line wrap: on
line diff
--- a/bits/DefaultPluginOutputIdMapper.h Mon Sep 19 15:52:38 2016 +0100 +++ b/bits/DefaultPluginOutputIdMapper.h Tue Sep 20 16:35:47 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]; }