加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

跨平台C++ Html Parser, basehtmlparser.h

(2005-05-26 11:40:12)
标签:

杂谈

分类: 计算机与 Internet


#ifndef _BaseHtmlParser_H_
#define _BaseHtmlParser_H_
#include <vector>
#include <string>
using namespace std;


class CBaseHtmlParser
{
public:
 //!struct to save a string, with a pointer and a size
 struct SZ_STRING
 {
  const char* pbData;
  size_t cbData;
 };

public:
 CBaseHtmlParser();
 virtual ~CBaseHtmlParser();

 //Init or Destroy, do nothing here now
 virtual void Initialize(){}
 virtual void Destroy(){}

 //Two interface to parser html page
 virtual bool Parse(const string& URL,const string& Content);
 virtual bool Parse(const SZ_STRING &strUrl,const SZ_STRING &strContent);

 //Util api for get a absolute url based on current page
 void Relativity2AbsoluteURL(string& URL);

 //event when a tag begin, such as '<a href=..' , then strTagName is 'a', Attribs contains 'href'
 virtual void OnStartTag(const SZ_STRING & strTagName,vector< pair<SZ_STRING,SZ_STRING> > Attribs){};
 //event when a tag close, such as '</a>', then strTagName is 'a'
 virtual void OnEndTag(const SZ_STRING & strTagName){};
 //event when text between tags, such as '<>hello<>', then strData is 'hello'
 virtual void OnData(const SZ_STRING & strData){};
 //event when script or comment, such as '<!-- .../-->' or '<script ..> </script>'
 virtual void OnComment(const SZ_STRING & strComment){};
private:
 char m_szBaseURL[1024];
 char m_szBaseDomain[1024];
};

#endif

 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有