?? xmlbase.h
字號:
// ================================================================================
//
// author: Rainer Schuster
//
// created: 09.03.2005 10:11:08
//
// filename: xmlbase.h
//
// You are allowed to use this code freely. Modify and/or redistribute it. This code is as it is.
// I'm not responsible for any errors or damage. Use it at your own risk.
#ifndef _DCC_XML_BASE_H_INCLUDED
#define _DCC_XML_BASE_H_INCLUDED
#pragma warning(disable: 4786)
#include "xmltools.h"
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOMErrorHandler.hpp>
#include <xercesc/util/XMLString.hpp>
#include <vector>
#include <map>
// =================
class CXMLGridRow;
// =================
typedef std::map <int, CString> CColsMap;
typedef std::pair <int, CString> CColsPair;
typedef std::map <int, CXMLGridRow> CXMLGridData;
typedef std::pair <int, CXMLGridRow> CXMLGridDataPair;
typedef std::map <CString, LPPICTURE> CPictureMap;
typedef std::pair <CString, LPPICTURE> CPicturePair;
// =================
XERCES_CPP_NAMESPACE_USE
// ================= CXMLGridRow
class CXMLGridRow
{
public:
long m_lIndex;
CColsMap *m_pCols;
CXMLGridRow()
{
m_pCols = new CColsMap();
m_lIndex = -1;
};
CXMLGridRow(const CXMLGridRow &src)
{
m_lIndex = src.m_lIndex;
m_pCols = new CColsMap( *(src.m_pCols));
};
~CXMLGridRow()
{
if( m_pCols )
{
m_pCols->clear();
delete m_pCols;
}
m_pCols = NULL;
};
void Insert( const char *lpcszEntry)
{
(*m_pCols)[m_pCols->size()] = _T(lpcszEntry);
};
void Insert( int iIdx, const char *lpcszEntry)
{
(*m_pCols)[iIdx] = _T(lpcszEntry);
};
};
// ================= CXMLBase
class CXMLBase
{
public:
bool Init(const char* lpcszXMLFile, const char* lpcszID);
protected:
virtual void Parse( DOMDocument *doc, const char* lpcszID)=0;
};
// ================= CXMLGrid
class CXMLGrid : public CXMLBase
{
public:
CXMLGrid(){ m_lRowCount = 0; };
~CXMLGrid(){};
virtual void Parse ( DOMDocument *doc, const char* lpcszID);
virtual void ParseRow ( DOMNode *node);
virtual void ParseCol ( DOMNode *node, CXMLGridRow &row);
virtual void ParseAttributes ( DOMNode *node);
virtual void ParseHeader ( DOMNode *node);
virtual void OnUnknownAttribute ( DOMNode *node);
CXMLGridData m_rows;
protected:
CXMLGridRow m_header;
long m_lRowCount;
CString m_strLabel;
CString m_strID;
CString m_strIcons;
};
// ============== codesnippet from xerces samples
// ---------------------------------------------------------------------------
// Simple error handler deriviative to install on parser
// ---------------------------------------------------------------------------
class XMLBaseErrorHandler : public DOMErrorHandler
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XMLBaseErrorHandler ();
~XMLBaseErrorHandler ();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool getSawErrors() const;
// -----------------------------------------------------------------------
// Implementation of the DOM ErrorHandler interface
// -----------------------------------------------------------------------
bool handleError(const DOMError& domError);
void resetErrors();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLBaseErrorHandler (const XMLBaseErrorHandler &);
void operator=(const XMLBaseErrorHandler &);
// -----------------------------------------------------------------------
// Private data members
//
// fSawErrors
// This is set if we get any errors, and is queryable via a getter
// method. Its used by the main code to suppress output if there are
// errors.
// -----------------------------------------------------------------------
bool fSawErrors;
};
inline bool XMLBaseErrorHandler ::getSawErrors() const
{
return fSawErrors;
}
BOOL LoadIcon( CString strIcon2Load, CString strPath, CPictureMap *map);
BOOL LoadPictureFile(LPCTSTR szFile, LPPICTURE* pgpPicture);
#endif //_DCC_XML_BASE_H_INCLUDED
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -