• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_DISTRO_FILTER_H
17 #define DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_DISTRO_FILTER_H
18 
19 #include <list>
20 #include <sstream>
21 #include <string>
22 
23 #include "pt_json.h"
24 
25 namespace OHOS {
26 namespace AppPackingTool {
27 struct PolicyValue {
28     std::string policy = "";
29     std::list<std::string> value;
30 
31     bool ParseFromJson(std::unique_ptr<PtJson>& root);
32     bool ParseFromJsonApiVersion(std::unique_ptr<PtJson>& root);
33     bool IsEmpty() const;
34 };
35 
36 typedef PolicyValue ApiVersion;
37 typedef PolicyValue ScreenShape;
38 typedef PolicyValue ScreenDensity;
39 typedef PolicyValue ScreenWindow;
40 typedef PolicyValue CountryCode;
41 
42 struct DistroFilter {
43     ApiVersion apiVersion;
44     ScreenShape screenShape;
45     ScreenDensity screenDensity;
46     ScreenWindow screenWindow;
47     CountryCode countryCode;
48 
49     bool ParseFromJson(std::unique_ptr<PtJson>& root);
50     bool IsEmpty() const;
51     std::string Dump() const;
52 
53 private:
54     bool ParseApiVersion(std::unique_ptr<PtJson>& root);
55     bool ParseScreenShape(std::unique_ptr<PtJson>& root);
56     bool ParseScreenDensity(std::unique_ptr<PtJson>& root);
57     bool ParseScreenWindow(std::unique_ptr<PtJson>& root);
58     bool ParseCountryCode(std::unique_ptr<PtJson>& root);
59 };
60 }  // namespace AppPackingTool
61 }  // namespace OHOS
62 #endif  // DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_DISTRO_FILTER_H
63