Loading common/string.cpp +110 −0 Original line number Original line Diff line number Diff line Loading @@ -320,3 +320,113 @@ char* strupper( char* Text ) return Text; return Text; } } int RefDesStringCompare( const wxString& strFWord, const wxString& strSWord ) { // The different sections of the first string wxString strFWordBeg, strFWordMid, strFWordEnd; // The different sections of the second string wxString strSWordBeg, strSWordMid, strSWordEnd; int isEqual = 0; // The numerical results of a string compare int iReturn = 0; // The variable that is being returned long lFirstDigit = 0; /* The converted middle section of the first *string */ long lSecondDigit = 0; /* The converted middle section of the second *string */ // Split the two strings into separate parts SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd ); SplitString( strSWord, &strSWordBeg, &strSWordMid, &strSWordEnd ); // Compare the Beginning section of the strings isEqual = strFWordBeg.CmpNoCase( strSWordBeg ); if( isEqual > 0 ) iReturn = 1; else if( isEqual < 0 ) iReturn = -1; else { // If the first sections are equal compare their digits strFWordMid.ToLong( &lFirstDigit ); strSWordMid.ToLong( &lSecondDigit ); if( lFirstDigit > lSecondDigit ) iReturn = 1; else if( lFirstDigit < lSecondDigit ) iReturn = -1; else { // If the first two sections are equal compare the endings isEqual = strFWordEnd.CmpNoCase( strSWordEnd ); if( isEqual > 0 ) iReturn = 1; else if( isEqual < 0 ) iReturn = -1; else iReturn = 0; } } return iReturn; } int SplitString( wxString strToSplit, wxString* strBeginning, wxString* strDigits, wxString* strEnd ) { // Clear all the return strings strBeginning->Empty(); strDigits->Empty(); strEnd->Empty(); // There no need to do anything if the string is empty if( strToSplit.length() == 0 ) return 0; // Starting at the end of the string look for the first digit int ii; for( ii = (strToSplit.length() - 1); ii >= 0; ii-- ) { if( isdigit( strToSplit[ii] ) ) break; } // If there were no digits then just set the single string if( ii < 0 ) *strBeginning = strToSplit; else { // Since there is at least one digit this is the trailing string *strEnd = strToSplit.substr( ii + 1 ); // Go to the end of the digits int position = ii + 1; for( ; ii >= 0; ii-- ) { if( !isdigit( strToSplit[ii] ) ) break; } // If all that was left was digits, then just set the digits string if( ii < 0 ) *strDigits = strToSplit.substr( 0, position ); /* We were only looking for the last set of digits everything else is *part of the preamble */ else { *strDigits = strToSplit.substr( ii + 1, position - ii - 1 ); *strBeginning = strToSplit.substr( 0, ii + 1 ); } } return 0; } eeschema/build_BOM.cpp +0 −125 Original line number Original line Diff line number Diff line Loading @@ -71,12 +71,6 @@ static bool SortLabelsBySheet( const LABEL_OBJECT& obj1, static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList ); static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList ); static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ); static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ); int RefDesStringCompare( const wxString& lhs, const wxString& rhs ); int SplitString( wxString strToSplit, wxString* strBeginning, wxString* strDigits, wxString* strEnd ); // separator used in bom export to spreadsheet // separator used in bom export to spreadsheet static char s_ExportSeparatorSymbol; static char s_ExportSeparatorSymbol; Loading Loading @@ -1049,122 +1043,3 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ) } } /* This function will act just like the strcmp function but correctly sort * the numerical order in the string * return -1 if first string is less than the second * return 0 if the strings are equal * return 1 if the first string is greater than the second */ int RefDesStringCompare( const wxString& strFWord, const wxString& strSWord ) { // The different sections of the first string wxString strFWordBeg, strFWordMid, strFWordEnd; // The different sections of the second string wxString strSWordBeg, strSWordMid, strSWordEnd; int isEqual = 0; // The numerical results of a string compare int iReturn = 0; // The variable that is being returned long lFirstDigit = 0; /* The converted middle section of the first *string */ long lSecondDigit = 0; /* The converted middle section of the second *string */ // Split the two string into separate parts SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd ); SplitString( strSWord, &strSWordBeg, &strSWordMid, &strSWordEnd ); // Compare the Beginning section of the strings isEqual = strFWordBeg.CmpNoCase( strSWordBeg ); if( isEqual > 0 ) iReturn = 1; else if( isEqual < 0 ) iReturn = -1; else { // If the first sections are equal compare there digits strFWordMid.ToLong( &lFirstDigit ); strSWordMid.ToLong( &lSecondDigit ); if( lFirstDigit > lSecondDigit ) iReturn = 1; else if( lFirstDigit < lSecondDigit ) iReturn = -1; else { // If the first two sections are equal compare the endings isEqual = strFWordEnd.CmpNoCase( strSWordEnd ); if( isEqual > 0 ) iReturn = 1; else if( isEqual < 0 ) iReturn = -1; else iReturn = 0; } } return iReturn; } /* This is the function that breaks a string into three parts. * The alphabetic preamble * The numeric part * Any alphabetic ending * For example C10A is split to C 10 A */ int SplitString( wxString strToSplit, wxString* strBeginning, wxString* strDigits, wxString* strEnd ) { // Clear all the return strings strBeginning->Clear(); strDigits->Clear(); strEnd->Clear(); // There no need to do anything if the string is empty if( strToSplit.length() == 0 ) return 0; // Starting at the end of the string look for the first digit int ii; for( ii = (strToSplit.length() - 1); ii >= 0; ii-- ) { if( isdigit( strToSplit[ii] ) ) break; } // If there were no digits then just set the single string if( ii < 0 ) *strBeginning = strToSplit; else { // Since there is at least one digit this is the trailing string *strEnd = strToSplit.substr( ii + 1 ); // Go to the end of the digits int position = ii + 1; for( ; ii >= 0; ii-- ) { if( !isdigit( strToSplit[ii] ) ) break; } // If all that was left was digits, then just set the digits string if( ii < 0 ) *strDigits = strToSplit.substr( 0, position ); /* We were only looking for the last set of digits everything else is *part of the preamble */ else { *strDigits = strToSplit.substr( ii + 1, position - ii - 1 ); *strBeginning = strToSplit.substr( 0, ii + 1 ); } } return 0; } eeschema/class_drawsheetpath.cpp +14 −3 Original line number Original line Diff line number Diff line Loading @@ -220,7 +220,7 @@ wxString SCH_SHEET_PATH::Path() * (the "normal" path uses the time stamps which do not changes even when * (the "normal" path uses the time stamps which do not changes even when * editing sheet parameters) * editing sheet parameters) */ */ wxString SCH_SHEET_PATH::PathHumanReadable() wxString SCH_SHEET_PATH::PathHumanReadable() const { { wxString s, t; wxString s, t; Loading Loading @@ -355,6 +355,7 @@ SCH_ITEM* SCH_SHEET_PATH::MatchNextItem( wxFindReplaceData& aSearchData, bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 ) bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 ) { { m_numSheets = d1.m_numSheets; m_numSheets = d1.m_numSheets; unsigned i; unsigned i; for( i = 0; i < m_numSheets; i++ ) for( i = 0; i < m_numSheets; i++ ) { { Loading @@ -370,10 +371,11 @@ bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 ) } } bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const { { if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets ) return false; return false; for( unsigned i = 0; i < m_numSheets; i++ ) for( unsigned i = 0; i < m_numSheets; i++ ) { { if( m_sheets[i] != d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] ) Loading @@ -384,15 +386,24 @@ bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) } } bool SCH_SHEET_PATH::operator!=( const SCH_SHEET_PATH& d1 ) bool SCH_SHEET_PATH::operator!=( const SCH_SHEET_PATH& d1 ) const { { if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets ) return true; return true; for( unsigned i = 0; i < m_numSheets; i++ ) for( unsigned i = 0; i < m_numSheets; i++ ) { { if( m_sheets[i] != d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] ) { /* printf( "micompare this:'%s' d1:'%s'\n", CONV_TO_UTF8( PathHumanReadable() ), CONV_TO_UTF8( d1.PathHumanReadable() ) ); */ return true; return true; } } } return false; return false; } } Loading eeschema/class_drawsheetpath.h +3 −3 Original line number Original line Diff line number Diff line Loading @@ -150,7 +150,7 @@ public: * stamps in the path. (Time stamps do not change even when editing * stamps in the path. (Time stamps do not change even when editing * sheet parameters). * sheet parameters). */ */ wxString PathHumanReadable(); wxString PathHumanReadable() const; /** Function BuildSheetPathInfoFromSheetPathValue /** Function BuildSheetPathInfoFromSheetPathValue * Fill this with data to access to the hierarchical sheet known by its * Fill this with data to access to the hierarchical sheet known by its Loading Loading @@ -207,9 +207,9 @@ public: bool operator=( const SCH_SHEET_PATH& d1 ); bool operator=( const SCH_SHEET_PATH& d1 ); bool operator==( const SCH_SHEET_PATH& d1 ); bool operator==( const SCH_SHEET_PATH& d1 ) const; bool operator!=( const SCH_SHEET_PATH& d1 ); bool operator!=( const SCH_SHEET_PATH& d1 ) const; }; }; Loading eeschema/class_netlist_object.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -10,7 +10,6 @@ #include "class_netlist_object.h" #include "class_netlist_object.h" #if defined(DEBUG) #if defined(DEBUG) #include <iostream> #include <iostream> const char* ShowType( NetObjetType aType ) const char* ShowType( NetObjetType aType ) Loading Loading @@ -134,3 +133,4 @@ NETLIST_OBJECT::NETLIST_OBJECT( NETLIST_OBJECT& aSource ) NETLIST_OBJECT::~NETLIST_OBJECT() NETLIST_OBJECT::~NETLIST_OBJECT() { { } } Loading
common/string.cpp +110 −0 Original line number Original line Diff line number Diff line Loading @@ -320,3 +320,113 @@ char* strupper( char* Text ) return Text; return Text; } } int RefDesStringCompare( const wxString& strFWord, const wxString& strSWord ) { // The different sections of the first string wxString strFWordBeg, strFWordMid, strFWordEnd; // The different sections of the second string wxString strSWordBeg, strSWordMid, strSWordEnd; int isEqual = 0; // The numerical results of a string compare int iReturn = 0; // The variable that is being returned long lFirstDigit = 0; /* The converted middle section of the first *string */ long lSecondDigit = 0; /* The converted middle section of the second *string */ // Split the two strings into separate parts SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd ); SplitString( strSWord, &strSWordBeg, &strSWordMid, &strSWordEnd ); // Compare the Beginning section of the strings isEqual = strFWordBeg.CmpNoCase( strSWordBeg ); if( isEqual > 0 ) iReturn = 1; else if( isEqual < 0 ) iReturn = -1; else { // If the first sections are equal compare their digits strFWordMid.ToLong( &lFirstDigit ); strSWordMid.ToLong( &lSecondDigit ); if( lFirstDigit > lSecondDigit ) iReturn = 1; else if( lFirstDigit < lSecondDigit ) iReturn = -1; else { // If the first two sections are equal compare the endings isEqual = strFWordEnd.CmpNoCase( strSWordEnd ); if( isEqual > 0 ) iReturn = 1; else if( isEqual < 0 ) iReturn = -1; else iReturn = 0; } } return iReturn; } int SplitString( wxString strToSplit, wxString* strBeginning, wxString* strDigits, wxString* strEnd ) { // Clear all the return strings strBeginning->Empty(); strDigits->Empty(); strEnd->Empty(); // There no need to do anything if the string is empty if( strToSplit.length() == 0 ) return 0; // Starting at the end of the string look for the first digit int ii; for( ii = (strToSplit.length() - 1); ii >= 0; ii-- ) { if( isdigit( strToSplit[ii] ) ) break; } // If there were no digits then just set the single string if( ii < 0 ) *strBeginning = strToSplit; else { // Since there is at least one digit this is the trailing string *strEnd = strToSplit.substr( ii + 1 ); // Go to the end of the digits int position = ii + 1; for( ; ii >= 0; ii-- ) { if( !isdigit( strToSplit[ii] ) ) break; } // If all that was left was digits, then just set the digits string if( ii < 0 ) *strDigits = strToSplit.substr( 0, position ); /* We were only looking for the last set of digits everything else is *part of the preamble */ else { *strDigits = strToSplit.substr( ii + 1, position - ii - 1 ); *strBeginning = strToSplit.substr( 0, ii + 1 ); } } return 0; }
eeschema/build_BOM.cpp +0 −125 Original line number Original line Diff line number Diff line Loading @@ -71,12 +71,6 @@ static bool SortLabelsBySheet( const LABEL_OBJECT& obj1, static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList ); static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList ); static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ); static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ); int RefDesStringCompare( const wxString& lhs, const wxString& rhs ); int SplitString( wxString strToSplit, wxString* strBeginning, wxString* strDigits, wxString* strEnd ); // separator used in bom export to spreadsheet // separator used in bom export to spreadsheet static char s_ExportSeparatorSymbol; static char s_ExportSeparatorSymbol; Loading Loading @@ -1049,122 +1043,3 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ) } } /* This function will act just like the strcmp function but correctly sort * the numerical order in the string * return -1 if first string is less than the second * return 0 if the strings are equal * return 1 if the first string is greater than the second */ int RefDesStringCompare( const wxString& strFWord, const wxString& strSWord ) { // The different sections of the first string wxString strFWordBeg, strFWordMid, strFWordEnd; // The different sections of the second string wxString strSWordBeg, strSWordMid, strSWordEnd; int isEqual = 0; // The numerical results of a string compare int iReturn = 0; // The variable that is being returned long lFirstDigit = 0; /* The converted middle section of the first *string */ long lSecondDigit = 0; /* The converted middle section of the second *string */ // Split the two string into separate parts SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd ); SplitString( strSWord, &strSWordBeg, &strSWordMid, &strSWordEnd ); // Compare the Beginning section of the strings isEqual = strFWordBeg.CmpNoCase( strSWordBeg ); if( isEqual > 0 ) iReturn = 1; else if( isEqual < 0 ) iReturn = -1; else { // If the first sections are equal compare there digits strFWordMid.ToLong( &lFirstDigit ); strSWordMid.ToLong( &lSecondDigit ); if( lFirstDigit > lSecondDigit ) iReturn = 1; else if( lFirstDigit < lSecondDigit ) iReturn = -1; else { // If the first two sections are equal compare the endings isEqual = strFWordEnd.CmpNoCase( strSWordEnd ); if( isEqual > 0 ) iReturn = 1; else if( isEqual < 0 ) iReturn = -1; else iReturn = 0; } } return iReturn; } /* This is the function that breaks a string into three parts. * The alphabetic preamble * The numeric part * Any alphabetic ending * For example C10A is split to C 10 A */ int SplitString( wxString strToSplit, wxString* strBeginning, wxString* strDigits, wxString* strEnd ) { // Clear all the return strings strBeginning->Clear(); strDigits->Clear(); strEnd->Clear(); // There no need to do anything if the string is empty if( strToSplit.length() == 0 ) return 0; // Starting at the end of the string look for the first digit int ii; for( ii = (strToSplit.length() - 1); ii >= 0; ii-- ) { if( isdigit( strToSplit[ii] ) ) break; } // If there were no digits then just set the single string if( ii < 0 ) *strBeginning = strToSplit; else { // Since there is at least one digit this is the trailing string *strEnd = strToSplit.substr( ii + 1 ); // Go to the end of the digits int position = ii + 1; for( ; ii >= 0; ii-- ) { if( !isdigit( strToSplit[ii] ) ) break; } // If all that was left was digits, then just set the digits string if( ii < 0 ) *strDigits = strToSplit.substr( 0, position ); /* We were only looking for the last set of digits everything else is *part of the preamble */ else { *strDigits = strToSplit.substr( ii + 1, position - ii - 1 ); *strBeginning = strToSplit.substr( 0, ii + 1 ); } } return 0; }
eeschema/class_drawsheetpath.cpp +14 −3 Original line number Original line Diff line number Diff line Loading @@ -220,7 +220,7 @@ wxString SCH_SHEET_PATH::Path() * (the "normal" path uses the time stamps which do not changes even when * (the "normal" path uses the time stamps which do not changes even when * editing sheet parameters) * editing sheet parameters) */ */ wxString SCH_SHEET_PATH::PathHumanReadable() wxString SCH_SHEET_PATH::PathHumanReadable() const { { wxString s, t; wxString s, t; Loading Loading @@ -355,6 +355,7 @@ SCH_ITEM* SCH_SHEET_PATH::MatchNextItem( wxFindReplaceData& aSearchData, bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 ) bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 ) { { m_numSheets = d1.m_numSheets; m_numSheets = d1.m_numSheets; unsigned i; unsigned i; for( i = 0; i < m_numSheets; i++ ) for( i = 0; i < m_numSheets; i++ ) { { Loading @@ -370,10 +371,11 @@ bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 ) } } bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const { { if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets ) return false; return false; for( unsigned i = 0; i < m_numSheets; i++ ) for( unsigned i = 0; i < m_numSheets; i++ ) { { if( m_sheets[i] != d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] ) Loading @@ -384,15 +386,24 @@ bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) } } bool SCH_SHEET_PATH::operator!=( const SCH_SHEET_PATH& d1 ) bool SCH_SHEET_PATH::operator!=( const SCH_SHEET_PATH& d1 ) const { { if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets ) return true; return true; for( unsigned i = 0; i < m_numSheets; i++ ) for( unsigned i = 0; i < m_numSheets; i++ ) { { if( m_sheets[i] != d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] ) { /* printf( "micompare this:'%s' d1:'%s'\n", CONV_TO_UTF8( PathHumanReadable() ), CONV_TO_UTF8( d1.PathHumanReadable() ) ); */ return true; return true; } } } return false; return false; } } Loading
eeschema/class_drawsheetpath.h +3 −3 Original line number Original line Diff line number Diff line Loading @@ -150,7 +150,7 @@ public: * stamps in the path. (Time stamps do not change even when editing * stamps in the path. (Time stamps do not change even when editing * sheet parameters). * sheet parameters). */ */ wxString PathHumanReadable(); wxString PathHumanReadable() const; /** Function BuildSheetPathInfoFromSheetPathValue /** Function BuildSheetPathInfoFromSheetPathValue * Fill this with data to access to the hierarchical sheet known by its * Fill this with data to access to the hierarchical sheet known by its Loading Loading @@ -207,9 +207,9 @@ public: bool operator=( const SCH_SHEET_PATH& d1 ); bool operator=( const SCH_SHEET_PATH& d1 ); bool operator==( const SCH_SHEET_PATH& d1 ); bool operator==( const SCH_SHEET_PATH& d1 ) const; bool operator!=( const SCH_SHEET_PATH& d1 ); bool operator!=( const SCH_SHEET_PATH& d1 ) const; }; }; Loading
eeschema/class_netlist_object.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -10,7 +10,6 @@ #include "class_netlist_object.h" #include "class_netlist_object.h" #if defined(DEBUG) #if defined(DEBUG) #include <iostream> #include <iostream> const char* ShowType( NetObjetType aType ) const char* ShowType( NetObjetType aType ) Loading Loading @@ -134,3 +133,4 @@ NETLIST_OBJECT::NETLIST_OBJECT( NETLIST_OBJECT& aSource ) NETLIST_OBJECT::~NETLIST_OBJECT() NETLIST_OBJECT::~NETLIST_OBJECT() { { } }