comparison bits/PreservingPluginOutputIdMapper.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 class PreservingPluginOutputIdMapper : public PluginOutputIdMapper 47 class PreservingPluginOutputIdMapper : public PluginOutputIdMapper
48 { 48 {
49 public: 49 public:
50 PreservingPluginOutputIdMapper() { } 50 PreservingPluginOutputIdMapper() { }
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 int i = 0; 54 int i = 0;
55 while (i < n) { 55 while (i < n) {
56 if (outputId == m_ids[i]) { 56 if (outputId == m_ids[i]) {
57 return i; 57 return i;
60 } 60 }
61 m_ids.push_back(outputId); 61 m_ids.push_back(outputId);
62 return i; 62 return i;
63 } 63 }
64 64
65 virtual std::string indexToId(int index) const { 65 virtual std::string indexToId(int index) const noexcept {
66 //!!! todo: this should in fact throw, or otherwise return an error 66 if (index < 0 || size_t(index) >= m_ids.size()) return "";
67 return m_ids[index]; 67 return m_ids[index];
68 } 68 }
69 69
70 private: 70 private:
71 mutable std::vector<std::string> m_ids; 71 mutable std::vector<std::string> m_ids;