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
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.
18 #ifndef GEOROUTERREPLYPARSER_H
19 #define GEOROUTERREPLYPARSER_H
21 #include "common/HereMaps_global.h"
23 #include "common/GeoCoordinates.h"
24 #include "common/GeoBoundingBox.h"
25 #include "routes/RouteSegment.h"
27 #include <libxml/tree.h>
28 #include <libxml/xpath.h>
30 HERE_MAPS_BEGIN_NAMESPACE
38 * This class encapsulates a parser of replies to routing requests. It provides
39 * methods dedicated to parsing specific nodes of the reply data and populating
40 * a destination object supplied by the caller.
44 class GeoRouterReplyParser
49 * This method retrieves the route details held in the XML node supplied by
52 * @param pNode A pointer to the XML node to parse.
54 * @param rDst A reference to an object which is to receive the results.
56 * @param pCtx A pointer to the XPath context.
58 * @param pError A pointer to an object that is populated
59 * with error information should parsing fail.
61 * @return <code>true</code> on success, otherwise <code>false</code> (in
62 * which case the last argument to the method can be used to retrieve
63 * the error information.
65 static bool ParseRouteEntry(xmlNodePtr pNode, GeoRoute& rDst, xmlXPathContextPtr pCtx, ParserError*& pError);
68 * This method retrieves a route summary entry held in the XML node supplied
71 * @param pNode A pointer to the XML node to parse.
73 * @param rDst A reference to an object which is to receive the results.
75 * @param pCtx A pointer to the XPath context.
77 * @param pError A pointer to an object that is populated
78 * with error information should parsing fail.
80 * @return <code>true</code> on success, otherwise <code>false</code> (in
81 * which case the last argument to the method can be used to retrieve
82 * the error information.
84 static bool ParseSummary(xmlNodePtr pNode, GeoRoute& rDst, xmlXPathContextPtr pCtx, ParserError*& pError);
87 * This method retrieves a route travel mode held in the XML node supplied
90 * @param pNode A pointer to the XML node to parse.
92 * @param rDst A reference to an object which is to receive the results.
94 * @param pCtx A pointer to the XPath context.
96 * @param pError A pointer to an object that is populated
97 * with error information should parsing fail.
99 * @return <code>true</code> on success, otherwise <code>false</code> (in
100 * which case the last argument to the method can be used to retrieve
101 * the error information.
103 static bool ParseMode(xmlNodePtr pNode, GeoRoute& rDst, xmlXPathContextPtr pCtx, ParserError*& pError);
106 * This method retrieves the route shape definition from the XML node
107 * supplied by the caller.
109 * @param pNode A pointer to the XML node to parse.
111 * @param rDst A reference to an object which is to receive the results.
113 * @param pCtx A pointer to the XPath context.
115 * @param pError A pointer to an object that is populated
116 * with error information should parsing fail.
118 * @return <code>true</code> on success, otherwise <code>false</code> (in
119 * which case the last argument to the method can be used to retrieve
120 * the error information.
122 static bool ParseShape(xmlNodePtr pNode, GeoCoordinateList& rDst, xmlXPathContextPtr pCtx, ParserError*& pError);
125 * This method retrieves a route bounding box from the XML node
126 * supplied by the caller.
128 * @param pNode A pointer to the XML node to parse.
130 * @param rDst A reference to an object which is to receive the results.
132 * @param pCtx A pointer to the XPath context.
134 * @param pError A pointer to an object that is populated
135 * with error information should parsing fail.
137 * @return <code>true</code> on success, otherwise <code>false</code> (in
138 * which case the last argument to the method can be used to retrieve
139 * the error information.
141 static bool ParseBoundingBox(xmlNodePtr pNode, GeoBoundingBox& rDst, xmlXPathContextPtr pCtx, ParserError*& pError);
144 * This method retrieves a route waypoint defined in the XML node supplied
147 * @param pNode A pointer to the XML node to parse.
149 * @param rDst A reference to an object which is to receive the results.
151 * @param pCtx A pointer to the XPath context.
153 * @param pError A pointer to an object that is populated
154 * with error information should parsing fail.
156 * @return <code>true</code> on success, otherwise <code>false</code> (in
157 * which case the last argument to the method can be used to retrieve
158 * the error information.
160 static bool ParseCoordinate(xmlNodePtr pNode, GeoCoordinates& rDst, xmlXPathContextPtr pCtx, ParserError*& pError);
163 * This method retrieves a route leg defined in the XML node supplied by the
166 * @param pNode A pointer to the XML node to parse.
168 * @param rDst A reference to an object which is to receive the results.
170 * @param pCtx A pointer to the XPath context.
172 * @param pError A pointer to an object that is populated
173 * with error information should parsing fail.
175 * @return <code>true</code> on success, otherwise <code>false</code> (in
176 * which case the last argument to the method can be used to retrieve
177 * the error information.
179 static bool ParseLeg(xmlNodePtr pNode, RouteSegment& rDst, xmlXPathContextPtr pCtx, ParserError*& pError);
182 * This method retrieves the details of a maneuver defined in the XML node
183 * supplied by the caller.
185 * @param pNode A pointer to the XML node to parse.
187 * @param rDst A reference to an object which is to receive the results.
189 * @param pCtx A pointer to the XPath context.
191 * @param pError A pointer to an object that is populated
192 * with error information should parsing fail.
194 * @return <code>true</code> on success, otherwise <code>false</code> (in
195 * which case the last argument to the method can be used to retrieve
196 * the error information.
198 static bool ParseManeuver(xmlNodePtr pNode, Maneuver& rDst, GeoCoordinateList& vSegmentPath, xmlXPathContextPtr pCtx, ParserError*& pError);
201 static bool ExtractContent(xmlNodePtr pNode, String& sDst, ParserError*& pError);
202 static xmlNodePtr FindChildNode(xmlNodePtr pNode, const char* pUTF8Literal);
204 static void AppendOrSet(ParserError*& pError, ParserError* pLoc);
206 HERE_MAPS_NO_COPY_NO_ASSIGN(GeoRouterReplyParser);
210 HERE_MAPS_END_NAMESPACE
212 #endif // GEOROUTERREPLYPARSER_H