Debian Codegraph @

podofo/tools/private/MainEntryPoint.cpp

raw
1 #include <vector>
2 #include <string>
3 #include <iostream>
4
5 #include <utf8cpp/utf8.h>
6 #include <podofo/main/PdfError.h>
7
8 using namespace std;
9 using namespace PoDoFo;
10
11 extern void Main(const cspan<string_view>& args);
12
13 #ifdef _WIN32
14 int wmain(int argc, wchar_t* argv[])
15 #else // !_WIN32
16 int main(int argc, char* argv[])
17 #endif // _WIN32
18 {
19 vector<string_view> args(argc);
20 #ifdef _WIN32
21 vector<string> args_(argc);
22 for (int i = 0; i < argc; i++)
23 {
24 args_[i] = utf8::utf16to8(u16string_view((const char16_t*)argv[i],
25 char_traits<char16_t>::length((const char16_t*)argv[i])));
26 args[i] = args_[i];
27 }
28 #else // !_WIN32
29 for (int i = 0; i < argc; i++)
30 args[i] = string_view(argv[i], char_traits<char>::length(argv[i]));
31 #endif // _WIN32
32 try
33 {
34 Main(args);
35 }
36 catch (const PdfError& ex)
37 {
38 cerr << "ERROR: An error occurred during processing the pdf file" << endl;
39 cerr << ex.what() << endl;
40 return (int)ex.GetCode();
41 }
42
43 return 0;
44 }