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 EntInfo *entInfo = new (std::nothrow) EntInfo();
49 if (entInfo && !entInfo->ReadFromParcel(parcel)) {
50 delete entInfo;
51 entInfo = nullptr;
52 }
53 return entInfo;
54 }
55
ReadFromParcel(Parcel & parcel)56 bool EntInfo::ReadFromParcel(Parcel &parcel)
57 {
58 enterpriseName = parcel.ReadString();
59 description = parcel.ReadString();
60 return true;
61 }
62 } // namespace EDM
63 } // namespace OHOS
64