Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Interop / Interop.Address.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Runtime.InteropServices;
19
20 internal static partial class Interop
21 {
22     [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_building_number")]
23     internal static extern ErrorCode GetBuildingNumber(this AddressHandle /* maps_address_h */ address, out string buildingNumber);
24
25     [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_building_number")]
26     internal static extern ErrorCode SetBuildingNumber(this AddressHandle /* maps_address_h */ address, string buildingNumber);
27
28     [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_street")]
29     internal static extern ErrorCode GetStreet(this AddressHandle /* maps_address_h */ address, out string street);
30
31     [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_street")]
32     internal static extern ErrorCode SetStreet(this AddressHandle /* maps_address_h */ address, string street);
33
34     [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_district")]
35     internal static extern ErrorCode GetDistrict(this AddressHandle /* maps_address_h */ address, out string district);
36
37     [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_district")]
38     internal static extern ErrorCode SetDistrict(this AddressHandle /* maps_address_h */ address, string district);
39
40     [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_city")]
41     internal static extern ErrorCode GetCity(this AddressHandle /* maps_address_h */ address, out string city);
42
43     [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_city")]
44     internal static extern ErrorCode SetCity(this AddressHandle /* maps_address_h */ address, string city);
45
46     [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_state")]
47     internal static extern ErrorCode GetState(this AddressHandle /* maps_address_h */ address, out string state);
48
49     [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_state")]
50     internal static extern ErrorCode SetState(this AddressHandle /* maps_address_h */ address, string state);
51
52     [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_country")]
53     internal static extern ErrorCode GetCountry(this AddressHandle /* maps_address_h */ address, out string country);
54
55     [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_country")]
56     internal static extern ErrorCode SetCountry(this AddressHandle /* maps_address_h */ address, string country);
57
58     [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_country_code")]
59     internal static extern ErrorCode GetCountryCode(this AddressHandle /* maps_address_h */ address, out string countryCode);
60
61     [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_country_code")]
62     internal static extern ErrorCode SetCountryCode(this AddressHandle /* maps_address_h */ address, string countryCode);
63
64     [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_county")]
65     internal static extern ErrorCode GetCounty(this AddressHandle /* maps_address_h */ address, out string county);
66
67     [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_county")]
68     internal static extern ErrorCode SetCounty(this AddressHandle /* maps_address_h */ address, string county);
69
70     [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_postal_code")]
71     internal static extern ErrorCode GetPostalCode(this AddressHandle /* maps_address_h */ address, out string postalCode);
72
73     [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_postal_code")]
74     internal static extern ErrorCode SetPostalCode(this AddressHandle /* maps_address_h */ address, string postalCode);
75
76     [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_freetext")]
77     internal static extern ErrorCode GetFreeText(this AddressHandle /* maps_address_h */ address, out string freetext);
78
79     [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_freetext")]
80     internal static extern ErrorCode SetFreeText(this AddressHandle /* maps_address_h */ address, string freetext);
81
82     internal class AddressHandle : SafeMapsHandle
83     {
84         [DllImport(Libraries.MapService, EntryPoint = "maps_address_create")]
85         internal static extern ErrorCode Create(out IntPtr /* maps_address_h */ address);
86
87         [DllImport(Libraries.MapService, EntryPoint = "maps_address_destroy")]
88         internal static extern ErrorCode Destroy(IntPtr /* maps_address_h */ address);
89
90         [DllImport(Libraries.MapService, EntryPoint = "maps_address_clone")]
91         internal static extern ErrorCode Clone(IntPtr /* maps_address_h */ origin, out IntPtr /* maps_address_h */ cloned);
92
93         internal string Building
94         {
95             get { return NativeGet(this.GetBuildingNumber); }
96             set { NativeSet(this.SetBuildingNumber, value); }
97         }
98
99         internal string Street
100         {
101             get { return NativeGet(this.GetStreet); }
102             set { NativeSet(this.SetStreet, value); }
103         }
104
105         internal string City
106         {
107             get { return NativeGet(this.GetCity); }
108             set { NativeSet(this.SetCity, value); }
109         }
110
111         internal string District
112         {
113             get { return NativeGet(this.GetDistrict); }
114             set { NativeSet(this.SetDistrict, value); }
115         }
116
117         internal string State
118         {
119             get { return NativeGet(this.GetState); }
120             set { NativeSet(this.SetState, value); }
121         }
122
123         internal string Country
124         {
125             get { return NativeGet(this.GetCountry); }
126             set { NativeSet(this.SetCountry, value); }
127         }
128
129         internal string CountryCode
130         {
131             get { return NativeGet(this.GetCountryCode); }
132             set { NativeSet(this.SetCountryCode, value); }
133         }
134
135         internal string County
136         {
137             get { return NativeGet(this.GetCounty); }
138             set { NativeSet(this.SetCounty, value); }
139         }
140
141         internal string PostalCode
142         {
143             get { return NativeGet(this.GetPostalCode); }
144             set { NativeSet(this.SetPostalCode, value); }
145         }
146
147         internal string FreeText
148         {
149             get { return NativeGet(this.GetFreeText); }
150             set { NativeSet(this.SetFreeText, value); }
151         }
152
153         internal AddressHandle(IntPtr handle, bool needToRelease) : base(handle, needToRelease, Destroy)
154         {
155         }
156
157         internal AddressHandle() : this(IntPtr.Zero, true)
158         {
159             Create(out handle).ThrowIfFailed("Failed to create native handle");
160         }
161
162         internal static AddressHandle CloneFrom(IntPtr nativeHandle)
163         {
164             IntPtr handle;
165             Clone(nativeHandle, out handle).ThrowIfFailed("Failed to clone native handle");
166             return new AddressHandle(handle, true);
167         }
168
169         internal static AddressHandle Create(IntPtr nativeHandle)
170         {
171             return new AddressHandle(nativeHandle, true);
172         }
173     }
174 }