KiCad PCB EDA Suite
pin_numbers.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015 Simon Richter
5 * Copyright (C) 2021 KiCad Developers, see AUTHORS.TXT for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef PIN_NUMBERS_H
26#define PIN_NUMBERS_H
27
28#include <wx/string.h>
29
30#include <set>
31
33{
34public:
35 wxString GetSummary() const;
36
41 wxString GetDuplicates() const;
42
43 static int Compare( const wxString& lhs, const wxString& rhs );
44
45private:
46 struct less
47 {
48 bool operator()( const wxString& lhs, const wxString& rhs ) const
49 {
50 return Compare( lhs, rhs ) < 0;
51 }
52 };
53
54 typedef std::set<wxString, less> container_type;
55
56 static wxString getNextSymbol( const wxString& str, wxString::size_type& cursor );
57
58public:
59 typedef container_type::value_type value_type;
60 typedef container_type::iterator iterator;
61 typedef container_type::const_iterator const_iterator;
62
63 void insert( value_type const& v )
64 {
65 // Check if the insertion occurred. If no insertion was performed then
66 // the pin number is a duplicate so add it to the duplicate set.
67 bool not_duplicate = pins.insert( v ).second;
68
69 if( not_duplicate == false )
70 {
71 duplicate_pins.insert( v );
72 }
73 }
74
75 container_type::size_type size() const { return pins.size(); }
76
77 iterator begin() { return pins.begin(); }
78 iterator end() { return pins.end(); }
79 const_iterator begin() const { return pins.begin(); }
80 const_iterator end() const { return pins.end(); }
81
82private:
84 std::set<wxString> duplicate_pins;
85};
86
87#endif
const_iterator end() const
Definition: pin_numbers.h:80
wxString GetDuplicates() const
Gets a formatted string of all the pins that have duplicate numbers.
container_type::value_type value_type
Definition: pin_numbers.h:59
container_type::iterator iterator
Definition: pin_numbers.h:60
std::set< wxString, less > container_type
Definition: pin_numbers.h:54
static wxString getNextSymbol(const wxString &str, wxString::size_type &cursor)
Definition: pin_numbers.cpp:30
const_iterator begin() const
Definition: pin_numbers.h:79
container_type::size_type size() const
Definition: pin_numbers.h:75
static int Compare(const wxString &lhs, const wxString &rhs)
void insert(value_type const &v)
Definition: pin_numbers.h:63
container_type pins
Definition: pin_numbers.h:83
wxString GetSummary() const
Definition: pin_numbers.cpp:70
iterator end()
Definition: pin_numbers.h:78
container_type::const_iterator const_iterator
Definition: pin_numbers.h:61
std::set< wxString > duplicate_pins
Definition: pin_numbers.h:84
iterator begin()
Definition: pin_numbers.h:77
bool operator()(const wxString &lhs, const wxString &rhs) const
Definition: pin_numbers.h:48