GCC Code Coverage Report


Directory: ./
File: libs/io/bitmap/detail/libtiff_common.hxx
Date: 2024-05-31 17:23:24
Exec Total Coverage
Lines: 20 21 95.2%
Branches: 26 52 50.0%

Line Branch Exec Source
1 /************************************************************************
2 *
3 * Copyright (C) 2023 IRCAD France
4 *
5 * This file is part of Sight.
6 *
7 * Sight is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Sight is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
19 *
20 ***********************************************************************/
21
22 #pragma once
23
24 #include <tiffio.h>
25
26 #include <cstdarg>
27 #include <cstdio>
28
29 namespace sight::io::bitmap::detail::tiff
30 {
31
32 //------------------------------------------------------------------------------
33
34 30 inline static int map_proc(thandle_t, void**, toff_t*)
35 {
36 30 return 0;
37 }
38
39 //------------------------------------------------------------------------------
40
41 inline static void unmap_proc(thandle_t, void*, toff_t)
42 {
43 }
44
45 //------------------------------------------------------------------------------
46
47 6 inline static void error_handler(const char* _module, const char* _fmt, va_list _args)
48 {
49 6 char error_buffer[0xFFFF];
50 6 vsnprintf(error_buffer, sizeof(error_buffer), _fmt, _args);
51
52 6 std::string msg("Tiff Error: ");
53
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 msg += _module;
54
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 msg += ": ";
55
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 msg += error_buffer;
56
57
15/30
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 6 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 6 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 6 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 6 times.
✗ Branch 26 not taken.
✓ Branch 29 taken 6 times.
✗ Branch 30 not taken.
✓ Branch 33 taken 6 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 6 times.
✗ Branch 37 not taken.
✓ Branch 39 taken 6 times.
✗ Branch 40 not taken.
✓ Branch 43 taken 6 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 6 times.
✗ Branch 47 not taken.
36 SIGHT_THROW(msg);
58 6 }
59
60 //------------------------------------------------------------------------------
61
62 1 inline static void warning_handler(const char* _module, const char* _fmt, va_list _args)
63 {
64 1 char warning_buffer[0xFFFF];
65 1 vsnprintf(warning_buffer, sizeof(warning_buffer), _fmt, _args);
66
67 1 std::string msg("Tiff Warning: ");
68
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 msg += _module;
69
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 msg += ": ";
70
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 msg += warning_buffer;
71
72
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
2 SIGHT_WARN(msg);
73 1 }
74
75 static const struct handler_registry final
76 {
77 inline handler_registry() noexcept
78 {
79 TIFFSetErrorHandler(&error_handler);
80 TIFFSetWarningHandler(&warning_handler);
81 }
82 } REGISTRY;
83
84 } // namespace sight::io::bitmap::detail::tiff
85