KiCad PCB EDA Suite
rsort_wxString Struct Reference

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

#include <string_utils.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 240 of file string_utils.h.

Member Function Documentation

◆ operator()()

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

Definition at line 242 of file string_utils.h.

243  {
244  wxString::const_reverse_iterator sA = strA.rbegin();
245  wxString::const_reverse_iterator eA = strA.rend();
246 
247  wxString::const_reverse_iterator sB = strB.rbegin();
248  wxString::const_reverse_iterator eB = strB.rend();
249 
250  if( strA.empty() )
251  {
252  if( strB.empty() )
253  return false;
254 
255  // note: this rule implies that a null string is first in the sort order
256  return true;
257  }
258 
259  if( strB.empty() )
260  return false;
261 
262  while( sA != eA && sB != eB )
263  {
264  if( ( *sA ) == ( *sB ) )
265  {
266  ++sA;
267  ++sB;
268  continue;
269  }
270 
271  if( ( *sA ) < ( *sB ) )
272  return true;
273  else
274  return false;
275  }
276 
277  if( sB == eB )
278  return false;
279 
280  return true;
281  }

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