• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 "geocode_convert_location_request.h"
17 
18 namespace OHOS {
19 namespace Location {
GeocodeConvertLocationRequest()20 GeocodeConvertLocationRequest::GeocodeConvertLocationRequest()
21 {
22     locale_ = "";
23     latitude_ = 0.0;
24     longitude_ = 0.0;
25     maxItems_ = 0;
26     transId_ = "";
27     country_ = "";
28 }
29 
~GeocodeConvertLocationRequest()30 GeocodeConvertLocationRequest::~GeocodeConvertLocationRequest() {}
31 
GetLocale()32 std::string GeocodeConvertLocationRequest::GetLocale()
33 {
34     return locale_;
35 }
36 
SetLocale(std::string locale)37 void GeocodeConvertLocationRequest::SetLocale(std::string locale)
38 {
39     locale_ = locale;
40 }
41 
GetLatitude()42 double GeocodeConvertLocationRequest::GetLatitude()
43 {
44     return latitude_;
45 }
46 
SetLatitude(double latitude)47 void GeocodeConvertLocationRequest::SetLatitude(double latitude)
48 {
49     latitude_ = latitude;
50 }
51 
GetLongitude()52 double GeocodeConvertLocationRequest::GetLongitude()
53 {
54     return longitude_;
55 }
56 
SetLongitude(double longitude)57 void GeocodeConvertLocationRequest::SetLongitude(double longitude)
58 {
59     longitude_ = longitude;
60 }
61 
GetMaxItems()62 int32_t GeocodeConvertLocationRequest::GetMaxItems()
63 {
64     return maxItems_;
65 }
66 
SetMaxItems(int32_t maxItems)67 void GeocodeConvertLocationRequest::SetMaxItems(int32_t maxItems)
68 {
69     maxItems_ = maxItems;
70 }
71 
GetTransId()72 std::string GeocodeConvertLocationRequest::GetTransId()
73 {
74     return transId_;
75 }
76 
SetTransId(std::string transId)77 void GeocodeConvertLocationRequest::SetTransId(std::string transId)
78 {
79     transId_ = transId;
80 }
81 
GetCountry()82 std::string GeocodeConvertLocationRequest::GetCountry()
83 {
84     return country_;
85 }
86 
SetCountry(std::string country)87 void GeocodeConvertLocationRequest::SetCountry(std::string country)
88 {
89     country_ = country;
90 }
91 
Marshalling(Parcel & parcel) const92 bool GeocodeConvertLocationRequest::Marshalling(Parcel& parcel) const
93 {
94     parcel.WriteString16(Str8ToStr16(locale_)); // locale
95     parcel.WriteDouble(latitude_); // latitude
96     parcel.WriteDouble(longitude_); // longitude
97     parcel.WriteInt32(maxItems_); // maxItems
98     parcel.WriteString16(Str8ToStr16(transId_)); // transId
99     parcel.WriteString16(Str8ToStr16(country_)); // country
100     return true;
101 }
102 
Unmarshalling(Parcel & parcel)103 GeocodeConvertLocationRequest* GeocodeConvertLocationRequest::Unmarshalling(Parcel& parcel)
104 {
105     auto geoConvertRequest = new GeocodeConvertLocationRequest();
106     geoConvertRequest->ReadFromParcel(parcel);
107     return geoConvertRequest;
108 }
109 
ReadFromParcel(Parcel & parcel)110 void GeocodeConvertLocationRequest::ReadFromParcel(Parcel& parcel)
111 {
112     locale_ = Str16ToStr8(parcel.ReadString16()); // locale
113     latitude_ = parcel.ReadDouble(); // latitude
114     longitude_ =  parcel.ReadDouble(); // longitude
115     maxItems_ = parcel.ReadInt32(); // maxItems
116     transId_ = Str16ToStr8(parcel.ReadString16()); // transId
117     country_ = Str16ToStr8(parcel.ReadString16()); // country
118 }
119 
UnmarshallingMessageParcel(MessageParcel & parcel)120 std::unique_ptr<GeocodeConvertLocationRequest> GeocodeConvertLocationRequest::UnmarshallingMessageParcel(
121     MessageParcel& parcel)
122 {
123     auto geoConvertRequest = std::make_unique<GeocodeConvertLocationRequest>();
124     geoConvertRequest->ReadFromMessageParcel(parcel);
125     return geoConvertRequest;
126 }
127 
ReadFromMessageParcel(MessageParcel & parcel)128 void GeocodeConvertLocationRequest::ReadFromMessageParcel(MessageParcel& parcel)
129 {
130     locale_ = Str16ToStr8(parcel.ReadString16()); // locale
131     latitude_ = parcel.ReadDouble(); // latitude
132     longitude_ =  parcel.ReadDouble(); // longitude
133     maxItems_ = parcel.ReadInt32(); // maxItems
134     transId_ = Str16ToStr8(parcel.ReadString16()); // transId
135     country_ = Str16ToStr8(parcel.ReadString16()); // country
136 }
137 } // namespace Location
138 } // namespace OHOS
139