KiCad PCB EDA Suite
rsort_wxString Struct Reference

A helper for sorting strings from the rear. More...

#include <kicad_string.h>

Public Member Functions

bool operator() (const wxString &strA, const wxString &strB) const
 

Detailed Description

A helper for sorting strings from the rear.

Useful for things like 3d model names where they tend to be largely repititous at the front.

Definition at line 207 of file kicad_string.h.

Member Function Documentation

bool rsort_wxString::operator() ( const wxString &  strA,
const wxString &  strB 
) const
inline

Definition at line 209 of file kicad_string.h.

210  {
211  wxString::const_reverse_iterator sA = strA.rbegin();
212  wxString::const_reverse_iterator eA = strA.rend();
213 
214  wxString::const_reverse_iterator sB = strB.rbegin();
215  wxString::const_reverse_iterator eB = strB.rend();
216 
217  if( strA.empty() )
218  {
219  if( strB.empty() )
220  return false;
221 
222  // note: this rule implies that a null string is first in the sort order
223  return true;
224  }
225 
226  if( strB.empty() )
227  return false;
228 
229  while( sA != eA && sB != eB )
230  {
231  if( (*sA) == (*sB) )
232  {
233  ++sA;
234  ++sB;
235  continue;
236  }
237 
238  if( (*sA) < (*sB) )
239  return true;
240  else
241  return false;
242  }
243 
244  if( sB == eB )
245  return false;
246 
247  return true;
248  }

The documentation for this struct was generated from the following file: