Fix build.
[libdcp.git] / src / verify.h
index 7696ea851151ab2bf5e32b6c53a07335e9b4e1e8..69a10292b2f16e052fc0bce5879a6f4cca6b50b9 100644 (file)
 #define LIBDCP_VERIFY_H
 
 
+#include <boost/any.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/function.hpp>
 #include <boost/optional.hpp>
+#include <map>
 #include <string>
 #include <vector>
 
@@ -432,6 +434,16 @@ public:
                 *  file contains the CPL filename
                 */
                INVALID_MAIN_SOUND_CONFIGURATION,
+               /** An interop subtitle file has a <LoadFont> node which refers to a font file that is not found.
+                *  note contains the <LoadFont> ID
+                */
+               MISSING_FONT,
+               /** A tile part in a JPEG2000 frame is too big.
+                *  frame contains the frame index (counted from 0)
+                *  component contains the component index (0, 1 or 2)
+                *  size contains the invalid size in bytes.
+                */
+               INVALID_JPEG2000_TILE_PART_SIZE,
        };
 
        VerificationNote (Type type, Code code)
@@ -442,29 +454,33 @@ public:
        VerificationNote (Type type, Code code, std::string note)
                : _type (type)
                , _code (code)
-               , _note (note)
-       {}
+       {
+               _data[Data::NOTE] = note;
+       }
 
        VerificationNote (Type type, Code code, boost::filesystem::path file)
                : _type (type)
                , _code (code)
-               , _file (file)
-       {}
+       {
+               _data[Data::FILE] = file;
+       }
 
        VerificationNote (Type type, Code code, std::string note, boost::filesystem::path file)
                : _type (type)
                , _code (code)
-               , _note (note)
-               , _file (file)
-       {}
+       {
+               _data[Data::NOTE] = note;
+               _data[Data::FILE] = file;
+       }
 
        VerificationNote (Type type, Code code, std::string note, boost::filesystem::path file, uint64_t line)
                : _type (type)
                , _code (code)
-               , _note (note)
-               , _file (file)
-               , _line (line)
-       {}
+       {
+               _data[Data::NOTE] = note;
+               _data[Data::FILE] = file;
+               _data[Data::LINE] = line;
+       }
 
        Type type () const {
                return _type;
@@ -474,27 +490,70 @@ public:
                return _code;
        }
 
+private:
+       enum class Data {
+               NOTE,  ///< further information about the error
+               FILE,  ///< path of file containing the error
+               LINE,  ///< error line number within the FILE
+               FRAME,
+               COMPONENT,
+               SIZE,
+       };
+
+       template <class T>
+       boost::optional<T> data(Data key) const
+       {
+               auto iter = _data.find(key);
+               if (iter == _data.end()) {
+                       return {};
+               }
+               return boost::any_cast<T>(iter->second);
+       }
+
+public:
        boost::optional<std::string> note () const {
-               return _note;
+               return data<std::string>(Data::NOTE);
        }
 
        boost::optional<boost::filesystem::path> file () const {
-               return _file;
+               return data<boost::filesystem::path>(Data::FILE);
        }
 
        boost::optional<uint64_t> line () const {
-               return _line;
+               return data<uint64_t>(Data::LINE);
+       }
+
+       VerificationNote& set_frame(int frame) {
+               _data[Data::FRAME] = frame;
+               return *this;
+       }
+
+       boost::optional<int> frame() const {
+               return data<int>(Data::FRAME);
+       }
+
+       VerificationNote& set_component(int component) {
+               _data[Data::COMPONENT] = component;
+               return *this;
+       }
+
+       boost::optional<int> component() const {
+               return data<int>(Data::COMPONENT);
+       }
+
+       VerificationNote& set_size(int size) {
+               _data[Data::SIZE] = size;
+               return *this;
+       }
+
+       boost::optional<int> size() const {
+               return data<int>(Data::SIZE);
        }
 
 private:
        Type _type;
        Code _code;
-       /** Further information about the error, if applicable */
-       boost::optional<std::string> _note;
-       /** Path of file containing the error, if applicable */
-       boost::optional<boost::filesystem::path> _file;
-       /** Error line number within _file, if applicable */
-       boost::optional<uint64_t> _line;
+       std::map<Data, boost::any> _data;
 };