comparison 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
comparison
equal deleted inserted replaced
64:85ec33975434 65:2d866edd79d5
47 for (const auto &d: outputs) { 47 for (const auto &d: outputs) {
48 m_ids.push_back(d.identifier); 48 m_ids.push_back(d.identifier);
49 } 49 }
50 } 50 }
51 51
52 virtual int idToIndex(std::string outputId) const { 52 virtual int idToIndex(std::string outputId) const noexcept {
53 int n = int(m_ids.size()); 53 int n = int(m_ids.size());
54 for (int i = 0; i < n; ++i) { 54 for (int i = 0; i < n; ++i) {
55 if (outputId == m_ids[i]) { 55 if (outputId == m_ids[i]) {
56 return i; 56 return i;
57 } 57 }
58 } 58 }
59 //!!! todo: this should in fact throw, or otherwise return an error 59 return -1;
60 return 0;
61 } 60 }
62 61
63 virtual std::string indexToId(int index) const { 62 virtual std::string indexToId(int index) const noexcept {
64 //!!! todo: this should in fact throw, or otherwise return an error 63 if (index < 0 || size_t(index) >= m_ids.size()) return "";
65 return m_ids[index]; 64 return m_ids[index];
66 } 65 }
67 66
68 private: 67 private:
69 std::vector<std::string> m_ids; 68 std::vector<std::string> m_ids;