• 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_ITEM_H
17 #define OHOS_RESTOOL_RESOURCE_ITEM_H
18 
19 #include <vector>
20 #include "resource_data.h"
21 
22 namespace OHOS {
23 namespace Global {
24 namespace Restool {
25 class ResourceItem {
26 public:
27     ResourceItem();
28     ResourceItem(const ResourceItem &other);
29     ResourceItem(const std::string &name, const std::vector<KeyParam> &keyparams, ResType type);
30     virtual ~ResourceItem();
31 
32     bool SetData(const std::string &data);
33     bool SetData(const int8_t *data, uint32_t length);
34     void SetFilePath(const std::string &filePath);
35     void SetLimitKey(const std::string &limitKey);
36     void SetName(const std::string &name);
37     void MarkCoverable();
38 
39     const int8_t *GetData() const;
40     uint32_t GetDataLength() const;
41     const std::string &GetName() const;
42     const ResType &GetResType() const;
43     const std::vector<KeyParam> &GetKeyParam() const;
44     const std::string &GetFilePath() const;
45     const std::string &GetLimitKey() const;
46     bool IsCoverable() const;
47     const std::vector<std::string> SplitValue() const;
48     bool IsArray() const;
49     bool IsPair() const;
50     void CheckData();
51 
52     ResourceItem &operator=(const ResourceItem &other);
53 private:
54     void ReleaseData();
55     void CopyFrom(const ResourceItem &other);
56     int8_t *data_ = nullptr;
57     uint32_t dataLen_ = 0;
58     std::string name_;
59     std::vector<KeyParam> keyparams_;
60     ResType type_;
61     std::string filePath_;
62     std::string limitKey_;
63     bool coverable_ = false;
64 };
65 }
66 }
67 }
68 #endif