Coverage Report

Created: 2026-03-31 07:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/poppler/cpp/poppler-rectangle.h
Line
Count
Source
1
/*
2
 * Copyright (C) 2009-2010, Pino Toscano <pino@kde.org>
3
 * Copyright (C) 2025, Albert Astals Cid <aacid@kde.org>
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2, or (at your option)
8
 * any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
18
 */
19
20
#ifndef POPPLER_RECTANGLE_H
21
#define POPPLER_RECTANGLE_H
22
23
#include "poppler_cpp_export.h"
24
25
#include <ostream>
26
27
namespace poppler {
28
29
template<typename T>
30
class rectangle
31
{
32
public:
33
0
    rectangle() : x1(), y1(), x2(), y2() { }
34
5.45M
    rectangle(T _x, T _y, T w, T h) : x1(_x), y1(_y), x2(x1 + w), y2(y1 + h) { }
35
    ~rectangle() = default;
36
37
0
    bool is_empty() const { return (x1 == x2) && (y1 == y2); }
38
39
    T x() const { return x1; }
40
41
    T y() const { return y1; }
42
43
0
    T width() const { return x2 - x1; }
44
45
0
    T height() const { return y2 - y1; }
46
47
12.4k
    T left() const { return x1; }
48
12.4k
    T top() const { return y1; }
49
12.4k
    T right() const { return x2; }
50
12.4k
    T bottom() const { return y2; }
51
52
12.4k
    void set_left(T value) { x1 = value; }
53
12.4k
    void set_top(T value) { y1 = value; }
54
12.4k
    void set_right(T value) { x2 = value; }
55
12.4k
    void set_bottom(T value) { y2 = value; }
56
57
private:
58
    T x1, y1, x2, y2;
59
};
60
61
using rect = rectangle<int>;
62
using rectf = rectangle<double>;
63
64
POPPLER_CPP_EXPORT std::ostream &operator<<(std::ostream &stream, rect r);
65
POPPLER_CPP_EXPORT std::ostream &operator<<(std::ostream &stream, const rectf &r);
66
67
}
68
69
#endif