xj qian
2024-06-26 ebc4b46218d7b9f090d1084a741a1622971d19a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#pragma once
 
typedef wchar_t* BSTR ;
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 KXMLParseError;
 
    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 gen_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, double val);
        wchar_t* transformNode(KXMLDOMNode stylesheet);
        KXMLDOMNode    transformNodeToObject(KXMLDOMNode);
    protected:
        void* impl;
    public:
        KXMLDOMNode(void* impl);
        KXMLDOMNode():KXMLDOMNode(nullptr) {}
        ~KXMLDOMNode();
    public:
        KXMLDOMNode(const KXMLDOMNode& rhs);
        const KXMLDOMNode& operator =(const KXMLDOMNode& rhs);
    public:
        operator bool() { return impl ? true : false; }
    public:
        void* getImpl();
    };
 
    class KXMLDOMDocument : public KXMLDOMNode
    {
    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:
        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);
        KXMLParseError validate();
        //bool validateNode();
    public:
        KXMLDOMDocument(void* impl);
        KXMLDOMDocument();
        ~KXMLDOMDocument();
    public:
        const KXMLDOMDocument& operator =(const KXMLDOMDocument& rhs);
        KXMLDOMDocument(const KXMLDOMDocument& rhs);
    };
 
    class KXMLDOMElement : public KXMLDOMNode
    {
    public:
        KXMLDOMElement( KXMLDOMNode v);
        KXMLDOMElement(void* impl) :KXMLDOMNode(impl) {}
        KXMLDOMElement() :KXMLDOMNode() {}
    };
    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 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) {}
    };
 
}}
 
 
 
using KXMLDOMDocument=Hxsoft::XFrame::KXMLDOMDocument;
using KXMLDOMNode=Hxsoft::XFrame::KXMLDOMNode;
using KXMLDOMElement=Hxsoft::XFrame::KXMLDOMElement;
using KXMLDOMNodeList = Hxsoft::XFrame::KXMLDOMNodeList;
 
class KXMLParseError : public KXMLDOMNode
{
public:
    KXMLParseError(KXMLDOMNode& v);
    KXMLParseError(void* impl) :KXMLDOMNode(impl) {}
};
 
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; }
};