From c264823731f064aa43cfb37ab749d93ac84a9f2f Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Wed, 1 Jan 2014 20:17:07 -0600 Subject: [PATCH] 8 bit string relief via class UTF8 --- common/footprint_info.cpp | 4 +-- common/fp_lib_table.cpp | 36 +++++++++---------- common/fpid.cpp | 12 +++---- common/gal/stroke_font.cpp | 33 ++++++++--------- common/utf8.cpp | 4 +-- include/fp_lib_table.h | 2 +- include/fpid.h | 26 +++++++------- include/gal/stroke_font.h | 19 +++++----- include/richio.h | 2 +- include/utf8.h | 17 +++++++++ pcbnew/class_board.cpp | 14 ++++---- .../dialog_edit_module_for_Modedit.cpp | 2 +- pcbnew/dialogs/dialog_fp_plugin_options.cpp | 12 +++---- pcbnew/eagle_plugin.cpp | 8 ++--- pcbnew/gen_modules_placefile.cpp | 4 ++- pcbnew/github/github_plugin.cpp | 16 ++++----- pcbnew/io_mgr.cpp | 2 +- pcbnew/io_mgr.h | 4 +-- pcbnew/kicad_plugin.cpp | 3 +- pcbnew/legacy_plugin.cpp | 9 ++--- pcbnew/librairi.cpp | 6 ++-- pcbnew/loadcmp.cpp | 4 +-- pcbnew/plugin.cpp | 24 ++++++------- pcbnew/xchgmod.cpp | 4 +-- 24 files changed, 142 insertions(+), 125 deletions(-) diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index 4fe00f4108..4396ec66c1 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -273,8 +273,8 @@ FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName ) wxString::Format( wxT( "'%s' is not a valid FPID." ), GetChars( aFootprintName ) ) ); - wxString libNickname = FROM_UTF8( fpid.GetLibNickname().c_str() ); - wxString footprintName = FROM_UTF8( fpid.GetFootprintName().c_str() ); + wxString libNickname = fpid.GetLibNickname(); + wxString footprintName = fpid.GetFootprintName(); if( libNickname == fp.GetNickname() && footprintName == fp.GetFootprintName() ) return &fp; diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index 5ee2c3a2bf..fe8aeb92cc 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -173,7 +173,7 @@ MODULE* FP_LIB_TABLE::FootprintLoad( const wxString& aNickname, const wxString& FPID& fpid = (FPID&) ret->GetFPID(); // Catch any misbehaving plugin, which should be setting internal footprint name properly: - wxASSERT( aFootprintName == FROM_UTF8( fpid.GetFootprintName().c_str() ) ); + wxASSERT( aFootprintName == (wxString) fpid.GetFootprintName() ); // and clearing nickname wxASSERT( !fpid.GetLibNickname().size() ); @@ -195,7 +195,7 @@ FP_LIB_TABLE::SAVE_T FP_LIB_TABLE::FootprintSave( const wxString& aNickname, con // Try loading the footprint to see if it already exists, caller wants overwrite // protection, which is atypical, not the default. - wxString fpname = FROM_UTF8( aFootprint->GetFPID().GetFootprintName().c_str() ); + wxString fpname = aFootprint->GetFPID().GetFootprintName(); std::auto_ptr m( row->plugin->FootprintLoad( row->GetFullURI( true ), fpname, row->GetProperties() ) ); @@ -480,16 +480,17 @@ PROPERTIES* FP_LIB_TABLE::ParseOptions( const std::string& aOptionsList ) } -std::string FP_LIB_TABLE::FormatOptions( const PROPERTIES* aProperties ) +UTF8 FP_LIB_TABLE::FormatOptions( const PROPERTIES* aProperties ) { - std::string ret; + UTF8 ret; if( aProperties ) { for( PROPERTIES::const_iterator it = aProperties->begin(); it != aProperties->end(); ++it ) { const std::string& name = it->first; - const std::string& value = it->second; + + const UTF8& value = it->second; if( ret.size() ) ret += OPT_SEP; @@ -741,7 +742,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL { if( aReporter ) { - msg.Printf( _( "Cannot find footprint library file \"%s\" in any of the " + msg.Printf( _( "Cannot find footprint library file '%s' in any of the " "KiCad legacy library search paths.\n" ), GetChars( fn.GetFullPath() ) ); aReporter->Report( msg ); @@ -751,8 +752,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL continue; } - module = pi->FootprintLoad( libPath, - FROM_UTF8( component->GetFPID().GetFootprintName().c_str() ) ); + module = pi->FootprintLoad( libPath, component->GetFPID().GetFootprintName() ); if( module ) { @@ -766,10 +766,10 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL { if( aReporter ) { - msg.Printf( _( "Component `%s` footprint <%s> was not found in any legacy " + msg.Printf( _( "Component `%s` footprint '%s' was not found in any legacy " "library.\n" ), GetChars( component->GetReference() ), - GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ); + GetChars( component->GetFPID().Format() ) ); aReporter->Report( msg ); } @@ -811,10 +811,10 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL { if( aReporter ) { - msg.Printf( _( "Component `%s` footprint <%s> legacy library path <%s > " + msg.Printf( _( "Component `%s` footprint '%s' legacy library path <%s > " "was not found in the footprint library table.\n" ), GetChars( component->GetReference() ), - GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ); + GetChars( component->GetFPID().Format() ) ); aReporter->Report( msg ); } @@ -830,9 +830,9 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL { if( aReporter ) { - msg.Printf( _( "Component `%s` FPID <%s> is not valid.\n" ), + msg.Printf( _( "Component `%s` FPID '%s' is not valid.\n" ), GetChars( component->GetReference() ), - GetChars( FROM_UTF8( newFPID.Format().c_str() ) ) ); + GetChars( newFPID.Format() ) ); aReporter->Report( msg ); } @@ -860,7 +860,7 @@ void FP_LIB_TABLE::SetProjectPathEnvVariable( const wxFileName& aPath ) else path = aPath.GetPath(); - wxLogTrace( traceFpLibTable, wxT( "Setting env %s to <%s>." ), + wxLogTrace( traceFpLibTable, wxT( "Setting env %s to '%s'." ), GetChars( ProjectPathEnvVariableName() ), GetChars( path ) ); wxSetEnv( ProjectPathEnvVariableName(), path ); } @@ -899,7 +899,7 @@ wxString FP_LIB_TABLE::GetProjectFileName( const wxFileName& aPath ) fn.SetName( defaultFileName ); } - wxLogTrace( traceFpLibTable, wxT( "Project specific footprint library table file <%s>." ), + wxLogTrace( traceFpLibTable, wxT( "Project specific footprint library table file '%s'." ), GetChars( fn.GetFullPath() ) ); return fn.GetFullPath(); @@ -917,7 +917,7 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARS if( !fn.DirExists() && !fn.Mkdir( 0x777, wxPATH_MKDIR_FULL ) ) { - THROW_IO_ERROR( wxString::Format( _( "Cannot create global library table path <%s>." ), + THROW_IO_ERROR( wxString::Format( _( "Cannot create global library table path '%s'." ), GetChars( fn.GetPath() ) ) ); } @@ -954,7 +954,7 @@ wxString FP_LIB_TABLE::GetGlobalTableFileName() fn.SetName( GetFileName() ); - wxLogTrace( traceFpLibTable, wxT( "Global footprint library table file <%s>." ), + wxLogTrace( traceFpLibTable, wxT( "Global footprint library table file '%s'." ), GetChars( fn.GetFullPath() ) ); return fn.GetFullPath(); diff --git a/common/fpid.cpp b/common/fpid.cpp index 92e1ee2786..ef9f35b89f 100644 --- a/common/fpid.cpp +++ b/common/fpid.cpp @@ -265,9 +265,9 @@ int FPID::SetRevision( const std::string& aRevision ) } -std::string FPID::Format() const +UTF8 FPID::Format() const { - std::string ret; + UTF8 ret; if( nickname.size() ) { @@ -287,9 +287,9 @@ std::string FPID::Format() const } -std::string FPID::GetFootprintNameAndRev() const +UTF8 FPID::GetFootprintNameAndRev() const { - std::string ret; + UTF8 ret; if( revision.size() ) { @@ -301,11 +301,11 @@ std::string FPID::GetFootprintNameAndRev() const } -std::string FPID::Format( const std::string& aLogicalLib, const std::string& aFootprintName, +UTF8 FPID::Format( const std::string& aLogicalLib, const std::string& aFootprintName, const std::string& aRevision ) throw( PARSE_ERROR ) { - std::string ret; + UTF8 ret; int offset; if( aLogicalLib.size() ) diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp index bd536dca7e..2020954d61 100644 --- a/common/gal/stroke_font.cpp +++ b/common/gal/stroke_font.cpp @@ -147,7 +147,7 @@ BOX2D STROKE_FONT::computeBoundingBox( const GLYPH& aGLYPH, const VECTOR2D& aGLY } -void STROKE_FONT::Draw( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle ) +void STROKE_FONT::Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRotationAngle ) { // Context needs to be saved before any transformations m_gal->Save(); @@ -192,7 +192,7 @@ void STROKE_FONT::Draw( const wxString& aText, const VECTOR2D& aPosition, double { size_t length = newlinePos - begin; - drawSingleLineText( aText.Mid( begin, length ) ); + drawSingleLineText( aText.substr( begin, length ) ); m_gal->Translate( VECTOR2D( 0.0, lineHeight ) ); begin = newlinePos + 1; @@ -200,20 +200,20 @@ void STROKE_FONT::Draw( const wxString& aText, const VECTOR2D& aPosition, double } // Draw the last (or the only one) line - if( !aText.IsEmpty() ) - drawSingleLineText( aText.Mid( begin ) ); + if( !aText.empty() ) + drawSingleLineText( aText.substr( begin ) ); m_gal->Restore(); } -void STROKE_FONT::drawSingleLineText( const wxString& aText ) +void STROKE_FONT::drawSingleLineText( const UTF8& aText ) { // By default the overbar is turned off m_overbar = false; - double xOffset; - VECTOR2D glyphSize( m_glyphSize ); + double xOffset; + VECTOR2D glyphSize( m_glyphSize ); // Compute the text size VECTOR2D textSize = computeTextSize( aText ); @@ -254,12 +254,12 @@ void STROKE_FONT::drawSingleLineText( const wxString& aText ) xOffset = 0.0; } - for( wxString::const_iterator chIt = aText.begin(); chIt != aText.end(); ++chIt ) + for( UTF8::uni_iter chIt = aText.ubegin(), end = aText.uend(); chIt < end; ++chIt ) { // Toggle overbar if( *chIt == '~' ) { - if( ++chIt == aText.end() ) + if( ++chIt >= end ) break; if( *chIt != '~' ) // It was a single tilda, it toggles overbar @@ -274,13 +274,14 @@ void STROKE_FONT::drawSingleLineText( const wxString& aText ) dd = '?' - ' '; GLYPH& glyph = m_glyphs[dd]; - BOX2D& bbox = m_glyphBoundingBoxes[dd]; + BOX2D& bbox = m_glyphBoundingBoxes[dd]; if( m_overbar ) { VECTOR2D startOverbar( xOffset, -getInterline() * OVERBAR_HEIGHT ); VECTOR2D endOverbar( xOffset + glyphSize.x * bbox.GetEnd().x, -getInterline() * OVERBAR_HEIGHT ); + m_gal->DrawLine( startOverbar, endOverbar ); } @@ -317,25 +318,25 @@ void STROKE_FONT::drawSingleLineText( const wxString& aText ) } -VECTOR2D STROKE_FONT::computeTextSize( const wxString& aText ) const +VECTOR2D STROKE_FONT::computeTextSize( const UTF8& aText ) const { VECTOR2D result = VECTOR2D( 0.0, m_glyphSize.y ); - for( wxString::const_iterator chIt = aText.begin(); chIt != aText.end(); ++chIt ) + for( UTF8::uni_iter it = aText.ubegin(), end = aText.uend(); it < end; ++it ) { - wxASSERT_MSG( *chIt != '\n', + wxASSERT_MSG( *it != '\n', wxT( "This function is intended to work with single line strings" ) ); // If it is double tilda, then it is displayed as a single tilda // If it is single tilda, then it is toggling overbar, so we need to skip it - if( *chIt == '~' ) + if( *it == '~' ) { - if( ++chIt == aText.end() ) + if( ++it >= end ) break; } // Index in the bounding boxes table - unsigned dd = *chIt - ' '; + unsigned dd = *it - ' '; if( dd >= m_glyphBoundingBoxes.size() || dd < 0 ) dd = '?' - ' '; diff --git a/common/utf8.cpp b/common/utf8.cpp index 48478bb15b..637d9fc8e1 100644 --- a/common/utf8.cpp +++ b/common/utf8.cpp @@ -24,7 +24,7 @@ #include -/* THROW_IO_ERROR needs this, but it will soon be including this file, so until some +/* THROW_IO_ERROR needs this, but it includes this file, so until some factoring of THROW_IO_ERROR into a separate header, defer and use the asserts. #include */ @@ -33,7 +33,7 @@ /* These are not inlined so that code space is saved by encapsulating the - creation of intermediate objects and referencing wxConvUTF8. + creation of intermediate objects and the referencing of wxConvUTF8. */ diff --git a/include/fp_lib_table.h b/include/fp_lib_table.h index 43dcf7e62a..5ce7d5236f 100644 --- a/include/fp_lib_table.h +++ b/include/fp_lib_table.h @@ -339,7 +339,7 @@ public: * @param aProperties is the PROPERTIES to format or NULL. If NULL the returned * string will be empty. */ - static std::string FormatOptions( const PROPERTIES* aProperties ); + static UTF8 FormatOptions( const PROPERTIES* aProperties ); /** * Function Format diff --git a/include/fpid.h b/include/fpid.h index 6417cfbc6f..17155858b8 100644 --- a/include/fpid.h +++ b/include/fpid.h @@ -27,7 +27,7 @@ #define _FPID_H_ #include - +#include /** * Class FPID @@ -53,7 +53,7 @@ * * @author Dick Hollenbeck */ -class FPID // aka GUID +class FPID { public: @@ -88,7 +88,7 @@ public: * Function GetLibNickname * returns the logical library name portion of a FPID. */ - const std::string& GetLibNickname() const + const UTF8& GetLibNickname() const { return nickname; } @@ -108,7 +108,7 @@ public: * Function GetFootprintName * returns the footprint name, i.e. footprintName. */ - const std::string& GetFootprintName() const { return footprint; } + const UTF8& GetFootprintName() const { return footprint; } /** * Function SetFootprintName @@ -120,15 +120,15 @@ public: int SetRevision( const std::string& aRevision ); - const std::string& GetRevision() const { return revision; } + const UTF8& GetRevision() const { return revision; } - std::string GetFootprintNameAndRev() const; + UTF8 GetFootprintNameAndRev() const; /** * Function Format * returns the fully formatted text of the FPID. */ - std::string Format() const; + UTF8 Format() const; /** * Function Format @@ -137,7 +137,7 @@ public: * * @throw PARSE_ERROR if any of the pieces are illegal. */ - static std::string Format( const std::string& aLibNickname, const std::string& aFootprintName, + static UTF8 Format( const std::string& aLibNickname, const std::string& aFootprintName, const std::string& aRevision ) throw( PARSE_ERROR ); @@ -182,8 +182,8 @@ public: */ int compare( const FPID& aFPID ) const; - bool operator <( const FPID& aFPID ) const { return this->compare( aFPID ) < 0; } - bool operator >( const FPID& aFPID ) const { return this->compare( aFPID ) > 0; } + bool operator < ( const FPID& aFPID ) const { return this->compare( aFPID ) < 0; } + bool operator > ( const FPID& aFPID ) const { return this->compare( aFPID ) > 0; } bool operator ==( const FPID& aFPID ) const { return this->compare( aFPID ) == 0; } bool operator !=( const FPID& aFPID ) const { return !(*this == aFPID); } @@ -192,9 +192,9 @@ public: #endif protected: - std::string nickname; ///< The nickname of the footprint library or empty. - std::string footprint; ///< The name of the footprint in the logical library. - std::string revision; ///< The footprint revision. + UTF8 nickname; ///< The nickname of the footprint library or empty. + UTF8 footprint; ///< The name of the footprint in the logical library. + UTF8 revision; ///< The footprint revision. }; diff --git a/include/gal/stroke_font.h b/include/gal/stroke_font.h index afa8d7f61c..71b2d421ed 100644 --- a/include/gal/stroke_font.h +++ b/include/gal/stroke_font.h @@ -29,8 +29,8 @@ #ifndef STROKE_FONT_H_ #define STROKE_FONT_H_ -#include #include +#include #include @@ -70,7 +70,7 @@ public: * @param aPosition is the text position in world coordinates. * @param aRotationAngle is the text rotation angle. */ - void Draw( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle ); + void Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRotationAngle ); /** * @brief Set the glyph size. @@ -173,7 +173,7 @@ private: * * @param aText is the text to be drawn. */ - void drawSingleLineText( const wxString& aText ); + void drawSingleLineText( const UTF8& aText ); /** * @brief Compute the size of a given text. @@ -181,20 +181,19 @@ private: * @param aText is the text string. * @return is the text size. */ - VECTOR2D computeTextSize( const wxString& aText ) const; + VECTOR2D computeTextSize( const UTF8& aText ) const; /** * @brief Returns number of lines for a given text. * * @param aText is the text to be checked. - * @return Number of lines of aText. + * @return unsigned - The number of lines in aText. */ - unsigned int linesCount( const wxString& aText ) const + unsigned linesCount( const UTF8& aText ) const { - wxString::const_iterator it, itEnd; - unsigned int lines = 1; + unsigned lines = 1; - for( it = aText.begin(), itEnd = aText.end(); it != itEnd; ++it ) + for( UTF8::const_iterator it = aText.begin(), itEnd = aText.end(); it != itEnd; ++it ) { if( *it == '\n' ) ++lines; @@ -214,4 +213,4 @@ private: }; } // namespace KIGFX -#endif /* STROKE_FONT_H_ */ +#endif // STROKE_FONT_H_ diff --git a/include/richio.h b/include/richio.h index dc66d6c82b..6440fda7b0 100644 --- a/include/richio.h +++ b/include/richio.h @@ -29,8 +29,8 @@ // "richio" after its author, Richard Hollenbeck, aka Dick Hollenbeck. -#include #include +#include // I really did not want to be dependent on wxWidgets in richio // but the errorText needs to be wide char so wxString rules. diff --git a/include/utf8.h b/include/utf8.h index 7f60173083..c1bf94a971 100644 --- a/include/utf8.h +++ b/include/utf8.h @@ -83,6 +83,23 @@ public: return *this; } + UTF8& operator=( const char* s ) + { + std::string::operator=( s ); + return *this; + } + + UTF8& operator=( char c ) + { + std::string::operator=( c ); + return *this; + } + + UTF8 substr( size_t pos = 0, size_t len = npos ) const + { + return std::string::substr( pos, len ); + } + operator wxString () const; /// This one is not in std::string, and one wonders why... might be a solid diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 22b082fc9d..a56c226d63 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -2447,7 +2447,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, msg.Printf( _( "Checking netlist component footprint \"%s:%s:%s\".\n" ), GetChars( component->GetReference() ), GetChars( component->GetTimeStamp() ), - GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ); + GetChars( component->GetFPID().Format() ) ); aReporter->Report( msg ); } @@ -2465,7 +2465,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, msg.Printf( _( "Adding new component \"%s:%s\" footprint \"%s\".\n" ), GetChars( component->GetReference() ), GetChars( component->GetTimeStamp() ), - GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ); + GetChars( component->GetFPID().Format() ) ); if( aReporter->ReportWarnings() ) aReporter->Report( msg ); @@ -2476,7 +2476,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, "footprint \"%s\".\n" ), GetChars( component->GetReference() ), GetChars( component->GetTimeStamp() ), - GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ); + GetChars( component->GetFPID().Format() ) ); if( aReporter->ReportErrors() ) aReporter->Report( msg ); @@ -2509,8 +2509,8 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, "\"%s\".\n" ), GetChars( footprint->GetReference() ), GetChars( footprint->GetPath() ), - GetChars( FROM_UTF8( footprint->GetFPID().Format().c_str() ) ), - GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ); + GetChars( footprint->GetFPID().Format() ), + GetChars( component->GetFPID().Format() ) ); if( aReporter->ReportWarnings() ) aReporter->Report( msg ); @@ -2521,7 +2521,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, "footprint \"%s\".\n" ), GetChars( footprint->GetReference() ), GetChars( footprint->GetPath() ), - GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ); + GetChars( component->GetFPID().Format() ) ); if( aReporter->ReportErrors() ) aReporter->Report( msg ); @@ -2755,7 +2755,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets, msg.Printf( _( "** Error: Component \"%s\" pad '%s' not found in footprint \"%s\" **\n" ), GetChars( component->GetReference() ), GetChars( padname ), - footprint->GetFPID().Format().c_str() ); + GetChars( footprint->GetFPID().Format() ) ); aReporter->Report( msg ); } } diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index d2c81102fe..cb1aeb12dc 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -117,7 +117,7 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties() m_ReferenceCtrl->SetValue( m_referenceCopy->GetText() ); m_ValueCtrl->SetValue( m_valueCopy->GetText() ); m_ValueCtrl->SetValue( m_valueCopy->GetText() ); - m_FootprintNameCtrl->SetValue( FROM_UTF8( m_currentModule->GetFPID().Format().c_str() ) ); + m_FootprintNameCtrl->SetValue( m_currentModule->GetFPID().Format() ); m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non SMD components" ) ); m_AttributsCtrl->SetItemToolTip( 1, diff --git a/pcbnew/dialogs/dialog_fp_plugin_options.cpp b/pcbnew/dialogs/dialog_fp_plugin_options.cpp index dc3a0b5127..316ce5afa1 100644 --- a/pcbnew/dialogs/dialog_fp_plugin_options.cpp +++ b/pcbnew/dialogs/dialog_fp_plugin_options.cpp @@ -84,7 +84,7 @@ public: for( PROPERTIES::const_iterator it = props->begin(); it != props->end(); ++it, ++row ) { m_grid->SetCellValue( row, 0, FROM_UTF8( it->first.c_str() ) ); - m_grid->SetCellValue( row, 1, FROM_UTF8( it->second.c_str() ) ); + m_grid->SetCellValue( row, 1, it->second ); } delete props; @@ -184,7 +184,7 @@ private: for( int row = 0; rowGetCellValue( row, 0 ).Trim( false ).Trim() ); - string value = TO_UTF8( m_grid->GetCellValue( row, 1 ).Trim( false ).Trim() ); + UTF8 value = m_grid->GetCellValue( row, 1 ).Trim( false ).Trim(); if( name.size() ) { @@ -192,9 +192,7 @@ private: } } - string options = FP_LIB_TABLE::FormatOptions( &props ); - - return FROM_UTF8( options.c_str() ); + return FP_LIB_TABLE::FormatOptions( &props ); } void saveColSizes() @@ -261,11 +259,11 @@ private: if( event.IsSelection() ) { string option = TO_UTF8( event.GetString() ); - string help_text; + UTF8 help_text; if( m_choices.Value( option.c_str(), &help_text ) ) { - wxString page = FROM_UTF8( help_text.c_str() ); + wxString page = help_text; m_html->SetPage( page ); } diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index ef4f1e42a9..80b2fe78c5 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -2711,8 +2711,8 @@ void EAGLE_PLUGIN::centerBoard() { if( m_props ) { - string page_width; - string page_height; + UTF8 page_width; + UTF8 page_height; if( m_props->Value( "page_width", &page_width ) && m_props->Value( "page_height", &page_height ) ) @@ -2873,10 +2873,10 @@ void EAGLE_PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const PLUGIN::FootprintLibOptions( aListToAppendTo ); /* - (*aListToAppendTo)["ignore_duplicates"] = wxString( _( + (*aListToAppendTo)["ignore_duplicates"] = UTF8( _( "Ignore duplicately named footprints within the same Eagle library. " "Only the first similarly named footprint will be loaded." - )).utf8_str(); + )); */ } diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index 6d4301df6b..c5d1fc7073 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -479,9 +479,11 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName, for( int ii = 0; ii < moduleCount; ii++ ) { wxPoint module_pos; + const wxString& ref = list[ii].m_Reference; const wxString& val = list[ii].m_Value; - const wxString& pkg = FROM_UTF8( list[ii].m_Module->GetFPID().Format().c_str() ); + const wxString& pkg = list[ii].m_Module->GetFPID().Format(); + sprintf( line, "%-8.8s %-16.16s %-16.16s", TO_UTF8( ref ), TO_UTF8( val ), TO_UTF8( pkg ) ); diff --git a/pcbnew/github/github_plugin.cpp b/pcbnew/github/github_plugin.cpp index b552669381..7099a83a88 100644 --- a/pcbnew/github/github_plugin.cpp +++ b/pcbnew/github/github_plugin.cpp @@ -166,7 +166,7 @@ MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath, } } - string fp_name = TO_UTF8( aFootprintName ); + UTF8 fp_name = aFootprintName; MODULE_CITER it = m_gh_cache->find( fp_name ); @@ -321,20 +321,20 @@ void GITHUB_PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const // inherit options supported by all PLUGINs. PLUGIN::FootprintLibOptions( aListToAppendTo ); - (*aListToAppendTo)[ PRETTY_DIR ] = wxString( _( + (*aListToAppendTo)[ PRETTY_DIR ] = UTF8( _( "Set this property to a directory where footprints are to be written as pretty " "footprints when saving to this library. Anything saved will take precedence over " "footprints by the same name in the github repo. These saved footprints can then " "be sent to the library maintainer as updates. " "

The directory must have a .pretty file extension because the " "format of the save is pretty.

" - )).utf8_str(); + )); /* - (*aListToAppendTo)["cache_github_zip_in_this_dir"] = wxString( _( + (*aListToAppendTo)["cache_github_zip_in_this_dir"] = UTF8( _( "Set this property to a directory where the github *.zip file will be cached. " "This should speed up subsequent visits to this library." - )).utf8_str(); + )); */ } @@ -356,11 +356,11 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP if( aProperties ) { - string pretty_dir; + UTF8 pretty_dir; if( aProperties->Value( PRETTY_DIR, &pretty_dir ) ) { - wxString wx_pretty_dir = FROM_UTF8( pretty_dir.c_str() ); + wxString wx_pretty_dir = pretty_dir; wx_pretty_dir = FP_LIB_TABLE::ExpandSubstitutions( wx_pretty_dir ); @@ -409,7 +409,7 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP if( fn.GetExt() == kicad_mod ) { - string fp_name = TO_UTF8( fn.GetName() ); // omit extension & path + UTF8 fp_name = fn.GetName(); // omit extension & path m_gh_cache->insert( fp_name, entry ); } diff --git a/pcbnew/io_mgr.cpp b/pcbnew/io_mgr.cpp index 6baa48513a..f29fe6fe23 100644 --- a/pcbnew/io_mgr.cpp +++ b/pcbnew/io_mgr.cpp @@ -44,7 +44,7 @@ // is there a better place for this function? -bool PROPERTIES::Value( const char* aName, std::string* aFetchedValue ) const +bool PROPERTIES::Value( const char* aName, UTF8* aFetchedValue ) const { PROPERTIES::const_iterator it = find( aName ); diff --git a/pcbnew/io_mgr.h b/pcbnew/io_mgr.h index 58f6459d17..6ac100ff7f 100644 --- a/pcbnew/io_mgr.h +++ b/pcbnew/io_mgr.h @@ -38,7 +38,7 @@ class MODULE; * is a name/value tuple with unique names and optional values. The names * may be iterated alphabetically. */ -class PROPERTIES : public std::map< std::string, std::string > +class PROPERTIES : public std::map< std::string, UTF8 > { // alphabetical tuple of name and value hereby defined. @@ -53,7 +53,7 @@ public: * exists and aFetchedValue is not NULL. * @return bool - true if property is found, else false. */ - bool Value( const char* aName, std::string* aFetchedValue = NULL ) const; + bool Value( const char* aName, UTF8* aFetchedValue = NULL ) const; }; diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 5a2caa377b..d18c32edaa 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -1782,8 +1782,7 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri MODULE_MAP& mods = m_cache->GetModules(); // Quietly overwrite module and delete module file from path for any by same name. - wxFileName fn( aLibraryPath, FROM_UTF8( aFootprint->GetFPID().GetFootprintName().c_str() ), - KiCadFootprintFileExtension ); + wxFileName fn( aLibraryPath, aFootprint->GetFPID().GetFootprintName(), KiCadFootprintFileExtension ); if( !fn.IsOk() ) { diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 11afe8aa0f..4bc6e4550a 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -1144,8 +1144,9 @@ void LEGACY_PLUGIN::LoadMODULE( MODULE* aModule ) } } - wxString msg = wxString::Format( wxT( "Missing '$EndMODULE' for MODULE '%s'" ), - aModule->GetFPID().GetFootprintName().c_str() ); + wxString msg = wxString::Format( + wxT( "Missing '$EndMODULE' for MODULE '%s'" ), + GetChars( aModule->GetFPID().GetFootprintName() ) ); THROW_IO_ERROR( msg ); } @@ -1200,7 +1201,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) padchar, padchar, m_reader->LineNumber(), - aModule->GetFPID().GetFootprintName().c_str() + GetChars( aModule->GetFPID().GetFootprintName() ) ); THROW_IO_ERROR( m_error ); } @@ -1401,7 +1402,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule ) (unsigned char) line[1], (unsigned char) line[1], m_reader->LineNumber(), - aModule->GetFPID().GetFootprintName().c_str() + GetChars( aModule->GetFPID().GetFootprintName() ) ); THROW_IO_ERROR( m_error ); } diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index e767664afd..7fd65174f3 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -285,7 +285,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule ) if( aModule == NULL ) return; - fn.SetName( FROM_UTF8( aModule->GetFPID().GetFootprintName().c_str() ) ); + fn.SetName( aModule->GetFPID().GetFootprintName() ); wxString wildcard = wxGetTranslation( KiCadFootprintLibFileWildcard ); @@ -485,7 +485,7 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary() return false; FPID fpid( fpid_txt ); - wxString fpname = FROM_UTF8( fpid.GetFootprintName().c_str() ); + wxString fpname = fpid.GetFootprintName(); // Confirmation wxString msg = wxString::Format( FMT_OK_DELETE, fpname.GetData(), nickname.GetData() ); @@ -581,7 +581,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibrary, SetMsgPanel( aModule ); // Ask what to use as the footprint name in the library - wxString footprintName = FROM_UTF8( aModule->GetFPID().GetFootprintName().c_str() ); + wxString footprintName = aModule->GetFPID().GetFootprintName(); if( aDisplayDialog ) { diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 85ae9335f8..f435f867c8 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -451,8 +451,8 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId ) wxCHECK_MSG( m_footprintLibTable != NULL, NULL, wxT( "Cannot look up FPID in NULL FP_LIB_TABLE." ) ); - wxString nickname = FROM_UTF8( aFootprintId.GetLibNickname().c_str() ); - wxString fpname = FROM_UTF8( aFootprintId.GetFootprintName().c_str() ); + wxString nickname = aFootprintId.GetLibNickname(); + wxString fpname = aFootprintId.GetFootprintName(); if( nickname.size() ) { diff --git a/pcbnew/plugin.cpp b/pcbnew/plugin.cpp index 65e032cd95..fd6359f4c5 100644 --- a/pcbnew/plugin.cpp +++ b/pcbnew/plugin.cpp @@ -114,34 +114,34 @@ void PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const { // disable all these in another couple of months, after everyone has seen them: #if 1 - (*aListToAppendTo)["debug_level"] = wxString( _( + (*aListToAppendTo)["debug_level"] = UTF8( _( "Enable debug logging for Footprint*() functions in this PLUGIN." - )).utf8_str(); + )); - (*aListToAppendTo)["read_filter_regex"] = wxString( _( + (*aListToAppendTo)["read_filter_regex"] = UTF8( _( "Regular expression footprint name filter." - )).utf8_str(); + )); - (*aListToAppendTo)["enable_transaction_logging"] = wxString( _( + (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _( "Enable transaction logging. The mere presence of this option turns on the " " logging, no need to set a Value." - )).utf8_str(); + )); - (*aListToAppendTo)["username"] = wxString( _( + (*aListToAppendTo)["username"] = UTF8( _( "User name for login to some special library server." - )).utf8_str(); + )); - (*aListToAppendTo)["password"] = wxString( _( + (*aListToAppendTo)["password"] = UTF8( _( "Password for login to some special library server." - )).utf8_str(); + )); #endif #if 1 // Suitable for a C++ to python PLUGIN::Footprint*() adapter, move it to the adapter // if and when implemented. - (*aListToAppendTo)["python_footprint_plugin"] = wxString( _( + (*aListToAppendTo)["python_footprint_plugin"] = UTF8( _( "Enter the python module which implements the PLUGIN::Footprint*() functions." - )).utf8_str(); + )); #endif } diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 184d650e3f..a4ce86869f 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -394,8 +394,8 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* aModule, aNewFootprintFPID.Format().c_str() ); m_WinMessages->AppendText( line ); - wxString moduleName = FROM_UTF8( aNewFootprintFPID.GetFootprintName().c_str() ); - wxString libName = FROM_UTF8( aNewFootprintFPID.GetLibNickname().c_str() ); + wxString moduleName = aNewFootprintFPID.GetFootprintName(); + wxString libName = aNewFootprintFPID.GetLibNickname(); newModule = m_parent->LoadFootprint( aNewFootprintFPID );