You.i Engine
YiParsingError.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_PARSING_ERROR_H_
3 #define _YI_PARSING_ERROR_H_
4 
5 #include <utility/YiString.h>
6 
16 {
17 public:
22 
26  enum class ErrorType
27  {
28  None = 0,
34  };
35 
36 public:
38  virtual ~CYIParsingError();
39 
43  virtual ErrorType GetParsingErrorCode() const;
44 
48  virtual CYIString GetParsingErrorMessage() const;
49 
53  virtual void SetParsingErrorCode(ErrorType errorCode);
54 
58  virtual void SetParsingErrorMessage(CYIString errorMessage);
59 
63  virtual bool HasError() const;
64 
68  virtual bool IsRequiredField(const CYIString &rFieldName) const;
69 
70 private:
71  ErrorType m_parsingErrorCode;
72  CYIString m_parsingErrorMessage;
73 };
74 
76 {
77  return m_parsingErrorCode;
78 }
79 
81 {
82  return m_parsingErrorMessage;
83 }
84 
86 {
87  m_parsingErrorCode = errorCode;
88 }
89 
91 {
92  m_parsingErrorMessage = errorMessage;
93 }
94 
95 inline bool CYIParsingError::HasError() const
96 {
97  return m_parsingErrorCode != ErrorType::None;
98 }
99 
100 inline bool CYIParsingError::IsRequiredField(const CYIString &rFieldName) const
101 {
102  YI_UNUSED(rFieldName);
103  // In the default implementation all fields are required
104  return true;
105 }
106 
111 #endif /* _YI_PARSING_ERROR_H_ */
virtual ErrorType GetParsingErrorCode() const
Definition: YiParsingError.h:75
static const CYIString INVALID_OBJECT_MESSAGE
Definition: YiParsingError.h:20
ErrorType
Definition: YiParsingError.h:26
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:36
virtual void SetParsingErrorMessage(CYIString errorMessage)
Definition: YiParsingError.h:90
virtual bool HasError() const
Definition: YiParsingError.h:95
virtual void SetParsingErrorCode(ErrorType errorCode)
Definition: YiParsingError.h:85
A class to store errors in the parsing of encoded data, such as JSON or XML.
Definition: YiParsingError.h:15
static const CYIString DATA_FIELD_MISSING_MESSAGE
Definition: YiParsingError.h:18
static const CYIString FILE_READ_ERROR_MESSAGE
Definition: YiParsingError.h:21
virtual ~CYIParsingError()
#define YI_UNUSED(param)
Definition: YiPredef.h:94
virtual CYIString GetParsingErrorMessage() const
Definition: YiParsingError.h:80
static const CYIString DATA_FIELD_UNRECOGNIZED_MESSAGE
Definition: YiParsingError.h:19
virtual bool IsRequiredField(const CYIString &rFieldName) const
Definition: YiParsingError.h:100