2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
20 internal static partial class Interop
22 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_get")]
23 internal static extern ErrorCode Get(this PlaceFilterHandle /* maps_place_filter_h */ filter, string key, out string value);
25 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_set")]
26 internal static extern ErrorCode Set(this PlaceFilterHandle /* maps_place_filter_h */ filter, string key, string value);
28 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_get_keyword")]
29 internal static extern ErrorCode GetKeyword(this PlaceFilterHandle /* maps_place_filter_h */ filter, out string keyword);
31 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_set_keyword")]
32 internal static extern ErrorCode SetKeyword(this PlaceFilterHandle /* maps_place_filter_h */ filter, string keyword);
34 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_get_place_name")]
35 internal static extern ErrorCode GetPlaceName(this PlaceFilterHandle /* maps_place_filter_h */ filter, out string placeName);
37 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_set_place_name")]
38 internal static extern ErrorCode SetPlaceName(this PlaceFilterHandle /* maps_place_filter_h */ filter, string placeName);
40 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_get_category")]
41 internal static extern ErrorCode GetCategory(this PlaceFilterHandle /* maps_place_filter_h */ filter, out IntPtr /* maps_place_category_h */ category);
43 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_set_category")]
44 internal static extern ErrorCode SetCategory(this PlaceFilterHandle /* maps_place_filter_h */ filter, PlaceCategoryHandle /* maps_place_category_h */ category);
46 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_get_place_address")]
47 internal static extern ErrorCode GetPlaceAddress(this PlaceFilterHandle /* maps_place_filter_h */ filter, out string placeAddress);
49 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_set_place_address")]
50 internal static extern ErrorCode SetPlaceAddress(this PlaceFilterHandle /* maps_place_filter_h */ filter, string placeAddress);
52 internal class PlaceFilterHandle : SafeMapsHandle
54 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
55 internal delegate bool PlaceFilterPropertiesCallback(int index, int total, string key, IntPtr /* void */ value, IntPtr /* void */ userData);
57 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_foreach_property")]
58 internal static extern ErrorCode ForeachProperty(IntPtr /* maps_place_filter_h */ filter, PlaceFilterPropertiesCallback callback, IntPtr /* void */ userData);
61 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_create")]
62 internal static extern ErrorCode Create(out IntPtr /* maps_place_filter_h */ filter);
64 [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_destroy")]
65 internal static extern ErrorCode Destroy(IntPtr /* maps_place_filter_h */ filter);
67 internal string Keyword
69 get { return NativeGet(this.GetKeyword); }
70 set { NativeSet(this.SetKeyword, value); }
73 internal string PlaceName
75 get { return NativeGet(this.GetPlaceName); }
76 set { NativeSet(this.SetPlaceName, value); }
79 internal string PlaceAddress
81 get { return NativeGet(this.GetPlaceAddress); }
82 set { NativeSet(this.SetPlaceAddress, value); }
85 internal PlaceCategoryHandle Category
87 get { return NativeGet(this.GetCategory, PlaceCategoryHandle.Create); }
88 set { NativeSet(this.SetCategory, value); }
91 public PlaceFilterHandle(IntPtr handle, bool needToRelease) : base(handle, needToRelease, Destroy)
95 public PlaceFilterHandle() : this(IntPtr.Zero, true)
97 Create(out handle).ThrowIfFailed("Failed to create native handle");
100 internal void ForeachProperty(Action<string, string> action)
102 PlaceFilterPropertiesCallback callback = (index, total, key, value, userData) =>
104 action(key, Marshal.PtrToStringUni(value));
108 ForeachProperty(handle, callback, IntPtr.Zero).WarnIfFailed("Failed to get address list from native handle");