• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 OHOS_RESTOOL_RESOURCE_DATA_H
17 #define OHOS_RESTOOL_RESOURCE_DATA_H
18 
19 #include<map>
20 #include<stdint.h>
21 #include<string>
22 
23 namespace OHOS {
24 namespace Global {
25 namespace Restool {
26 const static std::string TOOL_NAME = "restool";
27 const static std::string RESOURCES_DIR = "resources";
28 const static std::string CONFIG_JSON = "config.json";
29 const static std::string MODULE_JSON = "module.json";
30 const static std::string RAW_FILE_DIR = "rawfile";
31 const static std::string ID_DEFINED_FILE = "id_defined.json";
32 const static std::string RESOURCE_INDEX_FILE = "resources.index";
33 const static std::string SEPARATOR = "/";
34 const static std::string WIN_SEPARATOR = "\\";
35 const static std::string NEW_LINE_PATH = "\r\nat ";
36 const static std::string LONG_PATH_HEAD = "\\\\?\\";
37 const static int32_t VERSION_MAX_LEN = 128;
38 const static int32_t INT_TO_BYTES = sizeof(uint32_t);
39 static const int8_t RESTOOL_VERSION[VERSION_MAX_LEN] = { "Restool 2.010" };
40 const static int32_t TAG_LEN = 4;
41 
42 enum class KeyType {
43     LANGUAGE = 0,
44     REGION = 1,
45     RESOLUTION = 2,
46     ORIENTATION = 3,
47     DEVICETYPE = 4,
48     SCRIPT = 5,
49     NIGHTMODE = 6,
50     MCC = 7,
51     MNC = 8,
52     // RESERVER 9
53     INPUTDEVICE = 10,
54     KEY_TYPE_MAX,
55 };
56 
57 enum class ResType {
58     ELEMENT = 0,
59     ANIMATION = 1,
60     LAYOUT = 3,
61     RAW = 6,
62     INTEGER = 8,
63     STRING = 9,
64     STRARRAY = 10,
65     INTARRAY = 11,
66     BOOLEAN = 12,
67     COLOR = 14,
68     ID = 15,
69     THEME = 16,
70     PLURAL = 17,
71     FLOAT = 18,
72     MEDIA = 19,
73     PROF = 20,
74     GRAPHIC = 21,
75     PATTERN = 22,
76     INVALID_RES_TYPE = -1,
77 };
78 
79 enum class OrientationType {
80     VERTICAL = 0,
81     HORIZONTAL = 1,
82 };
83 
84 const std::map<std::string, OrientationType> g_orientaionMap = {
85     { "vertical", OrientationType::VERTICAL },
86     { "horizontal", OrientationType::HORIZONTAL },
87 };
88 
89 enum class DeviceType {
90     PHONE = 0,
91     TABLET = 1,
92     CAR = 2,
93     // RESERVER 3
94     TV = 4,
95     WEARABLE = 6,
96 };
97 
98 const std::map<std::string, DeviceType> g_deviceMap = {
99     { "phone", DeviceType::PHONE },
100     { "tablet", DeviceType::TABLET },
101     { "car", DeviceType::CAR },
102     { "tv", DeviceType::TV },
103     { "wearable", DeviceType::WEARABLE },
104 };
105 
106 enum class ResolutionType {
107     SDPI = 120,
108     MDPI = 160,
109     LDPI = 240,
110     XLDPI = 320,
111     XXLDPI = 480,
112     XXXLDPI = 640,
113 };
114 
115 const std::map<std::string, ResolutionType> g_resolutionMap = {
116     { "sdpi", ResolutionType::SDPI },
117     { "mdpi",  ResolutionType::MDPI },
118     { "ldpi",  ResolutionType::LDPI },
119     { "xldpi", ResolutionType::XLDPI },
120     { "xxldpi", ResolutionType::XXLDPI },
121     { "xxxldpi", ResolutionType::XXXLDPI },
122 };
123 
124 enum class NightMode {
125     DARK = 0,
126     LIGHT = 1,
127 };
128 
129 const std::map<std::string, NightMode> g_nightModeMap = {
130     { "dark", NightMode::DARK },
131     { "light", NightMode::LIGHT },
132 };
133 
134 enum class InputDevice {
135     INPUTDEVICE_NOT_SET = -1,
136     INPUTDEVICE_POINTINGDEVICE = 0,
137 };
138 
139 const std::map<std::string, InputDevice> g_inputDeviceMap = {
140     { "pointingdevice", InputDevice::INPUTDEVICE_POINTINGDEVICE },
141 };
142 
143 struct KeyParam {
144     KeyType keyType;
145     uint32_t value;
146 };
147 
148 struct IdData {
149     uint32_t id;
150     uint32_t dataOffset;
151 };
152 
153 const std::map<std::string, ResType> g_fileClusterMap = {
154     { "element", ResType::ELEMENT },
155     { "media", ResType::MEDIA },
156     { "profile", ResType::PROF },
157 };
158 
159 const std::map<std::string, ResType> g_contentClusterMap = {
160     { "id", ResType::ID },
161     { "integer", ResType::INTEGER },
162     { "string", ResType::STRING },
163     { "strarray", ResType::STRARRAY },
164     { "intarray", ResType::INTARRAY },
165     { "color", ResType::COLOR },
166     { "plural", ResType::PLURAL },
167     { "boolean", ResType::BOOLEAN },
168     { "pattern", ResType::PATTERN },
169     { "theme", ResType::THEME },
170     { "float", ResType::FLOAT }
171 };
172 
173 const std::map<int32_t, ResType> g_resTypeMap = {
174     { static_cast<int32_t>(ResType::ELEMENT), ResType::ELEMENT},
175     { static_cast<int32_t>(ResType::ANIMATION), ResType::ANIMATION},
176     { static_cast<int32_t>(ResType::LAYOUT), ResType::LAYOUT},
177     { static_cast<int32_t>(ResType::RAW), ResType::RAW},
178     { static_cast<int32_t>(ResType::INTEGER), ResType::INTEGER},
179     { static_cast<int32_t>(ResType::STRING), ResType::STRING},
180     { static_cast<int32_t>(ResType::STRARRAY), ResType::STRARRAY},
181     { static_cast<int32_t>(ResType::INTARRAY), ResType::INTARRAY},
182     { static_cast<int32_t>(ResType::BOOLEAN), ResType::BOOLEAN},
183     { static_cast<int32_t>(ResType::COLOR), ResType::COLOR},
184     { static_cast<int32_t>(ResType::ID), ResType::ID},
185     { static_cast<int32_t>(ResType::THEME), ResType::THEME},
186     { static_cast<int32_t>(ResType::PLURAL), ResType::PLURAL},
187     { static_cast<int32_t>(ResType::FLOAT), ResType::FLOAT},
188     { static_cast<int32_t>(ResType::MEDIA), ResType::MEDIA},
189     { static_cast<int32_t>(ResType::PROF), ResType::PROF},
190     { static_cast<int32_t>(ResType::GRAPHIC), ResType::GRAPHIC},
191     { static_cast<int32_t>(ResType::PATTERN), ResType::PATTERN},
192     { static_cast<int32_t>(ResType::INVALID_RES_TYPE), ResType::INVALID_RES_TYPE},
193 };
194 
195 struct DirectoryInfo {
196     std::string limitKey;
197     std::string fileCluster;
198     std::string dirPath;
199     std::vector<KeyParam> keyParams;
200     ResType dirType;
201 };
202 
203 struct FileInfo : DirectoryInfo {
204     std::string filePath;
205     std::string filename;
206     ResType fileType;
207 };
208 }
209 }
210 }
211 #endif
212