-
Notifications
You must be signed in to change notification settings - Fork 0
/
jplstran.cpp
73 lines (68 loc) · 1.89 KB
/
jplstran.cpp
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
// Copyright (c) Mathieu Malaterre
// SPDX-License-Identifier: BSD-3-Clause
#include "cjpls_options.h"
#include "factory.h" // for factory
#include "format.h" // for format
#include "image.h" // for image, image_info
#include "jls.h" // for format
#include "jplstran_options.h"
#include <iostream> // for operator<<, endl, basic_ostream, cerr
#include <memory> // for unique_ptr
static void transform(jlst::tran_options& options)
{
if (options.jai_imageio)
{
jlst::jls* ptr = new jlst::jls;
std::unique_ptr<jlst::jls> jls_format(ptr);
jls_format->fix_jai(options.get_dest(0), options.get_source(0));
}
else if (options.standard_spiff_header)
{
jlst::jls* ptr = new jlst::jls;
std::unique_ptr<jlst::jls> jls_format(ptr);
jls_format->fix_spiff(options.get_dest(0), options.get_source(0));
}
else
{
jlst::jls* ptr = new jlst::jls;
std::unique_ptr<jlst::jls> jls_format(ptr);
jls_format->transform(options.get_dest(0), options.get_source(0), options);
}
}
int main(int argc, char* argv[])
{
jlst::tran_options options{};
try
{
if (!options.process(argc, argv))
{
// help, or version requested. Return without error
return EXIT_SUCCESS;
}
}
catch (std::exception& e)
{
std::cerr << "Invalid options: " << e.what() << std::endl;
return EXIT_FAILURE;
}
catch (...)
{
std::cerr << "unknown exception during options parsing" << std::endl;
return EXIT_FAILURE;
}
try
{
transform(options);
}
catch (std::exception& e)
{
std::cerr << "Invalid options: " << e.what() << std::endl;
return EXIT_FAILURE;
}
catch (...)
{
std::cerr << "unknown exception during transform" << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}