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