*/
template <class T>
T
-collect (std::list<RawSubtitle> raw)
+collect (std::vector<RawSubtitle> raw)
{
- raw.sort ();
+ std::stable_sort (raw.begin(), raw.end());
T out;
boost::optional<Subtitle> current;
- for (std::list<RawSubtitle>::const_iterator i = raw.begin (); i != raw.end(); ++i) {
- if (current && current->same_metadata (*i)) {
+ for (auto const& i: raw) {
+ if (current && current->same_metadata(i)) {
/* This RawSubtitle can be added to current... */
- if (!current->lines.empty() && current->lines.back().same_metadata (*i)) {
+ if (!current->lines.empty() && current->lines.back().same_metadata(i)) {
/* ... and indeed to its last line */
- current->lines.back().blocks.push_back (Block (*i));
+ current->lines.back().blocks.push_back(Block(i));
} else {
/* ... as a new line */
- current->lines.push_back (Line (*i));
+ current->lines.push_back(Line(i));
}
} else {
/* We must start a new Subtitle */
if (current) {
out.push_back (current.get ());
}
- current = Subtitle (*i);
+ current = Subtitle (i);
}
}
#include <dcp/smpte_subtitle_asset.h>
#include <boost/filesystem.hpp>
-using std::list;
using std::cout;
using std::string;
using std::exception;
/*
- Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
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
#include "exceptions.h"
#include <boost/foreach.hpp>
-using std::string;
using std::list;
+using std::string;
using namespace sub;
ProgrammingError::ProgrammingError (string file, int line)
/*
- Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
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
#ifndef LIBSUB_EXCEPTIONS_H
#define LIBSUB_EXCEPTIONS_H
+#include <list>
#include <stdexcept>
#include <string>
-#include <list>
+#include <vector>
namespace sub {
#include "horizontal_position.h"
#include <boost/optional.hpp>
#include <string>
-#include <list>
+#include <vector>
namespace sub {
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
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
#define LIBSUB_READER_H
#include "raw_subtitle.h"
-#include <list>
#include <map>
#include <string>
+#include <vector>
struct subrip_reader_convert_line_test;
public:
virtual ~Reader () {}
- std::list<RawSubtitle> subtitles () const {
+ std::vector<RawSubtitle> subtitles () const {
return _subs;
}
void warn (std::string) const;
- std::list<RawSubtitle> _subs;
+ std::vector<RawSubtitle> _subs;
};
}
using std::vector;
using std::map;
using std::cout;
-using std::list;
using boost::optional;
using boost::function;
using namespace boost::algorithm;
* @param line SSA line string (i.e. just the subtitle, possibly with embedded stuff)
* @return List of RawSubtitles to represent line with vertical reference TOP_OF_SUBTITLE.
*/
-list<RawSubtitle>
+vector<RawSubtitle>
SSAReader::parse_line (RawSubtitle base, string line, int play_res_x, int play_res_y)
{
enum {
BACKSLASH
} state = TEXT;
- list<RawSubtitle> subs;
+ vector<RawSubtitle> subs;
RawSubtitle current = base;
string style;
SSAReader (FILE* f);
SSAReader (std::string subs);
- static std::list<RawSubtitle> parse_line (RawSubtitle base, std::string line, int play_res_x, int play_res_y);
+ static std::vector<RawSubtitle> parse_line (RawSubtitle base, std::string line, int play_res_x, int play_res_y);
static void parse_style (RawSubtitle& sub, std::string style, int play_res_x, int play_res_y);
private:
#include <boost/locale.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
-#include <list>
#include <cmath>
#include <fstream>
-#include <vector>
#include <iomanip>
#include <set>
+#include <vector>
-using std::list;
using std::set;
using std::ofstream;
using std::string;
}
vector<char*>
-make_tti_blocks (list<Subtitle> const& subtitles, STLBinaryTables const& tables, float frames_per_second)
+make_tti_blocks (vector<Subtitle> const& subtitles, STLBinaryTables const& tables, float frames_per_second)
{
static int const tti_size = 128;
vector<char*> tti;
/** @param language ISO 3-character country code for the language of the subtitles */
- void
+void
sub::write_stl_binary (
- list<Subtitle> subtitles,
+ vector<Subtitle> subtitles,
float frames_per_second,
Language language,
string original_programme_title,
class Subtitle;
extern void write_stl_binary (
- std::list<Subtitle> subtitles,
+ std::vector<Subtitle> subtitles,
float frames_per_second,
Language language,
std::string original_programme_title,
#include <vector>
#include <iostream>
-using std::list;
using std::ostream;
using std::istream;
using std::string;
using std::string;
using std::vector;
-using std::list;
using std::cout;
using std::hex;
using boost::lexical_cast;
string tag;
- list<Colour> colours;
+ vector<Colour> colours;
colours.push_back (Colour (1, 1, 1));
/* XXX: missing <font> support */
#include "reader.h"
#include <boost/function.hpp>
+#include <list>
struct subrip_reader_convert_line_test;
struct subrip_reader_convert_time_test;
#include "raw_subtitle.h"
#include <boost/optional.hpp>
#include <string>
-#include <list>
+#include <vector>
namespace sub {
/** vertical position of the baseline of the text */
VerticalPosition vertical_position;
- std::list<Block> blocks;
+ std::vector<Block> blocks;
bool same_metadata (RawSubtitle) const;
};
boost::optional<Time> fade_up;
boost::optional<Time> fade_down;
- std::list<Line> lines;
+ std::vector<Line> lines;
bool same_metadata (RawSubtitle) const;
};
using std::ostream;
using std::map;
using std::list;
-using boost::optional;
using std::shared_ptr;
+using std::vector;
+using boost::optional;
using namespace sub;
/** @param s A string.
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;
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) {
#include <boost/test/unit_test.hpp>
#include <boost/optional/optional_io.hpp>
-using std::list;
using std::shared_ptr;
+using std::vector;
/* Test reading of a DCP XML file */
BOOST_AUTO_TEST_CASE (dcp_reader_test1)
{
sub::DCPReader reader ("test/data/test1.xml");
- list<sub::Subtitle> subs = sub::collect<list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<vector<sub::Subtitle>> (reader.subtitles());
- list<sub::Subtitle>::iterator i = subs.begin ();
- BOOST_REQUIRE (i != subs.end ());
+ auto i = subs.begin();
+ BOOST_REQUIRE (i != subs.end());
BOOST_CHECK_EQUAL (i->from, sub::Time::from_hms (0, 0, 5, 198 * 4));
BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 0, 7, 115 * 4));
BOOST_CHECK_EQUAL (i->fade_up.get(), sub::Time::from_hms (0, 0, 0, 4));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 4));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
sub::Block b = j->blocks.front ();
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 4));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front ();
BOOST_CHECK_EQUAL (b.font.get(), "theFontId");
BOOST_CHECK_EQUAL (b.italic, true);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 4));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.font.get(), "theFontId");
BOOST_CHECK_EQUAL (b.italic, false);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 4));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.font.get(), "theFontId");
BOOST_CHECK_EQUAL (b.italic, false);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_AUTO_TEST_CASE (dcp_reader_test2)
{
sub::DCPReader reader ("test/data/test2.xml");
- list<sub::Subtitle> subs = sub::collect<list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<vector<sub::Subtitle>> (reader.subtitles ());
- list<sub::Subtitle>::iterator i = subs.begin ();
+ auto i = subs.begin ();
BOOST_REQUIRE (i != subs.end ());
BOOST_CHECK_EQUAL (i->from, sub::Time::from_hms (0, 0, 41, 62 * 4));
BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 0, 43, 52 * 4));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 0));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin ();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front ();
BOOST_CHECK_EQUAL (b.font.get(), "theFont");
BOOST_CHECK_EQUAL (b.italic, true);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 0));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin ();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front ();
BOOST_CHECK_EQUAL (b.font.get(), "theFont");
BOOST_CHECK_EQUAL (b.italic, true);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 0));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.font.get(), "theFont");
BOOST_CHECK_EQUAL (b.italic, true);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 0));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.font.get(), "theFont");
BOOST_CHECK_EQUAL (b.italic, true);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 0));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.font.get(), "theFont");
BOOST_CHECK_EQUAL (b.italic, true);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 0));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.font.get(), "theFont");
BOOST_CHECK_EQUAL (b.italic, true);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 0));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.font.get(), "theFont");
BOOST_CHECK_EQUAL (b.italic, false);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 0));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.font.get(), "theFont");
BOOST_CHECK_EQUAL (b.italic, false);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 0));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.font.get(), "theFont");
BOOST_CHECK_EQUAL (b.italic, false);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 0));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.font.get(), "theFont");
BOOST_CHECK_EQUAL (b.italic, false);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
BOOST_CHECK_EQUAL (i->fade_down.get(), sub::Time::from_hms (0, 0, 0, 0));
{
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.font.get(), "theFont");
BOOST_CHECK_EQUAL (b.italic, true);
BOOST_CHECK (b.colour == sub::Colour (1, 1, 1));
#include <fstream>
using std::ifstream;
-using std::list;
+using std::vector;
BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test1)
{
boost::filesystem::path p = private_test / "fd586c30-6d38-48f2-8241-27359acf184c_sub.xml";
sub::write_stl_binary (
- sub::collect<list<sub::Subtitle> > (sub::DCPReader(p).subtitles ()),
+ sub::collect<vector<sub::Subtitle>> (sub::DCPReader(p).subtitles()),
25,
sub::LANGUAGE_FRENCH,
"", "",
boost::filesystem::path p = private_test / "93e8a6bf-499e-4d36-9350-a9bfa2e6758a_sub.xml";
sub::write_stl_binary (
- sub::collect<list<sub::Subtitle> > (sub::DCPReader(p).subtitles ()),
+ sub::collect<vector<sub::Subtitle>> (sub::DCPReader(p).subtitles()),
25,
sub::LANGUAGE_FRENCH,
"", "",
boost::filesystem::path p = private_test / "P_FTR_Subs_DE-FR_24fps_R1.xml";
sub::write_stl_binary (
- sub::collect<list<sub::Subtitle> > (sub::DCPReader(p).subtitles ()),
+ sub::collect<vector<sub::Subtitle>> (sub::DCPReader(p).subtitles()),
25,
sub::LANGUAGE_FRENCH,
"", "",
BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test4)
{
sub::write_stl_binary (
- sub::collect<list<sub::Subtitle> > (sub::DCPReader("test/data/test1.xml").subtitles ()),
+ sub::collect<vector<sub::Subtitle>> (sub::DCPReader("test/data/test1.xml").subtitles()),
25,
sub::LANGUAGE_FRENCH,
"", "",
boost::filesystem::path p = private_test / "065d39ff-6723-4dbf-a94f-849cde82f5e1_sub.mxf";
sub::write_stl_binary (
- sub::collect<list<sub::Subtitle> > (sub::DCPReader(p).subtitles ()),
+ sub::collect<vector<sub::Subtitle>> (sub::DCPReader(p).subtitles()),
25,
sub::LANGUAGE_FRENCH,
"", "",
boost::filesystem::path p = private_test / "P_FTR_FullSubs_DE_24fps.xml";
sub::write_stl_binary (
- sub::collect<list<sub::Subtitle> > (sub::DCPReader(p).subtitles ()),
+ sub::collect<vector<sub::Subtitle>> (sub::DCPReader(p).subtitles()),
24,
sub::LANGUAGE_GERMAN,
"", "",
{
boost::filesystem::path p = "test/data/test3.xml";
sub::write_stl_binary (
- sub::collect<list<sub::Subtitle> > (sub::DCPReader(p).subtitles ()),
+ sub::collect<vector<sub::Subtitle>> (sub::DCPReader(p).subtitles()),
24,
sub::LANGUAGE_GERMAN,
"", "",
{
boost::filesystem::path p = private_test / "91a30f25-b415-4ffe-9623-bdae43a381d3_sub.xml";
sub::write_stl_binary (
- sub::collect<list<sub::Subtitle> > (sub::DCPReader(p).subtitles()),
+ sub::collect<vector<sub::Subtitle>> (sub::DCPReader(p).subtitles()),
24,
sub::LANGUAGE_GERMAN,
"", "",
{
boost::filesystem::path p = private_test / "8b95f204-f2a6-4586-8e67-2dc671a78e72_sub.xml";
sub::write_stl_binary (
- sub::collect<list<sub::Subtitle> > (sub::DCPReader(p).subtitles()),
+ sub::collect<vector<sub::Subtitle>> (sub::DCPReader(p).subtitles()),
24,
sub::LANGUAGE_GERMAN,
"", "",
/*
- Copyright (C) 2016-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
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
#include <cmath>
#include <iostream>
-using std::list;
using std::fabs;
+using std::vector;
BOOST_AUTO_TEST_CASE (ssa_reader_test)
{
FILE* f = fopen (p.string().c_str(), "r");
sub::SSAReader reader (f);
fclose (f);
- list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<vector<sub::Subtitle>> (reader.subtitles());
- list<sub::Subtitle>::iterator i = subs.begin ();
+ auto i = subs.begin ();
BOOST_REQUIRE (i != subs.end ());
BOOST_CHECK_EQUAL (i->from, sub::Time::from_hms (0, 2, 40, 650));
BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 2, 41, 790));
- list<sub::Line>::iterator j = i->lines.begin();
+ auto j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
sub::Block b = j->blocks.front ();
BOOST_AUTO_TEST_CASE (ssa_reader_line_test1)
{
sub::RawSubtitle base;
- list<sub::RawSubtitle> r = sub::SSAReader::parse_line (
+ auto r = sub::SSAReader::parse_line (
base,
"This is a line with some {\\i1}italics{\\i0} and then\\nthere is a new line.",
1920, 1080
);
- list<sub::RawSubtitle>::const_iterator i = r.begin ();
+ auto i = r.begin();
BOOST_CHECK_EQUAL (i->text, "This is a line with some ");
BOOST_CHECK_EQUAL (i->italic, false);
++i;
BOOST_AUTO_TEST_CASE (ssa_reader_line_test2)
{
sub::RawSubtitle base;
- list<sub::RawSubtitle> r = sub::SSAReader::parse_line (
+ auto r = sub::SSAReader::parse_line (
base,
"{\\i1}It's all just italics{\\i0}",
1920, 1080
);
- list<sub::RawSubtitle>::const_iterator i = r.begin ();
+ auto i = r.begin ();
BOOST_CHECK_EQUAL (i->text, "It's all just italics");
BOOST_CHECK_EQUAL (i->italic, true);
++i;
FILE* f = fopen (p.string().c_str(), "r");
sub::SSAReader reader (f);
fclose (f);
- list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<vector<sub::Subtitle>> (reader.subtitles());
- list<sub::Subtitle>::iterator i = subs.begin ();
- list<sub::Line>::iterator j;
- list<sub::Block>::iterator k;
+ auto i = subs.begin();
+ vector<sub::Line>::iterator j;
+ vector<sub::Block>::iterator k;
/* Hello world */
SUB_START (sub::Time::from_hms (0, 0, 1, 230), sub::Time::from_hms (0, 0, 4, 550));
FILE* f = fopen (p.string().c_str(), "r");
sub::SSAReader reader (f);
fclose (f);
- list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<vector<sub::Subtitle>> (reader.subtitles());
- list<sub::Subtitle>::iterator i = subs.begin ();
- list<sub::Line>::iterator j;
- list<sub::Block>::iterator k;
+ auto i = subs.begin();
+ vector<sub::Line>::iterator j;
+ vector<sub::Block>::iterator k;
BOOST_REQUIRE (i != subs.end ());
FILE* f = fopen (p.string().c_str(), "r");
sub::SSAReader reader (f);
fclose (f);
- list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<vector<sub::Subtitle>> (reader.subtitles());
- list<sub::Subtitle>::iterator i = subs.begin ();
- list<sub::Line>::iterator j;
- list<sub::Block>::iterator k;
+ auto i = subs.begin ();
+ vector<sub::Line>::iterator j;
+ vector<sub::Block>::iterator k;
BOOST_REQUIRE (i != subs.end ());
BOOST_REQUIRE (f);
sub::SSAReader reader (f);
fclose (f);
- list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<vector<sub::Subtitle>> (reader.subtitles());
- list<sub::Subtitle>::iterator i = subs.begin ();
- list<sub::Line>::iterator j;
- list<sub::Block>::iterator k;
+ auto i = subs.begin ();
+ vector<sub::Line>::iterator j;
+ vector<sub::Block>::iterator k;
BOOST_REQUIRE (i != subs.end ());
FILE* f = fopen (p.string().c_str(), "r");
sub::SSAReader reader (f);
fclose (f);
- list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<vector<sub::Subtitle>> (reader.subtitles());
- list<sub::Subtitle>::iterator i = subs.begin ();
- list<sub::Line>::iterator j;
- list<sub::Block>::iterator k;
+ auto i = subs.begin ();
+ vector<sub::Line>::iterator j;
+ vector<sub::Block>::iterator k;
/* Hello world */
SUB_START (sub::Time::from_hms (0, 0, 1, 230), sub::Time::from_hms (0, 0, 4, 550));
BOOST_AUTO_TEST_CASE (ssa_reader_fs)
{
sub::RawSubtitle base;
- list<sub::RawSubtitle> r = sub::SSAReader::parse_line (
+ auto r = sub::SSAReader::parse_line (
base,
"This is a line with some {\\fs64}font sizing.",
1920, 1080
);
- list<sub::RawSubtitle>::const_iterator i = r.begin ();
+ auto i = r.begin ();
BOOST_CHECK_EQUAL (i->text, "This is a line with some ");
++i;
BOOST_REQUIRE (i != r.end ());
BOOST_AUTO_TEST_CASE (ssa_reader_c)
{
sub::RawSubtitle base;
- list<sub::RawSubtitle> r = sub::SSAReader::parse_line (
+ auto r = sub::SSAReader::parse_line (
base,
"{\\c&H00FFFF&}Dieser Untertitel ist gelb",
1920, 1080
);
- list<sub::RawSubtitle>::const_iterator i = r.begin ();
+ auto i = r.begin ();
BOOST_CHECK_EQUAL (i->text, "Dieser Untertitel ist gelb");
BOOST_CHECK (i->colour == sub::Colour::from_rgb_hex("ffff00"));
++i;
#include <boost/test/unit_test.hpp>
#include <fstream>
-using std::list;
using std::ifstream;
using std::ofstream;
using std::shared_ptr;
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
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
#include "subtitle.h"
#include <boost/test/unit_test.hpp>
-using std::list;
+using std::vector;
/** Test writing of a binary STL file */
BOOST_AUTO_TEST_CASE (stl_binary_writer_test)
{
- list<sub::Subtitle> subs;
+ vector<sub::Subtitle> subs;
{
sub::Subtitle s;
#include <boost/test/unit_test.hpp>
#include <fstream>
-using std::list;
using std::ifstream;
using std::vector;
{
ifstream file ("test/data/test_text.stl");
sub::STLTextReader reader (file);
- list<sub::Subtitle> subs = sub::collect<list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<vector<sub::Subtitle>> (reader.subtitles());
- list<sub::Subtitle>::iterator i = subs.begin ();
+ auto i = subs.begin ();
/* First subtitle */
BOOST_CHECK_EQUAL (i->from, sub::Time::from_hmsf (0, 0, 41, 9));
BOOST_CHECK_EQUAL (i->to, sub::Time::from_hmsf (0, 0, 42, 21));
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin ();
BOOST_CHECK (j != i->lines.end ());
BOOST_CHECK_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front ();
BOOST_CHECK_EQUAL (b.text, " This is a subtitle ");
BOOST_CHECK_EQUAL (b.font.get(), "Arial");
BOOST_CHECK_EQUAL (b.font_size.points().get(), 42);
BOOST_CHECK_EQUAL (l.blocks.size(), 7);
BOOST_CHECK_EQUAL (l.vertical_position.line.get(), 0);
- list<sub::Block>::iterator k = l.blocks.begin ();
+ auto k = l.blocks.begin ();
BOOST_CHECK (k != l.blocks.end ());
BOOST_CHECK_EQUAL (k->text, " This is some ");
#include <iostream>
#include <cstdio>
-using std::list;
using std::cerr;
using std::vector;
using std::fabs;
FILE* f = fopen ("test/data/test.srt", "r");
sub::SubripReader reader (f);
fclose (f);
- list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<std::vector<sub::Subtitle>> (reader.subtitles());
- list<sub::Subtitle>::iterator i = subs.begin ();
+ auto i = subs.begin ();
/* First subtitle */
BOOST_CHECK_EQUAL (i->from, sub::Time::from_hms (0, 0, 41, 90));
BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 0, 42, 210));
- list<sub::Line>::iterator j = i->lines.begin ();
+ auto j = i->lines.begin();
BOOST_CHECK (j != i->lines.end ());
BOOST_CHECK_EQUAL (j->blocks.size(), 1);
- sub::Block b = j->blocks.front ();
+ auto b = j->blocks.front();
BOOST_CHECK_EQUAL (b.text, "This is a subtitle");
/* No font is specified by subrip, so none should be seen here */
BOOST_CHECK (!b.font);
BOOST_CHECK_EQUAL (l.vertical_position.line.get(), 0);
BOOST_CHECK_EQUAL (l.vertical_position.reference.get(), sub::TOP_OF_SUBTITLE);
- list<sub::Block>::iterator k = l.blocks.begin ();
+ auto k = l.blocks.begin();
BOOST_CHECK (k != l.blocks.end ());
BOOST_CHECK_EQUAL (k->text, "This is some ");
FILE* f = fopen ("test/data/test2.srt", "r");
sub::SubripReader reader (f);
fclose (f);
- list<sub::Subtitle> subs = sub::collect<list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<vector<sub::Subtitle>> (reader.subtitles());
- list<sub::Subtitle>::const_iterator i = subs.begin();
+ auto i = subs.begin();
BOOST_CHECK (i != subs.end ());
BOOST_CHECK_EQUAL (i->from, sub::Time::from_hms (0, 1, 49, 200));
rs = sub::RawSubtitle();
r.convert_line ("<b>This is <i>nesting</i> of subtitles</b>", rs);
BOOST_CHECK_EQUAL (r._subs.size(), 3);
- list<sub::RawSubtitle>::iterator i = r._subs.begin ();
+ auto i = r._subs.begin();
BOOST_CHECK_EQUAL (i->text, "This is ");
BOOST_CHECK_EQUAL (i->bold, true);
BOOST_CHECK_EQUAL (i->italic, false);
FILE* f = fopen (p.string().c_str(), "r");
sub::SubripReader reader (f);
fclose (f);
- list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
+ auto subs = sub::collect<std::vector<sub::Subtitle>> (reader.subtitles());
- list<sub::Subtitle>::iterator i = subs.begin ();
- list<sub::Line>::iterator j;
- list<sub::Block>::iterator k;
+ auto i = subs.begin ();
+ vector<sub::Line>::iterator j;
+ vector<sub::Block>::iterator k;
BOOST_REQUIRE (i != subs.end ());
FILE* f = fopen (p.string().c_str(), "r");
sub::SubripReader reader (f);
fclose (f);
- list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> >(reader.subtitles());
+ auto subs = sub::collect<std::vector<sub::Subtitle>>(reader.subtitles());
- list<sub::Subtitle>::iterator i = subs.begin ();
+ auto i = subs.begin();
std::cout << i->lines.front().blocks.front().text << "\n";
std::string const t = i->lines.front().blocks.front().text;
using std::cerr;
using std::cout;
using std::map;
-using std::list;
using std::shared_ptr;
using namespace sub;