#include "sub_assert.h"
#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;
/* Buffer to build the TTI blocks in */
char buffer[tti_size];
- BOOST_FOREACH (Subtitle const& i, subtitles) {
+ for (auto const& i: subtitles) {
/* Find the top vertical position of this subtitle */
optional<int> top;
- BOOST_FOREACH (Line const& j, i.lines) {
+ for (auto const& j: i.lines) {
int const vp = vertical_position (j);
if (!top || vp < top.get ()) {
top = vp;
bool underline = false;
optional<int> last_vp;
- BOOST_FOREACH (Line const& j, i.lines) {
+ for (auto const& j: i.lines) {
/* CR/LF down to this line */
int const vp = vertical_position (j);
last_vp = vp;
- BOOST_FOREACH (Block const& k, j.blocks) {
+ for (auto const& k: j.blocks) {
if (k.underline && !underline) {
text += "\x82";
underline = true;
offset += this_time;
/* Extension block number. Count up from 0 but use 0xff for the last one */
- put_int_as_int (buffer + 3, this_time < block_size ? 0xff : block_number, 1);
+ put_int_as_int (buffer + 3, offset == text.length() ? 0xff : block_number, 1);
++block_number;
char* finished = new char[tti_size];
/** @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,
int longest = 0;
- BOOST_FOREACH (Subtitle const& i, subtitles) {
- BOOST_FOREACH (Line const& j, i.lines) {
+ for (auto const& i: subtitles) {
+ for (auto const& j: i.lines) {
int t = 0;
- BOOST_FOREACH (Block const& k, j.blocks) {
+ for (auto const& k: j.blocks) {
t += k.text.size ();
}
longest = std::max (longest, t);
ofstream output (file_name.string().c_str());
output.write (buffer, 1024);
- BOOST_FOREACH (char* i, tti_blocks) {
+ for (auto i: tti_blocks) {
output.write (i, 128);
delete[] i;
}