-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubtitleSave.cpp
More file actions
77 lines (58 loc) · 1.95 KB
/
subtitleSave.cpp
File metadata and controls
77 lines (58 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* File: subtitleSave.cpp
* Author: rukshan
*
* Created on August 30, 2013, 7:59 PM
*/
#include "subtitleSave.h"
#include "subtitleEditor.h"
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <sstream> //include this to use string streams
#include <string>
using namespace std;
subtitleSave::subtitleSave() {
cout << endl;
}
subtitleSave::subtitleSave(const subtitleSave& orig) {
}
subtitleSave::~subtitleSave() {
}
void subtitleSave::saveFile(vector<srtFormat> s, string path) {// save to file
ofstream myfile;
myfile.open(path.c_str(), ios::trunc); // create new file
string start, stop;
for (int i = 0; i < s.size(); i++) {
srtFormat f = s.at(i);
start = f.startH + ":" + f.startM + ":" + f.startS + "," + f.startMs;
stop = f.stopH + ":" + f.stopM + ":" + f.stopS + "," + f.stopMs;
myfile << s.at(i).id << endl; // add id
myfile << start + " --> " + stop << endl; // add start and stop time information
myfile << s.at(i).text << endl; //add text
myfile << endl;
}
myfile.close(); // close the opened file
}
void subtitleSave::saveAsSRT(node nodes[]) {
}
void subtitleSave::saveAsASS(vector<srtFormat> s, string path) {
//Dialogue: 0,0:00:32.69,0:00:36.33,sincity,,0000,0000,0000,,
//{\i1}She shivers in the wind\Nlike the last leaf on a dying tree.{\i0}
//
ofstream myfile;
myfile.open(path.c_str(), ios::trunc); // create new file
string start, stop;
for (int i = 0; i < s.size(); i++) {
srtFormat f = s.at(i);
start = f.startH + ":" + f.startM + ":" + f.startS + "." + f.startMs;
stop = f.stopH + ":" + f.stopM + ":" + f.stopS + "." + f.stopMs;
myfile << "Dialogue: 0,";
myfile << start << ",";
myfile << stop << ",";
myfile << "sincity,,0000,0000,0000,,";
myfile << s.at(i).text << endl;
}
myfile.close(); // close the opened file
}