• 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_INCREMENT_INDEX_H
17 #define OHOS_RESTOOL_INCREMENT_INDEX_H
18 
19 #include "resource_item.h"
20 #include "resource_util.h"
21 
22 namespace OHOS {
23 namespace Global {
24 namespace Restool {
25 class IncrementIndex {
26 public:
27     IncrementIndex(const std::string &indexPath, const std::vector<std::string> &folder);
~IncrementIndex()28     virtual ~IncrementIndex() {};
29     bool Save(const std::map<int32_t, std::vector<ResourceItem>> &items) const;
30     bool Load(std::map<int32_t, std::vector<ResourceItem>> &items) const;
31     void SetSkipPaths(const std::vector<std::string> &skipPaths);
32 
33     static const std::string INDEX_FILE;
34 private:
35     bool LoadIndex(const Json::Value &indexInfo, std::map<int32_t, std::vector<ResourceItem>> &items) const;
36     bool ParseResourceItem(const Json::Value &item, const std::string &filePath, ResourceItem &resourceItem) const;
37     bool GetResourceItemProp(const Json::Value &item, const std::string &key, std::string &value) const;
38     bool PushResourceItem(const ResourceItem &resourceItem, int32_t id,
39         std::map<int32_t, std::vector<ResourceItem>> &items) const;
40     bool IsIgnore(const std::string &filePath) const;
41     const std::string &indexPath_;
42     const std::vector<std::string> &folder_;
43     std::vector<std::string> skipPaths_;
44 };
45 }
46 }
47 }
48 #endif