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 "string_serializer.h"
17 #include <string_ex.h>
18
19 namespace OHOS {
20 namespace EDM {
Deserialize(const std::string & jsonString,std::string & dataObj)21 bool StringSerializer::Deserialize(const std::string &jsonString, std::string &dataObj)
22 {
23 dataObj = jsonString;
24 return true;
25 }
26
Serialize(const std::string & dataObj,std::string & jsonString)27 bool StringSerializer::Serialize(const std::string &dataObj, std::string &jsonString)
28 {
29 jsonString = dataObj;
30 return true;
31 }
32
GetPolicy(MessageParcel & data,std::string & result)33 bool StringSerializer::GetPolicy(MessageParcel &data, std::string &result)
34 {
35 result = Str16ToStr8(data.ReadString16());
36 return true;
37 }
38
WritePolicy(MessageParcel & reply,std::string & result)39 bool StringSerializer::WritePolicy(MessageParcel &reply, std::string &result)
40 {
41 return reply.WriteString16(Str8ToStr16(result));
42 }
43
MergePolicy(std::vector<std::string> & data,std::string & result)44 bool StringSerializer::MergePolicy(std::vector<std::string> &data, std::string &result)
45 {
46 for (auto iter = data.rbegin(); iter != data.rend(); ++iter) {
47 result = *iter;
48 return true;
49 }
50 return true;
51 }
52 } // namespace EDM
53 } // namespace OHOS