summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exceptions.cc7
-rw-r--r--src/exceptions.h7
-rw-r--r--src/main_sound_configuration.cc10
-rw-r--r--src/main_sound_configuration.h7
4 files changed, 11 insertions, 20 deletions
diff --git a/src/exceptions.cc b/src/exceptions.cc
index fce1b583..ebcd70da 100644
--- a/src/exceptions.cc
+++ b/src/exceptions.cc
@@ -179,13 +179,6 @@ MainSoundConfigurationError::MainSoundConfigurationError (std::string s)
}
-UnknownChannelIdError::UnknownChannelIdError (std::string id)
- : runtime_error(String::compose("Unrecognised channel ID '%1'", id))
-{
-
-}
-
-
NoReelsError::NoReelsError ()
: runtime_error("Cannot write a CPL which has no reels")
{
diff --git a/src/exceptions.h b/src/exceptions.h
index 49f5a21e..5ccd616c 100644
--- a/src/exceptions.h
+++ b/src/exceptions.h
@@ -330,13 +330,6 @@ public:
};
-class UnknownChannelIdError : public std::runtime_error
-{
-public:
- UnknownChannelIdError (std::string s);
-};
-
-
class NoReelsError : public std::runtime_error
{
public:
diff --git a/src/main_sound_configuration.cc b/src/main_sound_configuration.cc
index c22da40b..f9bb07c1 100644
--- a/src/main_sound_configuration.cc
+++ b/src/main_sound_configuration.cc
@@ -83,9 +83,9 @@ MainSoundConfiguration::MainSoundConfiguration(string s)
if (i == "-") {
_channels.push_back(optional<Channel>());
} else {
- try {
- _channels.push_back(mca_id_to_channel(i));
- } catch (UnknownChannelIdError&) {
+ if (auto channel = mca_id_to_channel(i)) {
+ _channels.push_back(*channel);
+ } else {
_valid = false;
}
}
@@ -155,7 +155,7 @@ MainSoundConfiguration::set_mapping(int index, Channel c)
}
-Channel
+optional<Channel>
dcp::mca_id_to_channel(string id)
{
transform(id.begin(), id.end(), id.begin(), ::tolower);
@@ -192,7 +192,7 @@ dcp::mca_id_to_channel(string id)
return Channel::SIGN_LANGUAGE;
}
- throw UnknownChannelIdError(id);
+ return {};
}
diff --git a/src/main_sound_configuration.h b/src/main_sound_configuration.h
index 2c872ba2..8c4ac596 100644
--- a/src/main_sound_configuration.h
+++ b/src/main_sound_configuration.h
@@ -53,7 +53,12 @@ enum class MCASoundField
extern std::string channel_to_mca_id(Channel c, MCASoundField field);
-extern Channel mca_id_to_channel(std::string);
+
+/** @param id MCA channel ID
+ * @return Corresponding dcp::Channel, or empty if the id is not recognised.
+ */
+extern boost::optional<Channel> mca_id_to_channel(std::string id);
+
extern std::string channel_to_mca_name(Channel c, MCASoundField field);
extern ASDCP::UL channel_to_mca_universal_label(Channel c, MCASoundField field, ASDCP::Dictionary const* dict);