• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PRINT_RANGE_H
17 #define PRINT_RANGE_H
18 
19 #include <vector>
20 #include "parcel.h"
21  #include <json/json.h>
22 
23 namespace OHOS::Print {
24 class PrintRange final : public Parcelable {
25 public:
26     explicit PrintRange();
27 
28     PrintRange(const PrintRange &right);
29 
30     PrintRange &operator=(const PrintRange &right);
31 
32     virtual ~PrintRange();
33 
34     void Reset();
35 
36     [[nodiscard]] bool HasStartPage() const;
37 
38     [[nodiscard]] uint32_t GetStartPage() const;
39 
40     [[nodiscard]] bool HasEndPage() const;
41 
42     [[nodiscard]] uint32_t GetEndPage() const;
43 
44     [[nodiscard]] bool HasPages() const;
45 
46     void GetPages(std::vector<uint32_t> &pages) const;
47 
48     void SetStartPage(uint32_t startPage);
49 
50     void SetEndPage(uint32_t endPage);
51 
52     void SetPages(const std::vector<uint32_t> &pages);
53 
54     virtual bool Marshalling(Parcel &parcel) const override;
55 
56     static std::shared_ptr<PrintRange> Unmarshalling(Parcel &parcel);
57 
58     Json::Value ConvertToJsonObject() const;
59 
60     void Dump();
61 
62 private:
63     void ReadFromParcel(Parcel &parcel);
64 
65 private:
66     bool hasStartPage_;
67     uint32_t startPage_;
68 
69     bool hasEndPage_;
70     uint32_t endPage_;
71 
72     bool hasPages_;
73     std::vector<uint32_t> pages_;
74 };
75 }  // namespace OHOS::Print
76 #endif  // PRINT_RANGE_H
77