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, 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#pragma once
26
27#include <wx/string.h>
28
29#include <set>
30
32{
33public:
34 wxString GetSummary() const;
35
40 wxString GetDuplicates() const;
41
42 static int Compare( const wxString& lhs, const wxString& rhs );
43
44private:
45 struct less
46 {
47 bool operator()( const wxString& lhs, const wxString& rhs ) const
48 {
49 return Compare( lhs, rhs ) < 0;
50 }
51 };
52
53 typedef std::set<wxString, less> container_type;
54
55 static wxString getNextSymbol( const wxString& str, wxString::size_type& cursor );
56
57public:
58 typedef container_type::value_type value_type;
59 typedef container_type::iterator iterator;
60 typedef container_type::const_iterator const_iterator;
61
62 void insert( value_type const& v )
63 {
64 // Check if the insertion occurred. If no insertion was performed then
65 // the pin number is a duplicate so add it to the duplicate set.
66 bool not_duplicate = pins.insert( v ).second;
67
68 if( not_duplicate == false )
69 {
70 duplicate_pins.insert( v );
71 }
72 }
73
74 container_type::size_type size() const { return pins.size(); }
75
76 iterator begin() { return pins.begin(); }
77 iterator end() { return pins.end(); }
78 const_iterator begin() const { return pins.begin(); }
79 const_iterator end() const { return pins.end(); }
80
81private:
83 std::set<wxString> duplicate_pins;
84};
const_iterator end() const
Definition pin_numbers.h:79
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:58
container_type::iterator iterator
Definition pin_numbers.h:59
std::set< wxString, less > container_type
Definition pin_numbers.h:53
static wxString getNextSymbol(const wxString &str, wxString::size_type &cursor)
const_iterator begin() const
Definition pin_numbers.h:78
container_type::size_type size() const
Definition pin_numbers.h:74
static int Compare(const wxString &lhs, const wxString &rhs)
void insert(value_type const &v)
Definition pin_numbers.h:62
container_type pins
Definition pin_numbers.h:82
wxString GetSummary() const
iterator end()
Definition pin_numbers.h:77
container_type::const_iterator const_iterator
Definition pin_numbers.h:60
std::set< wxString > duplicate_pins
Definition pin_numbers.h:83
iterator begin()
Definition pin_numbers.h:76
bool operator()(const wxString &lhs, const wxString &rhs) const
Definition pin_numbers.h:47