2 Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "reader_factory.h"
24 #include <boost/filesystem.hpp>
33 using boost::shared_ptr;
39 cerr << "Syntax: " << n << " <file>\n";
43 main (int argc, char* argv[])
47 static struct option long_options[] = {
48 { "help", no_argument, 0, 'h'},
52 int c = getopt_long (argc, argv, "h", long_options, &option_index);
65 if (argc <= optind || argc > (optind + 1)) {
70 if (!boost::filesystem::exists (argv[optind])) {
71 cerr << argv[0] << ": file " << argv[optind] << " not found.\n";
75 shared_ptr<Reader> reader = reader_factory (argv[optind]);
77 cerr << argv[0] << ": could not read subtitle file " << argv[optind] << "\n";
81 map<string, string> metadata = reader->metadata ();
82 for (map<string, string>::const_iterator i = metadata.begin(); i != metadata.end(); ++i) {
83 cout << i->first << ": " << i->second << "\n";
86 list<sub::Subtitle> subs = collect<list<sub::Subtitle> > (reader->subtitles ());
88 for (list<sub::Subtitle>::const_iterator i = subs.begin(); i != subs.end(); ++i) {
89 cout << "Subtitle " << n << " at " << i->from << " -> " << i->to << "\n";
90 for (list<sub::Line>::const_iterator j = i->lines.begin(); j != i->lines.end(); ++j) {
94 if (j->vertical_position.proportional) {
95 cout << j->vertical_position.proportional.get() << " of screen";
96 } else if (j->vertical_position.line) {
97 cout << j->vertical_position.line.get() << " lines of " << j->vertical_position.lines.get();
99 if (j->vertical_position.reference) {
101 switch (j->vertical_position.reference.get()) {
105 case VERTICAL_CENTRE_OF_SCREEN:
108 case BOTTOM_OF_SCREEN:
111 case TOP_OF_SUBTITLE:
112 cout << "top of subtitle";
119 bool underline = false;
120 for (list<sub::Block>::const_iterator k = j->blocks.begin(); k != j->blocks.end(); ++k) {
121 if (k->italic && !italic) {
123 } else if (italic && !k->italic) {
126 if (k->underline && !underline) {
128 } else if (underline && !k->underline) {
133 underline = k->underline;