Skip to content

Commit 75d2977

Browse files
committed
clean includes
1 parent d2ab047 commit 75d2977

22 files changed

+29
-37
lines changed

cli/src/back_translate.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44

55
#include <odr/internal/util/file_util.hpp>
66

7-
#include <iostream>
87
#include <string>
98

109
using namespace odr;
1110

1211
int main(int, char **argv) {
12+
const std::shared_ptr logger =
13+
Logger::create_stdio("odr-back-translate", LogLevel::verbose);
14+
1315
const std::string input{argv[1]};
1416
const std::string diff_path{argv[2]};
1517
const std::string output{argv[3]};
1618

1719
const DocumentFile document_file{input};
1820

1921
if (document_file.password_encrypted()) {
20-
std::cerr << "encrypted documents are not supported" << std::endl;
22+
ODR_FATAL(*logger, "encrypted documents are not supported");
2123
return 1;
2224
}
2325

cli/src/meta.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,27 @@
1010
using namespace odr;
1111

1212
int main(const int argc, char **argv) {
13+
const std::shared_ptr logger =
14+
Logger::create_stdio("odr-meta", LogLevel::verbose);
15+
1316
const std::string input{argv[1]};
1417

15-
const bool has_password = argc >= 4;
16-
std::string password;
17-
if (has_password) {
18+
std::optional<std::string> password;
19+
if (argc >= 3) {
1820
password = argv[2];
1921
}
2022

2123
DocumentFile document_file{input};
2224

23-
if (document_file.password_encrypted() && has_password) {
25+
if (document_file.password_encrypted() && !password) {
26+
ODR_FATAL(*logger, "document encrypted but no password given");
27+
return 2;
28+
}
29+
if (document_file.password_encrypted()) {
2430
try {
25-
document_file = document_file.decrypt(password);
31+
document_file = document_file.decrypt(*password);
2632
} catch (const WrongPasswordError &) {
27-
std::cerr << "wrong password" << std::endl;
33+
ODR_FATAL(*logger, "wrong password");
2834
return 1;
2935
}
3036
}

cli/src/server.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
#include "odr/archive.hpp"
2-
1+
#include <odr/archive.hpp>
32
#include <odr/exceptions.hpp>
43
#include <odr/file.hpp>
54
#include <odr/filesystem.hpp>
65
#include <odr/html.hpp>
76
#include <odr/http_server.hpp>
87

9-
#include <iostream>
108
#include <string>
119

1210
using namespace odr;
1311

1412
int main(const int argc, char **argv) {
15-
std::shared_ptr logger =
13+
const std::shared_ptr logger =
1614
Logger::create_stdio("odr-server", LogLevel::verbose);
1715

1816
std::string input{argv[1]};

cli/src/translate.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
#include <odr/html.hpp>
44

55
#include <filesystem>
6-
#include <iostream>
76
#include <string>
87

98
using namespace odr;
109

1110
int main(const int argc, char **argv) {
11+
const std::shared_ptr logger =
12+
Logger::create_stdio("odr-translate", LogLevel::verbose);
13+
1214
const std::string input{argv[1]};
1315
const std::string output{argv[2]};
1416

@@ -20,14 +22,14 @@ int main(const int argc, char **argv) {
2022
DecodedFile decoded_file{input};
2123

2224
if (decoded_file.password_encrypted() && !password) {
23-
std::cerr << "document encrypted but no password given" << std::endl;
25+
ODR_FATAL(*logger, "document encrypted but no password given");
2426
return 2;
2527
}
2628
if (decoded_file.password_encrypted()) {
2729
try {
2830
decoded_file = decoded_file.decrypt(*password);
2931
} catch (const WrongPasswordError &) {
30-
std::cerr << "wrong password" << std::endl;
32+
ODR_FATAL(*logger, "wrong password");
3133
return 1;
3234
}
3335
}

src/odr/document_path.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <odr/document_element.hpp>
44

55
#include <algorithm>
6-
#include <iostream>
76
#include <stdexcept>
87

98
namespace odr {

src/odr/internal/common/path.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <cstdint>
44
#include <filesystem>
5-
#include <iostream>
65
#include <string>
76
#include <typeindex>
87

src/odr/internal/csv/csv_file.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
#include <odr/internal/csv/csv_util.hpp>
44

5-
#include <iostream>
6-
75
namespace odr::internal::csv {
86

97
CsvFile::CsvFile(std::shared_ptr<text::TextFile> file)

src/odr/internal/html/pdf_file.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <odr/internal/pdf/pdf_graphics_state.hpp>
1616

1717
#include <fstream>
18+
#include <iostream>
1819

1920
namespace odr::internal::html {
2021

src/odr/internal/json/json_file.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
#include <odr/internal/json/json_util.hpp>
44

5-
#include <iostream>
6-
75
namespace odr::internal::json {
86

97
JsonFile::JsonFile(std::shared_ptr<text::TextFile> file)

src/odr/internal/magic.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include <odr/internal/libmagic/libmagic.hpp>
88
#include <odr/internal/util/string_util.hpp>
99

10-
#include <iostream>
11-
1210
namespace odr::internal {
1311

1412
namespace {

0 commit comments

Comments
 (0)