25#include <fmt/format.h> 
   35        wxXmlAttribute( aName, wxEmptyString ),
 
   38    std::visit( [&]<
typename T0>( T0&& arg )
 
   40                    using T = std::decay_t<T0>;
 
   42                    if constexpr( std::is_same_v<T, int> )
 
   44                        wxXmlAttribute::SetValue( wxString::Format( 
"%d", arg ) );
 
   46                    else if constexpr( std::is_same_v<T, double> )
 
   50                        if( arg != 0.0 && std::fabs( arg ) <= 0.0001 )
 
   52                            buf = fmt::format( 
"{:.16f}", arg );
 
   55                            while( !buf.empty() && buf[buf.size() - 1] == 
'0' )
 
   62                            if( buf[buf.size() - 1] == 
'.' )
 
   69                            buf = fmt::format( 
"{:.10g}", arg );
 
   72                        wxXmlAttribute::SetValue( buf );
 
   74                    else if constexpr( std::is_same_v<T, wxString> )
 
   76                        wxXmlAttribute::SetValue( arg );
 
   80                        static_assert( 
false, 
"Missing type handling in XNODE::FormatContents" );
 
 
   88    AddAttribute( aKey, aValue ? wxT( 
"yes" ) : wxT( 
"no" ) );
 
 
   95    wxXmlNode::AddAttribute( attr );
 
 
  102    wxXmlNode::AddAttribute( attr );
 
 
  109    wxXmlNode::AddAttribute( attr );
 
 
  117    case wxXML_ELEMENT_NODE:
 
  122            out->
Print( 0, 
")\n" );
 
  124            out->
Print( 0, 
")" );
 
 
  137    for( wxXmlAttribute* attr = GetAttributes(); attr; attr = attr->GetNext() )
 
  141        if( 
auto xa = 
dynamic_cast<XATTR*
>( attr ) )
 
  145            std::visit( ["e]<
typename T0>( T0&& )
 
  147                        using T = std::decay_t<T0>;
 
  149                        if constexpr( std::is_same_v<T, int> || std::is_same_v<T, double> )
 
  156        out->
Print( 0, 
" (%s %s)",
 
  158                    quote ? out->
Quotew( attr->GetValue() ).c_str() : 
TO_UTF8( attr->GetValue() ) );
 
  164    case wxXML_ELEMENT_NODE:
 
  167            if( child->GetType() != wxXML_TEXT_NODE )
 
  170                    out->
Print( 0, 
"\n" );
 
  172                child->Format( out );
 
  176                child->Format( out );
 
  182    case wxXML_TEXT_NODE:
 
  183        out->
Print( 0, 
" %s", out->
Quotew( GetContent() ).c_str() );
 
 
An extension of wxXmlAttribute that stores a variant type rather than just a string.
 
std::variant< wxString, int, double > VALUE_TYPE
 
VALUE_TYPE m_originalValue
 
XNODE * GetChildren() const
 
void FormatContents(OUTPUTFORMATTER *out) const
Write the contents of object as UTF8 out to an OUTPUTFORMATTER as an S-expression.
 
void AddAttribute(const wxString &aName, const wxString &aValue) override
 
void AddBool(const wxString &aKey, bool aValue)
 
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.