KiCad PCB EDA Suite
S3D::rsort_wxString Struct Reference

#include <str_rsort.h>

Public Member Functions

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

Detailed Description

Definition at line 38 of file str_rsort.h.

Member Function Documentation

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

Definition at line 40 of file str_rsort.h.

41  {
42  // sort a wxString using the reverse character order; for 3d model
43  // filenames this will typically be a much faster operation than
44  // a normal alphabetic sort
45  wxString::const_reverse_iterator sA = strA.rbegin();
46  wxString::const_reverse_iterator eA = strA.rend();
47 
48  wxString::const_reverse_iterator sB = strB.rbegin();
49  wxString::const_reverse_iterator eB = strB.rend();
50 
51  if( strA.empty() )
52  {
53  if( strB.empty() )
54  return false;
55 
56  // note: this rule implies that a null string is first in the sort order
57  return true;
58  }
59 
60  if( strB.empty() )
61  return false;
62 
63  while( sA != eA && sB != eB )
64  {
65  if( (*sA) == (*sB) )
66  {
67  ++sA;
68  ++sB;
69  continue;
70  }
71 
72  if( (*sA) < (*sB) )
73  return true;
74  else
75  return false;
76  }
77 
78  if( sB == eB )
79  return false;
80 
81  return true;
82  }

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