Bump libcxml.
[libdcp.git] / src / types.cc
index 9af5f119c666217e9fe5186a7c1599db3fc35bca..4c53b162722f4cab5b0b76c92580cb33ecb4cfe6 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -36,6 +36,7 @@
 #include "exceptions.h"
 #include "compose.hpp"
 #include "dcp_assert.h"
+#include <libxml++/libxml++.h>
 #include <boost/algorithm/string.hpp>
 #include <vector>
 #include <cstdio>
@@ -369,3 +370,87 @@ dcp::content_kind_from_string (string kind)
 
        throw BadContentKindError (kind);
 }
+
+string
+dcp::marker_to_string (dcp::Marker m)
+{
+       switch (m) {
+       case FFOC:
+               return "FFOC";
+       case LFOC:
+               return "LFOC";
+       case FFTC:
+               return "FFTC";
+       case LFTC:
+               return "LFTC";
+       case FFOI:
+               return "FFOI";
+       case LFOI:
+               return "LFOI";
+       case FFEC:
+               return "FFEC";
+       case LFEC:
+               return "LFEC";
+       case FFMC:
+               return "FFMC";
+       case LFMC:
+               return "LFMC";
+       }
+
+       DCP_ASSERT (false);
+}
+
+dcp::Marker
+dcp::marker_from_string (string s)
+{
+       if (s == "FFOC") {
+               return FFOC;
+       } else if (s == "LFOC") {
+               return LFOC;
+       } else if (s == "FFTC") {
+               return FFTC;
+       } else if (s == "LFTC") {
+               return LFTC;
+       } else if (s == "FFOI") {
+               return FFOI;
+       } else if (s == "LFOI") {
+               return LFOI;
+       } else if (s == "FFEC") {
+               return FFEC;
+       } else if (s == "LFEC") {
+               return LFEC;
+       } else if (s == "FFMC") {
+               return FFMC;
+       } else if (s == "LFMC") {
+               return LFMC;
+       }
+
+       DCP_ASSERT (false);
+}
+
+Rating::Rating (cxml::ConstNodePtr node)
+{
+       agency = node->string_child("Agency");
+       label = node->string_child("Label");
+       node->done ();
+}
+
+void
+Rating::as_xml (xmlpp::Element* parent) const
+{
+       parent->add_child("Agency")->add_child_text(agency);
+       parent->add_child("Label")->add_child_text(label);
+}
+
+bool
+dcp::operator== (Rating const & a, Rating const & b)
+{
+       return a.agency == b.agency && a.label == b.label;
+}
+
+ostream &
+dcp::operator<< (ostream& s, Rating const & r)
+{
+       s << r.agency << " " << r.label;
+       return s;
+}