?? htmlformat.h
字號(hào):
#ifndef HTML_FORMAT_H
#define HTML_FORMAT_H
#ifdef __cplusplus
extern "C"
{
#endif
//#include "htmlbase.h"
#ifdef __cplusplus
}
#endif
#include <ctype.h>
#include <sys/stat.h>
#define METHOD_GB2312_TO_UTF8 0
#define METHOD_UTF8_TO_GB2312 1
#define TRIM_LEFT 0
#define TRIM_RIGHT 1
#define TRIM_BOTH 2
class Format
{
public:
Format(){};
virtual ~Format(){};
virtual void format(char* content) = 0;
protected:
void TRIM(char* data = NULL);
};
///////////////下面是Decorator類相關(guān)
class Decorator:public Format
{
public:
Decorator(Format* format)
{
m_format = format;
};
virtual ~Decorator(){};
virtual void format(char* content)
{
if(m_format)
m_format->format(content);
};
private:
Format* m_format;
};
///////////////
class HTML: public Decorator
{
public:
HTML(Format* format, char* begin, char* end):Decorator(format)
{
begintag = begin;
endtag = end;
if(begintag)
begin_len = strlen(begintag);
if(endtag)
end_len = strlen(endtag);
};
virtual ~HTML(){};
virtual void format(char* content);
private:
char* begintag;
char* endtag;
int begin_len;
int end_len;
};
class Replace: public Decorator
{
public:
Replace(Format* format, char* before, char* after):Decorator(format)
{
beforetag = before;
aftertag = after;
if(beforetag)
beforetag_len = strlen(beforetag);
if(aftertag)
aftertag_len = strlen(aftertag);
};
virtual ~Replace(){};
virtual void format(char* content);
private:
char* beforetag;
char* aftertag;
int beforetag_len;
int aftertag_len;
};
class Blank: public Decorator
{
public:
Blank(Format* format):Decorator(format){tag = " ";tag_len=strlen(tag);};
virtual ~Blank(){};
virtual void format(char* content);
private:
char* tag;
int tag_len;
};
class CodeConvert: public Decorator
{
public:
CodeConvert(int method = METHOD_UTF8_TO_GB2312):Decorator(NULL)
{
m_method = method;
};
virtual ~CodeConvert(){};
virtual void format(char* content);
private:
int m_method;
};
////////////////供外部調(diào)用類
class HtmlFormat: public Format
{
public:
HtmlFormat(){};
virtual ~HtmlFormat(){};
virtual void format(char* content);
void format_code_convert(char *content, char* begintag = NULL, char* endtag = NULL, int method = METHOD_UTF8_TO_GB2312);
void codeConvert(char *content, int method = METHOD_UTF8_TO_GB2312);
};
#endif//HTML_FORMAT_H
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -