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 repetitious at the front.

Definition at line 225 of file kicad_string.h.

Member Function Documentation

◆ operator()()

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

Definition at line 227 of file kicad_string.h.

228  {
229  wxString::const_reverse_iterator sA = strA.rbegin();
230  wxString::const_reverse_iterator eA = strA.rend();
231 
232  wxString::const_reverse_iterator sB = strB.rbegin();
233  wxString::const_reverse_iterator eB = strB.rend();
234 
235  if( strA.empty() )
236  {
237  if( strB.empty() )
238  return false;
239 
240  // note: this rule implies that a null string is first in the sort order
241  return true;
242  }
243 
244  if( strB.empty() )
245  return false;
246 
247  while( sA != eA && sB != eB )
248  {
249  if( (*sA) == (*sB) )
250  {
251  ++sA;
252  ++sB;
253  continue;
254  }
255 
256  if( (*sA) < (*sB) )
257  return true;
258  else
259  return false;
260  }
261 
262  if( sB == eB )
263  return false;
264 
265  return true;
266  }

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