[M120 Migration][MM] Fix EME AD insert issue
[platform/framework/web/chromium-efl.git] / printing / page_range.h
1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PRINTING_PAGE_RANGE_H_
6 #define PRINTING_PAGE_RANGE_H_
7
8 #include <stdint.h>
9
10 #include <limits>
11 #include <vector>
12
13 #include "base/component_export.h"
14
15 namespace printing {
16
17 struct PageRange;
18
19 using PageRanges = std::vector<PageRange>;
20
21 // Print range is inclusive. To select one page, set from == to.
22 struct COMPONENT_EXPORT(PRINTING) PageRange {
23   // Any value above maximum practical page count (enforced by PageNumber)
24   // would work, but we chose something that works even where the page
25   // numbers are 1-based (i.e. can be increased by one without overflow).
26   static constexpr uint32_t kMaxPage = std::numeric_limits<uint32_t>::max() - 1;
27
28   uint32_t from;
29   uint32_t to;
30
31   bool operator<(const PageRange& rhs) const {
32     return from < rhs.from || (from == rhs.from && to < rhs.to);
33   }
34   bool operator==(const PageRange& rhs) const {
35     return from == rhs.from && to == rhs.to;
36   }
37
38   // Ensures entries come in monotonically increasing order and do not
39   // overlap.
40   static void Normalize(PageRanges& ranges);
41 };
42
43 }  // namespace printing
44
45 #endif  // PRINTING_PAGE_RANGE_H_