Fix format of versions in .pc files.
[libsub.git] / src / util.cc
index 89af13fb0d33dd8820e338ebc9ec38b8d2f61d9c..244630dc7bd8d8e247fab9f3c255be549addfaaf 100644 (file)
@@ -21,7 +21,7 @@
 #include "reader.h"
 #include "subtitle.h"
 #include "collect.h"
-#include <boost/shared_ptr.hpp>
+#include <memory>
 #include <string>
 #include <iostream>
 #include <cstdio>
@@ -31,9 +31,9 @@ using std::string;
 using std::getline;
 using std::ostream;
 using std::map;
-using std::list;
+using std::shared_ptr;
+using std::vector;
 using boost::optional;
-using boost::shared_ptr;
 using namespace sub;
 
 /** @param s A string.
@@ -100,27 +100,27 @@ sub::remove_unicode_bom (optional<string>& line)
 void
 sub::dump (shared_ptr<const Reader> reader, ostream& os)
 {
-       map<string, string> metadata = reader->metadata ();
-       for (map<string, string>::const_iterator i = metadata.begin(); i != metadata.end(); ++i) {
-               os << i->first << ": " << i->second << "\n";
+       auto metadata = reader->metadata ();
+       for (auto const& i: metadata) {
+               os << i.first << ": " << i.second << "\n";
        }
 
-       list<sub::Subtitle> subs = collect<list<sub::Subtitle> > (reader->subtitles ());
+       auto subs = collect<vector<sub::Subtitle>> (reader->subtitles());
        int n = 0;
-       for (list<sub::Subtitle>::const_iterator i = subs.begin(); i != subs.end(); ++i) {
-               os << "Subtitle " << n << " at " << i->from << " -> " << i->to << "\n";
-               for (list<sub::Line>::const_iterator j = i->lines.begin(); j != i->lines.end(); ++j) {
+       for (auto const& i: subs) {
+               os << "Subtitle " << n << " at " << i.from << " -> " << i.to << "\n";
+               for (auto const& j: i.lines) {
 
                        os << "\t";
 
-                       if (j->vertical_position.proportional) {
-                               os << j->vertical_position.proportional.get() << " of screen";
-                       } else if (j->vertical_position.line && j->vertical_position.lines) {
-                               os << j->vertical_position.line.get() << " lines of " << j->vertical_position.lines.get();
+                       if (j.vertical_position.proportional) {
+                               os << j.vertical_position.proportional.get() << " of screen";
+                       } else if (j.vertical_position.line && j.vertical_position.lines) {
+                               os << j.vertical_position.line.get() << " lines of " << j.vertical_position.lines.get();
                        }
-                       if (j->vertical_position.reference) {
+                       if (j.vertical_position.reference) {
                                os << " from ";
-                               switch (j->vertical_position.reference.get()) {
+                               switch (j.vertical_position.reference.get()) {
                                case TOP_OF_SCREEN:
                                        os << "top";
                                        break;
@@ -139,22 +139,22 @@ sub::dump (shared_ptr<const Reader> reader, ostream& os)
                        os << "\t";
                        bool italic = false;
                        bool underline = false;
-                       for (list<sub::Block>::const_iterator k = j->blocks.begin(); k != j->blocks.end(); ++k) {
-                               if (k->italic && !italic) {
+                       for (auto const& k: j.blocks) {
+                               if (k.italic && !italic) {
                                        os << "<i>";
-                               } else if (italic && !k->italic) {
+                               } else if (italic && !k.italic) {
                                        os << "</i>";
                                }
-                               if (k->underline && !underline) {
+                               if (k.underline && !underline) {
                                        os << "<u>";
-                               } else if (underline && !k->underline) {
+                               } else if (underline && !k.underline) {
                                        os << "</u>";
                                }
 
-                               italic = k->italic;
-                               underline = k->underline;
+                               italic = k.italic;
+                               underline = k.underline;
 
-                               os << k->text;
+                               os << k.text;
                        }
 
                        if (italic) {