You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /*
  18. * $Id: XSerializerHandlers.hpp 676796 2008-07-15 05:04:13Z dbertoni $
  19. */
  20. #if !defined(XSERIALIZER_HANDLER_HPP)
  21. #define XSERIALIZER_HANDLER_HPP
  22. // ---------------------------------------------------------------------------
  23. // Includes
  24. // ---------------------------------------------------------------------------
  25. #include <xercesc/sax2/Attributes.hpp>
  26. #include <xercesc/sax2/DefaultHandler.hpp>
  27. XERCES_CPP_NAMESPACE_USE
  28. class XSerializerHandlers : public DefaultHandler
  29. {
  30. public:
  31. // -----------------------------------------------------------------------
  32. // Constructors and Destructor
  33. // -----------------------------------------------------------------------
  34. XSerializerHandlers();
  35. ~XSerializerHandlers();
  36. // -----------------------------------------------------------------------
  37. // Getter methods
  38. // -----------------------------------------------------------------------
  39. XMLSize_t getElementCount() const
  40. {
  41. return fElementCount;
  42. }
  43. XMLSize_t getAttrCount() const
  44. {
  45. return fAttrCount;
  46. }
  47. XMLSize_t getCharacterCount() const
  48. {
  49. return fCharacterCount;
  50. }
  51. bool getSawErrors() const
  52. {
  53. return fSawErrors;
  54. }
  55. XMLSize_t getSpaceCount() const
  56. {
  57. return fSpaceCount;
  58. }
  59. // -----------------------------------------------------------------------
  60. // Handlers for the SAX ContentHandler interface
  61. // -----------------------------------------------------------------------
  62. void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs);
  63. void characters(const XMLCh* const chars, const XMLSize_t length);
  64. void ignorableWhitespace(const XMLCh* const chars, const XMLSize_t length);
  65. void resetDocument();
  66. // -----------------------------------------------------------------------
  67. // Handlers for the SAX ErrorHandler interface
  68. // -----------------------------------------------------------------------
  69. void warning(const SAXParseException& exc);
  70. void error(const SAXParseException& exc);
  71. void fatalError(const SAXParseException& exc);
  72. void resetErrors();
  73. private:
  74. // -----------------------------------------------------------------------
  75. // Private data members
  76. //
  77. // fAttrCount
  78. // fCharacterCount
  79. // fElementCount
  80. // fSpaceCount
  81. // These are just counters that are run upwards based on the input
  82. // from the document handlers.
  83. //
  84. // fSawErrors
  85. // This is set by the error handlers, and is queryable later to
  86. // see if any errors occured.
  87. // -----------------------------------------------------------------------
  88. XMLSize_t fAttrCount;
  89. XMLSize_t fCharacterCount;
  90. XMLSize_t fElementCount;
  91. XMLSize_t fSpaceCount;
  92. bool fSawErrors;
  93. };
  94. #endif