KiCad PCB EDA Suite
PinNumbers Class Reference

#include <pin_number.h>

Classes

struct  less
 

Public Types

typedef container_type::value_type value_type
 
typedef container_type::iterator iterator
 
typedef container_type::const_iterator const_iterator
 

Public Member Functions

wxString GetSummary () const
 
void insert (value_type const &v)
 
container_type::size_type size () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 

Static Public Member Functions

static int Compare (PinNumber const &lhs, PinNumber const &rhs)
 

Private Types

typedef std::set< PinNumber, lesscontainer_type
 

Private Attributes

container_type pins
 

Detailed Description

Definition at line 34 of file pin_number.h.

Member Typedef Documentation

◆ const_iterator

typedef container_type::const_iterator PinNumbers::const_iterator

Definition at line 55 of file pin_number.h.

◆ container_type

typedef std::set< PinNumber, less > PinNumbers::container_type
private

Definition at line 50 of file pin_number.h.

◆ iterator

typedef container_type::iterator PinNumbers::iterator

Definition at line 54 of file pin_number.h.

◆ value_type

typedef container_type::value_type PinNumbers::value_type

Definition at line 53 of file pin_number.h.

Member Function Documentation

◆ begin() [1/2]

iterator PinNumbers::begin ( )
inline

Definition at line 60 of file pin_number.h.

60 { return pins.begin(); }
container_type pins
Definition: pin_number.h:66

References pins.

Referenced by GetSummary().

◆ begin() [2/2]

const_iterator PinNumbers::begin ( ) const
inline

Definition at line 62 of file pin_number.h.

62 { return pins.begin(); }
container_type pins
Definition: pin_number.h:66

References pins.

◆ Compare()

int PinNumbers::Compare ( PinNumber const &  lhs,
PinNumber const &  rhs 
)
static

Definition at line 111 of file pin_number.cpp.

112 {
113  wxString::size_type cursor1 = 0;
114  wxString::size_type cursor2 = 0;
115 
116  wxString comp1, comp2;
117 
118  for( ; ; )
119  {
120  comp1 = GetNextComponent( lhs, cursor1 );
121  comp2 = GetNextComponent( rhs, cursor2 );
122 
123  if( comp1.empty() && comp2.empty() )
124  return 0;
125 
126  if( comp1.empty() )
127  return -2;
128 
129  if( comp2.empty() )
130  return 2;
131 
132  wxChar c1 = comp1[0];
133  wxChar c2 = comp2[0];
134 
135  if( wxIsdigit( c1 ) || c1 == '-' || c1 == '+' )
136  {
137  if( wxIsdigit( c2 ) || c2 == '-' || c2 == '+' )
138  {
139  // numeric comparison
140  wxString::size_type v1 = comp1.find_first_of( "vV" );
141 
142  if( v1 != wxString::npos )
143  comp1[v1] = '.';
144 
145  wxString::size_type v2 = comp2.find_first_of( "vV" );
146 
147  if( v2 != wxString::npos )
148  comp2[v2] = '.';
149 
150  double val1, val2;
151 
152  comp1.ToDouble( &val1 );
153  comp2.ToDouble( &val2 );
154 
155  if( val1 < val2 )
156  {
157  if( val1 == val2 - 1 )
158  return -1;
159  else
160  return -2;
161  }
162 
163  if( val1 > val2 )
164  {
165  if( val1 == val2 + 1 )
166  return 1;
167  else
168  return 2;
169  }
170  }
171  else
172  return -2;
173  }
174  else
175  {
176  if( wxIsdigit( c2 ) || c2 == '-' || c2 == '+' )
177  return 2;
178 
179  int res = comp1.Cmp( comp2 );
180 
181  if( res != 0 )
182  return res;
183  }
184  }
185 }
YYCODETYPE lhs

References numEval::lhs.

Referenced by PIN_TABLE_DATA_MODEL::compare(), GetSummary(), and PinNumbers::less::operator()().

◆ end() [1/2]

iterator PinNumbers::end ( )
inline

Definition at line 61 of file pin_number.h.

61 { return pins.end(); }
container_type pins
Definition: pin_number.h:66

References pins.

Referenced by GetSummary().

◆ end() [2/2]

const_iterator PinNumbers::end ( ) const
inline

Definition at line 63 of file pin_number.h.

63 { return pins.end(); }
container_type pins
Definition: pin_number.h:66

References pins.

◆ GetSummary()

wxString PinNumbers::GetSummary ( ) const

Definition at line 71 of file pin_number.cpp.

72 {
73  wxString ret;
74 
76  if( i == end() )
77  return ret;
78 
79  const_iterator begin_of_range = i;
80  const_iterator last;
81 
82  for( ;; )
83  {
84  last = i;
85  ++i;
86 
87  int rc = ( i != end() ) ? Compare( *last, *i ) : -2;
88 
89  assert( rc == -1 || rc == -2 );
90 
91  if( rc == -1 )
92  // adjacent elements
93  continue;
94 
95  ret += *begin_of_range;
96  if( begin_of_range != last )
97  {
98  ret += '-';
99  ret += *last;
100  }
101  if( i == end() )
102  break;
103  begin_of_range = i;
104  ret += ',';
105  }
106 
107  return ret;
108 }
static int Compare(PinNumber const &lhs, PinNumber const &rhs)
Definition: pin_number.cpp:111
container_type::const_iterator const_iterator
Definition: pin_number.h:55
iterator begin()
Definition: pin_number.h:60
iterator end()
Definition: pin_number.h:61
size_t i
Definition: json11.cpp:597

References begin(), Compare(), end(), and i.

Referenced by DIALOG_LIB_EDIT_PIN_TABLE::updateSummary().

◆ insert()

void PinNumbers::insert ( value_type const &  v)
inline

Definition at line 57 of file pin_number.h.

57 { pins.insert( v ); }
container_type pins
Definition: pin_number.h:66

References pins.

Referenced by DIALOG_LIB_EDIT_PIN_TABLE::updateSummary().

◆ size()

container_type::size_type PinNumbers::size ( ) const
inline

Definition at line 58 of file pin_number.h.

58 { return pins.size(); }
container_type pins
Definition: pin_number.h:66

References pins.

Member Data Documentation

◆ pins

container_type PinNumbers::pins
private

Definition at line 66 of file pin_number.h.

Referenced by begin(), end(), insert(), and size().


The documentation for this class was generated from the following files: