Move some methods to where they make more sense.
authorCarl Hetherington <cth@carlh.net>
Fri, 28 Sep 2018 23:10:17 +0000 (00:10 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 28 Sep 2018 23:10:17 +0000 (00:10 +0100)
src/types.cc
src/types.h
src/util.cc
src/util.h

index a7c621ffc688d02b6841a2e6ffa851ae572c004a..9af5f119c666217e9fe5186a7c1599db3fc35bca 100644 (file)
@@ -35,6 +35,7 @@
 #include "types.h"
 #include "exceptions.h"
 #include "compose.hpp"
+#include "dcp_assert.h"
 #include <boost/algorithm/string.hpp>
 #include <vector>
 #include <cstdio>
@@ -299,3 +300,72 @@ dcp::string_to_direction (string s)
 
        boost::throw_exception (DCPReadError ("unknown subtitle direction type"));
 }
+
+/** Convert a content kind to a string which can be used in a
+ *  &lt;ContentKind&gt; node.
+ *  @param kind ContentKind.
+ *  @return string.
+ */
+string
+dcp::content_kind_to_string (ContentKind kind)
+{
+       switch (kind) {
+       case FEATURE:
+               return "feature";
+       case SHORT:
+               return "short";
+       case TRAILER:
+               return "trailer";
+       case TEST:
+               return "test";
+       case TRANSITIONAL:
+               return "transitional";
+       case RATING:
+               return "rating";
+       case TEASER:
+               return "teaser";
+       case POLICY:
+               return "policy";
+       case PUBLIC_SERVICE_ANNOUNCEMENT:
+               return "psa";
+       case ADVERTISEMENT:
+               return "advertisement";
+       }
+
+       DCP_ASSERT (false);
+}
+
+/** Convert a string from a &lt;ContentKind&gt; node to a libdcp ContentKind.
+ *  Reasonably tolerant about varying case.
+ *  @param kind Content kind string.
+ *  @return libdcp ContentKind.
+ */
+dcp::ContentKind
+dcp::content_kind_from_string (string kind)
+{
+       transform (kind.begin(), kind.end(), kind.begin(), ::tolower);
+
+       if (kind == "feature") {
+               return FEATURE;
+       } else if (kind == "short") {
+               return SHORT;
+       } else if (kind == "trailer") {
+               return TRAILER;
+       } else if (kind == "test") {
+               return TEST;
+       } else if (kind == "transitional") {
+               return TRANSITIONAL;
+       } else if (kind == "rating") {
+               return RATING;
+       } else if (kind == "teaser") {
+               return TEASER;
+       } else if (kind == "policy") {
+               return POLICY;
+       } else if (kind == "psa") {
+               return PUBLIC_SERVICE_ANNOUNCEMENT;
+       } else if (kind == "advertisement") {
+               return ADVERTISEMENT;
+       }
+
+       throw BadContentKindError (kind);
+}
index 807c4df0db51a664b3a0db04c2c108f7ecc84a7b..2652524cb52023af20b1beb0228912c91e2431d1 100644 (file)
@@ -102,6 +102,9 @@ enum ContentKind
        ADVERTISEMENT
 };
 
+extern std::string content_kind_to_string (ContentKind kind);
+extern ContentKind content_kind_from_string (std::string kind);
+
 enum Effect
 {
        NONE,
index ac97af6e9d0199f24e28bb8fe7c8b98bcdc77ee2..df79fb26e1a3dc52dba989c3718889b0fc48715f 100644 (file)
@@ -148,75 +148,6 @@ dcp::make_digest (boost::filesystem::path filename, function<void (float)> progr
        return Kumu::base64encode (byte_buffer, SHA_DIGEST_LENGTH, digest, 64);
 }
 
-/** Convert a content kind to a string which can be used in a
- *  &lt;ContentKind&gt; node.
- *  @param kind ContentKind.
- *  @return string.
- */
-string
-dcp::content_kind_to_string (ContentKind kind)
-{
-       switch (kind) {
-       case FEATURE:
-               return "feature";
-       case SHORT:
-               return "short";
-       case TRAILER:
-               return "trailer";
-       case TEST:
-               return "test";
-       case TRANSITIONAL:
-               return "transitional";
-       case RATING:
-               return "rating";
-       case TEASER:
-               return "teaser";
-       case POLICY:
-               return "policy";
-       case PUBLIC_SERVICE_ANNOUNCEMENT:
-               return "psa";
-       case ADVERTISEMENT:
-               return "advertisement";
-       }
-
-       DCP_ASSERT (false);
-}
-
-/** Convert a string from a &lt;ContentKind&gt; node to a libdcp ContentKind.
- *  Reasonably tolerant about varying case.
- *  @param kind Content kind string.
- *  @return libdcp ContentKind.
- */
-dcp::ContentKind
-dcp::content_kind_from_string (string kind)
-{
-       transform (kind.begin(), kind.end(), kind.begin(), ::tolower);
-
-       if (kind == "feature") {
-               return FEATURE;
-       } else if (kind == "short") {
-               return SHORT;
-       } else if (kind == "trailer") {
-               return TRAILER;
-       } else if (kind == "test") {
-               return TEST;
-       } else if (kind == "transitional") {
-               return TRANSITIONAL;
-       } else if (kind == "rating") {
-               return RATING;
-       } else if (kind == "teaser") {
-               return TEASER;
-       } else if (kind == "policy") {
-               return POLICY;
-       } else if (kind == "psa") {
-               return PUBLIC_SERVICE_ANNOUNCEMENT;
-       } else if (kind == "advertisement") {
-               return ADVERTISEMENT;
-       }
-
-       throw BadContentKindError (kind);
-}
-
 /** @param s A string.
  *  @return true if the string contains only space, newline or tab characters, or is empty.
  */
index 9803ad03aa2f38541a8a86fe58b817ff7e929723..2f3b810a0ae64975f501e276a2cef2117885a6df 100644 (file)
@@ -61,8 +61,6 @@ class OpenJPEGImage;
 extern std::string make_uuid ();
 extern std::string make_digest (boost::filesystem::path filename, boost::function<void (float)>);
 extern std::string make_digest (Data data);
-extern std::string content_kind_to_string (ContentKind kind);
-extern ContentKind content_kind_from_string (std::string kind);
 extern bool empty_or_white_space (std::string s);
 extern bool ids_equal (std::string a, std::string b);
 extern std::string remove_urn_uuid (std::string raw);