adb9f6b4da5b29083a4123cf50020124c22cdd2d
[libdcp.git] / test / rewrite_subs.cc
1 #include <iostream>
2 #include "dcp.h"
3 #include "cpl.h"
4 #include "reel.h"
5 #include "subtitle_asset.h"
6
7 using std::cout;
8 using std::cerr;
9 using std::list;
10 using boost::shared_ptr;
11 using namespace libdcp;
12
13 int
14 main (int argc, char* argv[])
15 try
16 {
17         if (argc < 2) {
18                 cerr << "Syntax: " << argv[0] << " <dcp>\n";
19                 exit (EXIT_FAILURE);
20         }
21
22         DCP* dcp = new DCP (argv[1]);
23         dcp->read (false);
24         
25         list<shared_ptr<const CPL> > cpls = dcp->cpls ();
26         for (list<boost::shared_ptr<const CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) {
27
28                 list<shared_ptr<const Reel> > reels = (*i)->reels ();
29                 for (list<shared_ptr<const Reel> >::iterator j = reels.begin(); j != reels.end(); ++j) {
30
31                         if ((*j)->main_subtitle()) {
32                                 (*j)->main_subtitle()->write_xml ();
33                         }
34                 }
35         }
36
37         return 0;
38 }
39 catch (FileError& e)
40 {
41         cerr << e.what() << " (" << e.filename() << ")\n";
42         exit (EXIT_FAILURE);
43 }