Supporters update.
[dcpomatic.git] / src / lib / text_type.cc
1 /*
2     Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic 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     DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "compose.hpp"
23 #include "dcpomatic_assert.h"
24 #include "exceptions.h"
25 #include "text_type.h"
26 #include "types.h"
27
28 #include "i18n.h"
29
30
31 using std::string;
32
33
34 TextType
35 string_to_text_type(string s)
36 {
37         if (s == "unknown") {
38                 return TextType::UNKNOWN;
39         } else if (s == "open-subtitle") {
40                 return TextType::OPEN_SUBTITLE;
41         } else if (s == "closed-caption") {
42                 return TextType::CLOSED_CAPTION;
43         } else {
44                 throw MetadataError(String::compose("Unknown text type %1", s));
45         }
46 }
47
48 string
49 text_type_to_string(TextType t)
50 {
51         switch (t) {
52         case TextType::UNKNOWN:
53                 return "unknown";
54         case TextType::OPEN_SUBTITLE:
55                 return "open-subtitle";
56         case TextType::CLOSED_CAPTION:
57                 return "closed-caption";
58         default:
59                 DCPOMATIC_ASSERT(false);
60         }
61 }
62
63 string
64 text_type_to_name(TextType t)
65 {
66         switch (t) {
67         case TextType::UNKNOWN:
68                 return _("Timed text");
69         case TextType::OPEN_SUBTITLE:
70                 return _("Open subtitles");
71         case TextType::CLOSED_CAPTION:
72                 return _("Closed captions");
73         default:
74                 DCPOMATIC_ASSERT(false);
75         }
76 }
77
78