Commit 1ae44d09 authored by Dick Hollenbeck's avatar Dick Hollenbeck

work around 8 bit wxString B.S.

parent 6a26a7f9
......@@ -280,7 +280,7 @@ int OUTPUTFORMATTER::Print( int nestLevel, const char* fmt, ... ) throw( IO_ERRO
}
std::string OUTPUTFORMATTER::Quoted( const std::string& aWrapee ) throw( IO_ERROR )
std::string OUTPUTFORMATTER::Quotes( const std::string& aWrapee ) throw( IO_ERROR )
{
static const char quoteThese[] = "\t ()\n\r";
......@@ -329,6 +329,17 @@ std::string OUTPUTFORMATTER::Quoted( const std::string& aWrapee ) throw( IO_ERRO
}
std::string OUTPUTFORMATTER::Quotew( const wxString& aWrapee ) throw( IO_ERROR )
{
// s-expressions atoms are always encoded as UTF-8.
// The non-virutal function calls the virtual workhorse function, and if
// a different quoting or escaping strategy is desired from the standard,
// a derived class can overload Quotes() above, but
// should never be a reason to overload this Quotew() here.
return Quotes( (const char*) aWrapee.utf8_str() );
}
//-----<STRING_FORMATTER>----------------------------------------------------
void STRING_FORMATTER::write( const char* aOutBuf, int aCount ) throw( IO_ERROR )
......
......@@ -34,7 +34,7 @@ void XNODE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR )
switch( GetType() )
{
case wxXML_ELEMENT_NODE:
out->Print( nestLevel, "(%s", out->Quoted( GetName() ).c_str() );
out->Print( nestLevel, "(%s", out->Quotew( GetName() ).c_str() );
FormatContents( out, nestLevel );
if( GetNext() )
out->Print( 0, ")\n" );
......@@ -55,8 +55,8 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERRO
{
out->Print( 0, " (%s %s)",
// attr names should never need quoting, no spaces, we designed the file.
out->Quoted( attr->GetName() ).c_str(),
out->Quoted( attr->GetValue() ).c_str()
out->Quotew( attr->GetName() ).c_str(),
out->Quotew( attr->GetValue() ).c_str()
);
}
......@@ -82,7 +82,7 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERRO
break;
case wxXML_TEXT_NODE:
out->Print( 0, " %s", out->Quoted( GetContent() ).c_str() );
out->Print( 0, " %s", out->Quotew( GetContent() ).c_str() );
break;
default:
......
......@@ -32,10 +32,10 @@ wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx )
void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR )
{
out->Print( nestLevel, "(field (name %s)", out->Quoted( m_Name ).c_str() );
out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() );
if( !m_Value.IsEmpty() )
out->Print( 0, "(value %s)", out->Quoted( m_Value ).c_str() );
out->Print( 0, "(value %s)", out->Quotew( m_Value ).c_str() );
if( m_Visible )
out->Print( 0, " visible" );
......
......@@ -486,7 +486,7 @@ public:
}
/**
* Function Quoted
* Function Quotes
* checks \a aWrapee input string for a need to be quoted
* (e.g. contains a ')' character or a space), and for \" double quotes
* within the string that need to be escaped such that the DSNLEXER
......@@ -500,13 +500,9 @@ public:
*
* @throw IO_ERROR, if there is any kind of problem with the input string.
*/
virtual std::string Quoted( const std::string& aWrapee ) throw( IO_ERROR );
virtual std::string Quotes( const std::string& aWrapee ) throw( IO_ERROR );
std::string Quoted( const wxString& aWrapee ) throw( IO_ERROR )
{
// s-expressions atoms are always encoded as UTF-8
return Quoted( (const char*) aWrapee.utf8_str() );
}
std::string Quotew( const wxString& aWrapee ) throw( IO_ERROR );
//-----</interface functions>-----------------------------------------
};
......
......@@ -157,10 +157,10 @@ void LIB_TABLE::ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
throw( IO_ERROR )
{
out->Print( nestLevel, "(lib (logical %s)(type %s)(full_uri %s)(options %s))\n",
out->Quoted( logicalName ).c_str(),
out->Quoted( libType ).c_str(),
out->Quoted( fullURI ).c_str(),
out->Quoted( options ).c_str()
out->Quotes( logicalName ).c_str(),
out->Quotes( libType ).c_str(),
out->Quotes( fullURI ).c_str(),
out->Quotes( options ).c_str()
);
}
......
......@@ -134,7 +134,7 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
aFormatter->Print( aNestLevel+1, "(%s %d)\n", GetTokenName( T_scaleselection ),
scaleSelection );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", GetTokenName( T_outputdirectory ),
aFormatter->Quoted( CONV_TO_UTF8( outputDirectory ) ).c_str() );
aFormatter->Quotew( outputDirectory ).c_str() );
aFormatter->Print( 0, ")\n" );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment