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