1 /* 2 * Copyright (c) 2022 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 #include "edm_permission.h" 17 #include "string_ex.h" 18 19 namespace OHOS { 20 namespace EDM { EdmPermission()21EdmPermission::EdmPermission() {} ~EdmPermission()22EdmPermission::~EdmPermission() {} 23 EdmPermission(const std::string & name,const uint32_t & type)24EdmPermission::EdmPermission(const std::string &name, const uint32_t &type) 25 : permissionName_(name), adminType_(type) 26 {} 27 getPermissionName() const28const std::string &EdmPermission::getPermissionName() const 29 { 30 return permissionName_; 31 } 32 setPermissionName(const std::string & permissionName)33void EdmPermission::setPermissionName(const std::string &permissionName) 34 { 35 EdmPermission::permissionName_ = permissionName; 36 } 37 getAdminType() const38uint32_t EdmPermission::getAdminType() const 39 { 40 return adminType_; 41 } 42 setAdminType(uint32_t adminType)43void EdmPermission::setAdminType(uint32_t adminType) 44 { 45 EdmPermission::adminType_ = adminType; 46 } 47 operator ==(const EdmPermission & permission) const48bool EdmPermission::operator == (const EdmPermission &permission) const 49 { 50 return (permissionName_ == permission.getPermissionName() && adminType_ == permission.getAdminType()); 51 } 52 ReadFromParcel(Parcel & parcel)53bool EdmPermission::ReadFromParcel(Parcel &parcel) 54 { 55 permissionName_ = Str16ToStr8(parcel.ReadString16()); 56 adminType_ = parcel.ReadUint32(); 57 return true; 58 } 59 Marshalling(Parcel & parcel) const60bool EdmPermission::Marshalling(Parcel &parcel) const 61 { 62 parcel.WriteString16(Str8ToStr16(permissionName_)); 63 parcel.WriteUint32(adminType_); 64 return true; 65 } 66 Unmarshalling(Parcel & parcel)67EdmPermission *EdmPermission::Unmarshalling(Parcel &parcel) 68 { 69 auto *permission = new (std::nothrow)EdmPermission(); 70 permission->ReadFromParcel(parcel); 71 return permission; 72 } 73 } // namespace EDM 74 } // namespace OHOS