909cab738695c52a5c7392ee97a4beb9e36b2e38
[platform/core/location/maps-plugin-here.git] / inc / engine / common / ParserError.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 PARSERERROR_H
19 #define PARSERERROR_H
20
21 #include "HereMaps_global.h"
22
23 #include "common/ErrorBase.h"
24
25 HERE_MAPS_BEGIN_NAMESPACE
26
27 /**
28  * This class encapsulates an XML parser error. It allows you to set and
29  * retrieve the error message, error type and other details concerning an error
30  * condition. 
31  */
32 class EXPORT_API ParserError : public ErrorBase
33 {
34 public:
35     /** 
36      * This enumeration defines identifiers for the recognized error types.
37      */
38     enum Type
39     {
40         PE_InvalidXmlDocument,      ///< Indicates that the XML document is invalid.
41         PE_Utf8ConversionFailed,    ///< Indicates that UTF8 conversion failed.
42         PE_ExtractXMLTextNodeFail,  ///< Indicates that it an attempt to extract an XML node failed.
43         PE_MissingAttribute,        ///< Indicates that an attribute is missing.
44         PE_InternalParserError      ///< Indicates that an internal parser error occurred.
45     };
46
47     /**
48      * This method is a constructor.
49      * 
50      * @param aType A value indicating the error type.
51      */
52     ParserError(Type aType);
53
54     /**
55      * This method is a constructor.
56      * 
57      * @param aType A value indicating the error type.
58      * 
59      * @param sParentNodename A constant reference to the parent node (XML).
60      */
61     ParserError(Type aType, const String& sParentNodename);
62
63     /**
64      * This method is a constructor.
65      * 
66      * @param aType A value indicating the error type.
67      * 
68      * @param sParentNodename A constant reference to a string containing the
69      *        name of the parent node (XML).
70      * 
71      * @param sDescription A constant reference to a string containing the error description. 
72      */
73     ParserError(Type aType, const String& sParentNodename, const String& sDescription);
74
75     /**
76      * This method is the destructor.
77      */
78     virtual ~ParserError();
79
80     /**
81      * This method converts the given instance to a string. The default
82      * implementation outputs a string containing the error type, description,
83      * parser input and the name of the parent element.
84      * 
85      * @return A string representation of the given instance of the class.
86      */
87     virtual String ToString() const;
88
89     /**
90      * This method retrieves a value indicating the error type.
91      * 
92      * @return A value indicating the error type. 
93      */
94     Type getParserErrorType() const;
95
96     /**
97      * This method sets the parser input.
98      * 
99      * @param sInput A constant reference to a string containing parser input.
100      */
101     void setParserInput(const String& sInput);
102
103     /**
104      * This method retrieves the parser input.
105      * 
106      * @return A constant reference to a string containing parser input.
107      */
108     const String& getParserInput() const;
109
110     /**
111      * This method sets the name of the parent node.
112      * 
113      * @param sNodename A constant reference to a string containing name of the
114      *        parent (XML) node.
115      */
116     void setParentElement(const String& sNodename);
117
118     /**
119      * This method retrieves the name of the parent node.
120      * 
121      * @return A constant reference to a string containing name of the
122      *        parent (XML) node.
123      */
124     const String& getParentElement() const;
125
126     /**
127      * This method sets the error description.
128      * 
129      * @param sDsc A constant reference to a string containing the
130      *        description of the error.
131      */
132     void setDescription(const String& sDsc);
133
134     /**
135      * This method retrieves the error description.
136      * 
137      * @return A constant reference to a string containing the
138      *        description of the error.
139      */
140     const String& getDescription() const;
141
142 private:
143     class ParserErrorImpl;
144     ParserErrorImpl* m_pImpl;
145 };
146
147 HERE_MAPS_END_NAMESPACE
148
149 #endif