774a0f4a38d72ddc261995958fef8f15664876f8
[platform/upstream/libxml++.git] / libxml++ / validators / validator.h
1 /* validator.h
2  * libxml++ and this file are copyright (C) 2000 by Ari Johnson,
3  * (C) 2002-2004 by the libxml dev team and
4  * are covered by the GNU Lesser General Public License, which should be
5  * included with libxml++ as the file COPYING.
6  */
7
8 #ifndef __LIBXMLPP_VALIDATOR_H
9 #define __LIBXMLPP_VALIDATOR_H
10
11 #include <libxml++/nodes/element.h>
12 #include <libxml++/exceptions/validity_error.h>
13 #include <libxml++/exceptions/internal_error.h>
14
15 extern "C" {
16   struct _xmlValidCtxt;
17 }
18
19 namespace xmlpp {
20
21 /** Base class for XML validators.
22  */
23 class LIBXMLPP_API Validator : NonCopyable
24 {
25 public:
26   Validator();
27   ~Validator() override;
28
29 protected:
30   virtual void initialize_valid();
31   virtual void release_underlying();
32
33   virtual void on_validity_error(const Glib::ustring& message);
34   virtual void on_validity_warning(const Glib::ustring& message);
35
36   //TODO: When we can break ABI/API, remove handleException() and make
37   // handle_exception() protected virtual.
38   virtual void handleException(const exception& e);
39   virtual void check_for_exception();
40   virtual void check_for_validity_messages();
41
42   static void callback_validity_error(void* ctx, const char* msg, ...);
43   static void callback_validity_warning(void* ctx, const char* msg, ...);
44
45   _xmlValidCtxt* valid_;
46   exception* exception_;
47   Glib::ustring validate_error_;
48   Glib::ustring validate_warning_; //Built gradually - used in an exception at the end of parsing.
49
50 private:
51   /// To be called in an exception handler.
52   void handle_exception();
53 };
54
55 } // namespace xmlpp
56
57 #endif //__LIBXMLPP_VALIDATOR_H
58