libdcp
verify.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
3 
4  This file is part of libdcp.
5 
6  libdcp is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  libdcp is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with libdcp. If not, see <http://www.gnu.org/licenses/>.
18 
19  In addition, as a special exception, the copyright holders give
20  permission to link the code of portions of this program with the
21  OpenSSL library under certain conditions as described in each
22  individual source file, and distribute linked combinations
23  including the two.
24 
25  You must obey the GNU General Public License in all respects
26  for all of the code used other than OpenSSL. If you modify
27  file(s) with this exception, you may extend this exception to your
28  version of the file(s), but you are not obligated to do so. If you
29  do not wish to do so, delete this exception statement from your
30  version. If you delete this exception statement from all source
31  files in the program, then also delete it here.
32 */
33 
34 
40 #ifndef LIBDCP_VERIFY_H
41 #define LIBDCP_VERIFY_H
42 
43 
44 #include <boost/filesystem.hpp>
45 #include <boost/function.hpp>
46 #include <boost/optional.hpp>
47 #include <string>
48 #include <vector>
49 
50 
51 /* Something in windows.h defines this */
52 #undef ERROR
53 
54 
55 namespace dcp {
56 
57 
59 {
60 public:
61  /* I've been unable to make mingw happy with ERROR as a symbol, so
62  I'm using a VERIFY_ prefix here.
63  */
64  enum class Type {
65  ERROR,
66  BV21_ERROR,
67  WARNING
68  };
69 
91  // If you change the next line, also look in doc/manual/verifier.py in DCP-o-matic
92  // as it looks for it when compiling the manual. Also, in this enum:
93  // [...] will be taken as a reference to a section of Bv2.1
94  // _foo_ means foo should be written as a piece of code
95  enum class Code {
138  INVALID_XML,
278  MISSING_HASH,
284  MISSING_FFOC,
286  MISSING_LFOC,
390  EMPTY_TEXT,
395  };
396 
397  VerificationNote (Type type, Code code)
398  : _type (type)
399  , _code (code)
400  {}
401 
402  VerificationNote (Type type, Code code, std::string note)
403  : _type (type)
404  , _code (code)
405  , _note (note)
406  {}
407 
408  VerificationNote (Type type, Code code, boost::filesystem::path file)
409  : _type (type)
410  , _code (code)
411  , _file (file)
412  {}
413 
414  VerificationNote (Type type, Code code, std::string note, boost::filesystem::path file)
415  : _type (type)
416  , _code (code)
417  , _note (note)
418  , _file (file)
419  {}
420 
421  VerificationNote (Type type, Code code, std::string note, boost::filesystem::path file, uint64_t line)
422  : _type (type)
423  , _code (code)
424  , _note (note)
425  , _file (file)
426  , _line (line)
427  {}
428 
429  Type type () const {
430  return _type;
431  }
432 
433  Code code () const {
434  return _code;
435  }
436 
437  boost::optional<std::string> note () const {
438  return _note;
439  }
440 
441  boost::optional<boost::filesystem::path> file () const {
442  return _file;
443  }
444 
445  boost::optional<uint64_t> line () const {
446  return _line;
447  }
448 
449 private:
450  Type _type;
451  Code _code;
453  boost::optional<std::string> _note;
455  boost::optional<boost::filesystem::path> _file;
457  boost::optional<uint64_t> _line;
458 };
459 
460 
461 std::vector<VerificationNote> verify (
462  std::vector<boost::filesystem::path> directories,
463  boost::function<void (std::string, boost::optional<boost::filesystem::path>)> stage,
464  boost::function<void (float)> progress,
465  boost::optional<boost::filesystem::path> xsd_dtd_directory = boost::optional<boost::filesystem::path>()
466  );
467 
468 std::string note_to_string (dcp::VerificationNote note);
469 
470 bool operator== (dcp::VerificationNote const& a, dcp::VerificationNote const& b);
471 bool operator< (dcp::VerificationNote const& a, dcp::VerificationNote const& b);
472 
473 std::ostream& operator<<(std::ostream& s, dcp::VerificationNote const& note);
474 
475 
476 }
477 
478 
479 #endif
boost::optional< boost::filesystem::path > _file
Definition: verify.h:455
@ BV21_ERROR
may not always be considered an error, but violates a "shall" requirement of Bv2.1
boost::optional< std::string > _note
Definition: verify.h:453
boost::optional< uint64_t > _line
Definition: verify.h:457
Namespace for everything in libdcp.
Definition: array_data.h:50
std::string note_to_string(dcp::VerificationNote note)
Definition: verify.cc:1578