91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

采用C++編寫將C語言文件代碼高亮用html語言輸出

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?
#include?
#include?
using?namespace?boost;
using?namespace?std;

typedef?map::iterator?map_iter;
map?g_mapHighlight;
map?g_mapTokenRegex;
map?g_mapTokenType;

//配置信息
const?int?MAX_CONFIG=200;
const?char?*g_szConfigFile=“codeHl.ini“;
char?g_szLayout[MAX_CONFIG]=“background:#F3F3F3;padding:2px?10px;margin:10px;border:1px?solid?#CCC;font-size:14px“;
char?g_szFont[MAX_CONFIG]=“宋體“;
char?g_szKeyword[MAX_CONFIG]=“color:#0000FF;“;
char?g_szComment[MAX_CONFIG]=“color:#008000;“;
char?g_szPreprocessor[MAX_CONFIG]=“color:#0000FF;“;

long?getFileLength(ifstream&?in);
void?init();
string&?highlight(string&?str);
string&?htmlEncode(string?&str);
void?sourceToHTML(char?*szsFilechar?*szdFile);
void?writeConfig();
void?readConfig();

int?main(int?argc?char?*argv[])?{??
if?(argc<2)
{
cout<<“Usage:codeHl.exe?fileName\n“;
return?0;
}
sourceToHTML(argv[1]“a.html“);
return?0;
}

long?getFileLength(ifstream&?in)
{
long?psOld=in.tellg();
in.seekg(0ios::end);
long?ps=in.tellg();
in.seekg(psOld);
return?ps;
}
void?init()
{
TCHAR?szPath[MAX_PATH];?
GetWindowsDirectory(szPathMAX_PATH);
strcat_s(szPathMAX_PATH“\\codeHl.ini“);
//配置文件不存在
if?(?_access(szPath0)==-1?)
writeConfig();
else
readConfig();

//語法高亮方案
g_mapHighlight.insert(make_pair(?“Keyword“g_szKeyword?));
g_mapHighlight.insert(make_pair(?“Comment“g_szComment?));
g_mapHighlight.insert(make_pair(?“Preprocessor“g_szPreprocessor?));

//C++關(guān)鍵字
char?*szKeywords[]={
“auto““bool““break““case““catch““char““class““const““continue“
“default““delete““do““double““else““enum““explicit““export““extern“
“false““float““for““friend““goto““if““inline““int““l(fā)ong““mutable“
“namespace““new““operator““private““protected““public““register““return“
“short““signed““sizeof““static““static_cast““struct““switch“
“template““this““throw““true““try““typedef““typename““union““unsigned““using“
“virtual““void““volatile““wchar_t““while“
};
//初始化標識符對應(yīng)的類型及其正則查找語法
for(int?i=0;i {
g_mapTokenRegex.insert(make_pair(?szKeywords[i]string(“\\b(“)+szKeywords[i]+“)\\b“?));
g_mapTokenType.insert(make_pair(?szKeywords[i]“Keyword“?));
}
//初始化注釋類型和正則查找語法
g_mapTokenRegex.insert(make_pair(?“/**/“?“(/\\*(.|\\s)*?\\*/)“?));
g_mapTokenType.insert(make_pair(?“/**/“?“Comment“?));
g_mapTokenRegex.insert(make_pair(?“//“?“(//.*?)\r“?));
g_mapTokenType.insert(make_pair(?“//“?“Comment“?));
//預(yù)處理
g_mapTokenRegex.insert(make_pair(?“#“?“(#.*?\\s)“?));
g_mapTokenType.insert(make_pair(?“#“?“Preprocessor“?));
}

string&?htmlEncode(string?&str)
{
regex?reg(“<“);
str=regex_replace(strreg“<“);
reg=“>“;
str=regex_replace(strreg“>

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????476??2009-06-09?11:18??readme.txt

?????文件?????236544??2009-06-09?11:03??codeHl.exe

?????文件???????5091??2009-06-09?11:02??codeHl.cpp

-----------?---------??----------?-----??----

???????????????242111????????????????????3


評論

共有 條評論