Land Recent QUIC Changes.
[chromium-blink-merge.git] / printing / page_number.h
bloba51ad1e98ad37741f98ea0b4e1e9a9eb97535263
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PRINTING_PAGE_NUMBER_H_
6 #define PRINTING_PAGE_NUMBER_H_
8 #include <ostream>
10 #include "printing/page_range.h"
12 namespace printing {
14 class PrintSettings;
16 // Represents a page series following the array of page ranges defined in a
17 // PrintSettings.
18 class PRINTING_EXPORT PageNumber {
19 public:
20 // Initializes the page to the first page in the settings's range or 0.
21 PageNumber(const PrintSettings& settings, int document_page_count);
23 PageNumber();
25 void operator=(const PageNumber& other);
27 // Initializes the page to the first page in the setting's range or 0. It
28 // initialize to npos if the range is empty and document_page_count is 0.
29 void Init(const PrintSettings& settings, int document_page_count);
31 // Converts to a page numbers.
32 int ToInt() const {
33 return page_number_;
36 // Calculates the next page in the serie.
37 int operator++();
39 // Returns an instance that represents the end of a serie.
40 static const PageNumber npos() {
41 return PageNumber();
44 // Equality operator. Only the current page number is verified so that
45 // "page != PageNumber::npos()" works.
46 bool operator==(const PageNumber& other) const;
47 bool operator!=(const PageNumber& other) const;
49 private:
50 // The page range to follow.
51 const PageRanges* ranges_;
53 // The next page to be printed. -1 when not printing.
54 int page_number_;
56 // The next page to be printed. -1 when not used. Valid only if
57 // document()->settings().range.empty() is false.
58 int page_range_index_;
60 // Number of expected pages in the document. Used when ranges_ is NULL.
61 int document_page_count_;
64 // Debug output support.
65 template<class E, class T>
66 inline typename std::basic_ostream<E,T>& operator<<(
67 typename std::basic_ostream<E,T>& ss, const PageNumber& page) {
68 return ss << page.ToInt();
71 } // namespace printing
73 #endif // PRINTING_PAGE_NUMBER_H_