forked from andreww/fox
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathm_dom_extras.m4
188 lines (173 loc) · 5.63 KB
/
m_dom_extras.m4
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
dnl
include(`foreach.m4')dnl
dnl
include(`datatypes.m4')dnl
dnl
include(`common.m4')dnl
dnl
include(`m_dom_exception.m4')dnl
define(`TOHW_extractDataContent', `dnl
dnl
TOHW_subroutine(extractDataContent$1$2, (arg, data, dnl
ifelse(`$1',`Ch', `separator, csv, ')`'dnl
num, iostat))
type(Node), pointer :: arg
TOHWM4_declarationtype(`$1')`'dnl
ifelse(dnl
`$2', `Arr', `, dimension(:)',dnl
`$2', `Mat', `, dimension(:,:)')dnl
, intent(out) :: data
ifelse(`$1', `Ch', `
logical, intent(in), optional :: csv
character, intent(in), optional :: separator')
integer, intent(out), optional :: num, iostat
dnl
if (.not.associated(arg)) then
ifelse(`$1', `Ch',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL, `', `data = ""')',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)')
endif
ifelse(`$1', `Ch', `dnl
if (present(ex)) then
call rts(getTextContent(arg, ex), data, separator, csv, num, iostat)
else
call rts(getTextContent(arg), data, separator, csv, num, iostat)
endif
', `
if (present(ex)) then
call rts(getTextContent(arg, ex), data, num, iostat)
else
call rts(getTextContent(arg), data, num, iostat)
endif
')
end subroutine extractDataContent$1$2
')`'dnl
dnl
define(`TOHW_extractDataAttribute', `dnl
dnl
TOHW_subroutine(extractDataAttribute$1$2, (arg, name, data, dnl
ifelse(`$1',`Ch', `separator, csv, ')`'dnl
num, iostat))
type(Node), pointer :: arg
character(len=*), intent(in) :: name
ifelse(`$1',`Ch', `
logical, intent(in), optional :: csv
character, intent(in), optional :: separator')
TOHWM4_declarationtype(`$1')`'dnl
ifelse(dnl
`$2', `Arr', `, dimension(:)',dnl
`$2', `Mat', `, dimension(:,:)')dnl
, intent(out) :: data
integer, intent(out), optional :: num, iostat
dnl
if (.not.associated(arg)) then
ifelse(`$1', `Ch',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL, `', `data = ""')',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)')
elseif (getNodeType(arg)/=ELEMENT_NODE) then
ifelse(`$1', `Ch',
` TOHW_m_dom_throw_error(FoX_INVALID_NODE, `', `data = ""')',
` TOHW_m_dom_throw_error(FoX_INVALID_NODE)')
endif
ifelse(`$1', `Ch', `dnl
if (present(ex)) then
call rts(getAttribute(arg, name, ex), data, separator, csv, num, iostat)
else
call rts(getAttribute(arg, name), data, separator, csv, num, iostat)
endif
', `
if (present(ex)) then
call rts(getAttribute(arg, name, ex), data, num, iostat)
else
call rts(getAttribute(arg, name), data, num, iostat)
endif
')
end subroutine extractDataAttribute$1$2
')`'dnl
define(`TOHW_extractDataAttributeNS', `dnl
dnl
TOHW_subroutine(extractDataAttNS$1$2, (arg, namespaceURI, localName, data, dnl
ifelse(`$1',`Ch', `separator, csv, ')`'dnl
num, iostat))
type(Node), pointer :: arg
character(len=*), intent(in) :: namespaceURI, localName
TOHWM4_declarationtype(`$1')`'dnl
ifelse(dnl
`$2', `Arr', `, dimension(:)',dnl
`$2', `Mat', `, dimension(:,:)')dnl
, intent(out) :: data
ifelse(`$1',`Ch', `
logical, intent(in), optional :: csv
character, intent(in), optional :: separator')
integer, intent(out), optional :: num, iostat
dnl
if (.not.associated(arg)) then
ifelse(`$1', `Ch',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL, `', `data = ""')',
` TOHW_m_dom_throw_error(FoX_NODE_IS_NULL)')
elseif (getNodeType(arg)/=ELEMENT_NODE) then
ifelse(`$1', `Ch',
` TOHW_m_dom_throw_error(FoX_INVALID_NODE, `', `data = ""')',
` TOHW_m_dom_throw_error(FoX_INVALID_NODE)')
endif
ifelse(`$1', `Ch', `dnl
if (present(ex)) then
call rts(getAttributeNS(arg, namespaceURI, localName, ex), &
data, separator, csv, num, iostat)
else
call rts(getAttributeNS(arg, namespaceURI, localName), &
data, separator, csv, num, iostat)
endif
', `
if (present(ex)) then
call rts(getAttributeNS(arg, namespaceURI, localName, ex), &
data, num, iostat)
else
call rts(getAttributeNS(arg, namespaceURI, localName), &
data, num, iostat)
endif
')
end subroutine extractDataAttNS$1$2
')`'dnl
dnl
module m_dom_extras
use fox_m_fsys_realtypes, only: sp, dp
use fox_m_fsys_parse_input, only: rts
use m_dom_error, only: DOMException, inException, throw_exception, &
FoX_NODE_IS_NULL, FoX_INVALID_NODE
use m_dom_dom, only: Node, ELEMENT_NODE, &
getAttribute, getAttributeNS, getTextContent, getNodeType, getFoX_checks
implicit none
private
public :: extractDataContent
public :: extractDataAttribute
public :: extractDataAttributeNS
interface extractDataContent
m4_foreach(`x', TOHWM4_types, `TOHWM4_interfaceshortlist(`extractDataContent', x)')
end interface extractDataContent
interface extractDataAttribute
m4_foreach(`x', TOHWM4_types, `TOHWM4_interfaceshortlist(`extractDataAttribute', x)')
end interface extractDataAttribute
interface extractDataAttributeNS
m4_foreach(`x', TOHWM4_types, `TOHWM4_interfaceshortlist(`extractDataAttNS', x)')
end interface extractDataAttributeNS
contains
m4_foreach(`x', TOHWM4_types, `TOHW_extractDataContent(x, `Sca')
')
m4_foreach(`x', TOHWM4_types, `TOHW_extractDataContent(x, `Arr')
')
m4_foreach(`x', TOHWM4_types, `TOHW_extractDataContent(x, `Mat')
')
m4_foreach(`x', TOHWM4_types, `TOHW_extractDataAttribute(x, `Sca')
')
m4_foreach(`x', TOHWM4_types, `TOHW_extractDataAttribute(x, `Arr')
')
m4_foreach(`x', TOHWM4_types, `TOHW_extractDataAttribute(x, `Mat')
')
m4_foreach(`x', TOHWM4_types, `TOHW_extractDataAttributeNS(x, `Sca')
')
m4_foreach(`x', TOHWM4_types, `TOHW_extractDataAttributeNS(x, `Arr')
')
m4_foreach(`x', TOHWM4_types, `TOHW_extractDataAttributeNS(x, `Mat')
')
end module m_dom_extras