• 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_COMPILER_H
17 #define OHOS_RESTOOL_RESOURCE_COMPILER_H
18 
19 #include <vector>
20 #include "resource_data.h"
21 #include "resource_item.h"
22 
23 namespace OHOS {
24 namespace Global {
25 namespace Restool {
26 class IResourceCompiler {
27 public:
28     IResourceCompiler(ResType type, const std::string &output);
29     virtual ~IResourceCompiler();
30     uint32_t Compile(const std::vector<DirectoryInfo> &directoryInfos);
31     const std::map<int32_t, std::vector<ResourceItem>> &GetResult() const;
32     uint32_t Compile(const FileInfo &fileInfo);
33     void SetModuleName(const std::string &moduleName);
34     uint32_t CompileForAppend(const FileInfo &fileInfo);
35     const std::map<std::pair<ResType, std::string>, std::vector<ResourceItem>> &GetResourceItems() const;
36 
37 protected:
38     virtual uint32_t CompileSingleFile(const FileInfo &fileInfo);
39     bool MergeResourceItem(const ResourceItem &resourceItem);
40     std::string GetOutputFolder(const DirectoryInfo &directoryInfo) const;
41     ResType type_;
42     std::string output_;
43     std::string moduleName_;
44 
45     // id, resource items
46     std::map<int32_t, std::vector<ResourceItem>> resourceInfos_;
47     // ResType, name, resourceItems
48     std::map<std::pair<ResType, std::string>, std::vector<ResourceItem>> nameInfos_;
49 
50 private:
51     uint32_t PostCommit();
52 };
53 }
54 }
55 }
56 #endif