diff bits/PreservingPluginOutputIdMapper.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/PreservingPluginOutputIdMapper.h	Mon Sep 19 15:52:38 2016 +0100
+++ b/bits/PreservingPluginOutputIdMapper.h	Tue Sep 20 16:35:47 2016 +0100
@@ -49,7 +49,7 @@
 public:
     PreservingPluginOutputIdMapper() { }
 
-    virtual int idToIndex(std::string outputId) const {
+    virtual int idToIndex(std::string outputId) const noexcept {
 	int n = int(m_ids.size());
 	int i = 0;
 	while (i < n) {
@@ -62,8 +62,8 @@
 	return i;
     }
 
-    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];
     }