dnl
include(`foreach.m4')dnl
dnl
include(`datatypes.m4')dnl
dnl
dnl Note that, irritatingly, we have to exclude the possibility of
dnl a scalar character subroutine in order to not overlap with the
dnl basic one to which we are calling through.
dnl
define(`TOHWM4_subroutinename', `dnl
ifelse(`$2$3', `ScalarCh', `', `dnl
module procedure $1$2$3')`'dnl
')`'dnl
dnl
dnl First arg is name of quantity (Character, Attribute, PseudoAttribute)
dnl Second arg is whether this is scalar, array, or matrix.
dnl Third arg is type of property(character/logical etc.)
dnl
define(`TOHWM4_CharacterSub',`dnl
ifelse(`$2$3', `ScalarCh', `', `dnl
  subroutine $1$2$3 &
    (xf, chars`'dnl
ifelse(substr($3,0,4),`Real',`, fmt', substr($3,0,5), `Cmplx', `, fmt', `$2$3', `ScalarCh', `', `$3', `Ch', `, delimiter'))

    type(xmlf_t), intent(inout) :: xf
    TOHWM4_declarationtype(`$3'), intent(in) dnl
ifelse(`$2', `Array', `, dimension(:)', `$2', `Matrix',`, dimension(:,:)') dnl
 :: chars
dnl
ifelse(substr($3,0,4), `Real', `dnl 
    character(len=*), intent(in), optional :: fmt
', substr($3,0,5), `Cmplx', `dnl
    character(len=*), intent(in), optional :: fmt
', `$2$3', `ScalarCh', `', `$3', `Ch', `dnl
    character(len=1), intent(in), optional :: delimiter
')dnl

#ifndef DUMMYLIB
ifelse(substr($3,0,4), `Real', `dnl 
    if (present(fmt)) then
      call xml_Add$1(xf=xf, chars=str(chars, fmt)`'dnl
ifelse(`$2', `Array', `, ws_significant=.false.')`'dnl
ifelse(`$2', `Matrix', `, ws_significant=.false.'))
    else
  ', substr($3,0,5), `Cmplx', `dnl
    if (present(fmt)) then
      call xml_Add$1(xf=xf, chars=str(chars, fmt)`'dnl
ifelse(`$2', `Array', `, ws_significant=.false.')`'dnl
ifelse(`$2', `Matrix', `, ws_significant=.false.'))
    else
  ')dnl
    call xml_Add$1(xf=xf, chars=str(chars`'dnl
ifelse(`$2$3', `ScalarCh', `', `$3', `Ch', `, delimiter'))`'dnl
ifelse(`$2', `Array', `, ws_significant=.false.')`'dnl
ifelse(`$2', `Matrix', `, ws_significant=.false.')`'dnl
)
dnl
ifelse(substr($3,0,4), `Real', `dnl
    endif
', substr($3,0,5), `Cmplx', `dnl
    endif
')`'dnl
#endif
  end subroutine $1$2$3
')
')dnl
dnl
dnl
define(`TOHWM4_AttributeSub',`dnl
ifelse(`$2$3', `ScalarCh', `', `dnl
  subroutine $1$2$3 &
    (xf, name, value`'dnl
ifelse(substr($3,0,4),`Real',`, fmt', substr($3,0,5), `Cmplx', `, fmt', `$2$3', `ScalarCh', `', `$3', `Ch', `, delimiter')) 

    type(xmlf_t), intent(inout) :: xf
    character(len=*), intent(in) :: name
    TOHWM4_declarationtype(`$3'), intent(in) dnl
ifelse(`$2', `Array', `, dimension(:)', `$2', `Matrix',`, dimension(:,:)') dnl
 :: value
dnl
ifelse(substr($3,0,4), `Real', `dnl 
    character(len=*), intent(in), optional :: fmt
', substr($3,0,5), `Cmplx',`dnl
    character(len=*), intent(in), optional :: fmt
', `$2$3', `ScalarCh', `', `$3', `Ch', `dnl
    character(len=1), intent(in), optional :: delimiter
')
dnl
#ifndef DUMMYLIB
ifelse(substr($3,0,4),`Real',`dnl 
    if (present(fmt)) then
      call xml_Add$1(xf=xf, name=name, value=str(value, fmt)`'dnl
ifelse(`$2', `Array', `, ws_significant=.false.')`'dnl
ifelse(`$2', `Matrix', `, ws_significant=.false.'))
    else
  ', substr($3,0,5), `Cmplx', `dnl
    if (present(fmt)) then
      call xml_Add$1(xf=xf, name=name, value=str(value, fmt)`'dnl
ifelse(`$2', `Array', `, ws_significant=.false.')`'dnl
ifelse(`$2', `Matrix', `, ws_significant=.false.'))
    else
  ')dnl
    call xml_Add$1(xf=xf, name=name, value=str(value`'dnl
ifelse(`$2$3', `ScalarCh', `', `$3', `Ch', `, delimiter'))`'dnl
ifelse(`$2', `Array', `, ws_significant=.false.')`'dnl
ifelse(`$2', `Matrix', `, ws_significant=.false.'))
dnl
ifelse(substr($3,0,4), `Real', `dnl
    endif
', substr($3,0,5), `Cmplx', `dnl
    endif
')`'dnl
dnl
#endif
  end subroutine $1$2$3
')dnl
')dnl
dnl
dnl
dnl
! This file is AUTOGENERATED!!!!
! Do not edit this file; edit m_wxml_overloads.m4 and regenerate.
!
!
module m_wxml_overloads

#ifndef DUMMYLIB
  use m_common_format, only: str
#endif
  use m_common_realtypes, only: sp, dp
  use m_wxml_core, only: xmlf_t
  use m_wxml_core, only: xml_AddCharacters
  use m_wxml_core, only: xml_AddAttribute
  use m_wxml_core, only: xml_AddPseudoAttribute

  implicit none
  private

  interface xml_AddCharacters
m4_foreach(`type', `(Scalar, Array, Matrix)', `dnl
m4_foreach(`x', TOHWM4_types, `dnl
    TOHWM4_subroutinename(`Characters', type, x)
')dnl
')dnl
 end interface

  interface xml_AddAttribute
m4_foreach(`type', `(Scalar, Array, Matrix)', `dnl
m4_foreach(`x', TOHWM4_types, `dnl
    TOHWM4_subroutinename(`Attribute', type, x)
')dnl
')dnl
 end interface

  interface xml_AddPseudoAttribute
m4_foreach(`type', `(Scalar, Array, Matrix)', `dnl
m4_foreach(`x', TOHWM4_types, `dnl
    TOHWM4_subroutinename(`PseudoAttribute', type, x)
')dnl
')dnl
 end interface

  public :: xml_AddCharacters
  public :: xml_AddAttribute
  public :: xml_AddPseudoAttribute

contains

m4_foreach(`ArrayType', `(Scalar, Array, Matrix)', `dnl
m4_foreach(`x', TOHWM4_types, `dnl
TOHWM4_CharacterSub(`Characters', ArrayType, x)
')dnl
')dnl

m4_foreach(`ArrayType', `(Scalar, Array, Matrix)', `dnl
m4_foreach(`x', TOHWM4_types, `dnl
TOHWM4_AttributeSub(`Attribute', ArrayType, x)
')dnl
')dnl

m4_foreach(`ArrayType', `(Scalar, Array, Matrix)', `dnl
m4_foreach(`x', TOHWM4_types, `dnl
TOHWM4_AttributeSub(`PseudoAttribute', ArrayType, x)
')dnl
')dnl

end module m_wxml_overloads
