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.

TReaderCallbackProxy.h 2.8KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include "IReader.h"
  3. namespace XML {
  4. // ________________________________________________________________________________________________________________
  5. //
  6. template <class TOwnerClass>
  7. class TReaderCallbackProxy1 final : public IReaderCallback
  8. {
  9. public:
  10. TReaderCallbackProxy1(TOwnerClass& ownerObject,
  11. void (TOwnerClass::*mfpOpenChild)(const char* name, const char** attributeName, const char** attributeValue, size_t nAttribute),
  12. void (TOwnerClass::*mfpProcessChildData)(const char* data), void (TOwnerClass::*mfpCloseChild)())
  13. : m_ownerObject(ownerObject), m_mfpOpenChild(mfpOpenChild), m_mfpProcessChildData(mfpProcessChildData), m_mfpCloseChild(mfpCloseChild) { }
  14. void openChild(const char* name, const char** attributeName, const char** attributeValue, const size_t nAttribute) override
  15. {
  16. if (m_mfpOpenChild) { m_ownerObject.m_mfpOpenChild(name, attributeName, attributeValue, nAttribute); }
  17. }
  18. void processChildData(const char* data) override { if (m_mfpProcessChildData) { m_ownerObject.m_mfpProcessChildData(data); } }
  19. void closeChild() override { if (m_mfpCloseChild) { m_ownerObject.m_mfpCloseChild(); } }
  20. protected:
  21. TOwnerClass& m_ownerObject;
  22. void (TOwnerClass::*m_mfpOpenChild)(const char* name, const char** attributeName, const char** attributeValue, size_t nAttribute);
  23. void (TOwnerClass::*m_mfpProcessChildData)(const char* data);
  24. void (TOwnerClass::*m_mfpCloseChild)();
  25. };
  26. // ________________________________________________________________________________________________________________
  27. //
  28. template <class TOwnerClass,
  29. void (TOwnerClass::*TMfpOpenChild)(const char* name, const char** attributeName, const char** attributeValue, size_t nAttribute),
  30. void (TOwnerClass::*TMfpProcessChildData)(const char* data), void (TOwnerClass::*mfpCloseChild)()>
  31. class TReaderCallbackProxy2 final : public IReaderCallback
  32. {
  33. public:
  34. TReaderCallbackProxy2(TOwnerClass ownerObject)
  35. : m_ownerObject(ownerObject), m_mfpOpenChild(TMfpOpenChild), m_mfpProcessChildData(TMfpProcessChildData), m_mfpCloseChild(mfpCloseChild) { }
  36. void openChild(const char* name, const char** attributeName, const char** attributeValue, const size_t nAttribute) override
  37. {
  38. if (TMfpOpenChild) { m_ownerObject.mfpOpenChild(name, attributeName, attributeValue, nAttribute); }
  39. }
  40. void processChildData(const char* data) override { if (TMfpProcessChildData) { m_ownerObject.mfpProcessChildData(data); } }
  41. void closeChild() override { if (mfpCloseChild) { m_ownerObject.mfpCloseChild(); } }
  42. protected:
  43. TOwnerClass& m_ownerObject;
  44. void (TOwnerClass::*m_mfpOpenChild)(const char* name, const char** attributeName, const char** attributeValue, size_t nAttribute);
  45. void (TOwnerClass::*m_mfpProcessChildData)(const char* data);
  46. void (TOwnerClass::*m_mfpCloseChild)();
  47. };
  48. } // namespace XML