xtixml.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/xtixml.h
  3. // Purpose: xml streaming runtime metadata information (extended class info)
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Created: 27/07/03
  7. // Copyright: (c) 2003 Stefan Csomor
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_XTIXMLH__
  11. #define _WX_XTIXMLH__
  12. #include "wx/defs.h"
  13. #if wxUSE_EXTENDED_RTTI
  14. #include "wx/string.h"
  15. #include "wx/xtistrm.h"
  16. /*
  17. class WXDLLIMPEXP_XML wxXmlNode;
  18. class WXDLLIMPEXP_BASE wxPropertyInfo;
  19. class WXDLLIMPEXP_BASE wxObject;
  20. class WXDLLIMPEXP_BASE wxClassInfo;
  21. class WXDLLIMPEXP_BASE wxAnyList;
  22. class WXDLLIMPEXP_BASE wxHandlerInfo;
  23. class WXDLLIMPEXP_BASE wxObjectWriterCallback;
  24. */
  25. class WXDLLIMPEXP_XML wxObjectXmlWriter: public wxObjectWriter
  26. {
  27. public:
  28. wxObjectXmlWriter( wxXmlNode * parent );
  29. virtual ~wxObjectXmlWriter();
  30. //
  31. // streaming callbacks
  32. //
  33. // these callbacks really write out the values in the stream format
  34. //
  35. //
  36. // streaming callbacks
  37. //
  38. // these callbacks really write out the values in the stream format
  39. // begins writing out a new toplevel entry which has the indicated unique name
  40. virtual void DoBeginWriteTopLevelEntry( const wxString &name );
  41. // ends writing out a new toplevel entry which has the indicated unique name
  42. virtual void DoEndWriteTopLevelEntry( const wxString &name );
  43. // start of writing an object having the passed in ID
  44. virtual void DoBeginWriteObject(const wxObject *object,
  45. const wxClassInfo *classInfo, int objectID, const wxStringToAnyHashMap &metadata );
  46. // end of writing an toplevel object name param is used for unique
  47. // identification within the container
  48. virtual void DoEndWriteObject(const wxObject *object,
  49. const wxClassInfo *classInfo, int objectID );
  50. // writes a simple property in the stream format
  51. virtual void DoWriteSimpleType( const wxAny &value );
  52. // start of writing a complex property into the stream (
  53. virtual void DoBeginWriteProperty( const wxPropertyInfo *propInfo );
  54. // end of writing a complex property into the stream
  55. virtual void DoEndWriteProperty( const wxPropertyInfo *propInfo );
  56. virtual void DoBeginWriteElement();
  57. virtual void DoEndWriteElement();
  58. // insert an object reference to an already written object
  59. virtual void DoWriteRepeatedObject( int objectID );
  60. // insert a null reference
  61. virtual void DoWriteNullObject();
  62. // writes a delegate in the stream format
  63. virtual void DoWriteDelegate( const wxObject *object,
  64. const wxClassInfo* classInfo, const wxPropertyInfo *propInfo,
  65. const wxObject *eventSink, int sinkObjectID,
  66. const wxClassInfo* eventSinkClassInfo, const wxHandlerInfo* handlerIndo );
  67. private:
  68. struct wxObjectXmlWriterInternal;
  69. wxObjectXmlWriterInternal* m_data;
  70. };
  71. /*
  72. wxObjectXmlReader handles streaming in a class from XML
  73. */
  74. class WXDLLIMPEXP_XML wxObjectXmlReader: public wxObjectReader
  75. {
  76. public:
  77. wxObjectXmlReader(wxXmlNode *parent) { m_parent = parent; }
  78. virtual ~wxObjectXmlReader() {}
  79. // Reads a component from XML. The return value is the root object ID, which can
  80. // then be used to ask the readercallback about that object
  81. virtual int ReadObject( const wxString &name, wxObjectReaderCallback *readercallback );
  82. private:
  83. int ReadComponent(wxXmlNode *parent, wxObjectReaderCallback *callbacks);
  84. // read the content of this node (simple type) and return the corresponding value
  85. wxAny ReadValue(wxXmlNode *Node, const wxTypeInfo *type );
  86. wxXmlNode * m_parent;
  87. };
  88. #endif // wxUSE_EXTENDED_RTTI
  89. #endif