summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-09-27 00:34:17 +0200
committerCarl Hetherington <cth@carlh.net>2022-09-27 13:46:16 +0200
commit17847dc1bc68516bda8ca92e8561064dde896530 (patch)
tree51bb78738d0b8eff4abe15f33fb288215529712d /src/lib
parente0bcd3514f586b250a56c5049053476c4c002dc5 (diff)
Use EnumIndexedVector in DCPContent.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dcp_content.cc30
-rw-r--r--src/lib/dcp_content.h5
2 files changed, 13 insertions, 22 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index 193c9995a..2bbeba8c7 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -86,10 +86,6 @@ DCPContent::DCPContent (boost::filesystem::path p)
read_directory (p);
set_default_colour_conversion ();
-
- for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
- _reference_text[i] = false;
- }
}
DCPContent::DCPContent (cxml::ConstNodePtr node, int version)
@@ -101,10 +97,6 @@ DCPContent::DCPContent (cxml::ConstNodePtr node, int version)
text = TextContent::from_xml (this, node, version, notes);
atmos = AtmosContent::from_xml (this, node);
- for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
- _reference_text[i] = false;
- }
-
if (video && audio) {
audio->set_stream (
make_shared<AudioStream> (
@@ -128,11 +120,11 @@ DCPContent::DCPContent (cxml::ConstNodePtr node, int version)
_reference_video = node->optional_bool_child ("ReferenceVideo").get_value_or (false);
_reference_audio = node->optional_bool_child ("ReferenceAudio").get_value_or (false);
if (version >= 37) {
- _reference_text[static_cast<int>(TextType::OPEN_SUBTITLE)] = node->optional_bool_child("ReferenceOpenSubtitle").get_value_or(false);
- _reference_text[static_cast<int>(TextType::CLOSED_CAPTION)] = node->optional_bool_child("ReferenceClosedCaption").get_value_or(false);
+ _reference_text[TextType::OPEN_SUBTITLE] = node->optional_bool_child("ReferenceOpenSubtitle").get_value_or(false);
+ _reference_text[TextType::CLOSED_CAPTION] = node->optional_bool_child("ReferenceClosedCaption").get_value_or(false);
} else {
- _reference_text[static_cast<int>(TextType::OPEN_SUBTITLE)] = node->optional_bool_child("ReferenceSubtitle").get_value_or(false);
- _reference_text[static_cast<int>(TextType::CLOSED_CAPTION)] = false;
+ _reference_text[TextType::OPEN_SUBTITLE] = node->optional_bool_child("ReferenceSubtitle").get_value_or(false);
+ _reference_text[TextType::CLOSED_CAPTION] = false;
}
if (node->optional_string_child("Standard")) {
auto const s = node->optional_string_child("Standard").get();
@@ -372,8 +364,8 @@ DCPContent::as_xml (xmlpp::Node* node, bool with_paths) const
node->add_child("KDMValid")->add_child_text (_kdm_valid ? "1" : "0");
node->add_child("ReferenceVideo")->add_child_text (_reference_video ? "1" : "0");
node->add_child("ReferenceAudio")->add_child_text (_reference_audio ? "1" : "0");
- node->add_child("ReferenceOpenSubtitle")->add_child_text(_reference_text[static_cast<int>(TextType::OPEN_SUBTITLE)] ? "1" : "0");
- node->add_child("ReferenceClosedCaption")->add_child_text(_reference_text[static_cast<int>(TextType::CLOSED_CAPTION)] ? "1" : "0");
+ node->add_child("ReferenceOpenSubtitle")->add_child_text(_reference_text[TextType::OPEN_SUBTITLE] ? "1" : "0");
+ node->add_child("ReferenceClosedCaption")->add_child_text(_reference_text[TextType::CLOSED_CAPTION] ? "1" : "0");
if (_standard) {
switch (_standard.get ()) {
case dcp::Standard::INTEROP:
@@ -446,8 +438,8 @@ DCPContent::identifier () const
}
s += string (_reference_video ? "1" : "0");
- for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
- s += string (_reference_text[i] ? "1" : "0");
+ for (auto text: _reference_text) {
+ s += string(text ? "1" : "0");
}
return s;
}
@@ -540,7 +532,7 @@ DCPContent::set_reference_text (TextType type, bool r)
{
boost::mutex::scoped_lock lm (_mutex);
- _reference_text[static_cast<int>(type)] = r;
+ _reference_text[type] = r;
}
}
@@ -785,9 +777,7 @@ DCPContent::take_settings_from (shared_ptr<const Content> c)
_reference_video = dc->_reference_video;
_reference_audio = dc->_reference_audio;
- for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
- _reference_text[i] = dc->_reference_text[i];
- }
+ _reference_text = dc->_reference_text;
}
void
diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h
index efdfe30f7..17a9a9386 100644
--- a/src/lib/dcp_content.h
+++ b/src/lib/dcp_content.h
@@ -29,6 +29,7 @@
#include "content.h"
+#include "enum_indexed_vector.h"
#include "font.h"
#include <libcxml/cxml.h>
#include <dcp/content_kind.h>
@@ -123,7 +124,7 @@ public:
*/
bool reference_text (TextType type) const {
boost::mutex::scoped_lock lm (_mutex);
- return _reference_text[static_cast<int>(type)];
+ return _reference_text[type];
}
bool can_reference_text (std::shared_ptr<const Film> film, TextType type, std::string &) const;
@@ -209,7 +210,7 @@ private:
* rather than by rewrapping. The types here are the original text types,
* not what they are being used for.
*/
- bool _reference_text[static_cast<int>(TextType::COUNT)];
+ EnumIndexedVector<bool, TextType> _reference_text;
boost::optional<dcp::Standard> _standard;
boost::optional<dcp::ContentKind> _content_kind;