資源簡介
c++ CMarkup解析xml 感覺還不錯 分享CMarkup類

代碼片段和文件信息
//?Markup.cpp:?implementation?of?the?CMarkup?class.
//
//?Markup?Release?11.5
//?Copyright?(C)?2011?First?objective?Software?Inc.?All?rights?reserved
//?Go?to?www.firstobject.com?for?the?latest?CMarkup?and?EDOM?documentation
//?Use?in?commercial?applications?requires?written?permission
//?This?software?is?provided?“as?is“?with?no?warranty.
//
#include?
#include?“Markup.h“
#if?defined(MCD_STRERROR)?//?C?error?routine
#include?
#endif?//?C?error?routine
#if?defined?(MARKUP_ICONV)
#include?
#endif
#define?x_ATTRIBQUOTE?‘\“‘?//?can?be?double?or?single?quote
#if?defined(MARKUP_STL)?&&?(?defined(MARKUP_WINCONV)?||?(!?defined(MCD_STRERROR)))
#include??//?for?MultiByteToWideChar?WideCharToMultiByte?FormatMessage
#endif?//?need?windows.h?when?STL?and?(not?setlocale?or?not?strerror)?MFC?afx.h?includes?it?already?
#if?defined(MARKUP_MBCS)?//?MBCS/double?byte
#pragma?message(?“Note:?MBCS?build?(not?UTF-8)“?)
//?For?UTF-8?remove?MBCS?from?project?settings?C/C++?preprocessor?definitions
#if?defined?(MARKUP_WINCONV)
#include??//?for?VC++?_mbclen
#endif?//?WINCONV
#endif?//?MBCS/double?byte
#if?defined(_DEBUG)?&&?_MSC_VER?>?1000?//?VC++?DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#if?defined(DEBUG_NEW)
#define?new?DEBUG_NEW
#endif?//?DEBUG_NEW
#endif?//?VC++?DEBUG
//?Disable?“while?(?1?)“?warning?in?VC++?2002
#if?_MSC_VER?>=?1300?//?VC++?2002?(7.0)
#pragma?warning(disable:4127)
#endif?//?VC++?2002?(7.0)
//////////////////////////////////////////////////////////////////////
//?Internal?static?utility?functions
//
void?x_StrInsertReplace(?MCD_STR&?str?int?nLeft?int?nReplace?const?MCD_STR&?strInsert?)
{
//?Insert?strInsert?into?str?at?nLeft?replacing?nReplace?chars
//?Reduce?reallocs?on?growing?string?by?reserving?string?space
//?If?realloc?needed?allow?for?1.5?times?the?new?length
//
int?nStrLength?=?MCD_STRLENGTH(str);
int?nInsLength?=?MCD_STRLENGTH(strInsert);
int?nNewLength?=?nInsLength?+?nStrLength?-?nReplace;
int?nAllocLen?=?MCD_STRCAPACITY(str);
#if?defined(MCD_STRINSERTREPLACE)?//?STL?replace?method
if?(?nNewLength?>?nAllocLen?)
MCD_BLDRESERVE(?str?(nNewLength?+?nNewLength/2?+?128)?);
MCD_STRINSERTREPLACE(?str?nLeft?nReplace?strInsert?);
#else?//?MFC?no?replace?method
int?nBufferLen?=?nNewLength;
if?(?nNewLength?>?nAllocLen?)
nBufferLen?+=?nBufferLen/2?+?128;
MCD_CHAR*?pDoc?=?MCD_GETBUFFER(?str?nBufferLen?);
if?(?nInsLength?!=?nReplace?&&?nLeft+nReplace? memmove(?&pDoc[nLeft+nInsLength]?&pDoc[nLeft+nReplace]?(nStrLength-nLeft-nReplace)*sizeof(MCD_CHAR)?);
if?(?nInsLength?)
memcpy(?&pDoc[nLeft]?strInsert?nInsLength*sizeof(MCD_CHAR)?);
MCD_RELEASEBUFFER(?str?pDoc?nNewLength?);
#endif?//?MFC?no?replace?method
}
int?x_Hash(?MCD_PCSZ?p?int?nSize?)
{
unsigned?int?n=0;
while?(*p)
n?+=?(unsigned?int)(*p++);
return?n?%?nSize;
}
MCD_STR?x_IntTo
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????176798??2011-04-17?21:06??CMark類\Markup.cpp
?????文件??????20033??2011-04-17?21:06??CMark類\Markup.h
?????目錄??????????0??2013-10-24?16:37??CMark類
-----------?---------??----------?-----??----
???????????????196831????????????????????3
- 上一篇:C++ 操作注冊表
- 下一篇:AGC的算法DSP上的
評論
共有 條評論