-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileOut.cpp
More file actions
64 lines (51 loc) · 1.28 KB
/
FileOut.cpp
File metadata and controls
64 lines (51 loc) · 1.28 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
#include "FileOut.h"
#include <iostream>
#include <fstream>
using namespace std;
ofstream outCss;
ofstream outHtml;
FileOut::FileOut(){
outCss.open("style.css", ios_base::trunc);
outHtml.open("index.html", ios_base::trunc);
if (!outCss || !outHtml) {
throw runtime_error("Błąd otwierania pliku");
delete this;
}
}
FileOut::~FileOut()
{
outCss.close();
outHtml.close();
}
void FileOut::writeCssOption(string obj, vector<pair<string, string>> options)
{
outCss << obj << " {" << endl;
for (auto option : options) {
outCss << "\t" << option.first << ": " << option.second << ";" << endl;
}
outCss << "}" << endl;
}
void FileOut::writeHtmlOption(string tag, vector<pair<string, string>> options, bool closeTag, string content, int tabs)
{
string tabString = "";
if (tabs) for (int i = 0; i < tabs; i++) {
tabString += "\t";
}
outHtml << tabString << "<" << tag;
for (auto option : options) {
outHtml << " " << option.first << "=\"" << option.second << "\"";
}
outHtml << ">";
outHtml << content;
if (closeTag) {
outHtml << "</" << tag << ">";
}
outHtml << endl;
}
void FileOut::writeClosingTag(string tag, int tabs) {
string tabString = "";
if (tabs) for (int i = 0; i < tabs; i++) {
tabString += "\t";
}
outHtml << tabString << "</" << tag << ">" << endl;
}