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

typedef container_type::const_iterator PinNumbers::const_iterator

Definition at line 55 of file pin_number.h.

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

Definition at line 50 of file pin_number.h.

typedef container_type::iterator PinNumbers::iterator

Definition at line 54 of file pin_number.h.

typedef container_type::value_type PinNumbers::value_type

Definition at line 53 of file pin_number.h.

Member Function Documentation

iterator PinNumbers::begin ( )
inline

Definition at line 60 of file pin_number.h.

References pins.

Referenced by GetSummary().

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

Definition at line 62 of file pin_number.h.

References pins.

62 { return pins.begin(); }
container_type pins
Definition: pin_number.h:66
int PinNumbers::Compare ( PinNumber const &  lhs,
PinNumber const &  rhs 
)
static

Definition at line 110 of file pin_number.cpp.

Referenced by DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Compare(), GetSummary(), and PinNumbers::less::operator()().

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

Definition at line 61 of file pin_number.h.

References pins.

Referenced by GetSummary().

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

Definition at line 63 of file pin_number.h.

References pins.

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

Definition at line 70 of file pin_number.cpp.

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

Referenced by DIALOG_LIB_EDIT_PIN_TABLE::UpdateSummary().

71 {
72  wxString ret;
73 
74  const_iterator i = begin();
75  if( i == end() )
76  return ret;
77 
78  const_iterator begin_of_range = i;
79  const_iterator last;
80 
81  for( ;; )
82  {
83  last = i;
84  ++i;
85 
86  int rc = ( i != end() ) ? Compare( *last, *i ) : -2;
87 
88  assert( rc == -1 || rc == -2 );
89 
90  if( rc == -1 )
91  // adjacent elements
92  continue;
93 
94  ret += *begin_of_range;
95  if( begin_of_range != last )
96  {
97  ret += '-';
98  ret += *last;
99  }
100  if( i == end() )
101  break;
102  begin_of_range = i;
103  ret += ',';
104  }
105 
106  return ret;
107 }
static int Compare(PinNumber const &lhs, PinNumber const &rhs)
Definition: pin_number.cpp:110
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
void PinNumbers::insert ( value_type const &  v)
inline
container_type::size_type PinNumbers::size ( ) const
inline

Definition at line 58 of file pin_number.h.

References pins.

Referenced by DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Group::GetString(), and DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Group::GetValue().

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

Member Data Documentation

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: