changed attributes of header files
[platform/core/location/maps-plugin-here.git] / inc / engine / internal / JsonParser.h
1 /*
2  * Copyright (C) 2013 HERE Global B.V. All rights reserved.
3  * This software, including documentation, is protected by copyright controlled by
4  * HERE Global B.V. (“Software”). All rights are reserved. Copying, including reproducing,
5  * storing, adapting or translating, any or all of this material requires the prior
6  * written consent of HERE Global B.V. You may use this
7  * Software in accordance with the terms and conditions defined in the
8  * HERE Location Platform Services Terms and Conditions, available at
9  * http://developer.here.com/terms-conditions-base
10  *
11  * As an additional permission to the above, you may distribute Software,
12  * in object code format as part of an Application, according to, and subject to, terms and
13  * conditions defined in the Tizen Software Development kit (“SDK”) License Agreement.
14  * You may distribute such object code format Application under terms of your choice,
15  * provided that the header and source files of the Software have not been modified.
16  */
17
18 #ifndef JSON_PARSER_H_
19 #define JSON_PARSER_H_
20
21 #include "common/HereMaps_global.h"
22 #include "finder/Category.h"
23 #include "finder/ContactDetails.h"
24 #include "finder/ExtendedAttribute.h"
25 #include "finder/ImageContent.h"
26 #include "finder/ReviewContent.h"
27 #include "finder/EditorialContent.h"
28 #include "finder/PlaceItem.h"
29 #include "finder/SearchItem.h"
30 #include "finder/PlaceDetails.h"
31
32 #ifndef TIZEN_MIGRATION
33 #include <FBase.h>
34 #include <FWeb.h>
35 #endif
36 #include <vector>
37 #include <map>
38
39 #ifdef TIZEN_MIGRATION
40 #include "base/BaseByteBuffer.h"
41 #include <json.h>
42
43 #define JsonArray  json_object
44 #define JsonNumber json_object
45 #define JsonObject json_object
46 #define IJsonValue json_object
47 #define JsonBool   json_object
48
49 using namespace Tizen::Maps;
50 #else
51 using namespace Tizen::Base;
52 using namespace Tizen::Base::Utility;
53 using namespace Tizen::Web::Json;
54 #endif
55
56 HERE_MAPS_BEGIN_NAMESPACE
57
58 class DiscoveryReply;
59 class BaseContent;
60 class Address;
61 class GeoCoordinates;
62 class BaseQuery;
63 class GeoLocation;
64 class LinkObject;
65 class Ratings;
66 class GeoBoundingBox;
67 class SearchContext;
68 class FinderError;
69
70 /**
71  * Parses Places API Json data.
72  *
73  * @ingroup Search / Online / Parser
74  */
75 class JsonParser
76 {
77 public:
78
79     /**
80      * Parse discover search results.
81      * @param json_stream ByteBuffer.
82      * @param results_page Parsed Discovery query.
83      * @param error A pointer to an object that is populated
84      *        with error information should parsing fail.
85      */
86     static bool ParseDiscoverySearch( ByteBuffer& buf, DiscoveryReply& results_page, FinderError*& error);
87
88     /**
89      * Parse place result.
90      * @param json_stream ByteBuffer.
91      * @param place_data Parsed place data.
92      * @param error A pointer to an object that is populated
93      *        with error information should parsing fail.
94      */
95     static bool ParsePlaceResult( ByteBuffer& buf, PlaceDetails& place_data, FinderError*& error);
96
97 private:
98
99     static void ParseGeocodeSearch( ByteBuffer& json_stream,
100                                            std::vector< GeoLocation >& results );
101
102     static void ParseReverseGeocodeSearch( ByteBuffer& json_stream, Address& address );
103
104
105     static void ParseTextSuggestions( ByteBuffer& json, std::vector< String >& suggestions );
106
107
108     static void ParseDiscoverySearch( IJsonValue* json, DiscoveryReply& results_page );
109
110     static void ParsePlaceResult( IJsonValue* json, PlaceDetails& place_data );
111
112     static void ParseAlternativeNames( JsonArray* json_data,
113                                          PlaceDetails::AlternativeNames& alternative_names );
114
115     static void ParsePlaceLocation( JsonObject* json_data, GeoLocation& location );
116
117     static void ParsePosition( JsonObject* json_data, GeoCoordinates& position );
118
119     static void ParseAddress( JsonObject* json_data, Address& address );
120
121 #ifdef TIZEN_MIGRATION
122     static void ParseContacts( JsonArray* json_data, ContactDetailsList& contacts );
123
124     static void ParseContacts( JsonArray* json_data, const String& key,
125                                ContactDetailsList& contacts );
126
127     static void ParseLinkObject( JsonObject* json_data, LinkObject& link_object );
128 #else
129     static void ParseContacts( JsonArray* json_data, const String& key,
130                                ContactDetailsList& contacts );
131
132     static void ParseLinkObject( IJsonValue* json_data,
133                                    const char* object_name,
134                                    LinkObject& link_object );
135
136     static void ParseLinkObject( JsonObject* json_data, LinkObject& link_object );
137
138     static void ParseLinkObject( JsonObject* json_data,
139                                    const char* object_name,
140                                    LinkObject& link_object );
141 #endif
142     static void ParseRatings( JsonObject* json_data, Ratings& ratings );
143
144     static void ParseCategories( JsonArray* json_data, CategoryList& categories );
145
146     static void ParseCategory( JsonObject* json_data, Category& category );
147
148     static void ParseAttributes( JsonObject* json_data, ExtendedAttributeList& attributes );
149
150     static void ParseSearchContext( JsonObject* json_data, SearchContext& results_context );
151
152     static void ParseBbox( JsonObject* json_data, GeoBoundingBox& bbox );
153
154     static void ParseResultsItemPlace( JsonObject* json_data, PlaceItem& place_result );
155
156     static void ParseResultsItemSearch( JsonObject* json_data, SearchItem& search_result );
157
158     static void ParsePlaceRelated( JsonObject* json_data, PlaceDetails& place_data );
159
160     static void ParsePlaceMedia( JsonObject* json_data, PlaceDetails& place_data );
161
162     static void ParsePlaceEditorials( JsonObject* json_data, EditorialContentList& editorials );
163
164     static void ParsePlaceImages( JsonObject* json_data, ImageContentList& images );
165
166     static void ParsePlaceReviews( JsonObject* json_data, ReviewContentList& reviews );
167
168     static void ParsePlaceEditorial( JsonObject* json_data, EditorialContent& editorial );
169
170     static void ParsePlaceImage( JsonObject* json_data, ImageContent& image );
171
172     static void ParsePlaceReview( JsonObject* json_data, ReviewContent& review );
173
174     static void ParsePlaceBaseContent( JsonObject* json_data, BaseContent& media );
175
176     static void TraverseRootNode( ByteBuffer& json_stream, IJsonValue* root );
177     static void ParseCoordinates( IJsonValue* json_location, GeoLocation& loc );
178     static void ParseBoundingBox( IJsonValue* json_location, GeoLocation& loc );
179     static void ParseAddress( IJsonValue* json_location, GeoLocation& loc );
180
181     static void ParsePlaceResults(JsonArray* pObject, PlaceItemList&, SearchItemList& );
182
183 private:
184     static void GetStringValue(JsonObject* pObject, const String& sKey, String& value );
185     static void GetUriValue(JsonObject* pObject, const String& sKey, Uri& uri );
186     static bool GetValuePtr(JsonObject* pObject, const String& sKey, IJsonValue*& pValue );
187 };
188
189 HERE_MAPS_END_NAMESPACE
190
191 #endif // JSON_PARSER_H_