diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-01-12 23:12:46 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-01-12 23:12:46 +0000 |
| commit | 7e4e6be3628308b7b16c015e2f87b27e729258dc (patch) | |
| tree | 0d190200906496895c36a065a85add863e26e141 /tools | |
| parent | 9d183b0d37c02279cefad1deb5b73a2b5c9bb6e2 (diff) | |
Move verify API away from strings towards error codes.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/dcpverify.cc | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/tools/dcpverify.cc b/tools/dcpverify.cc index d246dc65..675b7522 100644 --- a/tools/dcpverify.cc +++ b/tools/dcpverify.cc @@ -32,6 +32,7 @@ */ #include "verify.h" +#include "compose.hpp" #include <boost/bind.hpp> #include <boost/optional.hpp> #include <boost/filesystem.hpp> @@ -72,6 +73,29 @@ progress () } +std::string +note_to_string (dcp::VerificationNote note) +{ + switch (note.code()) { + case dcp::VerificationNote::GENERAL_READ: + return *note.note(); + case dcp::VerificationNote::CPL_HASH_INCORRECT: + return "The hash of the CPL in the PKL does not agree with the CPL file"; + case dcp::VerificationNote::INVALID_PICTURE_FRAME_RATE: + return "The picture in a reel has an invalid frame rate"; + case dcp::VerificationNote::PICTURE_HASH_INCORRECT: + return dcp::String::compose("The hash of the picture asset %1 does not agree with the PKL file", note.file()->filename()); + case dcp::VerificationNote::PKL_CPL_PICTURE_HASHES_DISAGREE: + return "The PKL and CPL hashes disagree for a picture asset."; + case dcp::VerificationNote::SOUND_HASH_INCORRECT: + return dcp::String::compose("The hash of the sound asset %1 does not agree with the PKL file", note.file()->filename()); + case dcp::VerificationNote::PKL_CPL_SOUND_HASHES_DISAGREE: + return "The PKL and CPL hashes disagree for a sound asset."; + } + + return ""; +} + int main (int argc, char* argv[]) { @@ -117,14 +141,11 @@ main (int argc, char* argv[]) BOOST_FOREACH (dcp::VerificationNote i, notes) { switch (i.type()) { case dcp::VerificationNote::VERIFY_ERROR: - cout << "Error: " << i.note() << "\n"; + cout << "Error: " << note_to_string(i) << "\n"; failed = true; break; case dcp::VerificationNote::VERIFY_WARNING: - cout << "Warning: " << i.note() << "\n"; - break; - case dcp::VerificationNote::VERIFY_NOTE: - cout << "Note: " << i.note() << "\n"; + cout << "Warning: " << note_to_string(i) << "\n"; break; } } |
