XMLTags.h
上传用户:kj0090
上传日期:2007-03-02
资源大小:39k
文件大小:5k
源码类别:

xml/soap/webservice

开发平台:

C/C++

  1. /***********************************************************************
  2. *
  3. * This module is part of the XMLGUI system 
  4. *
  5. * File name:       XMLTags.h
  6. *
  7. * Creation date:   [15 AUGUST 2002] 
  8. *
  9. * Author(s):       [Kolosenko Ruslan]
  10. *
  11. * Description:     Declares the class XMLTags and descendants
  12. *
  13. **********************************************************************/
  14. #ifndef AFX_XML_TAGS_H_RKOL_8_15_2002_
  15. #define AFX_XML_TAGS_H_RKOL_8_15_2002_
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif // _MSC_VER > 1000
  19. #include "XMLGUIMacro.h"
  20. #include "XMLGUISyntax.h"
  21. #include "XMLParsingException.h"
  22. class XMLGUI_EXT_CLASS CXMLTag  
  23. {
  24. public:
  25.        // constructs CXMLTag object as a root tag of an XML document
  26. CXMLTag(LPCTSTR szXMLFile);
  27.        // constructs CXMLTag object as a wrapper of an XML node
  28.     CXMLTag(IXMLElement* pXMLElement);
  29. virtual ~CXMLTag();
  30.        // checks possibility to represent an XML element via CXMLTag object
  31.        // always returns TRUE inasmuch as any XML tag can be represented
  32.        // via generic class CXMLTag
  33.     static BOOL IsTypeValid(IXMLElement* /*pXMLElement*/)
  34.            { return TRUE; }   // any pXMLElement is allowed to be represented as CXMLTag
  35.        // returns encapsulated COM interface pointer
  36.     operator IXMLElement*()
  37.            { return m_pXMLElement; }
  38.        // methods for XML data retrieval
  39.     _bstr_t GetTitle();     // returns the name of the XML tag
  40.     _bstr_t GetText();      // returns the text within the XML tag
  41.     int     GetAttributeInt(LPCTSTR szAttributeName);     // returns value
  42.                           // of the specified attribute in numeric format
  43.     _bstr_t GetAttributeString(LPCTSTR szAttributeName);  // returns value
  44.                            // of the specified attribute in string format
  45.        // static methods for VARIANT values conversions
  46.     static int     GetIntegerValue(VARIANT var);   // converts VARIANT to number
  47.     static _bstr_t GetStringValue(VARIANT var);    // converts VARIANT to string
  48. protected:
  49.     IXMLDocument*   m_pXMLDocument;   // non-NULL only if the object is a root XML tag
  50.     IXMLElement*    m_pXMLElement;    // pointer to encapsulated IXMLElement interface
  51. };
  52. class XMLGUI_EXT_CLASS CXMLStylableTag : public CXMLTag
  53. {
  54. public:
  55.        // two types of constructors as in the base class CXMLTag
  56.     CXMLStylableTag(LPCTSTR szXMLFile);
  57.     CXMLStylableTag(IXMLElement* pXMLElement);
  58.     virtual ~CXMLStylableTag() {};
  59.        // checks possibility to represent an XML element via CXMLStylableTag object
  60.        // always returns TRUE allowing any tag to be assigned "style" attribute
  61.     static BOOL IsTypeValid(IXMLElement* /*pXMLElement*/)
  62.            { return TRUE; }
  63.     DWORD   GetStyles()               // returns set of assigned window styles
  64.            { return m_nStyles; }
  65.     DWORD   GetExStyles()             // returns set of assigned window ex.styles
  66.            { return m_nExStyles; }
  67. protected:
  68.     DWORD  m_nStyles;                 // assigned window styles
  69.     DWORD  m_nExStyles;               // assigned extended window styles
  70.        // parses string of the "style" attribute and sets member variables
  71.     void   ParseStylesAttribute(LPXMLGUIStylesValues pTagSpecificStyleSyntax = NULL,
  72.                                 LPXMLGUIStylesValues pTagSpecificExStyleSyntax = NULL);
  73.        // searches for Windows style constant through the specified syntax structure
  74.     DWORD  LookupStylesSet(LPXMLGUIStylesValues pStylesSet, LPCTSTR szStyle);
  75. };
  76. class XMLGUI_EXT_CLASS CXMLDialogTag : public CXMLStylableTag
  77. {
  78. public:
  79.        // two types of constructors as in the base class CXMLStylableTag
  80.     CXMLDialogTag(LPCTSTR szXMLFile);
  81.     CXMLDialogTag(IXMLElement* pXMLElement);
  82.     virtual ~CXMLDialogTag() {};
  83.        // checks possibility to represent an XML element via CXMLDialogTag object
  84.        // the tag name should be equal to "DIALOG" to allow such representation
  85.     static BOOL IsTypeValid(IXMLElement* pXMLElement)
  86.            { _bstr_t strTitle = CXMLTag(pXMLElement).GetTitle();
  87.              return !!strTitle && !wcscmp((const wchar_t*)strTitle,TAG_DIALOG); }
  88. };
  89. class XMLGUI_EXT_CLASS CXMLControlTag : public CXMLStylableTag
  90. {
  91. public:
  92.        // only one constructor is available,
  93.        // CXMLControlTag object cannot be a root tag
  94.        // and thus there's no way to build the object from an XML file
  95.     CXMLControlTag(IXMLElement* pXMLElement);
  96.     virtual ~CXMLControlTag() {};
  97.        // checks possibility to represent an XML element via CXMLControlTag object
  98.        // the tag name should be equal to "CONTROL" to allow such representation
  99.     static BOOL IsTypeValid(IXMLElement* pXMLElement)
  100.            { _bstr_t strTitle = CXMLTag(pXMLElement).GetTitle();
  101.              return !!strTitle && !wcscmp((const wchar_t*)strTitle,TAG_CONTROL); }
  102.        // control-specific functions
  103.     _bstr_t GetWindowClass();         // returns window class for the control
  104.     WORD    GetWindowClassOrdinal();  // returns class ordinal for the control
  105.     BOOL    IsActiveX()               // checks whether CXMLControlTag object
  106.            { return m_bActiveX; }                // represents an OLE control
  107. protected:
  108.     XMLGUIControlSyntax* m_pControlSyntax;  // points to syntax structure for controls
  109.                                                        // of predefined window classes
  110.     BOOL   m_bActiveX;                      // TRUE if XML tag describes an OLE control
  111. };
  112. #endif // AFX_XML_TAGS_H_RKOL_8_15_2002_