| | |
| | | #pragma once |
| | | |
| | | typedef wchar_t* BSTR ; |
| | | |
| | | #if 1 |
| | | namespace Hxsoft { namespace XFrame |
| | | { |
| | | class KXMLDOMNode; |
| | |
| | | class KXMLDOMTextNode; |
| | | class KXMLDOMProcessingInstruction; |
| | | class KXMLDOMNodeList; |
| | | class KXMLParseError; |
| | | class KXMLDOMParseError; |
| | | class KXMLDOMParseError; |
| | | class KXMLDOMSchemaCollection; |
| | | |
| | | enum KDOMNodeType |
| | | { |
| | |
| | | KXMLDOMNode(const KXMLDOMNode& rhs); |
| | | const KXMLDOMNode& operator =(const KXMLDOMNode& rhs); |
| | | public: |
| | | unsigned long AddRef(); |
| | | unsigned long Release(); |
| | | public: |
| | | LPARAM ptr() |
| | | { |
| | | this->AddRef(); |
| | | return (LPARAM)this->getImpl(); |
| | | } |
| | | KXMLDOMNode(LPARAM p) :KXMLDOMNode((void*)p) { |
| | | AddRef(); |
| | | } |
| | | public: |
| | | operator bool() { return impl ? true : false; } |
| | | bool operator !=(KXMLDOMNode& rhs) { return rhs.getImpl() != getImpl(); } |
| | | bool operator ==(KXMLDOMNode& rhs) { return rhs.getImpl() == getImpl(); } |
| | | public: |
| | | void* getImpl(); |
| | | }; |
| | | |
| | | |
| | | class KXMLDOMElement : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMElement(KXMLDOMNode v); |
| | | KXMLDOMElement(void* impl) :KXMLDOMNode(impl) {} |
| | | KXMLDOMElement() :KXMLDOMNode() {} |
| | | public: |
| | | KXMLDOMElement(LPARAM p) :KXMLDOMNode(p) {} |
| | | }; |
| | | |
| | | class KXMLDOMDocument : public KXMLDOMNode |
| | | { |
| | | public: |
| | | bool operator !() |
| | | { |
| | | return !impl || !documentElement(); |
| | | } |
| | | public: |
| | | const wchar_t* text(); |
| | | const wchar_t* url(); |
| | |
| | | |
| | | wchar_t* transformNode(KXMLDOMNode); |
| | | KXMLDOMNode transformNodeToObject(KXMLDOMNode); |
| | | KXMLParseError validate(); |
| | | public: |
| | | KXMLDOMParseError parseError(); |
| | | |
| | | public: |
| | | KXMLDOMSchemaCollection namespaces(); |
| | | KXMLDOMSchemaCollection schemas(); |
| | | bool setSchemas(KXMLDOMSchemaCollection collection); |
| | | KXMLDOMParseError validate(); |
| | | //bool validateNode(); |
| | | public: |
| | | KXMLDOMDocument(void* impl); |
| | |
| | | public: |
| | | const KXMLDOMDocument& operator =(const KXMLDOMDocument& rhs); |
| | | KXMLDOMDocument(const KXMLDOMDocument& rhs); |
| | | public: |
| | | void Reset() |
| | | { |
| | | if (documentElement())removeChild(documentElement()); |
| | | } |
| | | public: |
| | | static bool ValidSchema(const wchar_t* pSchema, BSTR& errText); |
| | | static bool ValidSchema(KXMLDOMDocument xml, KXMLDOMDocument schema, BSTR& errText); |
| | | public: |
| | | static int GetSchemaXml(LPTSTR pSchema, KXMLDOMDocument& x); |
| | | |
| | | }; |
| | | |
| | | class KXMLDOMElement : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMElement( KXMLDOMNode v); |
| | | KXMLDOMElement(void* impl) :KXMLDOMNode(impl) {} |
| | | KXMLDOMElement() :KXMLDOMNode() {} |
| | | }; |
| | | class KXMLDOMAttribute : public KXMLDOMNode |
| | | { |
| | | public: |
| | |
| | | KXMLDOMDocumentFragment(void* impl) :KXMLDOMNode(impl) {} |
| | | }; |
| | | |
| | | class KXMLParseError : public KXMLDOMNode |
| | | class KXMLDOMParseError : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLParseError(KXMLDOMNode& v); |
| | | KXMLParseError(void* impl) :KXMLDOMNode(impl) {} |
| | | KXMLDOMParseError(KXMLDOMNode& v); |
| | | KXMLDOMParseError(void* impl) :KXMLDOMNode(impl) {} |
| | | public: |
| | | int errorCode(); |
| | | int filepos(); |
| | | int line(); |
| | | int linepos(); |
| | | BSTR reason(); |
| | | BSTR srcText(); |
| | | BSTR url(); |
| | | }; |
| | | |
| | | class KXMLDOMSchemaCollection |
| | | { |
| | | public: |
| | | protected: |
| | | void* impl; |
| | | public: |
| | | KXMLDOMSchemaCollection(void* impl); |
| | | KXMLDOMSchemaCollection(); |
| | | KXMLDOMSchemaCollection(LPARAM p); |
| | | ~KXMLDOMSchemaCollection(); |
| | | public: |
| | | KXMLDOMSchemaCollection(const KXMLDOMSchemaCollection& rhs); |
| | | const KXMLDOMSchemaCollection& operator =(const KXMLDOMSchemaCollection& rhs); |
| | | public: |
| | | void* getImpl(); |
| | | }; |
| | | |
| | | }} |
| | | |
| | | class KXMLDOMElementPtr |
| | | { |
| | | private: |
| | | KXMLDOMElement* m_pElement; |
| | | public: |
| | | KXMLDOMElementPtr(LPARAM ele) :m_pElement((KXMLDOMElement* )ele) {} |
| | | KXMLDOMElementPtr(KXMLDOMElement* pEle) :m_pElement((KXMLDOMElement*)pEle) {} |
| | | //KXMLDOMElementPtr(KXMLDOMElement ele) :m_pElement(new KXMLDOMElement(ele)) {} |
| | | public: |
| | | KXMLDOMElement* value() { return m_pElement; } |
| | | public: |
| | | operator KXMLDOMElement* () { return m_pElement; } |
| | | operator KXMLDOMElement& () { return *m_pElement; } |
| | | KXMLDOMElement* operator -> () { return m_pElement; } |
| | | }; |
| | | |
| | | |
| | | using KXMLDOMDocument=Hxsoft::XFrame::KXMLDOMDocument; |
| | | using KXMLDOMNode=Hxsoft::XFrame::KXMLDOMNode; |
| | | using KXMLDOMElement=Hxsoft::XFrame::KXMLDOMElement; |
| | | using KXMLDOMNodeList = Hxsoft::XFrame::KXMLDOMNodeList; |
| | | using KXMLDOMParseError = Hxsoft::XFrame::KXMLDOMParseError; |
| | | using KXMLDOMSchemaCollection = Hxsoft::XFrame::KXMLDOMSchemaCollection; |
| | | |
| | | /* |
| | | class KXMLDOMParseError : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMParseError(KXMLDOMNode& v); |
| | | KXMLDOMParseError(void* impl) :KXMLDOMNode(impl) {} |
| | | public: |
| | | int errorCode(); |
| | | int filepos(); |
| | | int line(); |
| | | int linepos(); |
| | | BSTR reason(); |
| | | BSTR srcText(); |
| | | BSTR url(); |
| | | }; |
| | | */ |
| | | class KXMLDOMElementPtr |
| | | { |
| | | private: |
| | | KXMLDOMElement* m_pElement; |
| | | public: |
| | | KXMLDOMElementPtr(LPARAM ele) :m_pElement((KXMLDOMElement*)ele) {} |
| | | KXMLDOMElementPtr(KXMLDOMElement* pEle) :m_pElement(pEle) {} |
| | | KXMLDOMElementPtr(KXMLDOMElement ele) :m_pElement(new KXMLDOMElement(ele)) {} |
| | | public: |
| | | KXMLDOMElement* value() { return m_pElement; } |
| | | public: |
| | | operator KXMLDOMElement* () { return m_pElement; } |
| | | operator KXMLDOMElement& () { return *m_pElement; } |
| | | KXMLDOMElement* operator -> () { return m_pElement; } |
| | | }; |
| | | |
| | | #endif |
| | | |
| | | #if 0 |
| | | namespace Hxsoft { |
| | | namespace XFrame |
| | | { |
| | | class KXMLDOMNode; |
| | | class KXMLDOMAttribute; |
| | | class KXMLDOMElement; |
| | | class KXMLDOMCDATASection; |
| | | class KXMLDOMDocumentFragment; |
| | | class KXMLDOMComment; |
| | | class KXMLDOMEntityReference; |
| | | class KXMLDOMTextNode; |
| | | class KXMLDOMProcessingInstruction; |
| | | class KXMLDOMNodeList; |
| | | class KXMLDOMParseError; |
| | | class KXMLDOMSchemaCollection; |
| | | |
| | | enum KDOMNodeType |
| | | { |
| | | KNODE_INVALID = 0, |
| | | KNODE_ELEMENT = (KNODE_INVALID + 1), |
| | | KNODE_ATTRIBUTE = (KNODE_ELEMENT + 1), |
| | | KNODE_TEXT = (KNODE_ATTRIBUTE + 1), |
| | | KNODE_CDATA_SECTION = (KNODE_TEXT + 1), |
| | | KNODE_ENTITY_REFERENCE = (KNODE_CDATA_SECTION + 1), |
| | | KNODE_ENTITY = (KNODE_ENTITY_REFERENCE + 1), |
| | | KNODE_PROCESSING_INSTRUCTION = (KNODE_ENTITY + 1), |
| | | KNODE_COMMENT = (KNODE_PROCESSING_INSTRUCTION + 1), |
| | | KNODE_DOCUMENT = (KNODE_COMMENT + 1), |
| | | KNODE_DOCUMENT_TYPE = (KNODE_DOCUMENT + 1), |
| | | KNODE_DOCUMENT_FRAGMENT = (KNODE_DOCUMENT_TYPE + 1), |
| | | KNODE_NOTATION = (KNODE_DOCUMENT_FRAGMENT + 1) |
| | | }; |
| | | |
| | | class KXMLDOMNodeList |
| | | { |
| | | public: |
| | | long length(); |
| | | bool length(long&); |
| | | bool length(long*); |
| | | bool get_length(long* v) { return length(v); } |
| | | KXMLDOMNode item(int index); |
| | | bool item(int index, KXMLDOMNode& node); |
| | | bool item(int index, KXMLDOMNode* node); |
| | | bool get_item(int index, KXMLDOMNode* node) { return item(index, node); } |
| | | private: |
| | | void* impl; |
| | | public: |
| | | void* getImpl(); |
| | | public: |
| | | KXMLDOMNodeList(void* impl); |
| | | KXMLDOMNodeList() :impl(nullptr) {} |
| | | ~KXMLDOMNodeList(); |
| | | public: |
| | | operator bool() { return impl ? true : false; } |
| | | public: |
| | | KXMLDOMNodeList(const KXMLDOMNodeList& rhs); |
| | | const KXMLDOMNodeList& operator =(const KXMLDOMNodeList& rhs); |
| | | }; |
| | | |
| | | class KXMLDOMElement; |
| | | class KXMLDOMAttribute; |
| | | class KXMLDOMDocument; |
| | | class KXMLDOMNode { |
| | | public: |
| | | // attributes |
| | | // baseName |
| | | KXMLDOMNodeList childNodes(); |
| | | // dataType |
| | | // definition |
| | | KXMLDOMNode firstChild(); |
| | | KXMLDOMNode lastChild(); |
| | | // namespaceURI |
| | | // namespaceURI |
| | | KXMLDOMNode nextSibling(); |
| | | const wchar_t* nodeName(); |
| | | KDOMNodeType nodeType(); |
| | | KDOMNodeType get_nodeType() { return nodeType(); } |
| | | // nodeTypedValue |
| | | // nodeTypeString |
| | | // nodeValue |
| | | KXMLDOMDocument ownerDocument(); |
| | | KXMLDOMNode parentNode(); |
| | | // parsed |
| | | // prefix |
| | | KXMLDOMNode previousSibling(); |
| | | // specified |
| | | const wchar_t* tagName(); |
| | | const wchar_t* text(); |
| | | const wchar_t* xml(); |
| | | |
| | | bool get_tagName(BSTR& str); |
| | | bool get_text(BSTR& str); |
| | | bool get_xml(BSTR& str); |
| | | bool get_tagName(BSTR* str) { return get_tagName(*str); } |
| | | bool get_text(BSTR* str) { return get_text(*str); } |
| | | bool get_xml(BSTR* str) { return get_xml(*str); } |
| | | bool settext(const wchar_t* txt); |
| | | bool put_text(const wchar_t* txt) { return settext(txt); } |
| | | |
| | | |
| | | bool appendChild(KXMLDOMNode); |
| | | KXMLDOMNode cloneNode(bool); |
| | | wchar_t* getAttribute(const wchar_t* name); |
| | | void getAttribute(const wchar_t* name, void* vt); |
| | | KXMLDOMAttribute getAttributeNode(const wchar_t* name); |
| | | KXMLDOMNodeList getElementsByTagName(const wchar_t* name); |
| | | bool hasChildNodes(); |
| | | bool insertBefore(KXMLDOMNode newnode, KXMLDOMNode at); |
| | | void normalize(); |
| | | bool removeAttribute(const wchar_t* name); |
| | | bool removeAttributeNode(KXMLDOMNode attr); |
| | | bool removeChild(KXMLDOMNode val); |
| | | bool replaceChild(KXMLDOMNode newChild, KXMLDOMNode oldChild); |
| | | KXMLDOMNodeList selectNodes(const wchar_t*); |
| | | KXMLDOMNode selectSingleNode(const wchar_t*); |
| | | bool selectNodes(const wchar_t*, KXMLDOMNodeList& pNodeList); |
| | | bool selectSingleNode(const wchar_t*, KXMLDOMNode& pNode); |
| | | bool selectNodes(const wchar_t*, KXMLDOMNodeList* pNodeList); |
| | | bool selectSingleNode(const wchar_t*, KXMLDOMNode* pNode); |
| | | void setAttribute(const wchar_t* name, const wchar_t* value); |
| | | void setAttribute(const wchar_t* name, long val); |
| | | void setAttribute(const wchar_t* name, int val); |
| | | void setAttribute(const wchar_t* name, double val); |
| | | wchar_t* transformNode(KXMLDOMNode stylesheet); |
| | | KXMLDOMNode transformNodeToObject(KXMLDOMNode); |
| | | protected: |
| | | void* impl; |
| | | public: |
| | | KXMLDOMNode(void* impl); |
| | | KXMLDOMNode() :KXMLDOMNode(nullptr) {} |
| | | ~KXMLDOMNode(); |
| | | KXMLDOMNode(LPARAM p) :KXMLDOMNode((void*)p) { |
| | | AddRef(); |
| | | } |
| | | public: |
| | | KXMLDOMNode(const KXMLDOMNode& rhs); |
| | | const KXMLDOMNode& operator =(const KXMLDOMNode& rhs); |
| | | public: |
| | | operator bool() { return impl ? true : false; } |
| | | public: |
| | | void* getImpl(); |
| | | public: |
| | | unsigned long AddRef(); |
| | | unsigned long Release(); |
| | | public: |
| | | bool operator !=(KXMLDOMNode& rhs) { return rhs.getImpl() != getImpl(); } |
| | | bool operator ==(KXMLDOMNode& rhs) { return rhs.getImpl() == getImpl(); } |
| | | }; |
| | | |
| | | class KXMLDOMElement : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMElement(KXMLDOMNode v); |
| | | KXMLDOMElement(void* impl) :KXMLDOMNode(impl) {} |
| | | KXMLDOMElement() :KXMLDOMNode() {} |
| | | public: |
| | | KXMLDOMElement(LPARAM p) :KXMLDOMNode(p) {} |
| | | |
| | | }; |
| | | class KXMLDOMAttribute : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMAttribute(KXMLDOMNode& v); |
| | | KXMLDOMAttribute(void* impl) :KXMLDOMNode(impl) {} |
| | | }; |
| | | class KXMLDOMCDATASection : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMCDATASection(KXMLDOMNode& v); |
| | | KXMLDOMCDATASection(void* impl) :KXMLDOMNode(impl) {} |
| | | }; |
| | | |
| | | |
| | | class KXMLDOMDocument : public KXMLDOMNode |
| | | { |
| | | public: |
| | | bool operator !() |
| | | { |
| | | return !impl || !documentElement(); |
| | | } |
| | | public: |
| | | const wchar_t* text(); |
| | | const wchar_t* url(); |
| | | const wchar_t* xml(); |
| | | KXMLDOMElement documentElement(); |
| | | bool documentElement(KXMLDOMElement* pDoc); |
| | | bool get_documentElement(KXMLDOMElement* pDoc) { return documentElement(pDoc); } |
| | | public: |
| | | KXMLDOMParseError parseError(); |
| | | public: |
| | | bool appendChild(KXMLDOMNode); |
| | | KXMLDOMAttribute createAttribute(const wchar_t*); |
| | | KXMLDOMCDATASection createCDATASection(const wchar_t*); |
| | | KXMLDOMComment createComment(const wchar_t*); |
| | | KXMLDOMDocumentFragment createDocumentFragment(); |
| | | KXMLDOMElement createElement(const wchar_t*); |
| | | bool createElement(const wchar_t*, KXMLDOMElement* ele); |
| | | KXMLDOMEntityReference createEntityReference(const wchar_t*); |
| | | KXMLDOMNode createNode(KDOMNodeType ty, const wchar_t* name, const wchar_t* ns); |
| | | KXMLDOMProcessingInstruction createProcessingInstruction(const wchar_t* target, const wchar_t* data); |
| | | KXMLDOMTextNode createTextNode(const wchar_t*); |
| | | |
| | | KXMLDOMNodeList getElementsByTagName(const wchar_t*); |
| | | wchar_t* getProperty(const wchar_t*); |
| | | bool setProperty(const wchar_t* prop, const wchar_t* val); |
| | | bool setProperty(const wchar_t* prop, bool val); |
| | | bool hasChildNodes(); |
| | | bool importNode(KXMLDOMNode); |
| | | bool insertBefore(KXMLDOMNode newnode, KXMLDOMNode at); |
| | | bool load(const wchar_t*); |
| | | bool loadXML(const wchar_t*); |
| | | KXMLDOMNode nodeFromID(const wchar_t*); |
| | | bool removeChild(KXMLDOMNode); |
| | | bool replaceChild(KXMLDOMNode newChild, KXMLDOMNode oldChild); |
| | | bool save(const wchar_t*); |
| | | KXMLDOMNodeList selectNodes(const wchar_t*); |
| | | KXMLDOMNode selectSingleNode(const wchar_t*); |
| | | bool selectNodes(const wchar_t*, KXMLDOMNodeList& pNodeList); |
| | | bool selectSingleNode(const wchar_t*, KXMLDOMNode& pNode); |
| | | bool selectNodes(const wchar_t*, KXMLDOMNodeList* pNodeList); |
| | | bool selectSingleNode(const wchar_t*, KXMLDOMNode* pNode); |
| | | |
| | | wchar_t* transformNode(KXMLDOMNode); |
| | | KXMLDOMNode transformNodeToObject(KXMLDOMNode); |
| | | |
| | | public: |
| | | KXMLDOMSchemaCollection namespaces(); |
| | | KXMLDOMSchemaCollection schemas(); |
| | | bool setSchemas(KXMLDOMSchemaCollection collection); |
| | | KXMLDOMParseError validate(); |
| | | //bool validateNode(); |
| | | public: |
| | | KXMLDOMDocument(void* impl); |
| | | KXMLDOMDocument(); |
| | | ~KXMLDOMDocument(); |
| | | public: |
| | | const KXMLDOMDocument& operator =(const KXMLDOMDocument& rhs); |
| | | KXMLDOMDocument(const KXMLDOMDocument& rhs); |
| | | public: |
| | | void Reset() |
| | | { |
| | | if (documentElement())removeChild(documentElement()); |
| | | } |
| | | public: |
| | | static bool ValidSchema(const wchar_t* pSchema, BSTR& errText); |
| | | static bool ValidSchema(KXMLDOMDocument xml, KXMLDOMDocument schema, BSTR& errText); |
| | | public: |
| | | static int GetSchemaXml(LPTSTR pSchema, KXMLDOMDocument& x); |
| | | }; |
| | | |
| | | |
| | | class KXMLDOMComment : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMComment(KXMLDOMNode& v); |
| | | KXMLDOMComment(void* impl) :KXMLDOMNode(impl) {} |
| | | }; |
| | | |
| | | class KXMLDOMEntityReference : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMEntityReference(KXMLDOMNode& v); |
| | | KXMLDOMEntityReference(void* impl) :KXMLDOMNode(impl) {} |
| | | }; |
| | | |
| | | class KXMLDOMTextNode : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMTextNode(KXMLDOMNode& v); |
| | | KXMLDOMTextNode(void* impl) :KXMLDOMNode(impl) {} |
| | | }; |
| | | |
| | | class KXMLDOMProcessingInstruction : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMProcessingInstruction(KXMLDOMNode& v); |
| | | KXMLDOMProcessingInstruction(void* impl) :KXMLDOMNode(impl) {} |
| | | }; |
| | | class KXMLDOMDocumentFragment : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMDocumentFragment(KXMLDOMNode& v); |
| | | KXMLDOMDocumentFragment(void* impl) :KXMLDOMNode(impl) {} |
| | | }; |
| | | |
| | | class KXMLDOMParseError : public KXMLDOMNode |
| | | { |
| | | public: |
| | | KXMLDOMParseError(KXMLDOMNode& v); |
| | | KXMLDOMParseError(void* impl) :KXMLDOMNode(impl) {} |
| | | public: |
| | | int errorCode(); |
| | | int filepos(); |
| | | int line(); |
| | | int linepos(); |
| | | BSTR reason(); |
| | | BSTR srcText(); |
| | | BSTR url(); |
| | | }; |
| | | |
| | | class KXMLDOMSchemaCollection |
| | | { |
| | | public: |
| | | protected: |
| | | void* impl; |
| | | public: |
| | | KXMLDOMSchemaCollection(void* impl); |
| | | KXMLDOMSchemaCollection(); |
| | | KXMLDOMSchemaCollection(LPARAM p); |
| | | ~KXMLDOMSchemaCollection(); |
| | | public: |
| | | KXMLDOMSchemaCollection(const KXMLDOMSchemaCollection& rhs); |
| | | const KXMLDOMSchemaCollection& operator =(const KXMLDOMSchemaCollection& rhs); |
| | | public: |
| | | void* getImpl(); |
| | | }; |
| | | |
| | | } |
| | | } |
| | | |
| | | using KXMLDOMDocument = Hxsoft::XFrame::KXMLDOMDocument; |
| | | using KXMLDOMNode = Hxsoft::XFrame::KXMLDOMNode; |
| | | using KXMLDOMElement = Hxsoft::XFrame::KXMLDOMElement; |
| | | using KXMLDOMNodeList = Hxsoft::XFrame::KXMLDOMNodeList; |
| | | using KXMLDOMParseError = Hxsoft::XFrame::KXMLDOMParseError; |
| | | using KXMLDOMSchemaCollection = Hxsoft::XFrame::KXMLDOMSchemaCollection; |
| | | |
| | | #endif |
| | | |