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 243 of file string_utils.h.

Member Function Documentation

◆ operator()()

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

Definition at line 245 of file string_utils.h.

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

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