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 38 const int8_t *GetData() const; 39 uint32_t GetDataLength() const; 40 const std::string &GetName() const; 41 const ResType &GetResType() const; 42 const std::vector<KeyParam> &GetKeyParam() const; 43 const std::string &GetFilePath() const; 44 const std::string &GetLimitKey() const; 45 46 ResourceItem &operator=(const ResourceItem &other); 47 private: 48 void ReleaseData(); 49 void CopyFrom(const ResourceItem &other); 50 int8_t *data_ = nullptr; 51 uint32_t dataLen_; 52 std::string name_; 53 std::vector<KeyParam> keyparams_; 54 ResType type_; 55 std::string filePath_; 56 std::string limitKey_; 57 }; 58 } 59 } 60 } 61 #endif