1//---------------------------------------------------------------------------
2// This file is generated by wxPython's SIP generator.  Do not edit by hand.
3//
4// Copyright: (c) 2018 by Total Control Software
5// License:   wxWindows License
6
7%Module( name=wx._xml,
8         keyword_arguments="All",
9         use_argument_names=True,
10         all_raise_py_exception=True,
11         language="C++")
12{
13    %AutoPyName(remove_leading="wx")
14};
15
16%Copying
17    Copyright: (c) 2018 by Total Control Software
18    License:   wxWindows License
19%End
20
21%DefaultDocstringFormat(name="deindented")
22
23%Extract(id=pycode_xml, order=5)
24# This file is generated by wxPython's SIP generator.  Do not edit by hand.
25#
26# Copyright: (c) 2018 by Total Control Software
27# License:   wxWindows License
28
29"""
30Some simple XML classes for use with XRC.
31
32For more advanced XML needs it would be better to use one of the XML packages
33provided by Python.
34"""
35
36from ._xml import *
37
38%End
39
40//---------------------------------------------------------------------------
41
42%ModuleHeaderCode
43#include <wxPython/wxpy_api.h>
44%End
45
46%Import _core.sip
47
48
49//---------------------------------------------------------------------------
50
51const int wxXML_NO_INDENTATION;
52enum wxXmlNodeType
53{
54    wxXML_ELEMENT_NODE,
55    wxXML_ATTRIBUTE_NODE,
56    wxXML_TEXT_NODE,
57    wxXML_CDATA_SECTION_NODE,
58    wxXML_ENTITY_REF_NODE,
59    wxXML_ENTITY_NODE,
60    wxXML_PI_NODE,
61    wxXML_COMMENT_NODE,
62    wxXML_DOCUMENT_NODE,
63    wxXML_DOCUMENT_TYPE_NODE,
64    wxXML_DOCUMENT_FRAG_NODE,
65    wxXML_NOTATION_NODE,
66    wxXML_HTML_DOCUMENT_NODE
67};
68
69enum wxXmlDocumentLoadFlag
70{
71    wxXMLDOC_NONE,
72    wxXMLDOC_KEEP_WHITESPACE_NODES
73};
74
75class wxXmlNode
76{
77    %Docstring
78        XmlNode(parent, type, name, content=wx.EmptyString, attrs=None, next=None, lineNo=-1)
79        XmlNode(type, name, content=wx.EmptyString, lineNo=-1)
80        XmlNode(node)
81
82        Represents a node in an XML document.
83    %End
84    %TypeHeaderCode
85        #include <wx/xml/xml.h>
86    %End
87
88public:
89    wxXmlNode(
90        wxXmlNode * parent   /TransferThis/,
91        wxXmlNodeType type,
92        const wxString & name,
93        const wxString & content = wxEmptyString,
94        wxXmlAttribute * attrs = NULL,
95        wxXmlNode * next = NULL,
96        int lineNo = -1
97    );
98
99    wxXmlNode(
100        wxXmlNodeType type,
101        const wxString & name,
102        const wxString & content = wxEmptyString,
103        int lineNo = -1
104    );
105
106    wxXmlNode(
107        const wxXmlNode & node
108    );
109
110    virtual
111    ~wxXmlNode();
112
113    virtual
114    void AddAttribute(
115        const wxString & name,
116        const wxString & value
117    );
118    %Docstring
119        AddAttribute(name, value)
120        AddAttribute(attr)
121
122        Appends a attribute with given name and value to the list of
123        attributes for this node.
124    %End
125
126    virtual
127    void AddAttribute(
128        wxXmlAttribute * attr   /Transfer/
129    );
130
131    virtual
132    void AddChild(
133        wxXmlNode * child   /Transfer/
134    );
135    %Docstring
136        AddChild(child)
137
138        Adds node child as the last child of this node.
139    %End
140
141    virtual
142    bool DeleteAttribute(
143        const wxString & name
144    );
145    %Docstring
146        DeleteAttribute(name) -> bool
147
148        Removes the first attributes which has the given name from the list of
149        attributes for this node.
150    %End
151
152    wxString GetAttribute(
153        const wxString & attrName,
154        const wxString & defaultVal = wxEmptyString
155    ) const;
156    %Docstring
157        GetAttribute(attrName, defaultVal=wx.EmptyString) -> String
158
159        Returns the value of the attribute named attrName if it does exist.
160    %End
161
162    wxXmlAttribute * GetAttributes() const;
163    %Docstring
164        GetAttributes() -> XmlAttribute
165
166        Return a pointer to the first attribute of this node.
167    %End
168
169    wxXmlNode * GetChildren() const;
170    %Docstring
171        GetChildren() -> XmlNode
172
173        Returns the first child of this node.
174    %End
175
176    const wxString & GetContent() const;
177    %Docstring
178        GetContent() -> String
179
180        Returns the content of this node.
181    %End
182
183    int GetDepth(
184        wxXmlNode * grandparent = NULL
185    ) const;
186    %Docstring
187        GetDepth(grandparent=None) -> int
188
189        Returns the number of nodes which separate this node from grandparent.
190    %End
191
192    bool GetNoConversion() const;
193    %Docstring
194        GetNoConversion() -> bool
195
196        Returns a flag indicating whether encoding conversion is necessary
197        when saving.
198    %End
199
200    int GetLineNumber() const;
201    %Docstring
202        GetLineNumber() -> int
203
204        Returns line number of the node in the input XML file or -1 if it is
205        unknown.
206    %End
207
208    const wxString & GetName() const;
209    %Docstring
210        GetName() -> String
211
212        Returns the name of this node.
213    %End
214
215    wxXmlNode * GetNext() const;
216    %Docstring
217        GetNext() -> XmlNode
218
219        Returns a pointer to the sibling of this node or NULL if there are no
220        siblings.
221    %End
222
223    wxString GetNodeContent() const;
224    %Docstring
225        GetNodeContent() -> String
226
227        Returns the content of the first child node of type wxXML_TEXT_NODE or
228        wxXML_CDATA_SECTION_NODE.
229    %End
230
231    wxXmlNode * GetParent() const;
232    %Docstring
233        GetParent() -> XmlNode
234
235        Returns a pointer to the parent of this node or NULL if this node has
236        no parent.
237    %End
238
239    wxXmlNodeType GetType() const;
240    %Docstring
241        GetType() -> XmlNodeType
242
243        Returns the type of this node.
244    %End
245
246    bool HasAttribute(
247        const wxString & attrName
248    ) const;
249    %Docstring
250        HasAttribute(attrName) -> bool
251
252        Returns true if this node has a attribute named attrName.
253    %End
254
255    virtual
256    bool InsertChild(
257        wxXmlNode * child   /Transfer/,
258        wxXmlNode * followingNode
259    );
260    %Docstring
261        InsertChild(child, followingNode) -> bool
262
263        Inserts the child node immediately before followingNode in the
264        children list.
265    %End
266
267    virtual
268    bool InsertChildAfter(
269        wxXmlNode * child   /Transfer/,
270        wxXmlNode * precedingNode
271    );
272    %Docstring
273        InsertChildAfter(child, precedingNode) -> bool
274
275        Inserts the child node immediately after precedingNode in the children
276        list.
277    %End
278
279    bool IsWhitespaceOnly() const;
280    %Docstring
281        IsWhitespaceOnly() -> bool
282
283        Returns true if the content of this node is a string containing only
284        whitespaces (spaces, tabs, new lines, etc).
285    %End
286
287    virtual
288    bool RemoveChild(
289        wxXmlNode * child   /TransferBack/
290    );
291    %Docstring
292        RemoveChild(child) -> bool
293
294        Removes the given node from the children list.
295    %End
296
297    void SetContent(
298        const wxString & con
299    );
300    %Docstring
301        SetContent(con)
302
303        Sets the content of this node.
304    %End
305
306    void SetName(
307        const wxString & name
308    );
309    %Docstring
310        SetName(name)
311
312        Sets the name of this node.
313    %End
314
315    void SetNext(
316        wxXmlNode * next
317    );
318    %Docstring
319        SetNext(next)
320
321        Sets as sibling the given node.
322    %End
323
324    void SetNoConversion(
325        bool noconversion
326    );
327    %Docstring
328        SetNoConversion(noconversion)
329
330        Sets a flag to indicate whether encoding conversion is necessary when
331        saving.
332    %End
333
334    void SetParent(
335        wxXmlNode * parent
336    );
337    %Docstring
338        SetParent(parent)
339
340        Sets as parent the given node.
341    %End
342
343    void SetType(
344        wxXmlNodeType type
345    );
346    %Docstring
347        SetType(type)
348
349        Sets the type of this node.
350    %End
351
352    public:
353
354
355    %Property(name=Attributes, get=GetAttributes)
356    %Property(name=Children, get=GetChildren)
357    %Property(name=Content, get=GetContent, set=SetContent)
358    %Property(name=Depth, get=GetDepth)
359    %Property(name=LineNumber, get=GetLineNumber)
360    %Property(name=Name, get=GetName, set=SetName)
361    %Property(name=Next, get=GetNext, set=SetNext)
362    %Property(name=NoConversion, get=GetNoConversion, set=SetNoConversion)
363    %Property(name=NodeContent, get=GetNodeContent)
364    %Property(name=Parent, get=GetParent, set=SetParent)
365    %Property(name=Type, get=GetType, set=SetType)
366};  // end of class wxXmlNode
367
368
369class wxXmlAttribute
370{
371    %Docstring
372        XmlAttribute()
373        XmlAttribute(name, value, next=None)
374
375        Represents a node attribute.
376    %End
377    %TypeHeaderCode
378        #include <wx/xml/xml.h>
379    %End
380
381public:
382    wxXmlAttribute();
383
384    wxXmlAttribute(
385        const wxString & name,
386        const wxString & value,
387        wxXmlAttribute * next = NULL
388    );
389
390    virtual
391    ~wxXmlAttribute();
392
393    wxString GetName() const;
394    %Docstring
395        GetName() -> String
396
397        Returns the name of this attribute.
398    %End
399
400    wxXmlAttribute * GetNext() const;
401    %Docstring
402        GetNext() -> XmlAttribute
403
404        Returns the sibling of this attribute or NULL if there are no
405        siblings.
406    %End
407
408    wxString GetValue() const;
409    %Docstring
410        GetValue() -> String
411
412        Returns the value of this attribute.
413    %End
414
415    void SetName(
416        const wxString & name
417    );
418    %Docstring
419        SetName(name)
420
421        Sets the name of this attribute.
422    %End
423
424    void SetNext(
425        wxXmlAttribute * next
426    );
427    %Docstring
428        SetNext(next)
429
430        Sets the sibling of this attribute.
431    %End
432
433    void SetValue(
434        const wxString & value
435    );
436    %Docstring
437        SetValue(value)
438
439        Sets the value of this attribute.
440    %End
441
442    public:
443
444
445    %Property(name=Name, get=GetName, set=SetName)
446    %Property(name=Next, get=GetNext, set=SetNext)
447    %Property(name=Value, get=GetValue, set=SetValue)
448};  // end of class wxXmlAttribute
449
450
451class wxXmlDocument : wxObject
452{
453    %Docstring
454        XmlDocument()
455        XmlDocument(doc)
456        XmlDocument(filename, encoding="UTF-8")
457        XmlDocument(stream, encoding="UTF-8")
458
459        This class holds XML data/document as parsed by XML parser in the root
460        node.
461    %End
462    %TypeHeaderCode
463        #include <wx/xml/xml.h>
464    %End
465
466public:
467    wxXmlDocument();
468
469    wxXmlDocument(
470        const wxXmlDocument & doc
471    );
472
473    wxXmlDocument(
474        const wxString & filename,
475        const wxString & encoding = "UTF-8"
476    );
477
478    wxXmlDocument(
479        wxInputStream & stream,
480        const wxString & encoding = "UTF-8"
481    );
482
483    virtual
484    ~wxXmlDocument();
485
486    void AppendToProlog(
487        wxXmlNode * node   /Transfer/
488    );
489    %Docstring
490        AppendToProlog(node)
491
492        Appends a Process Instruction or Comment node to the document
493        prologue.
494    %End
495
496    wxXmlNode * DetachDocumentNode()   /TransferBack/;
497    %Docstring
498        DetachDocumentNode() -> XmlNode
499
500        Detaches the document node and returns it.
501    %End
502
503    wxXmlNode * DetachRoot()   /TransferBack/;
504    %Docstring
505        DetachRoot() -> XmlNode
506
507        Detaches the root entity node and returns it.
508    %End
509
510    const wxString & GetFileEncoding() const;
511    %Docstring
512        GetFileEncoding() -> String
513
514        Returns encoding of document (may be empty).
515    %End
516
517    wxXmlNode * GetDocumentNode() const;
518    %Docstring
519        GetDocumentNode() -> XmlNode
520
521        Returns the document node of the document.
522    %End
523
524    wxXmlNode * GetRoot() const;
525    %Docstring
526        GetRoot() -> XmlNode
527
528        Returns the root element node of the document.
529    %End
530
531    const wxString & GetVersion() const;
532    %Docstring
533        GetVersion() -> String
534
535        Returns the version of document.
536    %End
537
538    bool IsOk() const;
539    %Docstring
540        IsOk() -> bool
541
542        Returns true if the document has been loaded successfully.
543    %End
544
545    virtual
546    bool Load(
547        const wxString & filename,
548        const wxString & encoding = "UTF-8",
549        int flags = wxXMLDOC_NONE
550    );
551    %Docstring
552        Load(filename, encoding="UTF-8", flags=XMLDOC_NONE) -> bool
553        Load(stream, encoding="UTF-8", flags=XMLDOC_NONE) -> bool
554
555        Parses filename as an xml document and loads its data.
556    %End
557
558    virtual
559    bool Load(
560        wxInputStream & stream,
561        const wxString & encoding = "UTF-8",
562        int flags = wxXMLDOC_NONE
563    );
564
565    virtual
566    bool Save(
567        const wxString & filename,
568        int indentstep = 2
569    ) const;
570    %Docstring
571        Save(filename, indentstep=2) -> bool
572        Save(stream, indentstep=2) -> bool
573
574        Saves XML tree creating a file named with given string.
575    %End
576
577    virtual
578    bool Save(
579        wxOutputStream & stream,
580        int indentstep = 2
581    ) const;
582
583    void SetDocumentNode(
584        wxXmlNode * node   /Transfer/
585    );
586    %Docstring
587        SetDocumentNode(node)
588
589        Sets the document node of this document.
590    %End
591
592    void SetFileEncoding(
593        const wxString & encoding
594    );
595    %Docstring
596        SetFileEncoding(encoding)
597
598        Sets the encoding of the file which will be used to save the document.
599    %End
600
601    void SetRoot(
602        wxXmlNode * node   /Transfer/
603    );
604    %Docstring
605        SetRoot(node)
606
607        Sets the root element node of this document.
608    %End
609
610    void SetVersion(
611        const wxString & version
612    );
613    %Docstring
614        SetVersion(version)
615
616        Sets the version of the XML file which will be used to save the
617        document.
618    %End
619
620    static
621    wxVersionInfo GetLibraryVersionInfo();
622    %Docstring
623        GetLibraryVersionInfo() -> VersionInfo
624
625        Get expat library version information.
626    %End
627
628    public:
629
630
631    %Property(name=DocumentNode, get=GetDocumentNode, set=SetDocumentNode)
632    %Property(name=FileEncoding, get=GetFileEncoding, set=SetFileEncoding)
633    %Property(name=Root, get=GetRoot, set=SetRoot)
634    %Property(name=Version, get=GetVersion, set=SetVersion)
635};  // end of class wxXmlDocument
636
637
638%Extract(id=pycode_xml, order=10)
639import wx
640
641%End
642
643%Extract(id=pycode_xml)
644XmlProperty = wx.deprecated(XmlAttribute, 'Use XmlProperty instead.')
645
646%End
647
648
649//---------------------------------------------------------------------------
650
651