/GeneratedSaxParser/include/GeneratedSaxParserParserError.h

https://bitbucket.org/ZhangJingGuo/opencollada · C Header · 136 lines · 74 code · 30 blank · 32 comment · 0 complexity · dc9763e11bd4a24e193981f6013986c9 MD5 · raw file

  1. /*
  2. Copyright (c) 2008-2009 NetAllied Systems GmbH
  3. This file is part of GeneratedSaxParser.
  4. Licensed under the MIT Open Source License,
  5. for details please see LICENSE file or the website
  6. http://www.opensource.org/licenses/mit-license.php
  7. */
  8. #ifndef __GENERATEDSAXPARSER_PARSERERROR_H__
  9. #define __GENERATEDSAXPARSER_PARSERERROR_H__
  10. #include "GeneratedSaxParserPrerequisites.h"
  11. #include "GeneratedSaxParserTypes.h"
  12. namespace GeneratedSaxParser
  13. {
  14. class ParserError
  15. {
  16. public:
  17. enum Severity
  18. {
  19. SEVERITY_ERROR_NONCRITICAL,
  20. SEVERITY_CRITICAL,
  21. };
  22. enum ErrorType
  23. {
  24. ERROR_COULD_NOT_OPEN_FILE,
  25. ERROR_XML_PARSER_ERROR,
  26. ERROR_UNKNOWN_ELEMENT,
  27. ERROR_TEXTDATA_PARSING_FAILED,
  28. ERROR_UNKNOWN_ATTRIBUTE,
  29. ERROR_ATTRIBUTE_PARSING_FAILED,
  30. ERROR_REQUIRED_ATTRIBUTE_MISSING,
  31. ERROR_VALIDATION_MAX_OCCURS_EXCEEDED,
  32. ERROR_VALIDATION_MIN_OCCURS_UNMATCHED,
  33. ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT,
  34. ERROR_VALIDATION_SEQUENCE_NEXT_SIBLING_ALREADY_PRESENT,
  35. ERROR_VALIDATION_CHOICE_SIBLING_ALREADY_PRESENT,
  36. ERROR_VALIDATION_CHOICE_NO_CHILD_PRESENT,
  37. ERROR_VALIDATION_UNEXPECTED_ELEMENT,
  38. ERROR_VALIDATION_UNEXPECTED_CLOSING_TAG,
  39. ERROR_VALIDATION_MIN_INCLUSIVE,
  40. ERROR_VALIDATION_MAX_INCLUSIVE,
  41. ERROR_VALIDATION_MIN_EXCLUSIVE,
  42. ERROR_VALIDATION_MAX_EXCLUSIVE,
  43. ERROR_VALIDATION_LENGTH,
  44. ERROR_VALIDATION_MIN_LENGTH,
  45. ERROR_VALIDATION_MAX_LENGTH,
  46. ERROR_VALIDATION_PATTERN,
  47. SIMPLE_TYPE_VALIDATION_OK
  48. };
  49. private:
  50. /** The Severity of the error*/
  51. Severity mSeverity;
  52. /** The type of th error.*/
  53. ErrorType mErrorType;
  54. /** The hash of the element, the error occurred in.*/
  55. const char* mElementName;
  56. /** The hash of the attribute, that caused the error. Might be zero if no attribute
  57. was involved.*/
  58. const char* mAttributeName;
  59. /** The line number the error occurred in. Might be zero if the location could not be
  60. determined.*/
  61. size_t mLineNumber;
  62. /** The column number the error occurred in. Might be zero if the location could not be
  63. determined.*/
  64. size_t mColumnNumber;
  65. /** Additional text information. Its meaning depends on the error type. Might be empty.*/
  66. String mAdditionalText;
  67. public:
  68. ParserError(Severity severity,
  69. ErrorType errorType,
  70. const char* elementName,
  71. const char* attributeName,
  72. size_t lineNumber,
  73. size_t columnNumber,
  74. String additionalText = "");
  75. virtual ~ParserError();
  76. /** Returns the severity of the error.*/
  77. Severity getSeverity() const { return mSeverity; }
  78. /** Returns the error type.*/
  79. ErrorType getErrorType() const { return mErrorType; }
  80. /** Returns the name of the element, the error occurred in.*/
  81. const char* getElement() const { return mElementName; }
  82. /** Returns the name of the attribute, that caused the error. Might be zero if no attribute
  83. was involved.*/
  84. const char* getAttribute() const { return mAttributeName; }
  85. /** Returns the line number the error occurred in. Might be zero if the location could not be
  86. determined.*/
  87. size_t getLineNumber() const { return mLineNumber; }
  88. /** Returns the column number the error occurred in. Might be zero if the location could not be
  89. determined.*/
  90. size_t getColumnNumber() const { return mColumnNumber; }
  91. /** Returns the Additional text information. Its meaning depends on the error type. Might be empty.*/
  92. const String& getAdditionalText() const { return mAdditionalText; }
  93. /** Returns a human readable error message, describing the error.*/
  94. String getErrorMessage() const;
  95. public:
  96. private:
  97. ParserError();
  98. /** Disable default copy ctor. */
  99. ParserError( const ParserError& pre );
  100. /** Disable default assignment operator. */
  101. const ParserError& operator= ( const ParserError& pre );
  102. };
  103. } // namespace GeneratedSaxParser
  104. #endif // __GENERATEDSAXPARSER_PARSERERROR_H__