• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 "ent_info.h"
17 #include "edm_log.h"
18 #include "string_ex.h"
19 #include "parcel_macro.h"
20 
21 namespace OHOS {
22 namespace EDM {
EntInfo(const std::string & enterpriseName,const std::string & description)23 EntInfo::EntInfo(const std::string &enterpriseName, const std::string &description)
24     : enterpriseName(enterpriseName), description(description)
25 {
26     EDMLOGD("ent info instance is created with parameters");
27 }
28 
EntInfo()29 EntInfo::EntInfo()
30 {
31     EDMLOGD("ent info instance is created without parameter");
32 }
33 
~EntInfo()34 EntInfo::~EntInfo()
35 {
36     EDMLOGD("ent info instance is destroyed");
37 }
38 
Marshalling(Parcel & parcel) const39 bool EntInfo::Marshalling(Parcel &parcel) const
40 {
41     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, enterpriseName);
42     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, description);
43     return true;
44 }
45 
Unmarshalling(Parcel & parcel)46 EntInfo *EntInfo::Unmarshalling(Parcel &parcel)
47 {
48     auto *info = new (std::nothrow) EntInfo();
49     if (info && !info->ReadFromParcel(parcel)) {
50         EDMLOGW("read from parcel failed");
51         delete info;
52         info = nullptr;
53     }
54     return info;
55 }
56 
ReadFromParcel(Parcel & parcel)57 bool EntInfo::ReadFromParcel(Parcel &parcel)
58 {
59     enterpriseName = parcel.ReadString();
60     description = parcel.ReadString();
61     return true;
62 }
63 } // namespace EDM
64 } // namespace OHOS
65