From e2a4e0f08c9e8cc82fb20f1cd358897fae46c9ee Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 14 Feb 2018 22:13:31 +0000 Subject: Use a bool instead of an int for disable-forensic-picture and a optional instead of an int with a magic -1 for disable-forensic-audio. --- src/encrypted_kdm.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/encrypted_kdm.cc') diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index d7a2bcc6..7a7d98c1 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2017 Carl Hetherington + Copyright (C) 2013-2018 Carl Hetherington This file is part of libdcp. @@ -35,6 +35,7 @@ #include "util.h" #include "certificate_chain.h" #include "exceptions.h" +#include "compose.hpp" #include #include #include @@ -384,14 +385,14 @@ public: , authorized_device_info (node->node_child ("AuthorizedDeviceInfo")) , key_id_list (node->node_child ("KeyIdList")) { - disable_forensic_marking_picture = 0; - disable_forensic_marking_audio = 0; + disable_forensic_marking_picture = false; + disable_forensic_marking_audio = optional(); if (node->optional_node_child("ForensicMarkFlagList")) { BOOST_FOREACH (cxml::ConstNodePtr i, node->node_child("ForensicMarkFlagList")->node_children("ForensicMarkFlag")) { if (i->content() == picture_disable) { - disable_forensic_marking_picture = -1; + disable_forensic_marking_picture = true; } else if (starts_with(i->content(), audio_disable)) { - disable_forensic_marking_audio = -1; + disable_forensic_marking_audio = 0; string const above = audio_disable + "-above-channel-"; if (starts_with(i->content(), above)) { string above_number = i->content().substr(above.length()); @@ -429,8 +430,8 @@ public: } if (disable_forensic_marking_audio) { string mrkflg = audio_disable; - if (disable_forensic_marking_audio != -1) { - mrkflg = str (boost::format (mrkflg + "-above-channel-%u") % disable_forensic_marking_audio); + if (*disable_forensic_marking_audio > 0) { + mrkflg += String::compose ("-above-channel-%1", *disable_forensic_marking_audio); } forensic_mark_flag_list->add_child("ForensicMarkFlag")->add_child_text (mrkflg); } @@ -443,8 +444,8 @@ public: string content_title_text; LocalTime not_valid_before; LocalTime not_valid_after; - int disable_forensic_marking_picture; - int disable_forensic_marking_audio; + bool disable_forensic_marking_picture; + optional disable_forensic_marking_audio; boost::optional authorized_device_info; KeyIdList key_id_list; @@ -585,8 +586,8 @@ EncryptedKDM::EncryptedKDM ( LocalTime not_valid_before, LocalTime not_valid_after, Formulation formulation, - int disable_forensic_marking_picture, - int disable_forensic_marking_audio, + bool disable_forensic_marking_picture, + optional disable_forensic_marking_audio, list > key_ids, list keys ) -- cgit v1.2.3