home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / weblibev / htmlpavc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-02  |  6.3 KB  |  169 lines

  1.  
  2. ///////////////////////////////////////////////////////////////////////////////
  3. // Copyright 1995 by Potomac Software, Inc. Use of this material is subject to
  4. // the terms and conditions of the software license agreement.
  5.  
  6. #ifndef __HTMLPAVC_H__
  7. #define __HTMLPAVC_H__
  8.  
  9. #ifndef WEBLIB_NO_MFC
  10. #include <afxwin.h>  
  11. #endif
  12. #include "htmlpars.h"
  13. #include "dispatvc.h"
  14.  
  15. ///////////////////////////////////////////////////////////////////////////////
  16. // HTML parser classes.
  17. //
  18. // The CWeblibHtmlAPI class is a simple C++ wrapper around the API.
  19.  
  20. class CWeblibHtmlAPI
  21.   public:
  22.       CWeblibHtmlAPI();
  23.       CWeblibHtmlAPI(LPCSTR lpszFilename,WORD wOptions);
  24.       CWeblibHtmlAPI(LPCSTR lpszBuf,DWORD cbBuf,WORD wOptions);
  25.       virtual ~CWeblibHtmlAPI();
  26.       
  27.       BOOL IsGood() const;
  28.       
  29.     BOOL ParseFile(LPCSTR lpszFilename,WORD wOptions);
  30.     BOOL ParseBuf(LPCSTR lpszBuf,DWORD cbBuf,WORD wOptions);
  31.     BOOL EndParse(); 
  32.     
  33.     virtual BOOL EnumParseTree(HWND hwndNotify,UINT nMsg) const;
  34.     
  35.     HELEMENT GetChild(HELEMENT hElement) const;
  36.     HELEMENT GetParent(HELEMENT hElement) const;
  37.     HELEMENT GetSibling(HELEMENT hElement,WORD wRel) const;
  38.     
  39.     UINT GetElementType(HELEMENT hElement) const;
  40.     LPCSTR GetElementText(HELEMENT hElement) const;
  41.     
  42.     DWORD GetTextAttr(HELEMENT hElement) const;
  43.     
  44.     LPCSTR GetTagName(HELEMENT hElement) const;
  45.     UINT GetTagType(HELEMENT hElement) const;
  46.     
  47.     HTAGATTR GetTagAttr(HELEMENT hElement,HTAGATTR hTagAttr,WORD *pwType,LPSTR lpszAttr,
  48.         UINT cbAttr,LPSTR lpszValue,UINT cbValue) const; 
  49.     LPCSTR ExtractTagAttr(HELEMENT hElement,LPSTR lpszAttr) const;    
  50.         
  51.     HELEMENT FindText(HELEMENT hElement,LPCSTR lpszText) const;
  52.     HELEMENT FindSpecial(HELEMENT hElement,LPCSTR lpszSpecial) const;
  53.     HELEMENT FindComment(HELEMENT hElement,LPCSTR lpszCommentText) const;
  54.     
  55.     HELEMENT FindTagType(HELEMENT hElement,UINT nType) const;
  56.     HELEMENT FindTagName(HELEMENT hElement,LPCSTR lpszTag) const;
  57.     HELEMENT FindTagAttr(HELEMENT hElement,UINT nType,LPCSTR lpszAttr,
  58.         LPCSTR lpszValue) const;
  59.     
  60.     virtual BOOL EnumFindText(HELEMENT hElement,LPCSTR lpszText,
  61.         HWND hwndNotify,UINT nMsg) const;
  62.     virtual BOOL EnumFindSpecial(HELEMENT hElement,LPCSTR lpszSpecial,
  63.         HWND hwndNotify,UINT nMsg) const;
  64.     virtual BOOL EnumFindComment(HELEMENT hElement,LPCSTR lpszCommentText,
  65.         HWND hwndNotify,UINT nMsg) const;
  66.     
  67.     virtual BOOL EnumFindTagType(HELEMENT hElement,UINT nType,
  68.         HWND hwndNotify,UINT nMsg) const;
  69.     virtual BOOL EnumFindTagName(HELEMENT hElement,LPCSTR lpszTag,
  70.         HWND hwndNotify,UINT nMsg) const;
  71.     virtual BOOL EnumFindTagAttr(HELEMENT hElement,UINT nType,LPCSTR lpszAttr,
  72.         LPCSTR lpszValueText,HWND hwndNotify,UINT nMsg) const;
  73.         
  74.   protected:
  75.       HPARSE GetParseHandle() const
  76.           { return m_hParse; }
  77.         
  78.   private:
  79.     HPARSE m_hParse;
  80. };
  81.  
  82. ///////////////////////////////////////////////////////////////////////////////
  83. // If just want to use the above CWeblibHtmlAPI base class w/o MFC, then define
  84. // WEBLIB_NO_MFC in your project (for non-MSVC C++ compilers and class libraries).
  85.  
  86. #ifndef WEBLIB_NO_MFC
  87.  
  88. ///////////////////////////////////////////////////////////////////////////////
  89. // The CWeblibHtml derived class handles enumeration notification automatically,
  90. // invoking the proper virtual event handler method when an event is received. To use,
  91. // derive your own class from CWeblibHtml and override the notification handlers.
  92.  
  93. class CWeblibHtml : public CWeblibHtmlAPI, public CWeblibDispatch
  94. {
  95.   public:
  96.       CWeblibHtml();   
  97.       CWeblibHtml(LPCSTR lpszFilename,WORD wOptions);
  98.       CWeblibHtml(LPCSTR lpszBuf,DWORD cbBuf,WORD wOptions);
  99.       virtual ~CWeblibHtml();
  100.       
  101.       BOOL IsGood() const;
  102.       
  103.       ///////////////////////////////////////////////////////////////////////////
  104.     // New public methods intended to supplant all base class methods that take
  105.     // a notification window and message (notifications are sent to internal window).
  106.     
  107.     BOOL EnumParseTree(UINT nEnumID);
  108.     
  109.     BOOL EnumFindText(HELEMENT hElement,LPCSTR lpszText,UINT nEnumID);
  110.     BOOL EnumFindSpecial(HELEMENT hElement,LPCSTR lpszSpecial,UINT nEnumID);
  111.     BOOL EnumFindComment(HELEMENT hElement,LPCSTR lpszCommentText,UINT nEnumID);
  112.     
  113.     BOOL EnumFindTagType(HELEMENT hElement,UINT nType,UINT nEnumID);
  114.     BOOL EnumFindTagName(HELEMENT hElement,LPCSTR lpszTag,UINT nEnumID);
  115.     BOOL EnumFindTagAttr(HELEMENT hElement,UINT nType,LPCSTR lpszAttr,LPCSTR lpszValueText,
  116.         UINT nEnumID);
  117.  
  118.     ///////////////////////////////////////////////////////////////////////////
  119.     // Notification event handlers (override in your CWeblibHtml-derived class).
  120.     
  121.     virtual BOOL OnParseTree(WORD wType,HELEMENT hElement,UINT nEnumID);
  122.     virtual BOOL OnFindText(WORD wType,HELEMENT hElement,UINT nEnumID);
  123.     virtual BOOL OnFindSpecial(WORD wType,HELEMENT hElement,UINT nEnumID);
  124.     virtual BOOL OnFindComment(WORD wType,HELEMENT hElement,UINT nEnumID);
  125.     virtual BOOL OnFindTagType(WORD wType,HELEMENT hElement,UINT nEnumID);
  126.     virtual BOOL OnFindTagName(WORD wType,HELEMENT hElement,UINT nEnumID);
  127.     virtual BOOL OnFindTagAttr(WORD wType,HELEMENT hElement,UINT nEnumID);
  128.         
  129.     ///////////////////////////////////////////////////////////////////////////
  130.     // Internal window passes notification messages to Dispatch() method.
  131.         
  132.       virtual LRESULT Dispatch(UINT nMsg,WPARAM wParam,LPARAM lParam);
  133.     
  134.   private:
  135.   
  136.     ///////////////////////////////////////////////////////////////////////////
  137.     // Override public base class methods that take a notification window as 
  138.     // private (i.e., unavailable) since notifications are now sent to m_pWnd.
  139.     
  140.     virtual BOOL EnumParseTree(HWND hwndNotify,UINT nMsg) const;
  141.     
  142.     virtual BOOL EnumFindText(HELEMENT hElement,LPCSTR lpszText,
  143.         HWND hwndNotify,UINT nMsg) const;
  144.     virtual BOOL EnumFindSpecial(HELEMENT hElement,LPCSTR lpszSpecial,
  145.         HWND hwndNotify,UINT nMsg) const;
  146.     virtual BOOL EnumFindComment(HELEMENT hElement,LPCSTR lpszCommentText,
  147.         HWND hwndNotify,UINT nMsg) const;
  148.     
  149.     virtual BOOL EnumFindTagType(HELEMENT hElement,UINT nType,
  150.         HWND hwndNotify,UINT nMsg) const;
  151.     virtual BOOL EnumFindTagName(HELEMENT hElement,LPCSTR lpszTag,
  152.         HWND hwndNotify,UINT nMsg) const;
  153.     virtual BOOL EnumFindTagAttr(HELEMENT hElement,UINT nType,LPCSTR lpszAttr,
  154.         LPCSTR lpszValueText,HWND hwndNotify,UINT nMsg) const;
  155.         
  156.     BOOL PushEnumStack(UINT nEnumID);
  157.     BOOL PopEnumStack();
  158.     
  159.     CWnd *m_pWnd;
  160.     CUIntArray m_EnumStack;
  161. };
  162.  
  163. #endif    // WEBLIB_NO_MFC
  164.  
  165. #include "htmlpavc.inl"
  166.     
  167. #endif
  168.