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.

TWriterCallbackProxy.h 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include "IWriter.h"
  3. namespace XML {
  4. // ________________________________________________________________________________________________________________
  5. //
  6. template <class TOwnerClass>
  7. class TWriterCallbackProxy1 final : public IWriterCallback
  8. {
  9. public:
  10. TWriterCallbackProxy1(TOwnerClass& ownerObject, void (TOwnerClass::*mfpWrite)(const char* str))
  11. : m_ownerObject(ownerObject), m_mfpWrite(mfpWrite) { }
  12. void write(const char* str) override { if (m_mfpWrite) { m_ownerObject.m_mfpWrite(str); } }
  13. protected:
  14. TOwnerClass& m_ownerObject;
  15. void (TOwnerClass::*m_mfpWrite)(const char* str);
  16. };
  17. // ________________________________________________________________________________________________________________
  18. //
  19. template <class TOwnerClass, void (TOwnerClass::*TMfpWrite)(const char* str)>
  20. class TWriterCallbackProxy2 final : public IWriterCallback
  21. {
  22. public:
  23. TWriterCallbackProxy2(TOwnerClass ownerObject) : m_ownerObject(ownerObject), m_mfpWrite(TMfpWrite) { }
  24. void write(const char* str) override { if (TMfpWrite) { m_ownerObject.mfpWrite(str); } }
  25. protected:
  26. TOwnerClass& m_ownerObject;
  27. void (TOwnerClass::*m_mfpWrite)(const char* str);
  28. };
  29. // ________________________________________________________________________________________________________________
  30. //
  31. } // namespace XML