Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / ext / xrc / XS / XmlNode.xsp
1 #############################################################################
2 ## Name:        ext/xrc/XS/XmlNode.xsp
3 ## Purpose:     XS for Wx::XmlNode
4 ## Author:      Mattia Barbon
5 ## Modified by:
6 ## Created:     25/07/2003
7 ## RCS-ID:      $Id: XmlNode.xsp 2281 2007-11-11 13:46:12Z mbarbon $
8 ## Copyright:   (c) 2003, 2007 Mattia Barbon
9 ## Licence:     This program is free software; you can redistribute it and/or
10 ##              modify it under the same terms as Perl itself
11 #############################################################################
12
13 %module{Wx};
14
15 %typemap{wxXmlProperty*}{simple};
16 %typemap{wxXmlAttribute*}{simple};
17 %typemap{wxXmlNode*}{simple};
18 %typemap{wxXmlNodeType}{simple};
19
20 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
21
22 %name{Wx::XmlAttribute} class wxXmlAttribute
23 {
24     wxXmlAttribute(const wxString& name = wxEmptyString,
25                    const wxString& value = wxEmptyString,
26                    wxXmlAttribute* next = NULL);
27
28     wxString GetName() const;
29     wxString GetValue() const;
30     wxXmlAttribute* GetNext() const;
31
32     void SetName(const wxString& name);
33     void SetValue(const wxString& value);
34     void SetNext(wxXmlAttribute* next);
35 };
36
37 %{
38
39 void
40 wxXmlAttribute::Destroy()
41   CODE:
42     delete THIS;
43
44 %}
45
46 #else
47
48 %name{Wx::XmlProperty} class wxXmlProperty
49 {
50     wxXmlProperty(const wxString& name = wxEmptyString,
51                   const wxString& value = wxEmptyString,
52                   wxXmlProperty* next = NULL);
53
54     wxString GetName() const;
55     wxString GetValue() const;
56     wxXmlProperty* GetNext() const;
57
58     void SetName(const wxString& name);
59     void SetValue(const wxString& value);
60     void SetNext(wxXmlProperty* next);
61 };
62
63 %{
64
65 void
66 wxXmlProperty::Destroy()
67   CODE:
68     delete THIS;
69
70 %}
71
72 #endif
73
74 %name{Wx::XmlNode} class wxXmlNode
75 {
76 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
77     wxXmlNode(wxXmlNode* parent = NULL, wxXmlNodeType type = wxXmlNodeType(0),
78               const wxString& name = wxEmptyString,
79               const wxString& content = wxEmptyString,
80               wxXmlAttribute* props = NULL, wxXmlNode* next = NULL);
81 #else
82     wxXmlNode(wxXmlNode* parent = NULL, wxXmlNodeType type = wxXmlNodeType(0),
83               const wxString& name = wxEmptyString,
84               const wxString& content = wxEmptyString,
85               wxXmlProperty* props = NULL, wxXmlNode* next = NULL);
86 #endif
87
88     void AddChild(wxXmlNode* child);
89     void InsertChild(wxXmlNode *child, wxXmlNode *before_node);
90     bool RemoveChild(wxXmlNode *child);
91 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
92     void AddAttribute(const wxString& name, const wxString& value);
93     bool DeleteAttribute(const wxString& name);
94 #else
95     void AddProperty(const wxString& name, const wxString& value);
96     bool DeleteProperty(const wxString& name);
97 #endif
98
99     wxXmlNodeType GetType() const;
100     wxString GetName() const;
101     wxString GetContent() const;
102
103     wxXmlNode *GetParent() const;
104     wxXmlNode *GetNext() const;
105     wxXmlNode *GetChildren() const;
106
107 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
108     wxXmlAttribute *GetAttributes() const;
109 #else
110     wxXmlProperty *GetProperties() const;
111 #endif
112 ##    bool GetPropVal(const wxString& propName, wxString *value) const;
113 ##    wxString GetPropVal(const wxString& propName,
114 ##                        const wxString& defaultVal) const;
115 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
116     bool HasAttribute(const wxString& propName) const;
117 #else
118     bool HasProp(const wxString& propName) const;
119 #endif
120
121     void SetType(wxXmlNodeType type);
122     void SetName(const wxString& name);
123     void SetContent(const wxString& con);
124
125     void SetParent(wxXmlNode *parent);
126     void SetNext(wxXmlNode *next);
127     void SetChildren(wxXmlNode *child);
128
129 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
130     void SetAttributes(wxXmlAttribute *prop);
131 #else
132     void SetProperties(wxXmlProperty *prop);
133 #endif
134 ##    void AddProperty(wxXmlProperty *prop);
135 };
136
137 %{
138
139 void
140 wxXmlNode::Destroy()
141   CODE:
142     delete THIS;
143
144 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
145
146 SV*
147 wxXmlNode::GetAttribute(name, value = &PL_sv_undef)
148     wxString name
149     SV* value
150   CODE:
151     wxString tmp;
152     bool ok = THIS->GetAttribute(name, &tmp);
153     if( ok )
154         RETVAL = wxPli_wxString_2_sv( aTHX_ tmp, NEWSV(0, 0) );
155     else
156         RETVAL = SvREFCNT_inc( value );
157   OUTPUT: RETVAL
158
159 #else
160
161 SV*
162 wxXmlNode::GetPropVal(name, value = &PL_sv_undef)
163     wxString name
164     SV* value
165   CODE:
166     wxString tmp;
167     bool ok = THIS->GetPropVal(name, &tmp);
168     if( ok )
169         RETVAL = wxPli_wxString_2_sv( aTHX_ tmp, NEWSV(0, 0) );
170     else
171         RETVAL = SvREFCNT_inc( value );
172   OUTPUT: RETVAL
173
174 #endif
175 %}