📄 node.h
字号:
class CSchemaString : public CSchemaType
{
public:
CSchemaString(LPCTSTR szValue) : m_Value(szValue) {}
CSchemaString(const CString& sValue) : m_Value(sValue) {}
virtual operator CString() { return m_Value; }
typedef LPCTSTR basetype;
protected:
CString m_Value;
};
typedef CSchemaString CSchemaNormalizedString;
typedef CSchemaString CSchemaToken;
typedef CSchemaString CSchemaLanguage;
typedef CSchemaString CSchemaName;
typedef CSchemaString CSchemaNMToken;
typedef CSchemaString CSchemaNMTokens;
typedef CSchemaString CSchemaNCName;
typedef CSchemaString CSchemaID;
typedef CSchemaString CSchemaIDRef;
typedef CSchemaString CSchemaIDRefs;
typedef CSchemaString CSchemaEntity;
typedef CSchemaString CSchemaEntities;
typedef CSchemaString CSchemaAnyURI;
typedef CSchemaString CSchemaQName;
typedef CSchemaString CSchemaNotation;
///////////////////////////////////////////////////////////////////////////////
//
// CSchemaDate
//
///////////////////////////////////////////////////////////////////////////////
class CSchemaDate : public CSchemaType
{
public:
CSchemaDate(COleDateTime Value) : m_Value( Value ) {}
CSchemaDate(const CString& sValue) { m_Value.SetDate(_ttoi(sValue.Mid(0, 4)), _ttoi(sValue.Mid(5, 2)), _ttoi(sValue.Mid(8, 2))); }
virtual operator CString() { return m_Value.Format(_T("%Y-%m-%d")); }
typedef COleDateTime basetype;
protected:
COleDateTime m_Value;
};
///////////////////////////////////////////////////////////////////////////////
//
// CSchemaTime
//
///////////////////////////////////////////////////////////////////////////////
class CSchemaTime : public CSchemaType
{
public:
CSchemaTime(COleDateTime Value) : m_Value( Value ) {}
CSchemaTime(const CString& sValue) { m_Value.SetTime(_ttoi(sValue.Mid(0, 2)), _ttoi(sValue.Mid(3, 2)), _ttoi(sValue.Mid(6, 2))); }
virtual operator CString() { return m_Value.Format(_T("%H:%M:%S")); }
typedef COleDateTime basetype;
protected:
COleDateTime m_Value;
};
///////////////////////////////////////////////////////////////////////////////
//
// CSchemaDateTime
//
///////////////////////////////////////////////////////////////////////////////
class CSchemaDateTime : public CSchemaType
{
public:
CSchemaDateTime(COleDateTime Value) : m_Value( Value ) {}
CSchemaDateTime(const CString& sValue) { m_Value.SetDateTime(_ttoi(sValue.Mid(0, 4)), _ttoi(sValue.Mid(5, 2)), _ttoi(sValue.Mid(8, 2)), _ttoi(sValue.Mid(11, 2)), _ttoi(sValue.Mid(14, 2)), _ttoi(sValue.Mid(17, 2))); }
virtual operator CString() { return m_Value.Format(_T("%Y-%m-%dT%H:%M:%S")); }
typedef COleDateTime basetype;
protected:
COleDateTime m_Value;
};
///////////////////////////////////////////////////////////////////////////////
//
// CSchemaYear
//
///////////////////////////////////////////////////////////////////////////////
typedef CSchemaShort CSchemaYear;
///////////////////////////////////////////////////////////////////////////////
//
// CSchemaMonth
//
///////////////////////////////////////////////////////////////////////////////
class CSchemaMonth : public CSchemaType
{
public:
CSchemaMonth(unsigned char nValue) { m_Value = nValue; }
CSchemaMonth(const CString& sValue) { _stscanf(sValue, _T("--%02hi--"), &m_Value); }
virtual operator unsigned char() { return m_Value; }
virtual operator CString() { TCHAR szValue[32]; _sntprintf(szValue, 31, _T("--%02hi--"), m_Value); return szValue; }
typedef unsigned char basetype;
protected:
unsigned char m_Value;
};
///////////////////////////////////////////////////////////////////////////////
//
// CSchemaDay
//
///////////////////////////////////////////////////////////////////////////////
class CSchemaDay : public CSchemaType
{
public:
CSchemaDay(unsigned char nValue) { m_Value = nValue; }
CSchemaDay(const CString& sValue) { _stscanf(sValue, _T("---%02hi"), &m_Value); }
virtual operator unsigned char() { return m_Value; }
virtual operator CString() { TCHAR szValue[32]; _sntprintf(szValue, 31, _T("---%02hi"), m_Value); return szValue; }
typedef unsigned char basetype;
protected:
unsigned char m_Value;
};
///////////////////////////////////////////////////////////////////////////////
//
// CSchemaYearMonth
//
///////////////////////////////////////////////////////////////////////////////
class CSchemaYearMonth : public CSchemaType
{
public:
CSchemaYearMonth(short nYear, unsigned char nMonth) { m_nYear = nYear; m_nMonth = nMonth; }
CSchemaYearMonth(const CString& sValue) { _stscanf(sValue, _T("%04hi-%02hi"), &m_nYear, &m_nMonth); }
CSchemaYearMonth(LPCTSTR szValue) { CSchemaYearMonth(CString(szValue)); }
short GetYear() { return m_nYear; }
short GetMonth() { return m_nMonth; }
virtual operator CString() { TCHAR szValue[32]; _sntprintf(szValue, 31, _T("%04hi-%02hi"), m_nYear, m_nMonth); return szValue; }
bool operator ==(CSchemaYearMonth& rOther) { return m_nYear == rOther.m_nYear && m_nMonth == rOther.m_nMonth; }
bool operator <(CSchemaYearMonth& rOther) { return m_nYear < rOther.m_nYear || (m_nYear == rOther.m_nYear && m_nMonth < rOther.m_nMonth); }
typedef LPCTSTR basetype;
protected:
short m_nYear;
unsigned char m_nMonth;
};
///////////////////////////////////////////////////////////////////////////////
//
// CSchemaMonthDay
//
///////////////////////////////////////////////////////////////////////////////
class CSchemaMonthDay : public CSchemaType
{
public:
CSchemaMonthDay(unsigned char nMonth, unsigned char nDay) { m_nMonth = nMonth; m_nDay = nDay; }
CSchemaMonthDay(const CString& sValue) { _stscanf(sValue, _T("--%02hi-%02hi"), &m_nMonth, &m_nDay); }
CSchemaMonthDay(LPCTSTR szValue) { CSchemaMonthDay(CString(szValue)); }
short GetMonth() { return m_nMonth; }
short GetDay() { return m_nDay; }
virtual operator CString() { TCHAR szValue[32]; _sntprintf(szValue, 31, _T("--%02hi-%02hi"), m_nMonth, m_nDay); return szValue; }
bool operator ==(CSchemaMonthDay& rOther) { return m_nMonth == rOther.m_nMonth && m_nDay == rOther.m_nDay; }
bool operator <(CSchemaMonthDay& rOther) { return m_nMonth < rOther.m_nMonth || (m_nMonth == rOther.m_nMonth && m_nDay < rOther.m_nDay); }
typedef LPCTSTR basetype;
protected:
unsigned char m_nMonth;
unsigned char m_nDay;
};
///////////////////////////////////////////////////////////////////////////////
//
// CSchemaDuration
//
///////////////////////////////////////////////////////////////////////////////
class CSchemaDuration : public CSchemaType
{
public:
CSchemaDuration(LPCTSTR szValue) { CSchemaDuration(CString(szValue)); }
CSchemaDuration(const CString& sValue)
{
m_bPositive = true;
m_nYear = 0;
m_nMonth = 0;
m_nDay = 0;
m_nHour = 0;
m_nMinute = 0;
m_nSecond = 0;
bool bTime = false;
const TCHAR* szBuffer = (LPCTSTR)sValue;
if (*szBuffer == _T('-'))
{
m_bPositive = false;
szBuffer++;
}
if (*szBuffer != _T('P'))
{
return;
}
while (*szBuffer)
{
if (*szBuffer == _T('T'))
{
bTime = true;
szBuffer++;
}
int nData = _ttoi(szBuffer);
szBuffer += _tcsspn(szBuffer, _T("0123456789"));
if (*szBuffer == _T('.'))
{
szBuffer++;
szBuffer += _tcsspn(szBuffer, _T("0123456789"));
}
if (bTime)
{
switch (*szBuffer++)
{
case _T('H'): m_nHour = nData; break;
case _T('M'): m_nMinute = nData; break;
case _T('S'): m_nSecond = nData; break;
}
}
else
{
switch (*szBuffer++)
{
case _T('Y'): m_nYear = nData; break;
case _T('M'): m_nMonth = nData; break;
case _T('D'): m_nDay = nData; break;
}
}
}
}
short GetYear() { return m_nYear; }
short GetMonth() { return m_nMonth; }
short GetDay() { return m_nDay; }
short GetHour() { return m_nHour; }
short GetMinue() { return m_nHour; }
short GetSecond() { return m_nSecond; }
virtual operator CString()
{
CString sResult;
TCHAR szValue[32];
if (!m_bPositive)
sResult = _T('-');
sResult += _T('P');
if (m_nYear)
{
_sntprintf(szValue, 31, _T("%hiY"), m_nYear);
sResult += szValue;
}
if (m_nMonth)
{
_sntprintf(szValue, 31, _T("%hiM"), m_nMonth);
sResult += szValue;
}
if (m_nDay)
{
_sntprintf(szValue, 31, _T("%hiD"), m_nDay);
sResult += szValue;
}
if (m_nHour || m_nMinute || m_nSecond)
{
sResult += _T('T');
if (m_nHour)
{
_sntprintf(szValue, 31, _T("%hiH"), m_nHour);
sResult += szValue;
}
if (m_nMinute)
{
_sntprintf(szValue, 31, _T("%hiM"), m_nMinute);
sResult += szValue;
}
if (m_nSecond)
{
_sntprintf(szValue, 31, _T("%hiS"), m_nSecond);
sResult += szValue;
}
}
return sResult;
}
typedef LPCTSTR basetype;
protected:
bool m_bPositive;
short m_nYear;
short m_nMonth;
short m_nDay;
short m_nHour;
short m_nMinute;
short m_nSecond;
};
///////////////////////////////////////////////////////////////////////////////
//
// CSchemaHexBinary
//
///////////////////////////////////////////////////////////////////////////////
inline unsigned char hex2dec(TCHAR c)
{
if (c >= _T('0') && c <= _T('9'))
return c - _T('0');
if (c >= _T('a') && c <= _T('f'))
return 10 + c - _T('a');
if (c >= _T('A') && c <= _T('F'))
return 10 + c - _T('A');
return 0;
}
class CSchemaHexBinary : public CSchemaType
{
public:
CSchemaHexBinary(LPCTSTR szValue)
{
CSchemaHexBinary(CString(szValue));
}
CSchemaHexBinary(const CSchemaHexBinary& rOther)
{
m_nSize = rOther.m_nSize;
m_szData = new unsigned char[m_nSize];
memcpy(m_szData, rOther.m_szData, m_nSize);
}
CSchemaHexBinary(const CString& sValue)
{
m_nSize = sValue.GetLength() / 2;
m_szData = new unsigned char[m_nSize];
LPCTSTR szValue = (LPCTSTR)sValue;
unsigned char* szDataWriter = m_szData;
while (*szValue && *(szValue + 1))
{
*szDataWriter++ = hex2dec(*szValue) * 16 + hex2dec(*(szValue + 1));
szValue += 2;
}
}
virtual ~CSchemaHexBinary()
{
}
int GetSize() const { return m_nSize; }
unsigned char* GetData() { return m_szData; }
virtual operator CString()
{
return m_szData;
}
typedef LPCTSTR basetype;
protected:
int m_nSize;
unsigned char* m_szData;
};
///////////////////////////////////////////////////////////////////////////////
//
// CSchemaBase64Binary
//
///////////////////////////////////////////////////////////////////////////////
class CSchemaBase64Binary : public CSchemaType
{
public:
CSchemaBase64Binary(LPCTSTR szValue);
CSchemaBase64Binary(const CSchemaBase64Binary& rOther);
CSchemaBase64Binary(const CString& sValue);
virtual ~CSchemaBase64Binary();
CSchemaBase64Binary& operator =(const CSchemaBase64Binary& rOther);
int GetSize() const;
LPBYTE GetData() const;
void SetData(LPBYTE pData, int nSize, bool bCopy = true);
virtual operator CString();
typedef LPCTSTR basetype;
protected:
void Encode(LPBYTE pSrc, int nSrcSize, LPTSTR& rszDst, int& rnDstSize, int nMaxLineLength = 76);
void Decode(LPCTSTR szSrc, LPBYTE& rpDst, int& rnDstSize);
static const TCHAR m_EncodeArray[];
static const TCHAR m_DecodeArray[];
int m_nSize;
LPBYTE m_pData;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -