1 /* sane - Scanner Access Now Easy.
2 
3    Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt>
4 
5    This file is part of the SANE package.
6 
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License as
9    published by the Free Software Foundation; either version 2 of the
10    License, or (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef SANE_TESTSUITE_BACKEND_GENESYS_TESTS_PRINTERS_H
22 #define SANE_TESTSUITE_BACKEND_GENESYS_TESTS_PRINTERS_H
23 
24 #include "../../../backend/genesys/image_pixel.h"
25 #include "../../../backend/genesys/utilities.h"
26 #include <iostream>
27 #include <iomanip>
28 #include <vector>
29 
30 template<class T>
operator <<(std::ostream& str, const std::vector<T>& arg)31 std::ostream& operator<<(std::ostream& str, const std::vector<T>& arg)
32 {
33     str << genesys::format_vector_unsigned(4, arg) << '\n';
34     return str;
35 }
36 
operator <<(std::ostream& str, const genesys::PixelFormat& arg)37 inline std::ostream& operator<<(std::ostream& str, const genesys::PixelFormat& arg)
38 {
39     str << static_cast<unsigned>(arg);
40     return str;
41 }
42 
operator <<(std::ostream& str, const genesys::Pixel& arg)43 inline std::ostream& operator<<(std::ostream& str, const genesys::Pixel& arg)
44 {
45     str << "{ " << arg.r << ", " << arg.g << ", " << arg.b << " }";
46     return str;
47 }
48 
operator <<(std::ostream& str, const genesys::RawPixel& arg)49 inline std::ostream& operator<<(std::ostream& str, const genesys::RawPixel& arg)
50 {
51     auto flags = str.flags();
52     str << std::hex;
53     for (auto el : arg.data) {
54         str << static_cast<unsigned>(el) << " ";
55     }
56     str.flags(flags);
57     return str;
58 }
59 
60 #endif
61