kicad/eeschema/pin_numbers.h

86 lines
2.5 KiB
C
Raw Normal View History

2016-01-13 19:13:38 +00:00
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Simon Richter
* Copyright (C) 2021 KiCad Developers, see AUTHORS.TXT for contributors.
2016-01-13 19:13:38 +00:00
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef PIN_NUMBERS_H
#define PIN_NUMBERS_H
2016-01-13 19:13:38 +00:00
#include <wx/string.h>
#include <set>
class PIN_NUMBERS
2016-01-13 19:13:38 +00:00
{
public:
wxString GetSummary() const;
/// <summary>
/// Gets a formatted string of all the pins that have duplicate numbers.
/// </summary>
/// <returns></returns>
wxString GetDuplicates() const;
static int Compare( const wxString& lhs, const wxString& rhs );
2016-01-13 19:13:38 +00:00
private:
struct less
{
bool operator()( const wxString& lhs, const wxString& rhs ) const
2016-01-13 19:13:38 +00:00
{
return Compare( lhs, rhs ) < 0;
}
};
typedef std::set<wxString, less> container_type;
2016-01-13 19:13:38 +00:00
public:
typedef container_type::value_type value_type;
typedef container_type::iterator iterator;
typedef container_type::const_iterator const_iterator;
void insert( value_type const& v )
{
// Check if the insertion occurred. If no insertion was performed then
// the pin number is a duplicate so add it to the duplicate set.
bool not_duplicate = pins.insert( v ).second;
if( not_duplicate == false )
{
duplicate_pins.insert( v );
}
}
2016-01-13 19:13:38 +00:00
container_type::size_type size() const { return pins.size(); }
iterator begin() { return pins.begin(); }
iterator end() { return pins.end(); }
const_iterator begin() const { return pins.begin(); }
const_iterator end() const { return pins.end(); }
private:
container_type pins;
std::set<wxString> duplicate_pins;
2016-01-13 19:13:38 +00:00
};
#endif