X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tools%2Fdumpsubs.cc;h=cf7008ee8aa16b8f3327728393b852d16484fb98;hb=0271d2fa098e9b7b4b440ae6ae50bb01655264ae;hp=991d018dfc750aa5c7b3bf0a9ac73d3d72d76e3b;hpb=7d302ed6712518c5fdbf59f30e07b688865d56fa;p=libsub.git diff --git a/tools/dumpsubs.cc b/tools/dumpsubs.cc index 991d018..cf7008e 100644 --- a/tools/dumpsubs.cc +++ b/tools/dumpsubs.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2020 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #include "reader_factory.h" #include "reader.h" #include "collect.h" +#include "util.h" #include #include #include @@ -29,8 +30,7 @@ using std::string; using std::cerr; using std::cout; using std::map; -using std::list; -using boost::shared_ptr; +using std::shared_ptr; using namespace sub; static void @@ -78,74 +78,7 @@ main (int argc, char* argv[]) exit (EXIT_FAILURE); } - map metadata = reader->metadata (); - for (map::const_iterator i = metadata.begin(); i != metadata.end(); ++i) { - cout << i->first << ": " << i->second << "\n"; - } - - list subs = collect > (reader->subtitles ()); - int n = 0; - for (list::const_iterator i = subs.begin(); i != subs.end(); ++i) { - cout << "Subtitle " << n << " at " << i->from << " -> " << i->to << "\n"; - for (list::const_iterator j = i->lines.begin(); j != i->lines.end(); ++j) { - - cout << "\t"; - - if (j->vertical_position.proportional) { - cout << j->vertical_position.proportional.get() << " of screen"; - } else if (j->vertical_position.line && j->vertical_position.lines) { - cout << j->vertical_position.line.get() << " lines of " << j->vertical_position.lines.get(); - } - if (j->vertical_position.reference) { - cout << " from "; - switch (j->vertical_position.reference.get()) { - case TOP_OF_SCREEN: - cout << "top"; - break; - case VERTICAL_CENTRE_OF_SCREEN: - cout << "centre"; - break; - case BOTTOM_OF_SCREEN: - cout << "bottom"; - break; - case TOP_OF_SUBTITLE: - cout << "top of subtitle"; - break; - } - } - - cout << "\t"; - bool italic = false; - bool underline = false; - for (list::const_iterator k = j->blocks.begin(); k != j->blocks.end(); ++k) { - if (k->italic && !italic) { - cout << ""; - } else if (italic && !k->italic) { - cout << ""; - } - if (k->underline && !underline) { - cout << ""; - } else if (underline && !k->underline) { - cout << ""; - } - - italic = k->italic; - underline = k->underline; - - cout << k->text; - } - - if (italic) { - cout << ""; - } - if (underline) { - cout << ""; - } - cout << "\n"; - } - - ++n; - } + sub::dump (reader, cout); return 0; }