KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <wx/string.h>
24
25#include <set>
26
28{
29public:
30 wxString GetSummary() const;
31
36 wxString GetDuplicates() const;
37
38 static int Compare( const wxString& lhs, const wxString& rhs );
39
40private:
41 struct less
42 {
43 bool operator()( const wxString& lhs, const wxString& rhs ) const
44 {
45 return Compare( lhs, rhs ) < 0;
46 }
47 };
48
49 typedef std::set<wxString, less> container_type;
50
51 static wxString getNextSymbol( const wxString& str, wxString::size_type& cursor );
52
53public:
54 typedef container_type::value_type value_type;
55 typedef container_type::iterator iterator;
56 typedef container_type::const_iterator const_iterator;
57
58 void insert( value_type const& v )
59 {
60 // Check if the insertion occurred. If no insertion was performed then
61 // the pin number is a duplicate so add it to the duplicate set.
62 bool not_duplicate = pins.insert( v ).second;
63
64 if( not_duplicate == false )
65 {
66 duplicate_pins.insert( v );
67 }
68 }
69
70 container_type::size_type size() const { return pins.size(); }
71
72 iterator begin() { return pins.begin(); }
73 iterator end() { return pins.end(); }
74 const_iterator begin() const { return pins.begin(); }
75 const_iterator end() const { return pins.end(); }
76
77private:
79 std::set<wxString> duplicate_pins;
80};
const_iterator end() const
Definition pin_numbers.h:75
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:54
container_type::iterator iterator
Definition pin_numbers.h:55
std::set< wxString, less > container_type
Definition pin_numbers.h:49
static wxString getNextSymbol(const wxString &str, wxString::size_type &cursor)
const_iterator begin() const
Definition pin_numbers.h:74
container_type::size_type size() const
Definition pin_numbers.h:70
static int Compare(const wxString &lhs, const wxString &rhs)
void insert(value_type const &v)
Definition pin_numbers.h:58
container_type pins
Definition pin_numbers.h:78
wxString GetSummary() const
iterator end()
Definition pin_numbers.h:73
container_type::const_iterator const_iterator
Definition pin_numbers.h:56
std::set< wxString > duplicate_pins
Definition pin_numbers.h:79
iterator begin()
Definition pin_numbers.h:72
bool operator()(const wxString &lhs, const wxString &rhs) const
Definition pin_numbers.h:43